From 59055d7fbddba4ea18b59ef4bdda601d4ebee278 Mon Sep 17 00:00:00 2001 From: Dmitrii Kashin Date: Fri, 10 Oct 2014 04:04:44 +0400 Subject: [PATCH 1/6] Add batch flag for publish commands --- cmd/publish.go | 1 + cmd/publish_switch.go | 1 + cmd/publish_update.go | 1 + utils/gpg.go | 9 +++++++++ 4 files changed, 12 insertions(+) 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_switch.go b/cmd/publish_switch.go index d2c966f0..63b1705b 100644 --- a/cmd/publish_switch.go +++ b/cmd/publish_switch.go @@ -136,6 +136,7 @@ Example: 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") + cmd.Flag.Bool("batch", false, "run gpg with a detached tty") return cmd } diff --git a/cmd/publish_update.go b/cmd/publish_update.go index d3413e9e..d450fa2d 100644 --- a/cmd/publish_update.go +++ b/cmd/publish_update.go @@ -102,6 +102,7 @@ Example: cmd.Flag.String("passphrase-file", "", "GPG passhprase-file for the key (warning: could be insecure)") 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") + cmd.Flag.Bool("batch", false, "run gpg with a detached tty") return cmd } diff --git a/utils/gpg.go b/utils/gpg.go index 90244192..37221758 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,11 @@ type GpgSigner struct { keyRef string keyring, secretKeyring string passphrase, passphraseFile string + batch bool +} + +func (g *GpgSigner) SetBatch(batch bool) { + g.batch = batch } // SetKey sets key ID to use when signing files @@ -79,6 +85,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 } From a85aa11ecd54ddf977199316000f3859ceb53921 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 10 Oct 2014 17:50:08 +0400 Subject: [PATCH 2/6] Update flag description/include it everywhere. #122 --- cmd/publish_repo.go | 1 + cmd/publish_snapshot.go | 1 + cmd/publish_switch.go | 2 +- cmd/publish_update.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) 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 63b1705b..848773e6 100644 --- a/cmd/publish_switch.go +++ b/cmd/publish_switch.go @@ -133,10 +133,10 @@ 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") - cmd.Flag.Bool("batch", false, "run gpg with a detached tty") return cmd } diff --git a/cmd/publish_update.go b/cmd/publish_update.go index d450fa2d..dfe26a4a 100644 --- a/cmd/publish_update.go +++ b/cmd/publish_update.go @@ -100,9 +100,9 @@ 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") - cmd.Flag.Bool("batch", false, "run gpg with a detached tty") return cmd } From 6d1efe0200cf967a207ede5814f5e90b95a9fc91 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 10 Oct 2014 17:50:43 +0400 Subject: [PATCH 3/6] Docstrings, gofmt. #122 --- utils/gpg.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/gpg.go b/utils/gpg.go index 37221758..79a55da1 100644 --- a/utils/gpg.go +++ b/utils/gpg.go @@ -43,11 +43,12 @@ type GpgSigner struct { keyRef string keyring, secretKeyring string passphrase, passphraseFile string - batch bool + batch bool } +// SetBatch control --no-tty flag to gpg func (g *GpgSigner) SetBatch(batch bool) { - g.batch = batch + g.batch = batch } // SetKey sets key ID to use when signing files @@ -86,7 +87,7 @@ func (g *GpgSigner) gpgArgs() []string { args = append(args, "--passphrase-file", g.passphraseFile) } if g.batch { - args = append(args, "--no-tty") + args = append(args, "--no-tty") } return args From 98577892043083b748979e33b30640c0056087f8 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 10 Oct 2014 17:52:00 +0400 Subject: [PATCH 4/6] Regenerate man page. #122 --- man/aptly.1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 . From 89bb20388f537f21e4e8875c0db18ceea40237c0 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 10 Oct 2014 17:52:09 +0400 Subject: [PATCH 5/6] Fix unit tests. #122 --- deb/publish_test.go | 3 +++ 1 file changed, 3 insertions(+) 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) { } From 6b08b64d6261c09683fa1f7bddb6a6a51712ee8a Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 10 Oct 2014 17:53:49 +0400 Subject: [PATCH 6/6] Add latest contributors. --- AUTHORS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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