forked from OpenMandrivaSoftware/rhel-builder-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_arch.py
46 lines (34 loc) · 1 KB
/
check_arch.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
#!/usr/bin/python2
#
# Check if a package can be built for the given architecture
# (i.e., arch is not forbidden by ExcludeArch or included
# in ExclusiveArch set if the latter is defined)
#
import sys
import glob
import os.path
import rpm
if len(sys.argv) < 3:
sys.exit('Usage: %s srpm arch' % sys.argv[0])
srpm = sys.argv[1]
platform_arch = sys.argv[2]
ts = rpm.TransactionSet()
ts.setVSFlags(~(rpm.RPMVSF_NEEDPAYLOAD))
fdno = os.open(srpm, os.O_RDONLY)
hdr = ts.hdrFromFdno(fdno)
if hdr['excludearch']:
for a in hdr['excludearch']:
if a == platform_arch:
print("Architecture is excluded per package spec file (ExcludeArch tag)")
sys.exit(1)
exit_code = 0
if hdr['exclusivearch']:
exit_code = 1
for a in hdr['exclusivearch']:
print(a)
if a == platform_arch:
exit_code = 0
break
if exit_code == 1:
print("The package has ExclusiveArch tag set, but the current architecture is not mentioned there")
sys.exit(exit_code)