]> git.ipfire.org Git - people/jschlag/pbs.git/blob - src/buildservice/arches.py
Drop concept of non-public builds
[people/jschlag/pbs.git] / src / buildservice / arches.py
1 #!/usr/bin/python
2
3 from . import base
4
5 _priorities = {
6 "noarch" : 0,
7
8 # 64 bit
9 "x86_64" : 1,
10 "aarch64" : 2,
11
12 # 32 bit
13 "i686" : 3,
14 "armv7hl" : 4,
15 "armv5tel" : 5,
16 }
17
18 def priority(arch):
19 try:
20 return _priorities[arch]
21 except KeyError:
22 return 99
23
24 class Arches(base.Object):
25 def __iter__(self):
26 res = self.db.query("SELECT name FROM arches \
27 WHERE NOT name = ANY(%s)", ["noarch", "src"])
28
29 return iter(sorted((a.name for a in res), key=priority))
30
31 def exists(self, name):
32 # noarch doesn't really exist
33 if name == "noarch":
34 return False
35
36 res = self.db.get("SELECT 1 FROM arches \
37 WHERE name = %s", name)
38
39 if res:
40 return True
41
42 return False
43
44 def expand(self, arches):
45 if arches == "all":
46 return list(self)
47
48 res = []
49 for arch in arches.split():
50 if self.exists(arch):
51 res.append(arch)
52
53 return res