From f66302ef316f810efbea8fd8d5b6b15ca5a6f0c8 Mon Sep 17 00:00:00 2001 From: Vincent Batoufflet Date: Tue, 26 Aug 2014 23:22:51 +0200 Subject: [PATCH 1/3] Add ability to edit mirror architectures --- cmd/mirror_edit.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/mirror_edit.go b/cmd/mirror_edit.go index 15f41f64..e0e8710f 100644 --- a/cmd/mirror_edit.go +++ b/cmd/mirror_edit.go @@ -35,6 +35,10 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error { } } + if context.globalFlags.Lookup("architectures").Value.String() != "" { + repo.Architectures = context.ArchitecturesList() + } + err = context.CollectionFactory().RemoteRepoCollection().Update(repo) if err != nil { return fmt.Errorf("unable to edit: %s", err) From 755944652f8ceca6c8f59282e71e103343cbfcf6 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 29 Aug 2014 00:52:03 +0400 Subject: [PATCH 2/3] System tests for mirror edit with architectures. #99 --- system/t04_mirror/EditMirror6Test_gold | 2 ++ system/t04_mirror/EditMirror6Test_mirror_show | 19 +++++++++++++++++ system/t04_mirror/EditMirror7Test_gold | 2 ++ system/t04_mirror/edit.py | 21 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 system/t04_mirror/EditMirror6Test_gold create mode 100644 system/t04_mirror/EditMirror6Test_mirror_show create mode 100644 system/t04_mirror/EditMirror7Test_gold diff --git a/system/t04_mirror/EditMirror6Test_gold b/system/t04_mirror/EditMirror6Test_gold new file mode 100644 index 00000000..2a8ac06c --- /dev/null +++ b/system/t04_mirror/EditMirror6Test_gold @@ -0,0 +1,2 @@ +Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release... +Mirror [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy successfully updated. diff --git a/system/t04_mirror/EditMirror6Test_mirror_show b/system/t04_mirror/EditMirror6Test_mirror_show new file mode 100644 index 00000000..e47d2258 --- /dev/null +++ b/system/t04_mirror/EditMirror6Test_mirror_show @@ -0,0 +1,19 @@ +Name: wheezy-main +Archive Root URL: http://mirror.yandex.ru/debian/ +Distribution: wheezy +Components: main +Architectures: amd64, s390 +Download Sources: no +Number of packages: 56121 + +Information from release file: +Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc +Codename: wheezy +Components: main contrib non-free +Date: Sat, 12 Jul 2014 10:59:25 UTC +Description: Debian 7.6 Released 12 July 2014 + +Label: Debian +Origin: Debian +Suite: stable +Version: 7.6 diff --git a/system/t04_mirror/EditMirror7Test_gold b/system/t04_mirror/EditMirror7Test_gold new file mode 100644 index 00000000..04552006 --- /dev/null +++ b/system/t04_mirror/EditMirror7Test_gold @@ -0,0 +1,2 @@ +Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release... +ERROR: unable to edit: architecture x56 not available in repo [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy diff --git a/system/t04_mirror/edit.py b/system/t04_mirror/edit.py index 6453ad11..f6778819 100644 --- a/system/t04_mirror/edit.py +++ b/system/t04_mirror/edit.py @@ -58,3 +58,24 @@ class EditMirror5Test(BaseTest): self.check_output() self.check_cmd_output("aptly mirror show mirror5", "mirror_show", match_prepare=removeDates) + + +class EditMirror6Test(BaseTest): + """ + edit mirror: change architectures + """ + fixtureDB = True + runCmd = "aptly mirror edit -architectures=amd64,s390 wheezy-main" + + def check(self): + self.check_output() + self.check_cmd_output("aptly mirror show wheezy-main", "mirror_show", match_prepare=lambda s: re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s)) + + +class EditMirror7Test(BaseTest): + """ + edit mirror: change architectures to missing archs + """ + fixtureDB = True + runCmd = "aptly mirror edit -architectures=amd64,x56 wheezy-main" + expectedCode = 1 From 72f8e4ab619263952c1ef47f7cc9d64e654798eb Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 29 Aug 2014 00:52:47 +0400 Subject: [PATCH 3/3] Check architectures before applying arch change. #99 --- cmd/mirror_edit.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/mirror_edit.go b/cmd/mirror_edit.go index e0e8710f..ff5fbbe3 100644 --- a/cmd/mirror_edit.go +++ b/cmd/mirror_edit.go @@ -37,6 +37,11 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error { if context.globalFlags.Lookup("architectures").Value.String() != "" { repo.Architectures = context.ArchitecturesList() + + err = repo.Fetch(context.Downloader(), nil) + if err != nil { + return fmt.Errorf("unable to edit: %s", err) + } } err = context.CollectionFactory().RemoteRepoCollection().Update(repo) @@ -55,7 +60,7 @@ func makeCmdMirrorEdit() *commander.Command { Short: "edit properties of mirorr", Long: ` Command edit allows to change settings of mirror: -filters. +filters, list of architectures. Example: