summaryrefslogtreecommitdiffstats
path: root/meta/classes/linux-kernel-base.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/linux-kernel-base.bbclass')
-rw-r--r--meta/classes/linux-kernel-base.bbclass42
1 files changed, 42 insertions, 0 deletions
diff --git a/meta/classes/linux-kernel-base.bbclass b/meta/classes/linux-kernel-base.bbclass
new file mode 100644
index 0000000000..e58c228080
--- /dev/null
+++ b/meta/classes/linux-kernel-base.bbclass
@@ -0,0 +1,42 @@
1# parse kernel ABI version out of <linux/version.h>
2def get_kernelversion(p):
3 import re, os
4
5 fn = p + '/include/linux/utsrelease.h'
6 if not os.path.isfile(fn):
7 fn = p + '/include/linux/version.h'
8
9 import re
10 try:
11 f = open(fn, 'r')
12 except IOError:
13 return None
14
15 l = f.readlines()
16 f.close()
17 r = re.compile("#define UTS_RELEASE \"(.*)\"")
18 for s in l:
19 m = r.match(s)
20 if m:
21 return m.group(1)
22 return None
23
24def get_kernelmajorversion(p):
25 import re
26 r = re.compile("([0-9]+\.[0-9]+).*")
27 m = r.match(p);
28 if m:
29 return m.group(1)
30 return None
31
32def linux_module_packages(s, d):
33 import bb, os.path
34 suffix = ""
35 if (bb.data.getVar("PARALLEL_INSTALL_MODULES", d, 1) == "1"):
36 file = bb.data.expand('${STAGING_KERNEL_DIR}/kernel-abiversion', d)
37 if (os.path.exists(file)):
38 suffix = "-%s" % (get_kernelmajorversion(base_read_file(file)))
39 return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split()))
40
41# that's all
42