@@ -441,11 +441,8 @@ func archiveBasename(arch string, archiveVersion string) string {
441
441
func archiveUpload (archive string , blobstore string , signer string ) error {
442
442
// If signing was requested, generate the signature files
443
443
if signer != "" {
444
- pgpkey , err := base64 .StdEncoding .DecodeString (os .Getenv (signer ))
445
- if err != nil {
446
- return fmt .Errorf ("invalid base64 %s" , signer )
447
- }
448
- if err := build .PGPSignFile (archive , archive + ".asc" , string (pgpkey )); err != nil {
444
+ key := getenvBase64 (signer )
445
+ if err := build .PGPSignFile (archive , archive + ".asc" , string (key )); err != nil {
449
446
return err
450
447
}
451
448
}
@@ -489,6 +486,7 @@ func doDebianSource(cmdline []string) {
489
486
var (
490
487
signer = flag .String ("signer" , "" , `Signing key name, also used as package author` )
491
488
upload = flag .String ("upload" , "" , `Where to upload the source package (usually "ppa:ethereum/ethereum")` )
489
+ sshUser = flag .String ("sftp-user" , "" , `Username for SFTP upload (usually "geth-ci")` )
492
490
workdir = flag .String ("workdir" , "" , `Output directory for packages (uses temp dir if unset)` )
493
491
now = time .Now ()
494
492
)
@@ -498,11 +496,7 @@ func doDebianSource(cmdline []string) {
498
496
maybeSkipArchive (env )
499
497
500
498
// Import the signing key.
501
- if b64key := os .Getenv ("PPA_SIGNING_KEY" ); b64key != "" {
502
- key , err := base64 .StdEncoding .DecodeString (b64key )
503
- if err != nil {
504
- log .Fatal ("invalid base64 PPA_SIGNING_KEY" )
505
- }
499
+ if key := getenvBase64 ("PPA_SIGNING_KEY" ); len (key ) > 0 {
506
500
gpg := exec .Command ("gpg" , "--import" )
507
501
gpg .Stdin = bytes .NewReader (key )
508
502
build .MustRun (gpg )
@@ -523,12 +517,45 @@ func doDebianSource(cmdline []string) {
523
517
build .MustRunCommand ("debsign" , changes )
524
518
}
525
519
if * upload != "" {
526
- build . MustRunCommand ( "dput" , "--passive" , "--no- upload-log" , * upload , changes )
520
+ uploadDebianSource ( * workdir , * upload , * sshUser , changes )
527
521
}
528
522
}
529
523
}
530
524
}
531
525
526
+ func uploadDebianSource (workdir , ppa , sshUser , changes string ) {
527
+ // Create the dput config file.
528
+ dputConfig := filepath .Join (workdir , "dput.cf" )
529
+ p := strings .Split (ppa , "/" )
530
+ if len (p ) != 2 {
531
+ log .Fatal ("-upload PPA name must contain single /" )
532
+ }
533
+ templateData := map [string ]string {
534
+ "LaunchpadUser" : p [0 ],
535
+ "LaunchpadPPA" : p [1 ],
536
+ "LaunchpadSSH" : sshUser ,
537
+ }
538
+ if sshkey := getenvBase64 ("PPA_SSH_KEY" ); len (sshkey ) > 0 {
539
+ idfile := filepath .Join (workdir , "sshkey" )
540
+ ioutil .WriteFile (idfile , sshkey , 0600 )
541
+ templateData ["IdentityFile" ] = idfile
542
+ }
543
+ build .Render ("build/dput-launchpad.cf" , dputConfig , 0644 , templateData )
544
+
545
+ // Run dput to do the upload.
546
+ dput := exec .Command ("dput" , "-c" , dputConfig , "--no-upload-log" , ppa , changes )
547
+ dput .Stdin = strings .NewReader ("Yes\n " ) // accept SSH host key
548
+ build .MustRun (dput )
549
+ }
550
+
551
+ func getenvBase64 (variable string ) []byte {
552
+ dec , err := base64 .StdEncoding .DecodeString (os .Getenv (variable ))
553
+ if err != nil {
554
+ log .Fatal ("invalid base64 " + variable )
555
+ }
556
+ return []byte (dec )
557
+ }
558
+
532
559
func makeWorkdir (wdflag string ) string {
533
560
var err error
534
561
if wdflag != "" {
@@ -800,15 +827,10 @@ func doAndroidArchive(cmdline []string) {
800
827
os .Rename (archive , meta .Package + ".aar" )
801
828
if * signer != "" && * deploy != "" {
802
829
// Import the signing key into the local GPG instance
803
- b64key := os .Getenv (* signer )
804
- key , err := base64 .StdEncoding .DecodeString (b64key )
805
- if err != nil {
806
- log .Fatalf ("invalid base64 %s" , * signer )
807
- }
830
+ key := getenvBase64 (* signer )
808
831
gpg := exec .Command ("gpg" , "--import" )
809
832
gpg .Stdin = bytes .NewReader (key )
810
833
build .MustRun (gpg )
811
-
812
834
keyID , err := build .PGPKeyID (string (key ))
813
835
if err != nil {
814
836
log .Fatal (err )
0 commit comments