aboutsummaryrefslogtreecommitdiffstats
path: root/build/ci.go
diff options
context:
space:
mode:
Diffstat (limited to 'build/ci.go')
-rw-r--r--build/ci.go67
1 files changed, 46 insertions, 21 deletions
diff --git a/build/ci.go b/build/ci.go
index d2f4ce4fe..4ee76ced5 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -441,11 +441,8 @@ func archiveBasename(arch string, archiveVersion string) string {
func archiveUpload(archive string, blobstore string, signer string) error {
// If signing was requested, generate the signature files
if signer != "" {
- pgpkey, err := base64.StdEncoding.DecodeString(os.Getenv(signer))
- if err != nil {
- return fmt.Errorf("invalid base64 %s", signer)
- }
- if err := build.PGPSignFile(archive, archive+".asc", string(pgpkey)); err != nil {
+ key := getenvBase64(signer)
+ if err := build.PGPSignFile(archive, archive+".asc", string(key)); err != nil {
return err
}
}
@@ -488,7 +485,8 @@ func maybeSkipArchive(env build.Environment) {
func doDebianSource(cmdline []string) {
var (
signer = flag.String("signer", "", `Signing key name, also used as package author`)
- upload = flag.String("upload", "", `Where to upload the source package (usually "ppa:ethereum/ethereum")`)
+ upload = flag.String("upload", "", `Where to upload the source package (usually "ethereum/ethereum")`)
+ sshUser = flag.String("sftp-user", "", `Username for SFTP upload (usually "geth-ci")`)
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
now = time.Now()
)
@@ -498,11 +496,7 @@ func doDebianSource(cmdline []string) {
maybeSkipArchive(env)
// Import the signing key.
- if b64key := os.Getenv("PPA_SIGNING_KEY"); b64key != "" {
- key, err := base64.StdEncoding.DecodeString(b64key)
- if err != nil {
- log.Fatal("invalid base64 PPA_SIGNING_KEY")
- }
+ if key := getenvBase64("PPA_SIGNING_KEY"); len(key) > 0 {
gpg := exec.Command("gpg", "--import")
gpg.Stdin = bytes.NewReader(key)
build.MustRun(gpg)
@@ -513,22 +507,58 @@ func doDebianSource(cmdline []string) {
for _, distro := range debDistros {
meta := newDebMetadata(distro, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables)
pkgdir := stageDebianSource(*workdir, meta)
- debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d")
+ debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d", "-Zxz")
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 != "" {
- build.MustRunCommand("dput", "--passive", "--no-upload-log", *upload, changes)
+ ppaUpload(*workdir, *upload, *sshUser, []string{source, dsc, changes})
}
}
}
}
+func ppaUpload(workdir, ppa, sshUser string, files []string) {
+ p := strings.Split(ppa, "/")
+ if len(p) != 2 {
+ log.Fatal("-upload PPA name must contain single /")
+ }
+ 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")
+ 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)
+ }
+}
+
+func getenvBase64(variable string) []byte {
+ dec, err := base64.StdEncoding.DecodeString(os.Getenv(variable))
+ if err != nil {
+ log.Fatal("invalid base64 " + variable)
+ }
+ return []byte(dec)
+}
+
func makeWorkdir(wdflag string) string {
var err error
if wdflag != "" {
@@ -800,15 +830,10 @@ func doAndroidArchive(cmdline []string) {
os.Rename(archive, meta.Package+".aar")
if *signer != "" && *deploy != "" {
// Import the signing key into the local GPG instance
- b64key := os.Getenv(*signer)
- key, err := base64.StdEncoding.DecodeString(b64key)
- if err != nil {
- log.Fatalf("invalid base64 %s", *signer)
- }
+ key := getenvBase64(*signer)
gpg := exec.Command("gpg", "--import")
gpg.Stdin = bytes.NewReader(key)
build.MustRun(gpg)
-
keyID, err := build.PGPKeyID(string(key))
if err != nil {
log.Fatal(err)