Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions pubtools/pulplib/_impl/model/repository/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions pubtools/pulplib/_impl/schema/repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion pubtools/pulplib/_impl/schema/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 14 additions & 2 deletions tests/fake/test_fake_search_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
Expand Down Expand Up @@ -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",
),
]


Expand Down
18 changes: 17 additions & 1 deletion tests/repository/test_yum_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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