diff --git a/CHANGELOG.md b/CHANGELOG.md index 97da7fbc..3b998343 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 +- Introduced 'population_sources' and 'ubi_population' attributes for yum repository ## [2.5.0] - 2020-02-25 diff --git a/pubtools/pulplib/_impl/model/repository/yum.py b/pubtools/pulplib/_impl/model/repository/yum.py index 6c9e97da..7b17ec8d 100644 --- a/pubtools/pulplib/_impl/model/repository/yum.py +++ b/pubtools/pulplib/_impl/model/repository/yum.py @@ -70,6 +70,21 @@ class YumRepository(Repository): type = pulp_attrib(default="rpm-repo", type=str, pulp_field="notes._repo-type") + population_sources = pulp_attrib( + default=attr.Factory(FrozenList), + type=list, + converter=FrozenList, + pulp_field="notes.population_sources", + ) + """List of repository IDs used to populate this repository + """ + + ubi_population = pulp_attrib( + default=False, type=bool, pulp_field="notes.ubi_population" + ) + """Flag indicating whether repo should be populated from population_sources for the purposes of UBI + """ + mutable_urls = attr.ib( default=attr.Factory(lambda: FrozenList(["repodata/repomd.xml"])), type=list, diff --git a/pubtools/pulplib/_impl/schema/repository.yaml b/pubtools/pulplib/_impl/schema/repository.yaml index affaecbe..f0976cd4 100644 --- a/pubtools/pulplib/_impl/schema/repository.yaml +++ b/pubtools/pulplib/_impl/schema/repository.yaml @@ -83,6 +83,17 @@ properties: pub_temp_repo: type: boolean + # True if repository supposed to be populated from repositories + # mentioned in population_sources + ubi_population: + type: boolean + + # 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. distributors: 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", + ), ] diff --git a/tests/repository/test_yum_repository.py b/tests/repository/test_yum_repository.py index 822ec761..8ba46a5d 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(): + """test populate attributes are correctly parsed from repo notes""" + 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