Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # parse kernel ABI version out of <linux/version.h> |
| 2 | def 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 | |
| 27 | def 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 | |
| 36 | def linux_module_packages(s, d): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 37 | suffix = "" |
| 38 | return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split())) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | |
| 40 | # that's all |
| 41 | |