diff --git a/AUTHORS b/AUTHORS index 17fdfe01..aed10b9e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,4 +4,6 @@ List of contributors, in chronological order: * Sebastien Binet (https://github.com/sbinet) * Ryan Uber (https://github.com/ryanuber) * Simon Aquino (https://github.com/simonaquino) -* Vincent Batoufflet (https://github.com/vbatoufflet) \ No newline at end of file +* Vincent Batoufflet (https://github.com/vbatoufflet) +* Ivan Kurnosov (https://github.com/zerkms) +* Dmitrii Kashin (https://github.com/freehck) \ No newline at end of file diff --git a/cmd/publish.go b/cmd/publish.go index 1ad8b163..36830a88 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -16,6 +16,7 @@ func getSigner(flags *flag.FlagSet) (utils.Signer, error) { signer.SetKey(flags.Lookup("gpg-key").Value.String()) signer.SetKeyRing(flags.Lookup("keyring").Value.String(), flags.Lookup("secret-keyring").Value.String()) signer.SetPassphrase(flags.Lookup("passphrase").Value.String(), flags.Lookup("passphrase-file").Value.String()) + signer.SetBatch(flags.Lookup("batch").Value.Get().(bool)) err := signer.Init() if err != nil { diff --git a/cmd/publish_repo.go b/cmd/publish_repo.go index 405c5970..892d7a62 100644 --- a/cmd/publish_repo.go +++ b/cmd/publish_repo.go @@ -39,6 +39,7 @@ Example: cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("passphrase", "", "GPG passhprase for the key (warning: could be insecure)") cmd.Flag.String("passphrase-file", "", "GPG passhprase-file for the key (warning: could be insecure)") + cmd.Flag.Bool("batch", false, "run GPG with detached tty") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("label", "", "label to publish") diff --git a/cmd/publish_snapshot.go b/cmd/publish_snapshot.go index aab5edc4..7dd22844 100644 --- a/cmd/publish_snapshot.go +++ b/cmd/publish_snapshot.go @@ -201,6 +201,7 @@ Example: cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("passphrase", "", "GPG passhprase for the key (warning: could be insecure)") cmd.Flag.String("passphrase-file", "", "GPG passhprase-file for the key (warning: could be insecure)") + cmd.Flag.Bool("batch", false, "run GPG with detached tty") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("label", "", "label to publish") diff --git a/cmd/publish_switch.go b/cmd/publish_switch.go index d2c966f0..848773e6 100644 --- a/cmd/publish_switch.go +++ b/cmd/publish_switch.go @@ -133,6 +133,7 @@ Example: cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("passphrase", "", "GPG passhprase for the key (warning: could be insecure)") cmd.Flag.String("passphrase-file", "", "GPG passhprase-file for the key (warning: could be insecure)") + cmd.Flag.Bool("batch", false, "run GPG with detached tty") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)") cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") diff --git a/cmd/publish_update.go b/cmd/publish_update.go index d3413e9e..dfe26a4a 100644 --- a/cmd/publish_update.go +++ b/cmd/publish_update.go @@ -100,6 +100,7 @@ Example: cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("passphrase", "", "GPG passhprase for the key (warning: could be insecure)") cmd.Flag.String("passphrase-file", "", "GPG passhprase-file for the key (warning: could be insecure)") + cmd.Flag.Bool("batch", false, "run GPG with detached tty") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch") diff --git a/deb/publish_test.go b/deb/publish_test.go index 60e3a226..1aee5aab 100644 --- a/deb/publish_test.go +++ b/deb/publish_test.go @@ -36,6 +36,9 @@ func (n *NullSigner) Init() error { func (n *NullSigner) SetKey(keyRef string) { } +func (n *NullSigner) SetBatch(batch bool) { +} + func (n *NullSigner) SetKeyRing(keyring, secretKeyring string) { } diff --git a/man/aptly.1 b/man/aptly.1 index 642ade7f..f78fd8bd 100644 --- a/man/aptly.1 +++ b/man/aptly.1 @@ -1102,6 +1102,10 @@ $ aptly publish repo testing Options: . .TP +\-\fBbatch\fR=false +run GPG with detached tty +. +.TP \-\fBcomponent\fR= component name to publish (for multi\-component publishing, separate components with commas) . @@ -1181,6 +1185,10 @@ $ aptly publish snapshot wheezy\-main Options: . .TP +\-\fBbatch\fR=false +run GPG with detached tty +. +.TP \-\fBcomponent\fR= component name to publish (for multi\-component publishing, separate components with commas) . @@ -1260,6 +1268,10 @@ $ aptly publish update wheezy ppa wheezy\-7\.5 Options: . .TP +\-\fBbatch\fR=false +run GPG with detached tty +. +.TP \-\fBcomponent\fR= component names to update (for multi\-component publishing, separate components with commas) . @@ -1317,6 +1329,10 @@ $ aptly publish update wheezy ppa Options: . .TP +\-\fBbatch\fR=false +run GPG with detached tty +. +.TP \-\fBforce\-overwrite\fR=false overwrite files in package pool in case of mismatch . diff --git a/utils/gpg.go b/utils/gpg.go index 90244192..79a55da1 100644 --- a/utils/gpg.go +++ b/utils/gpg.go @@ -18,6 +18,7 @@ type Signer interface { SetKey(keyRef string) SetKeyRing(keyring, secretKeyring string) SetPassphrase(passphrase, passphraseFile string) + SetBatch(batch bool) DetachedSign(source string, destination string) error ClearSign(source string, destination string) error } @@ -42,6 +43,12 @@ type GpgSigner struct { keyRef string keyring, secretKeyring string passphrase, passphraseFile string + batch bool +} + +// SetBatch control --no-tty flag to gpg +func (g *GpgSigner) SetBatch(batch bool) { + g.batch = batch } // SetKey sets key ID to use when signing files @@ -79,6 +86,9 @@ func (g *GpgSigner) gpgArgs() []string { if g.passphraseFile != "" { args = append(args, "--passphrase-file", g.passphraseFile) } + if g.batch { + args = append(args, "--no-tty") + } return args }