diff options
-rw-r--r-- | meta/classes/kernel.bbclass | 30 | ||||
-rw-r--r-- | meta/classes/linux-kernel-base.bbclass | 42 |
2 files changed, 45 insertions, 27 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index c81112ede7..3a7fd5b499 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
@@ -1,4 +1,4 @@ | |||
1 | inherit module_strip | 1 | inherit linux-kernel-base module_strip |
2 | 2 | ||
3 | PROVIDES += "virtual/kernel" | 3 | PROVIDES += "virtual/kernel" |
4 | DEPENDS += "virtual/${TARGET_PREFIX}depmod-${@get_kernelmajorversion('${PV}')} virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules" | 4 | DEPENDS += "virtual/${TARGET_PREFIX}depmod-${@get_kernelmajorversion('${PV}')} virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules" |
@@ -10,7 +10,7 @@ PACKAGES_DYNAMIC += "kernel-image-*" | |||
10 | 10 | ||
11 | export OS = "${TARGET_OS}" | 11 | export OS = "${TARGET_OS}" |
12 | export CROSS_COMPILE = "${TARGET_PREFIX}" | 12 | export CROSS_COMPILE = "${TARGET_PREFIX}" |
13 | KERNEL_IMAGETYPE = "zImage" | 13 | KERNEL_IMAGETYPE ?= "zImage" |
14 | 14 | ||
15 | KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}" | 15 | KERNEL_PRIORITY = "${@bb.data.getVar('PV',d,1).split('-')[0].split('.')[-1]}" |
16 | 16 | ||
@@ -43,31 +43,7 @@ KERNEL_IMAGEDEST = "boot" | |||
43 | # | 43 | # |
44 | export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}" | 44 | export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}" |
45 | 45 | ||
46 | # parse kernel ABI version out of <linux/version.h> | 46 | KERNEL_VERSION = "${@get_kernelversion('${S}')}" |
47 | def get_kernelversion(p): | ||
48 | import re | ||
49 | try: | ||
50 | f = open(p, 'r') | ||
51 | except IOError: | ||
52 | return None | ||
53 | l = f.readlines() | ||
54 | f.close() | ||
55 | r = re.compile("#define UTS_RELEASE \"(.*)\"") | ||
56 | for s in l: | ||
57 | m = r.match(s) | ||
58 | if m: | ||
59 | return m.group(1) | ||
60 | return None | ||
61 | |||
62 | def get_kernelmajorversion(p): | ||
63 | import re | ||
64 | r = re.compile("([0-9]+\.[0-9]+).*") | ||
65 | m = r.match(p); | ||
66 | if m: | ||
67 | return m.group(1) | ||
68 | return None | ||
69 | |||
70 | KERNEL_VERSION = "${@get_kernelversion('${S}/include/linux/version.h')}" | ||
71 | KERNEL_MAJOR_VERSION = "${@get_kernelmajorversion('${KERNEL_VERSION}')}" | 47 | KERNEL_MAJOR_VERSION = "${@get_kernelmajorversion('${KERNEL_VERSION}')}" |
72 | 48 | ||
73 | KERNEL_LOCALVERSION ?= "" | 49 | KERNEL_LOCALVERSION ?= "" |
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> | ||
2 | def 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 | |||
24 | def 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 | |||
32 | def 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 | |||