aboutsummaryrefslogtreecommitdiff
path: root/personal_infra/hack_dnf_problems.py
blob: a88f1b5ba0fc3d11be0df349ed70502d3ad9dc15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python3

import itertools
import shlex
import subprocess

def _(*args):
    print(shlex.join(args))
    subprocess.run(args, check=True)

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(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)

failed = []

for r in problematic_repos:
    try:
        update_enabled([r])
    except Exception as e:
        failed.append(r)
        print(f"fail {r}: {e}")

print(f"failed {failed}")