Last active
May 3, 2020 10:41
-
-
Save ignatenkobrain/42973b15fd1bb7d203f32252e47c8e05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python3 | |
import argparse | |
import collections | |
import bugzilla | |
import solv | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("repo") | |
args = parser.parse_args() | |
pool = solv.Pool() | |
pool.setarch("x86_64") | |
for r in ("koji",): # "koji-source"): | |
repo = pool.add_repo(r) | |
f = solv.xfopen(f"/var/cache/dnf/{r}.solv") | |
repo.add_solv(f) | |
f.close() | |
""" | |
repodata = repo.add_repodata() | |
f = solv.xfopen(f"/var/cache/dnf/{r}-filenames.solvx") | |
repodata.add_solv( | |
f, | |
solv.Repo.REPO_USE_LOADING | |
| solv.Repo.REPO_EXTEND_SOLVABLES | |
| solv.Repo.REPO_LOCALPOOL, | |
) | |
f.close() | |
""" | |
pool.addfileprovides() | |
pool.createwhatprovides() | |
solver = pool.Solver() | |
solver.set_flag(solv.Solver.SOLVER_FLAG_IGNORE_RECOMMENDED, True) | |
candq = set(pool.solvables) | |
while candq: | |
jobs = [ | |
pool.Job( | |
solv.Job.SOLVER_SOLVABLE | |
| solv.Job.SOLVER_INSTALL | |
| solv.Job.SOLVER_WEAK, | |
p.id, | |
) | |
for p in candq | |
] | |
solver.solve(jobs) | |
candq_n = candq - set(pool.id2solvable(s) for s in solver.raw_decisions(1)) | |
if candq == candq_n: | |
break | |
candq = candq_n | |
if not candq: | |
return | |
to_report = collections.defaultdict(lambda: collections.defaultdict(list)) | |
for s in (pool.id2solvable(s) for s in sorted(s.id for s in candq)): | |
# XXX | |
if not s.name.startswith("python"): | |
continue | |
problems = solver.solve( | |
[pool.Job(solv.Job.SOLVER_SOLVABLE | solv.Job.SOLVER_INSTALL, s.id)] | |
) | |
if not problems: | |
continue | |
for problem in problems: | |
minfo = problem.findproblemrule().info() | |
if ( | |
minfo.type == solv.Solver.SOLVER_RULE_PKG_REQUIRES | |
or minfo.solvable != s | |
): | |
# This is problem of some other package | |
# [info.problemstr() for rule in problem.findallproblemrules() for info in rule.allinfos()] | |
continue | |
for problemrule in problem.findallproblemrules(): | |
for info in problemrule.allinfos(): | |
if s.arch == "src": | |
srcname = s.name | |
else: | |
srcname = s.lookup_sourcepkg().rsplit("-", 2)[0] | |
to_report[srcname][str(s)].append(info.problemstr()) | |
bz = bugzilla.Bugzilla("https://bugzilla.redhat.com") | |
ftibug = bz.getbug("F33FailsToInstall") | |
# ftbfsbug = bz.getbug("F33FTBFS") | |
query_fti = bz.build_query( | |
product="Fedora", | |
version="rawhide", | |
include_fields=["id", "status", "component"], | |
) | |
query_fti["blocks"] = ftibug.id | |
ignore_fti = {b.component for b in bz.query(query_fti) if b.status != "CLOSED"} | |
for src, pkgs in to_report.items(): | |
if src in ignore_fti: | |
print(f"Skipping becase bug already exists: {src}") | |
continue | |
if src.startswith("rust-"): | |
continue | |
msg = f"""Hello, | |
Your package ({src}) Fails To Install in Fedora 33: | |
""" | |
for pkg, problems in pkgs.items(): | |
msg += f"""--- | |
can't install {pkg}: | |
""" | |
for problem in problems: | |
msg += f" - {problem}\n" | |
msg += f"""--- | |
According to a policy for FTBFS/FTI bugs (https://docs.fedoraproject.org/en-US/fesco/Fails_to_build_from_source_Fails_to_install/), your package may be orphaned in 8+ weeks if you won't reply to this bug. | |
Thanks!""" | |
info = bz.build_createbug( | |
product="Fedora", | |
version="rawhide", | |
component=src, | |
summary=f"FTI: {src}: {', '.join(s.rsplit('-', 2)[0] for s in pkgs)}", | |
description=msg, | |
blocks=ftibug.id, | |
) | |
print(msg) | |
# bz.createbug(info) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment