Created
July 8, 2019 17:27
-
-
Save ignatenkobrain/2414b1335429f08e7247523e9c55fd1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import solv | |
import sys | |
pool = solv.Pool() | |
pool.setarch() | |
for r in ('rawhide', 'rawhide-source'): | |
repo = pool.add_repo(r) | |
f = solv.xfopen(f'/var/cache/dnf/{r}.solv') | |
repo.add_solv(f) | |
f.close() | |
pool.addfileprovides() | |
pool.createwhatprovides() | |
sel = pool.select(sys.argv[1], solv.Selection.SELECTION_NAME | solv.Selection.SELECTION_WITH_SOURCE) | |
s = pool.best_solvables(sel.solvables())[0] | |
if s.arch != 'src': | |
src = s.lookup_sourcepkg()[:-4] | |
sel = pool.select(src, solv.Selection.SELECTION_CANON | solv.Selection.SELECTION_SOURCE_ONLY) | |
if sel.isempty(): | |
raise Exception(s) | |
s = sel.solvables()[0] | |
ss = f'{s}.rpm' | |
for p in pool.solvables: | |
if p.arch == 'src' or p.lookup_sourcepkg() != ss: | |
continue | |
sel = pool.Selection_all() | |
sel.matchsolvable(p, 0, solv.SOLVABLE_REQUIRES) | |
if sel.isempty(): | |
continue | |
print(f'{p} is required by:') | |
for pp in sel.solvables(): | |
if pp.arch not in {'src', 'nosrc'} and pp.lookup_sourcepkg() == ss: | |
continue | |
print(f' - {pp}') | |
for dep in pp.lookup_deparray(solv.SOLVABLE_REQUIRES): | |
print(f' - {dep}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment