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
63
64
65
|
#!/usr/bin/env python3
import platform
import sys
import apt_pkg
os_release = platform.freedesktop_os_release()
if os_release["ID"] != "debian" and os_release.get("VERSION_CODENAME"):
print(os_release["VERSION_CODENAME"])
sys.exit(0)
apt_pkg.init()
c = apt_pkg.Cache(None)
d = apt_pkg.DepCache(c)
s = apt_pkg.SourceList()
s.read_main_list()
highest_prio = -1
highest_archive = None
for pkgfile, _ in d.get_candidate_ver(c["base-files"]).file_list:
print("processing: %s" % pkgfile, file=sys.stderr)
index = s.find_index(pkgfile)
if index is None:
print("index is none -- skipping", file=sys.stderr)
continue
if not index.is_trusted:
print("index is not trusted -- skipping", file=sys.stderr)
continue
archive = pkgfile.archive
if archive not in ["stable", "testing", "unstable"]:
print("index archive %s is %s -- skipping" % (index, archive), file=sys.stderr)
continue
prio = d.policy.get_priority(pkgfile)
if prio > highest_prio:
highest_prio = prio
highest_archive = archive
if highest_archive is None:
print(
"highest priority apt archive is neither stable, testing or unstable",
file=sys.stderr,
)
for f in c.file_list:
print("========================", file=sys.stderr)
for a in [
"architecture",
"archive",
"codename",
"component",
"filename",
"id",
"index_type",
"label",
"not_automatic",
"not_source",
"origin",
"site",
"size",
"version",
]:
print("%s: %s" % (a, getattr(f, a, None)), file=sys.stderr)
print("priority: ", d.policy.get_priority(f), file=sys.stderr)
exit(1)
print("highest archive priority: %s" % highest_archive, file=sys.stderr)
print(highest_archive)
|