Support operating on source repos (#10)
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m21s
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m21s
So I happened to find another reason to work on #10 - it's useful for figuring out the consequences of dropping a package: quality/tickets#880 (comment) The good news is, this turns out to be easy. We only need a small change to the repository modification code to handle source repos, where the package entries don't specifiy a sourcerpm - we just take the package name. We identify this case by looking at the package arch; if it's "src" we just take the name, if it's anything else we use the existing approach. With this change, you can just include the appropriate source repository as a base repository, and otherwise use rmdepcheck just the same. e.g. this command tests what happens if you drop the python-pytest-xprocess package from F44: ./rmdepcheck.py --removes https://dl.fedoraproject.org/pub/fedora/linux/development/44/Everything/x86_64/os/,https://dl.fedoraproject.org/pub/fedora/linux/development/44/Everything/source/tree/ python-pytest-xprocess You can see it works because there are results for .src packages from the source repo; these are build dependencies. If you run the same command without the source repo you get a smaller set of results covering only the runtime dependencies. Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
be15cb02b5
commit
cd1d5aa100
4 changed files with 88 additions and 13 deletions
|
|
@ -153,8 +153,13 @@ def replace_primary(primfn: str, removes: Iterable[str]) -> tuple[str, int, str,
|
|||
primtree = et.parse(primfn)
|
||||
primroot = primtree.getroot()
|
||||
for pkg in primroot.findall("common:package", XMLNS):
|
||||
srpm = mfind(mfind(pkg, "common:format", XMLNS), "rpm:sourcerpm", XMLNS).text
|
||||
if srpm and srpm.rsplit("-", 2)[0] in removes:
|
||||
if mfind(pkg, "common:arch", XMLNS).text == "src":
|
||||
spkg = mfind(pkg, "common:name", XMLNS).text
|
||||
else:
|
||||
spkg = mfind(mfind(pkg, "common:format", XMLNS), "rpm:sourcerpm", XMLNS).text
|
||||
if spkg:
|
||||
spkg = spkg.rsplit("-", 2)[0]
|
||||
if spkg and spkg in removes:
|
||||
primroot.remove(pkg)
|
||||
|
||||
tempfn = f"{rddir}/primtemp.xml"
|
||||
|
|
|
|||
|
|
@ -95,24 +95,43 @@ def test_get_download_primary():
|
|||
)
|
||||
|
||||
|
||||
def test_replace_primary():
|
||||
@pytest.mark.parametrize(
|
||||
"repotup", (
|
||||
(
|
||||
"binary",
|
||||
(
|
||||
"42daebf05f6c3cabe9d029acb3a8056f7fc533cde9820b7388d90acb1f6e7dbe",
|
||||
1067,
|
||||
"562981a96ba946cd0f993d180108c4dd107d1a5f24210c5768b19cdd93e8f33a",
|
||||
7531,
|
||||
)
|
||||
),
|
||||
(
|
||||
"source",
|
||||
(
|
||||
"3378e32450503892f65c6ff2a77a451f069146c4284a69f21752e113918da64f",
|
||||
566,
|
||||
"7ac52d6a0f3c0314a58f78eff39f4a7b5721127816b1b59d8ef30f4a29e091d9",
|
||||
1045,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
def test_replace_primary(repotup):
|
||||
repo, expected = repotup
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
shutil.copy2(
|
||||
# this is an old version of base's primary file
|
||||
f"{TESTDATA}/test_replace_primary.xml",
|
||||
# binary.xml is an old version of base's primary file
|
||||
# source.xml is a primary file from a repo with just
|
||||
# ccc.src and ddd.src packages
|
||||
f"{TESTDATA}/test_replace_primary_{repo}.xml",
|
||||
f"{tempdir}/test.xml",
|
||||
)
|
||||
ret = rmdepcheck.replace_primary(f"{tempdir}/test.xml", "ccc")
|
||||
print(tempdir)
|
||||
assert ret == (
|
||||
"42daebf05f6c3cabe9d029acb3a8056f7fc533cde9820b7388d90acb1f6e7dbe",
|
||||
1067,
|
||||
"562981a96ba946cd0f993d180108c4dd107d1a5f24210c5768b19cdd93e8f33a",
|
||||
7531,
|
||||
)
|
||||
assert ret == expected
|
||||
assert os.path.exists(
|
||||
# pylint: disable-next=line-too-long
|
||||
f"{tempdir}/42daebf05f6c3cabe9d029acb3a8056f7fc533cde9820b7388d90acb1f6e7dbe-primary.xml.zst"
|
||||
f"{tempdir}/{expected[0]}-primary.xml.zst"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
51
tests/testdata/test_replace_primary_source.xml
vendored
Normal file
51
tests/testdata/test_replace_primary_source.xml
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata xmlns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm" packages="2">
|
||||
<package type="rpm">
|
||||
<name>ccc</name>
|
||||
<arch>src</arch>
|
||||
<version epoch="0" ver="1.0" rel="1"/>
|
||||
<checksum type="sha256" pkgid="YES">81b6e8246bcf98be9d18b0848c70e1614d522939231f08559c80970a6dd367ae</checksum>
|
||||
<summary>Dummy summary</summary>
|
||||
<description>This is a dummy description.</description>
|
||||
<packager>Fedora Project</packager>
|
||||
<url></url>
|
||||
<time file="1773779954" build="1773779954"/>
|
||||
<size package="6297" installed="0" archive="124"/>
|
||||
<location href="ccc-1.0-1.src.rpm"/>
|
||||
<format>
|
||||
<rpm:license>GPL</rpm:license>
|
||||
<rpm:vendor>Fedora Project</rpm:vendor>
|
||||
<rpm:group>Applications/Productivity</rpm:group>
|
||||
<rpm:buildhost>toolbx</rpm:buildhost>
|
||||
<rpm:sourcerpm>ccc-1.0-1.src.rpm</rpm:sourcerpm>
|
||||
<rpm:header-range start="4504" end="6253"/>
|
||||
<rpm:provides>
|
||||
<rpm:entry name="ccc" flags="EQ" epoch="0" ver="1.0" rel="1"/>
|
||||
</rpm:provides>
|
||||
</format>
|
||||
</package>
|
||||
<package type="rpm">
|
||||
<name>ddd</name>
|
||||
<arch>src</arch>
|
||||
<version epoch="0" ver="1.0" rel="1"/>
|
||||
<checksum type="sha256" pkgid="YES">8961c521f38804fd4910310bd4a9bb075cbbde6bbd7fa52523dcd57d2953a4a2</checksum>
|
||||
<summary>Dummy summary</summary>
|
||||
<description>This is a dummy description.</description>
|
||||
<packager>Fedora Project</packager>
|
||||
<url></url>
|
||||
<time file="1773779954" build="1773779954"/>
|
||||
<size package="6297" installed="0" archive="124"/>
|
||||
<location href="ddd-1.0-1.src.rpm"/>
|
||||
<format>
|
||||
<rpm:license>GPL</rpm:license>
|
||||
<rpm:vendor>Fedora Project</rpm:vendor>
|
||||
<rpm:group>Applications/Productivity</rpm:group>
|
||||
<rpm:buildhost>toolbx</rpm:buildhost>
|
||||
<rpm:sourcerpm>ddd-1.0-1.src.rpm</rpm:sourcerpm>
|
||||
<rpm:header-range start="4504" end="6253"/>
|
||||
<rpm:provides>
|
||||
<rpm:entry name="ddd" flags="EQ" epoch="0" ver="1.0" rel="1"/>
|
||||
</rpm:provides>
|
||||
</format>
|
||||
</package>
|
||||
</metadata>
|
||||
Loading…
Add table
Add a link
Reference in a new issue