aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-02-20 16:48:12 +0800
committerGitHub <noreply@github.com>2019-02-20 16:48:12 +0800
commitc942700427557e3ff6de3aaf6b916e2f056c1ec2 (patch)
treecadf68e7206d6de42b1eefc6967214cf86e35ff2 /internal
parent7fa3509e2eaf1a4ebc12344590e5699406690f15 (diff)
parentcde35439e058b4f9579830fec9fb65ae0b998346 (diff)
downloaddexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar.gz
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar.bz2
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar.lz
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar.xz
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.tar.zst
dexon-c942700427557e3ff6de3aaf6b916e2f056c1ec2.zip
Merge pull request #19029 from holiman/update1.8
Update1.8
Diffstat (limited to 'internal')
-rw-r--r--internal/build/util.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/build/util.go b/internal/build/util.go
index 195bdb404..a41ecfbed 100644
--- a/internal/build/util.go
+++ b/internal/build/util.go
@@ -177,3 +177,34 @@ func ExpandPackagesNoVendor(patterns []string) []string {
}
return patterns
}
+
+// UploadSFTP uploads files to a remote host using the sftp command line tool.
+// The destination host may be specified either as [user@]host[: or as a URI in
+// the form sftp://[user@]host[:port].
+func UploadSFTP(identityFile, host, dir string, files []string) error {
+ sftp := exec.Command("sftp")
+ sftp.Stdout = nil
+ sftp.Stderr = os.Stderr
+ if identityFile != "" {
+ sftp.Args = append(sftp.Args, "-i", identityFile)
+ }
+ sftp.Args = append(sftp.Args, host)
+ fmt.Println(">>>", strings.Join(sftp.Args, " "))
+ if *DryRunFlag {
+ return nil
+ }
+
+ stdin, err := sftp.StdinPipe()
+ if err != nil {
+ return fmt.Errorf("can't create stdin pipe for sftp: %v", err)
+ }
+ if err := sftp.Start(); err != nil {
+ return err
+ }
+ in := io.MultiWriter(stdin, os.Stdout)
+ for _, f := range files {
+ fmt.Fprintln(in, "put", f, path.Join(dir, filepath.Base(f)))
+ }
+ stdin.Close()
+ return sftp.Wait()
+}