From fdc727411891530f16342ed2152c6ddf325f8c51 Mon Sep 17 00:00:00 2001 From: chengsiyuan Date: Mon, 18 Nov 2024 19:39:07 +0800 Subject: [PATCH] ELF executable or shared object file will be chmod to 0755 when upload. --- cmd/root.go | 5 ++++- go.mod | 2 ++ go.sum | 8 ++++---- pusher/ftp_pusher.go | 14 +++++++------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index cc95d66..aad4ec5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,7 +22,10 @@ var RootCmd = &cobra.Command{ Konwn-Issue: 1. Only support upload ftp now. - 2. File stat on remote device is not same as local (Please chmod on device!). + +Konwn-Behavior: + 1. Upload project to device, ELF executable or shared object file will be chmod to 0755. + 2. Generate upload yaml file from real evo project. Upload-Example: sylixos-uploader upload --path ~/sylixos-workspace/base-project --device 10.13.16.250 --method ftp diff --git a/go.mod b/go.mod index 051a76c..1fe89ab 100644 --- a/go.mod +++ b/go.mod @@ -15,3 +15,5 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect ) + +replace github.com/jlaffaye/ftp => github.com/go-sylixos/ftp v0.2.1 diff --git a/go.sum b/go.sum index 5b10f4d..8684be3 100644 --- a/go.sum +++ b/go.sum @@ -3,14 +3,14 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2 github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sylixos/ftp v0.2.1 h1:EF9I+4sKZjBJ9qTsf4yYNUnvvJO6eHpI1H0RojZMFmg= +github.com/go-sylixos/ftp v0.2.1/go.mod h1:dvLUr/8Fs9a2OBrEnCC5duphbkz/k/mSy5OkXg3PAgI= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jlaffaye/ftp v0.2.0 h1:lXNvW7cBu7R/68bknOX3MrRIIqZ61zELs1P2RAiA3lg= -github.com/jlaffaye/ftp v0.2.0/go.mod h1:is2Ds5qkhceAPy2xD6RLI6hmp/qysSoymZ+Z2uTnspI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -18,8 +18,8 @@ github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pusher/ftp_pusher.go b/pusher/ftp_pusher.go index aa0f998..7514566 100644 --- a/pusher/ftp_pusher.go +++ b/pusher/ftp_pusher.go @@ -150,18 +150,18 @@ func (f *FtpSylixOSPusher) pushFile(src, dst string) error { return err } - // Check if the file is ELF and set executable permissions if needed - if isELFExecutable(src) { - if err := os.Chmod(src, 0755); err != nil { - return err - } - } - // Upload the file if err := f.conn.Stor(dst, file); err != nil { return err } + // Set executable permissions if the file is ELF + if isELFExecutable(src) { + if err := f.conn.Chmod(dst, 0755); err != nil { + return err + } + } + return nil }