@@ -511,41 +511,44 @@ func doDebianSource(cmdline []string) {
511511 debuild .Dir = pkgdir
512512 build .MustRun (debuild )
513513
514- changes := fmt .Sprintf ("%s_%s_source.changes" , meta .Name (), meta .VersionString ())
515- changes = filepath .Join (* workdir , changes )
514+ var (
515+ basename = fmt .Sprintf ("%s_%s" , meta .Name (), meta .VersionString ())
516+ source = filepath .Join (* workdir , basename + ".tar.xz" )
517+ dsc = filepath .Join (* workdir , basename + ".dsc" )
518+ changes = filepath .Join (* workdir , basename + "_source.changes" )
519+ )
516520 if * signer != "" {
517521 build .MustRunCommand ("debsign" , changes )
518522 }
519523 if * upload != "" {
520- uploadDebianSource (* workdir , * upload , * sshUser , changes )
524+ ppaUpload (* workdir , * upload , * sshUser , [] string { source , dsc , changes } )
521525 }
522526 }
523527 }
524528}
525529
526- func uploadDebianSource (workdir , ppa , sshUser , changes string ) {
527- // Create the dput config file.
528- dputConfig := filepath .Join (workdir , "dput.cf" )
530+ func ppaUpload (workdir , ppa , sshUser string , files []string ) {
529531 p := strings .Split (ppa , "/" )
530532 if len (p ) != 2 {
531533 log .Fatal ("-upload PPA name must contain single /" )
532534 }
533- templateData := map [string ]string {
534- "LaunchpadUser" : p [0 ],
535- "LaunchpadPPA" : p [1 ],
536- "LaunchpadSSH" : sshUser ,
535+ if sshUser == "" {
536+ sshUser = p [0 ]
537537 }
538+ incomingDir := fmt .Sprintf ("~%s/ubuntu/%s" , p [0 ], p [1 ])
539+ // Create the SSH identity file if it doesn't exist.
540+ var idfile string
538541 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+ idfile = filepath .Join (workdir , "sshkey" )
543+ if _ , err := os .Stat (idfile ); os .IsNotExist (err ) {
544+ ioutil .WriteFile (idfile , sshkey , 0600 )
545+ }
546+ }
547+ // Upload
548+ dest := sshUser + "@ppa.launchpad.net"
549+ if err := build .UploadSFTP (idfile , dest , incomingDir , files ); err != nil {
550+ log .Fatal (err )
542551 }
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 )
549552}
550553
551554func getenvBase64 (variable string ) []byte {
0 commit comments