aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2025-08-01 08:51:53 +0200
committeralexpdp7 <alex@corcoles.net>2025-08-01 08:52:51 +0200
commitb859bc938954ee4d8e7674df4cea488062c5ce99 (patch)
tree1bc1526c3b36ffe9c4d73ed0588b2e84afda23d9
parent2f70ce4f1260fbffeb9f2175ddacafa5904e0bf1 (diff)
Refine hack_dnf_problems script
-rwxr-xr-xpersonal_infra/hack_dnf_problems.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/personal_infra/hack_dnf_problems.py b/personal_infra/hack_dnf_problems.py
index a88f1b5b..5c104d70 100755
--- a/personal_infra/hack_dnf_problems.py
+++ b/personal_infra/hack_dnf_problems.py
@@ -1,8 +1,10 @@
#!/usr/bin/python3
-import itertools
+import datetime
+import pathlib
import shlex
import subprocess
+import sys
def _(*args):
print(shlex.join(args))
@@ -12,27 +14,32 @@ def clean():
_("rpm", "--rebuilddb")
_("dnf", "clean", "all")
-def update_disabled(repos):
- args = ["dnf", "update", "-y"] + list(itertools.chain(*[("--disablerepo", r) for r in repos]))
- _(*args)
+def update_enabled(repo):
+ clean()
+ _("dnf", "update", "-y", "--disablerepo=*", "--enablerepo", repo)
-def update_enabled(repos):
- args = ["dnf", "update", "-y", "--disablerepo=*"] + list(itertools.chain(*[("--enablerepo", r) for r in repos]))
- _(*args)
-
-clean()
-
-problematic_repos = ["copr:copr.fedorainfracloud.org:mlampe:emacs-30", "okay", "extras"]
-
-update_disabled(problematic_repos)
+repolist = subprocess.run(["dnf", "repolist"], check=True, stdout=subprocess.PIPE, text=True).stdout
+repos = [lps[0] for lps in map(str.split, repolist.splitlines()[1:])]
failed = []
-for r in problematic_repos:
+for r in repos:
try:
- update_enabled([r])
+ update_enabled(r)
except Exception as e:
failed.append(r)
print(f"fail {r}: {e}")
-print(f"failed {failed}")
+if not failed:
+ sys.exit(0)
+
+failed_path = pathlib.Path("failed")
+
+existing_failed = failed_path.read_text() if failed_path.exists() else ""
+
+for f in failed:
+ existing_failed += f"{f} {datetime.date.today()}\n"
+
+failed_path.write_text(existing_failed)
+
+print(f"failed {failed}, wrote to {failed_path}")