Support operating on source repos (#10)
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m20s
AI Code Review / ai-review (pull_request_target) Successful in 15s
AI Code Review / remove-label (pull_request_target) Successful in 2s

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:
Adam Williamson 2026-03-17 11:55:12 -07:00
commit 79f816ad0e

View file

@ -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"