From 76ee4c1bc78d5bd5e1616a30f408db78f172d2e6 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 10 Oct 2022 16:00:14 +0300 Subject: [PATCH 1/5] [CU-2wn8fue] Fix bug with filtering packages by release status --- cli/cli.go | 2 +- common/rep.spec | 5 ++++- repo/repository.go | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 4f67bc62..3408258d 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -42,7 +42,7 @@ import ( // App info const ( APP = "rep" - VER = "3.0.0" + VER = "3.0.1" DESC = "YUM repository management utility" ) diff --git a/common/rep.spec b/common/rep.spec index 91995f38..4d3f71bf 100644 --- a/common/rep.spec +++ b/common/rep.spec @@ -52,7 +52,7 @@ Summary: YUM repository management utility Name: rep -Version: 3.0.0 +Version: 3.0.1 Release: 0%{?dist} Group: Applications/System License: Apache 2.0 @@ -167,5 +167,8 @@ fi ################################################################################ %changelog +* Mon Oct 10 2022 Anton Novojilov - 3.0.1-0 +- Fixed bug with filtering packages by release status + * Mon Jun 27 2022 Anton Novojilov - 3.0.0-0 - First public release of 3.x diff --git a/repo/repository.go b/repo/repository.go index efb69a36..54c751c5 100644 --- a/repo/repository.go +++ b/repo/repository.go @@ -217,7 +217,7 @@ func (p *Package) HasArch(arch string) bool { archFlag := data.SupportedArchs[arch].Flag - if archFlag == 0 { + if archFlag == data.ARCH_FLAG_UNKNOWN { return false } @@ -412,11 +412,12 @@ func (r *Repository) IsPackageReleased(pkg *Package) (bool, time.Time, error) { for _, arch := range data.ArchList { switch { - case arch == data.ARCH_NOARCH, !r.Release.HasArch(arch), r.Release.IsEmpty(arch): - continue - } - - if !pkg.HasArch(arch) && !pkg.Files.HasArch(arch) { + case arch != data.ARCH_SRC && pkg.HasArch(data.ARCH_NOARCH): + // Package is noarch package, do the check + case arch == data.ARCH_NOARCH, // Skip if it pseudo arch + !r.Release.HasArch(arch), // Skip if the release repo doesn't contain this arch + r.Release.IsEmpty(arch), // Skip if there are no packages with this arch + !pkg.HasArch(arch): // Skip if the package doesn't contain this arch continue } From 34d61bc0e83b503a39e94c6d5669db914a153d65 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 10 Oct 2022 16:28:12 +0300 Subject: [PATCH 2/5] Improve tests --- .github/workflows/ci.yml | 5 ----- repo/meta/meta_test.go | 22 +++++++++++++++++++--- repo/storage/fs/fs_storage_test.go | 22 ++++++++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0882810..54e650b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,11 +137,6 @@ jobs: if: steps.cache-deps.outputs.cache-hit != 'true' run: make deps - - name: Update modification date for test repository - run: | - touch -t $(date -d @1644506277 +'%Y%m%d%H%M.%S') \ - ${{env.SRC_DIR}}/testdata/testrepo/release/x86_64/repodata/* - - name: Build binary working-directory: ${{env.SRC_DIR}} run: make all diff --git a/repo/meta/meta_test.go b/repo/meta/meta_test.go index 3eb3a41c..b41fbfae 100644 --- a/repo/meta/meta_test.go +++ b/repo/meta/meta_test.go @@ -41,10 +41,26 @@ func (s *MetaSuite) SetUpSuite(c *C) { s.TmpDir = c.MkDir() metaDate := time.Unix(1644506277, 0) - err := os.Chtimes(metaFile, metaDate, metaDate) + metaDir := repoDir + "/repodata" + metaFiles := []string{ + "filelists.sqlite.bz2", + "filelists.xml.gz", + "filelists.xml.zck", + "other.sqlite.bz2", + "other.xml.gz", + "other.xml.zck", + "primary.sqlite.bz2", + "primary.xml.gz", + "primary.xml.zck", + "repomd.xml", + } + + for _, metaFile := range metaFiles { + err := os.Chtimes(metaDir+"/"+metaFile, metaDate, metaDate) - if err != nil { - c.Fatalf("Can't set metadata mtime: %v", err) + if err != nil { + c.Fatalf("Can't change metadata mtime: %v", err) + } } } diff --git a/repo/storage/fs/fs_storage_test.go b/repo/storage/fs/fs_storage_test.go index 4ef35afd..a451e95d 100644 --- a/repo/storage/fs/fs_storage_test.go +++ b/repo/storage/fs/fs_storage_test.go @@ -41,12 +41,26 @@ var defArchs = []string{data.ARCH_SRC, data.ARCH_X64} func (s *StorageSuite) SetUpSuite(c *C) { metaDate := time.Unix(1644506277, 0) - metaFile := dataDir + "/release/x86_64/repodata/repomd.xml" + metaDir := dataDir + "/release/x86_64/repodata" + metaFiles := []string{ + "filelists.sqlite.bz2", + "filelists.xml.gz", + "filelists.xml.zck", + "other.sqlite.bz2", + "other.xml.gz", + "other.xml.zck", + "primary.sqlite.bz2", + "primary.xml.gz", + "primary.xml.zck", + "repomd.xml", + } - err := os.Chtimes(metaFile, metaDate, metaDate) + for _, metaFile := range metaFiles { + err := os.Chtimes(metaDir+"/"+metaFile, metaDate, metaDate) - if err != nil { - c.Fatalf("Can't set metadata mtime: %v", err) + if err != nil { + c.Fatalf("Can't change metadata mtime: %v", err) + } } } From 089dca72709fa457e71eddfb1aef7ed90ed999e4 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 10 Oct 2022 16:44:10 +0300 Subject: [PATCH 3/5] Fix typos --- cli/cli.go | 2 +- cli/cmd_help.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 3408258d..4abc074e 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -590,7 +590,7 @@ func genUsage() *usage.Info { info.AddCommand(COMMAND_INFO, "Show info about package", "package") info.AddCommand(COMMAND_PAYLOAD, "Show package payload", "package", "?type") info.AddCommand(COMMAND_SIGN, "Sign one or more packages", "file…") - info.AddCommand(COMMAND_RESIGN, "Resign all packages in reposotory") + info.AddCommand(COMMAND_RESIGN, "Resign all packages in repository") info.AddCommand(COMMAND_ADD, "Add one or more packages to testing repository", "file…") info.AddCommand(COMMAND_REMOVE, "Remove package or packages from repository", "query…") info.AddCommand(COMMAND_RELEASE, "Copy package or packages from testing to release repository", "query…") diff --git a/cli/cmd_help.go b/cli/cmd_help.go index 9b7aee27..eb30856e 100644 --- a/cli/cmd_help.go +++ b/cli/cmd_help.go @@ -374,7 +374,7 @@ func helpFind() { help.Query(query.TERM_SHORT_REQUIRES, query.TERM_REQUIRES, "Package name or binary name required by the package", "Dependency") help.Query(query.TERM_SHORT_CONFLICTS, query.TERM_CONFLICTS, "Name of conflicting package", "Dependency") help.Query(query.TERM_SHORT_OBSOLETES, query.TERM_OBSOLETES, "Name of obsolete package", "Dependency") - help.Query(query.TERM_SHORT_RECOMMENDS, query.TERM_RECOMMENDS, "Name of package defined as recomended", "Dependency") + help.Query(query.TERM_SHORT_RECOMMENDS, query.TERM_RECOMMENDS, "Name of package defined as recommended", "Dependency") help.Query(query.TERM_SHORT_ENHANCES, query.TERM_ENHANCES, "Name of package defined as the enhancement", "Dependency") help.Query(query.TERM_SHORT_SUGGESTS, query.TERM_SUGGESTS, "Name of package defined as the suggestion", "Dependency") help.Query(query.TERM_SHORT_SUPPLEMENTS, query.TERM_SUPPLEMENTS, "Name of package defined as the supplement", "Dependency") From 542913edc50280533dc09ae83d422228075f7f6c Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 10 Oct 2022 16:57:47 +0300 Subject: [PATCH 4/5] Code formatting --- repo/groups/groups_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/repo/groups/groups_test.go b/repo/groups/groups_test.go index 9582bc3a..e579f158 100644 --- a/repo/groups/groups_test.go +++ b/repo/groups/groups_test.go @@ -139,31 +139,31 @@ func (s *GroupsSuite) TestWriting(c *C) { func (s *GroupsSuite) TestDataSorting(c *C) { pkgs := []*GroupPackage{ - &GroupPackage{Type: 1, Name: "packageA"}, - &GroupPackage{Type: 3, Name: "packageB"}, - &GroupPackage{Type: 2, Name: "package10"}, - &GroupPackage{Type: 2, Name: "package2"}, - &GroupPackage{Type: 0, Name: "packageX"}, + {Type: 1, Name: "packageA"}, + {Type: 3, Name: "packageB"}, + {Type: 2, Name: "package10"}, + {Type: 2, Name: "package2"}, + {Type: 0, Name: "packageX"}, } groups := []*Group{ - &Group{ID: "test10"}, - &Group{ID: "test5"}, + {ID: "test10"}, + {ID: "test5"}, } categories := []*Category{ - &Category{ID: "test10"}, - &Category{ID: "test5"}, + {ID: "test10"}, + {ID: "test5"}, } envs := []*Environment{ - &Environment{ID: "test10"}, - &Environment{ID: "test5"}, + {ID: "test10"}, + {ID: "test5"}, } langpacks := []*Langpack{ - &Langpack{Name: "test10"}, - &Langpack{Name: "test5"}, + {Name: "test10"}, + {Name: "test5"}, } sort.Sort(packageSlice(pkgs)) From c5f81810f828cd2ff6b170d6e5d3eb83733ac202 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 10 Oct 2022 17:10:12 +0300 Subject: [PATCH 5/5] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4e41f58..60d418ad 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Commands info package Show info about package payload package type Show package payload sign file… Sign one or more packages - resign Resign all packages in reposotory + resign Resign all packages in repository add file… Add one or more packages to testing repository remove query… Remove package or packages from repository release query… Copy package or packages from testing to release repository