blob: ba59222c24c600265f1a3764a71856c2e24439c6 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# parse kernel ABI version out of <linux/version.h>
2def get_kernelversion_headers(p):
3 import re
4
5 fn = p + '/include/linux/utsrelease.h'
6 if not os.path.isfile(fn):
7 # after 2.6.33-rc1
8 fn = p + '/include/generated/utsrelease.h'
9 if not os.path.isfile(fn):
10 fn = p + '/include/linux/version.h'
11
12 try:
13 f = open(fn, 'r')
14 except IOError:
15 return None
16
17 l = f.readlines()
18 f.close()
19 r = re.compile("#define UTS_RELEASE \"(.*)\"")
20 for s in l:
21 m = r.match(s)
22 if m:
23 return m.group(1)
24 return None
25
26
27def get_kernelversion_file(p):
28 fn = p + '/kernel-abiversion'
29
30 try:
31 with open(fn, 'r') as f:
32 return f.readlines()[0].strip()
33 except IOError:
34 return None
35
36def linux_module_packages(s, d):
Brad Bishopa5c52ff2018-11-23 10:55:50 +130037 suffix = ""
38 return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split()))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40# that's all
41