diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2019-02-14 23:10:09 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-02-19 16:58:45 +0800 |
commit | b247052a64a4954de83e50970c1551efe9f8a08b (patch) | |
tree | f1cc4816921b5fbaf830212b71bb5e90246d528e /build/ci.go | |
parent | 276f824707783ecbe092e521b5a7460515ee3e99 (diff) | |
download | dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar.gz dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar.bz2 dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar.lz dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar.xz dexon-b247052a64a4954de83e50970c1551efe9f8a08b.tar.zst dexon-b247052a64a4954de83e50970c1551efe9f8a08b.zip |
build: avoid dput and upload with sftp directly (#19067)
(cherry picked from commit a8ddf7ad8393cff80848b193c698ce5e6440e061)
Diffstat (limited to 'build/ci.go')
-rw-r--r-- | build/ci.go | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/build/ci.go b/build/ci.go index 6ca08d9ef..11fa759da 100644 --- a/build/ci.go +++ b/build/ci.go @@ -511,41 +511,44 @@ func doDebianSource(cmdline []string) { debuild.Dir = pkgdir build.MustRun(debuild) - changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString()) - changes = filepath.Join(*workdir, changes) + var ( + basename = fmt.Sprintf("%s_%s", meta.Name(), meta.VersionString()) + source = filepath.Join(*workdir, basename+".tar.xz") + dsc = filepath.Join(*workdir, basename+".dsc") + changes = filepath.Join(*workdir, basename+"_source.changes") + ) if *signer != "" { build.MustRunCommand("debsign", changes) } if *upload != "" { - uploadDebianSource(*workdir, *upload, *sshUser, changes) + ppaUpload(*workdir, *upload, *sshUser, []string{source, dsc, changes}) } } } } -func uploadDebianSource(workdir, ppa, sshUser, changes string) { - // Create the dput config file. - dputConfig := filepath.Join(workdir, "dput.cf") +func ppaUpload(workdir, ppa, sshUser string, files []string) { p := strings.Split(ppa, "/") if len(p) != 2 { log.Fatal("-upload PPA name must contain single /") } - templateData := map[string]string{ - "LaunchpadUser": p[0], - "LaunchpadPPA": p[1], - "LaunchpadSSH": sshUser, + if sshUser == "" { + sshUser = p[0] } + incomingDir := fmt.Sprintf("~%s/ubuntu/%s", p[0], p[1]) + // Create the SSH identity file if it doesn't exist. + var idfile string if sshkey := getenvBase64("PPA_SSH_KEY"); len(sshkey) > 0 { - idfile := filepath.Join(workdir, "sshkey") - ioutil.WriteFile(idfile, sshkey, 0600) - templateData["IdentityFile"] = idfile + idfile = filepath.Join(workdir, "sshkey") + if _, err := os.Stat(idfile); os.IsNotExist(err) { + ioutil.WriteFile(idfile, sshkey, 0600) + } + } + // Upload + dest := sshUser + "@ppa.launchpad.net" + if err := build.UploadSFTP(idfile, dest, incomingDir, files); err != nil { + log.Fatal(err) } - build.Render("build/dput-launchpad.cf", dputConfig, 0644, templateData) - - // Run dput to do the upload. - dput := exec.Command("dput", "-c", dputConfig, "--no-upload-log", ppa, changes) - dput.Stdin = strings.NewReader("Yes\n") // accept SSH host key - build.MustRun(dput) } func getenvBase64(variable string) []byte { |