diff --git a/Gomfile b/Gomfile index ddadba5f..f21cb86c 100644 --- a/Gomfile +++ b/Gomfile @@ -8,7 +8,7 @@ gom 'github.com/mattn/go-shellwords', :commit => 'c7ca6f94add751566a61cf2199e1de gom 'github.com/mitchellh/goamz/s3', :commit => '55f224c07975fddef9d2116600c664e30df3d594' gom 'github.com/mkrautz/goar', :commit => '36eb5f3452b1283a211fa35bc00c646fd0db5c4b' gom 'github.com/smira/commander', :commit => 'f408b00e68d5d6e21b9f18bd310978dafc604e47' -gom 'github.com/smira/flag', :commit => '0d0aac2addb39050f45e92c5a6252926096dc841' +gom 'github.com/smira/flag', :commit => '357ed3e599ffcbd4aeaa828e1d10da2df3ea5107' gom 'github.com/smira/go-ftp-protocol/protocol', :commit => '066b75c2b70dca7ae10b1b88b47534a3c31ccfaa' gom 'github.com/syndtr/goleveldb/leveldb', :commit => '9c181777fd66817ba10ce69563197ed8a645183c' gom 'github.com/ugorji/go/codec', :commit => '71c2886f5a673a35f909803f38ece5810165097b' diff --git a/cmd/cmd.go b/cmd/cmd.go index 34b7e511..542ee529 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -34,6 +34,18 @@ func ListPackagesRefList(reflist *deb.PackageRefList) (err error) { return } +// LookupOption checks boolean flag with default (usually config) and command-line +// setting +func LookupOption(defaultValue bool, flags *flag.FlagSet, name string) (result bool) { + result = defaultValue + + if flags.IsSet(name) { + result = flags.Lookup(name).Value.Get().(bool) + } + + return +} + // RootCommand creates root command in command tree func RootCommand() *commander.Command { cmd := &commander.Command{ diff --git a/cmd/context.go b/cmd/context.go index 1d459e10..d23ef126 100644 --- a/cmd/context.go +++ b/cmd/context.go @@ -104,16 +104,16 @@ func (context *AptlyContext) Config() *utils.ConfigStructure { func (context *AptlyContext) DependencyOptions() int { if context.dependencyOptions == -1 { context.dependencyOptions = 0 - if context.Config().DepFollowSuggests || context.globalFlags.Lookup("dep-follow-suggests").Value.Get().(bool) { + if LookupOption(context.Config().DepFollowSuggests, context.globalFlags, "dep-follow-suggests") { context.dependencyOptions |= deb.DepFollowSuggests } - if context.Config().DepFollowRecommends || context.globalFlags.Lookup("dep-follow-recommends").Value.Get().(bool) { + if LookupOption(context.Config().DepFollowRecommends, context.globalFlags, "dep-follow-recommends") { context.dependencyOptions |= deb.DepFollowRecommends } - if context.Config().DepFollowAllVariants || context.globalFlags.Lookup("dep-follow-all-variants").Value.Get().(bool) { + if LookupOption(context.Config().DepFollowAllVariants, context.globalFlags, "dep-follow-all-variants") { context.dependencyOptions |= deb.DepFollowAllVariants } - if context.Config().DepFollowSource || context.globalFlags.Lookup("dep-follow-source").Value.Get().(bool) { + if LookupOption(context.Config().DepFollowSource, context.globalFlags, "dep-follow-source") { context.dependencyOptions |= deb.DepFollowSource } } diff --git a/cmd/mirror.go b/cmd/mirror.go index 48c734a7..e4ce494a 100644 --- a/cmd/mirror.go +++ b/cmd/mirror.go @@ -8,7 +8,7 @@ import ( ) func getVerifier(flags *flag.FlagSet) (utils.Verifier, error) { - if context.Config().GpgDisableVerify || flags.Lookup("ignore-signatures").Value.Get().(bool) { + if LookupOption(context.Config().GpgDisableVerify, flags, "ignore-signatures") { return nil, nil } diff --git a/cmd/mirror_create.go b/cmd/mirror_create.go index d4150ac1..69c74226 100644 --- a/cmd/mirror_create.go +++ b/cmd/mirror_create.go @@ -16,7 +16,7 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error { return commander.ErrCommandError } - downloadSources := context.Config().DownloadSourcePackages || context.flags.Lookup("with-sources").Value.Get().(bool) + downloadSources := LookupOption(context.Config().DownloadSourcePackages, context.flags, "with-sources") var ( mirrorName, archiveURL, distribution string diff --git a/cmd/publish.go b/cmd/publish.go index 8b631e30..1ad8b163 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -8,7 +8,7 @@ import ( ) func getSigner(flags *flag.FlagSet) (utils.Signer, error) { - if flags.Lookup("skip-signing").Value.Get().(bool) || context.Config().GpgDisableSign { + if LookupOption(context.Config().GpgDisableSign, flags, "skip-signing") { return nil, nil } diff --git a/system/t04_mirror/CreateMirror24Test_gold b/system/t04_mirror/CreateMirror24Test_gold new file mode 100644 index 00000000..7fc9d2b4 --- /dev/null +++ b/system/t04_mirror/CreateMirror24Test_gold @@ -0,0 +1,6 @@ +Downloading http://security.debian.org/dists/wheezy/updates/InRelease... +gpgv: RSA key ID 46925553 +gpgv: Good signature from "Debian Archive Automatic Signing Key (7.0/wheezy) " + +Mirror [mirror24]: http://security.debian.org/ wheezy/updates successfully added. +You can run 'aptly mirror update mirror24' to download repository contents. diff --git a/system/t04_mirror/create.py b/system/t04_mirror/create.py index 91575aa9..6e1e8ab0 100644 --- a/system/t04_mirror/create.py +++ b/system/t04_mirror/create.py @@ -273,3 +273,16 @@ class CreateMirror23Test(BaseTest): """ runCmd = "aptly mirror create -ignore-signatures -filter='nginx | ' mirror23 http://security.debian.org/ wheezy/updates main" expectedCode = 1 + + +class CreateMirror24Test(BaseTest): + """ + create mirror: mirror with wrong filter + """ + runCmd = "aptly mirror create -ignore-signatures=false -keyring=aptlytest.gpg mirror24 http://security.debian.org/ wheezy/updates main" + fixtureGpg = True + outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) + + configOverride = { + "gpgDisableVerify": True + }