forked from openSUSE/openSUSE-release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checknewer.py
executable file
·62 lines (55 loc) · 1.84 KB
/
checknewer.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python3
# check if all packages in a repo are newer than all other repos
from __future__ import print_function
import sys
import re
import solv
pool = solv.Pool()
args = sys.argv[1:]
if len(args) < 2:
print("Check if all packages in a repo are newer than all other repos")
print()
print("Usage: checknewer NEWREPO OLDREPO1 [OLDREPO2...]")
print()
print("A repo is one of: foo.solv, primary.xml, packages (susetags)")
sys.exit(1)
firstrepo = None
for arg in args:
argf = solv.xfopen(arg)
repo = pool.add_repo(arg)
if not firstrepo:
firstrepo = repo
if re.search(r'solv$', arg):
repo.add_solv(argf)
elif re.search(r'primary\.xml', arg):
repo.add_rpmmd(argf, None)
elif re.search(r'packages', arg):
repo.add_susetags(argf, 0, None)
else:
print(f"{arg}: unknown repo type")
sys.exit(1)
# we only want self-provides
for p in pool.solvables:
if p.archid == solv.ARCH_SRC or p.archid == solv.ARCH_NOSRC:
continue
selfprovides = pool.rel2id(p.nameid, p.evrid, solv.REL_EQ)
p.unset(solv.SOLVABLE_PROVIDES)
p.add_deparray(solv.SOLVABLE_PROVIDES, selfprovides)
pool.createwhatprovides()
for p in firstrepo.solvables:
newerdep = pool.rel2id(p.nameid, p.evrid, solv.REL_GT | solv.REL_EQ)
for pp in pool.whatprovides(newerdep):
if pp.repo == firstrepo:
continue
if p.nameid != pp.nameid:
continue
if p.identical(pp):
continue
if p.archid != pp.archid and p.archid != solv.ARCH_NOARCH and pp.archid != solv.ARCH_NOARCH:
continue
src = p.name
if not p.lookup_void(solv.SOLVABLE_SOURCENAME):
src = p.lookup_str(solv.SOLVABLE_SOURCENAME)
if src is None:
src = "?"
print(f"{src}: {p} is older than {pp} from {pp.repo}")