From 1c45c79cc18edfcdaa3ee19a248a582121b261c0 Mon Sep 17 00:00:00 2001 From: Daniel Stelter-Gliese Date: Mon, 16 May 2016 03:25:00 +0200 Subject: [PATCH] Allow overriding architecture info from Release file Adds a flag -force-architectures to ignore missing architectures from mirrors. This flag can be used in cases where the mirrored repository does not provide an "Architecture: " line. Example Release file: http://mitaka-jessie.pkgs.mirantis.com/debian/dists/jessie-mitaka-backports/Release --- cmd/mirror_create.go | 2 ++ deb/remote.go | 6 ++++-- system/t03_help/MirrorCreateHelpTest_gold | 1 + system/t03_help/MirrorCreateTest_gold | 1 + system/t03_help/WrongFlagTest_gold | 1 + system/t04_mirror/CreateMirror16Test_gold | 2 +- system/t04_mirror/CreateMirror5Test_gold | 2 +- 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/mirror_create.go b/cmd/mirror_create.go index 299ca6e5..d8fbff71 100644 --- a/cmd/mirror_create.go +++ b/cmd/mirror_create.go @@ -43,6 +43,7 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error { repo.Filter = context.Flags().Lookup("filter").Value.String() repo.FilterWithDeps = context.Flags().Lookup("filter-with-deps").Value.Get().(bool) repo.SkipComponentCheck = context.Flags().Lookup("force-components").Value.Get().(bool) + repo.SkipArchitectureCheck = context.Flags().Lookup("force-architectures").Value.Get().(bool) if repo.Filter != "" { _, err = query.Parse(repo.Filter) @@ -97,6 +98,7 @@ Example: cmd.Flag.String("filter", "", "filter packages in mirror") cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well") cmd.Flag.Bool("force-components", false, "(only with component list) skip check that requested components are listed in Release file") + cmd.Flag.Bool("force-architectures", false, "(only with architecture list) skip check that requested architectures are listed in Release file") cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)") return cmd diff --git a/deb/remote.go b/deb/remote.go index 74155b3b..9610e3c3 100644 --- a/deb/remote.go +++ b/deb/remote.go @@ -60,6 +60,8 @@ type RemoteRepo struct { FilterWithDeps bool // SkipComponentCheck skips component list verification SkipComponentCheck bool + // SkipArchitectureCheck skips architecture list verification + SkipArchitectureCheck bool // Status marks state of repository (being updated, no action) Status int // WorkerPID is PID of the process modifying the mirror (if any) @@ -316,9 +318,9 @@ ok: architectures = utils.StrSlicesSubstract(architectures, []string{"source"}) if len(repo.Architectures) == 0 { repo.Architectures = architectures - } else { + } else if !repo.SkipArchitectureCheck { err = utils.StringsIsSubset(repo.Architectures, architectures, - fmt.Sprintf("architecture %%s not available in repo %s", repo)) + fmt.Sprintf("architecture %%s not available in repo %s, use -force-architectures to override", repo)) if err != nil { return err } diff --git a/system/t03_help/MirrorCreateHelpTest_gold b/system/t03_help/MirrorCreateHelpTest_gold index 07483573..5c988936 100644 --- a/system/t03_help/MirrorCreateHelpTest_gold +++ b/system/t03_help/MirrorCreateHelpTest_gold @@ -21,6 +21,7 @@ Options: -dep-follow-suggests=false: when processing dependencies, follow Suggests -filter="": filter packages in mirror -filter-with-deps=false: when filtering, include dependencies of matching packages as well + -force-architectures=false: (only with architecture list) skip check that requested architectures are listed in Release file -force-components=false: (only with component list) skip check that requested components are listed in Release file -ignore-signatures=false: disable verification of Release file signatures -keyring=: gpg keyring to use when verifying Release file (could be specified multiple times) diff --git a/system/t03_help/MirrorCreateTest_gold b/system/t03_help/MirrorCreateTest_gold index 7ca699a7..a63ef4a1 100644 --- a/system/t03_help/MirrorCreateTest_gold +++ b/system/t03_help/MirrorCreateTest_gold @@ -12,6 +12,7 @@ Options: -dep-follow-suggests=false: when processing dependencies, follow Suggests -filter="": filter packages in mirror -filter-with-deps=false: when filtering, include dependencies of matching packages as well + -force-architectures=false: (only with architecture list) skip check that requested architectures are listed in Release file -force-components=false: (only with component list) skip check that requested components are listed in Release file -ignore-signatures=false: disable verification of Release file signatures -keyring=: gpg keyring to use when verifying Release file (could be specified multiple times) diff --git a/system/t03_help/WrongFlagTest_gold b/system/t03_help/WrongFlagTest_gold index 32e018fe..c43e32d5 100644 --- a/system/t03_help/WrongFlagTest_gold +++ b/system/t03_help/WrongFlagTest_gold @@ -13,6 +13,7 @@ Options: -dep-follow-suggests=false: when processing dependencies, follow Suggests -filter="": filter packages in mirror -filter-with-deps=false: when filtering, include dependencies of matching packages as well + -force-architectures=false: (only with architecture list) skip check that requested architectures are listed in Release file -force-components=false: (only with component list) skip check that requested components are listed in Release file -ignore-signatures=false: disable verification of Release file signatures -keyring=: gpg keyring to use when verifying Release file (could be specified multiple times) diff --git a/system/t04_mirror/CreateMirror16Test_gold b/system/t04_mirror/CreateMirror16Test_gold index 5c2d6d64..86efa5f2 100644 --- a/system/t04_mirror/CreateMirror16Test_gold +++ b/system/t04_mirror/CreateMirror16Test_gold @@ -1,2 +1,2 @@ Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release... -ERROR: unable to fetch mirror: architecture source not available in repo [mirror16]: http://mirror.yandex.ru/debian/ wheezy +ERROR: unable to fetch mirror: architecture source not available in repo [mirror16]: http://mirror.yandex.ru/debian/ wheezy, use -force-architectures to override diff --git a/system/t04_mirror/CreateMirror5Test_gold b/system/t04_mirror/CreateMirror5Test_gold index dfac1c2d..88c67feb 100644 --- a/system/t04_mirror/CreateMirror5Test_gold +++ b/system/t04_mirror/CreateMirror5Test_gold @@ -1,2 +1,2 @@ Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release... -ERROR: unable to fetch mirror: architecture nano68 not available in repo [mirror5]: http://mirror.yandex.ru/debian/ wheezy +ERROR: unable to fetch mirror: architecture nano68 not available in repo [mirror5]: http://mirror.yandex.ru/debian/ wheezy, use -force-architectures to override