From 42af29d90686a98f9f5b2832f4b01674c98dcc02 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Thu, 26 Mar 2020 13:15:57 +0100 Subject: [PATCH 01/10] Added population_sources attribute for yum repositories --- pubtools/pulplib/_impl/model/repository/yum.py | 12 ++++++++++++ tests/repository/test_yum_repository.py | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pubtools/pulplib/_impl/model/repository/yum.py b/pubtools/pulplib/_impl/model/repository/yum.py index 6c9e97da..ed86fea7 100644 --- a/pubtools/pulplib/_impl/model/repository/yum.py +++ b/pubtools/pulplib/_impl/model/repository/yum.py @@ -70,6 +70,18 @@ class YumRepository(Repository): type = pulp_attrib(default="rpm-repo", type=str, pulp_field="notes._repo-type") + population_sources = pulp_attrib( + default=(), type=tuple, converter=tuple, pulp_field="notes.population_sources" + ) + """List of repositories used for populate the repository + """ + + ubi_population = pulp_attrib( + default=False, type=bool, pulp_field="notes.ubi_population" + ) + """Flag indicating whether repo should be populated or not + """ + mutable_urls = attr.ib( default=attr.Factory(lambda: FrozenList(["repodata/repomd.xml"])), type=list, diff --git a/tests/repository/test_yum_repository.py b/tests/repository/test_yum_repository.py index 822ec761..35b9c2ad 100644 --- a/tests/repository/test_yum_repository.py +++ b/tests/repository/test_yum_repository.py @@ -54,5 +54,21 @@ def test_from_data_skip_rsync_repodata(): ], } ) - assert repo.skip_rsync_repodata + + +def test_populate_attrs(): + """skip_rsync_repodata is initialized from distributors when possible""" + repo = Repository.from_data( + { + "id": "my-repo", + "notes": { + "_repo-type": "rpm-repo", + "population_sources": ["populate_repo1", "populate_repo2"], + "ubi_population": True, + }, + "distributors": [], + } + ) + assert repo.population_sources == ("populate_repo1", "populate_repo2") + assert repo.ubi_population From 802b8fe28b889491b9d177d06b8d3092c429773b Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Fri, 27 Mar 2020 11:43:01 +0100 Subject: [PATCH 02/10] Update pubtools/pulplib/_impl/model/repository/yum.py Co-Authored-By: Rohan McGovern --- pubtools/pulplib/_impl/model/repository/yum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubtools/pulplib/_impl/model/repository/yum.py b/pubtools/pulplib/_impl/model/repository/yum.py index ed86fea7..9227c3d8 100644 --- a/pubtools/pulplib/_impl/model/repository/yum.py +++ b/pubtools/pulplib/_impl/model/repository/yum.py @@ -73,7 +73,7 @@ class YumRepository(Repository): population_sources = pulp_attrib( default=(), type=tuple, converter=tuple, pulp_field="notes.population_sources" ) - """List of repositories used for populate the repository + """List of repository IDs used to populate this repository """ ubi_population = pulp_attrib( From 82467a317a48136620cb1d44c834c3f681ca27aa Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Fri, 27 Mar 2020 12:46:01 +0100 Subject: [PATCH 03/10] - replaced tuple with Frozenlist - fixed docs strings - added new attributes to schema file --- pubtools/pulplib/_impl/model/repository/yum.py | 7 +++++-- pubtools/pulplib/_impl/schema/repository.yaml | 9 +++++++++ tests/repository/test_yum_repository.py | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pubtools/pulplib/_impl/model/repository/yum.py b/pubtools/pulplib/_impl/model/repository/yum.py index 9227c3d8..f4209211 100644 --- a/pubtools/pulplib/_impl/model/repository/yum.py +++ b/pubtools/pulplib/_impl/model/repository/yum.py @@ -71,7 +71,10 @@ class YumRepository(Repository): type = pulp_attrib(default="rpm-repo", type=str, pulp_field="notes._repo-type") population_sources = pulp_attrib( - default=(), type=tuple, converter=tuple, pulp_field="notes.population_sources" + default=attr.Factory(FrozenList), + type=list, + converter=FrozenList, + pulp_field="notes.population_sources", ) """List of repository IDs used to populate this repository """ @@ -79,7 +82,7 @@ class YumRepository(Repository): ubi_population = pulp_attrib( default=False, type=bool, pulp_field="notes.ubi_population" ) - """Flag indicating whether repo should be populated or not + """Flag indicating whether repo should be populated or not for the purposes of UBI """ mutable_urls = attr.ib( diff --git a/pubtools/pulplib/_impl/schema/repository.yaml b/pubtools/pulplib/_impl/schema/repository.yaml index affaecbe..a2d0c8a4 100644 --- a/pubtools/pulplib/_impl/schema/repository.yaml +++ b/pubtools/pulplib/_impl/schema/repository.yaml @@ -83,6 +83,15 @@ properties: pub_temp_repo: type: boolean + # True if repository supposed to be populated from repositories + # mentioned in pupulation_sources + ubi_population: + type: boolean + + # List of repositories used for populating the repository + population_sources: + type: array + # List of repository distributors. # Note that order matters in this list. distributors: diff --git a/tests/repository/test_yum_repository.py b/tests/repository/test_yum_repository.py index 35b9c2ad..8ba46a5d 100644 --- a/tests/repository/test_yum_repository.py +++ b/tests/repository/test_yum_repository.py @@ -58,7 +58,7 @@ def test_from_data_skip_rsync_repodata(): def test_populate_attrs(): - """skip_rsync_repodata is initialized from distributors when possible""" + """test populate attributes are correctly parsed from repo notes""" repo = Repository.from_data( { "id": "my-repo", @@ -70,5 +70,5 @@ def test_populate_attrs(): "distributors": [], } ) - assert repo.population_sources == ("populate_repo1", "populate_repo2") + assert repo.population_sources == ["populate_repo1", "populate_repo2"] assert repo.ubi_population From a0adbed87e92517a6a0ad1a532846ceefeede085 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Thu, 2 Apr 2020 10:02:17 +0200 Subject: [PATCH 04/10] Update pubtools/pulplib/_impl/schema/repository.yaml Co-Authored-By: Rohan McGovern --- pubtools/pulplib/_impl/schema/repository.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubtools/pulplib/_impl/schema/repository.yaml b/pubtools/pulplib/_impl/schema/repository.yaml index a2d0c8a4..2d4845af 100644 --- a/pubtools/pulplib/_impl/schema/repository.yaml +++ b/pubtools/pulplib/_impl/schema/repository.yaml @@ -84,7 +84,7 @@ properties: type: boolean # True if repository supposed to be populated from repositories - # mentioned in pupulation_sources + # mentioned in population_sources ubi_population: type: boolean From eb0454a2dd1c9b46519f9de7f58a6a1705f4c9e1 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Thu, 2 Apr 2020 10:02:55 +0200 Subject: [PATCH 05/10] Update pubtools/pulplib/_impl/schema/repository.yaml Co-Authored-By: Rohan McGovern --- pubtools/pulplib/_impl/schema/repository.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubtools/pulplib/_impl/schema/repository.yaml b/pubtools/pulplib/_impl/schema/repository.yaml index 2d4845af..f0976cd4 100644 --- a/pubtools/pulplib/_impl/schema/repository.yaml +++ b/pubtools/pulplib/_impl/schema/repository.yaml @@ -91,6 +91,8 @@ properties: # List of repositories used for populating the repository population_sources: type: array + items: + type: string # List of repository distributors. # Note that order matters in this list. From 2b8c22d4405b650db4ad1f706378b403a40a825d Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Thu, 2 Apr 2020 14:47:11 +0200 Subject: [PATCH 06/10] Added changelog note --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97da7fbc..68018892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - sourcerpm attribute for Rpm unit +- Added 'population_sources' and 'ubi_population' ## [2.5.0] - 2020-02-25 From f5953b9cbebf045b260abae8fa539f742412e846 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Mon, 6 Apr 2020 09:30:42 +0200 Subject: [PATCH 07/10] Update CHANGELOG.md Co-Authored-By: Nathan Gillett --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68018892..aa8d1a89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - sourcerpm attribute for Rpm unit -- Added 'population_sources' and 'ubi_population' +###Added +- Introduced 'population_sources' and 'ubi_population' attributes for yum repository ## [2.5.0] - 2020-02-25 From 8e32632f0cb4fb50c0174b66bfa51841d998b8d1 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Mon, 6 Apr 2020 10:01:40 +0200 Subject: [PATCH 08/10] Fixed docs string for ubi_population attr --- pubtools/pulplib/_impl/model/repository/yum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubtools/pulplib/_impl/model/repository/yum.py b/pubtools/pulplib/_impl/model/repository/yum.py index f4209211..7b17ec8d 100644 --- a/pubtools/pulplib/_impl/model/repository/yum.py +++ b/pubtools/pulplib/_impl/model/repository/yum.py @@ -82,7 +82,7 @@ class YumRepository(Repository): ubi_population = pulp_attrib( default=False, type=bool, pulp_field="notes.ubi_population" ) - """Flag indicating whether repo should be populated or not for the purposes of UBI + """Flag indicating whether repo should be populated from population_sources for the purposes of UBI """ mutable_urls = attr.ib( From f02d537d766ea082f528cafe1ab9b128dfae3c8f Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Mon, 6 Apr 2020 10:47:16 +0200 Subject: [PATCH 09/10] Fixed sourcerpm attribute for srpm units --- pubtools/pulplib/_impl/schema/unit.yaml | 4 +++- tests/fake/test_fake_search_content.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pubtools/pulplib/_impl/schema/unit.yaml b/pubtools/pulplib/_impl/schema/unit.yaml index 56ec14cd..42f691b6 100644 --- a/pubtools/pulplib/_impl/schema/unit.yaml +++ b/pubtools/pulplib/_impl/schema/unit.yaml @@ -61,7 +61,9 @@ definitions: # source rpm filename sourcerpm: - type: string + anyOf: + - type: string + - type: "null" # Short ID of key used to sign this RPM signing_key: diff --git a/tests/fake/test_fake_search_content.py b/tests/fake/test_fake_search_content.py index 7d797444..d41003e2 100644 --- a/tests/fake/test_fake_search_content.py +++ b/tests/fake/test_fake_search_content.py @@ -22,7 +22,13 @@ def populated_repo(controller): RpmUnit( content_type_id="srpm", name="bash", version="4.0", release="1", arch="src" ), - RpmUnit(name="glibc", version="5.0", release="1", arch="x86_64"), + RpmUnit( + name="glibc", + version="5.0", + release="1", + arch="x86_64", + sourcerpm="glibc-5.0-1.el5_11.1.src.rpm", + ), ModulemdUnit( name="module1", stream="s1", version=1234, context="a1b2", arch="x86_64" ), @@ -91,7 +97,13 @@ def test_search_content_by_type(populated_repo): units = list(populated_repo.search_content(crit)) assert sorted(units) == [ RpmUnit(name="bash", version="4.0", release="1", arch="x86_64"), - RpmUnit(name="glibc", version="5.0", release="1", arch="x86_64"), + RpmUnit( + name="glibc", + version="5.0", + release="1", + arch="x86_64", + sourcerpm="glibc-5.0-1.el5_11.1.src.rpm", + ), ] From 1ebf02c9b6dba9729039a7740957e88aaf8ef475 Mon Sep 17 00:00:00 2001 From: Jindrich Luza Date: Tue, 7 Apr 2020 10:32:51 +0200 Subject: [PATCH 10/10] Update CHANGELOG.md Co-Authored-By: Rohan McGovern --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8d1a89..3b998343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - sourcerpm attribute for Rpm unit -###Added - Introduced 'population_sources' and 'ubi_population' attributes for yum repository ## [2.5.0] - 2020-02-25