-
Notifications
You must be signed in to change notification settings - Fork 0
/
dists
executable file
·73 lines (54 loc) · 1.82 KB
/
dists
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
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
import os
import sys
import itertools
from distro_info import DebianDistroInfo, UbuntuDistroInfo
def get_sorted_dists(distro_functions):
dist_objects = itertools.chain(
*(func(result="object") for func in distro_functions)
)
unique_dists = {
dist.series for dist in sorted(dist_objects, key=lambda x: x.created)
}
return sorted(unique_dists)
def get_debian_dists():
debian = DebianDistroInfo()
oldstable = debian.codename("oldstable")
stable = debian.codename("stable")
testing = debian.codename("testing")
dists = [oldstable, stable, testing, "unstable", "experimental"]
dists.extend(
[
f"{release}-{suffix}"
for release in [oldstable, stable, testing]
for suffix in ["backports", "proposed-updates", "updates"]
]
)
dists.extend([f"{release}-backports-sloppy" for release in [oldstable, stable]])
return ",".join(sorted(dists))
def get_ubuntu_dists():
ubuntu_info = UbuntuDistroInfo()
sorted_ubuntu_dists = get_sorted_dists(
[ubuntu_info.supported]
) # , ubuntu_info.supported_esm])
dists = []
for release in sorted_ubuntu_dists:
dists.extend(
[
f"{release}-{suffix}"
for suffix in ["proposed", "updates", "backports", "security"]
]
)
dists.append(release)
return ",".join(dists)
def main():
if len(sys.argv) != 2 or sys.argv[1] not in ["debian", "ubuntu", "ubuntu-ports"]:
script = os.path.basename(sys.argv[0])
print(f"Usage: {script} [debian|ubuntu|ubuntu-ports]", file=sys.stderr)
sys.exit(1)
if sys.argv[1] == "debian":
print(get_debian_dists())
sys.exit(0)
print(get_ubuntu_dists())
if __name__ == "__main__":
main()