diff options
author | He Zhe <zhe.he@windriver.com> | 2016-05-25 04:47:16 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-30 15:58:11 +0100 |
commit | 0437a59e3c298d40aaa96af09b80bff8fcbe292d (patch) | |
tree | 0f97feda6f977e4e4c837897313413347ee36273 /meta/classes/kernel-grub.bbclass | |
parent | 077377e912ce3eabd4978b4246272665f8304b66 (diff) | |
download | poky-0437a59e3c298d40aaa96af09b80bff8fcbe292d.tar.gz |
kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time
Add KERNEL_IMAGETYPES to support building packaging and installing
multi types of kernel images, such as zImage uImage, at one time.
KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE work as before.
(From OE-Core rev: 849b67b2e4820564b5e5c9bd4bb293c44351c5f3)
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel-grub.bbclass')
-rw-r--r-- | meta/classes/kernel-grub.bbclass | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/meta/classes/kernel-grub.bbclass b/meta/classes/kernel-grub.bbclass index a63f482a91..f7dcc0715a 100644 --- a/meta/classes/kernel-grub.bbclass +++ b/meta/classes/kernel-grub.bbclass | |||
@@ -10,41 +10,44 @@ | |||
10 | # updates the new kernel as the boot priority. | 10 | # updates the new kernel as the boot priority. |
11 | # | 11 | # |
12 | 12 | ||
13 | pkg_preinst_kernel-image_append () { | 13 | python __anonymous () { |
14 | import re | ||
15 | |||
16 | preinst = ''' | ||
14 | # Parsing confliction | 17 | # Parsing confliction |
15 | [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list" | 18 | [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list" |
16 | [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg" | 19 | [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg" |
17 | if [ -n "$grubcfg" ]; then | 20 | if [ -n "$grubcfg" ]; then |
18 | # Dereference symlink to avoid confliction with new kernel name. | 21 | # Dereference symlink to avoid confliction with new kernel name. |
19 | if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then | 22 | if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then |
20 | if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then | 23 | if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then |
21 | kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 2>/dev/null` | 24 | kimage=`realpath $D/boot/KERNEL_IMAGETYPE 2>/dev/null` |
22 | if [ -f "$D$kimage" ]; then | 25 | if [ -f "$D$kimage" ]; then |
23 | sed -i "s:${KERNEL_IMAGETYPE} \+root=:${kimage##*/} root=:" $grubcfg | 26 | sed -i "s:KERNEL_IMAGETYPE \+root=:${kimage##*/} root=:" $grubcfg |
24 | fi | 27 | fi |
25 | fi | 28 | fi |
26 | fi | 29 | fi |
27 | 30 | ||
28 | # Rename old kernel if it conflicts with new kernel name. | 31 | # Rename old kernel if it conflicts with new kernel name. |
29 | if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=" $grubcfg; then | 32 | if grep -q "/KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=" $grubcfg; then |
30 | if [ -f "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" ]; then | 33 | if [ -f "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" ]; then |
31 | timestamp=`date +%s` | 34 | timestamp=`date +%s` |
32 | kimage="$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back" | 35 | kimage="$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}-$timestamp-back" |
33 | sed -i "s:${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg | 36 | sed -i "s:KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg |
34 | mv "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" "$kimage" | 37 | mv "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" "$kimage" |
35 | fi | 38 | fi |
36 | fi | 39 | fi |
37 | fi | 40 | fi |
38 | } | 41 | ''' |
39 | 42 | ||
40 | pkg_postinst_kernel-image_prepend () { | 43 | postinst = ''' |
41 | get_new_grub_cfg() { | 44 | get_new_grub_cfg() { |
42 | grubcfg="$1" | 45 | grubcfg="$1" |
43 | old_image="$2" | 46 | old_image="$2" |
44 | title="Update ${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-${PV}" | 47 | title="Update KERNEL_IMAGETYPE-${KERNEL_VERSION}-${PV}" |
45 | if [ "${grubcfg##*/}" = "grub.cfg" ]; then | 48 | if [ "${grubcfg##*/}" = "grub.cfg" ]; then |
46 | rootfs=`grep " *linux \+[^ ]\+ \+root=" $grubcfg -m 1 | \ | 49 | rootfs=`grep " *linux \+[^ ]\+ \+root=" $grubcfg -m 1 | \ |
47 | sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"` | 50 | sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"` |
48 | 51 | ||
49 | echo "menuentry \"$title\" {" | 52 | echo "menuentry \"$title\" {" |
50 | echo " set root=(hd0,1)" | 53 | echo " set root=(hd0,1)" |
@@ -52,7 +55,7 @@ pkg_postinst_kernel-image_prepend () { | |||
52 | echo "}" | 55 | echo "}" |
53 | elif [ "${grubcfg##*/}" = "menu.list" ]; then | 56 | elif [ "${grubcfg##*/}" = "menu.list" ]; then |
54 | rootfs=`grep "kernel \+[^ ]\+ \+root=" $grubcfg -m 1 | \ | 57 | rootfs=`grep "kernel \+[^ ]\+ \+root=" $grubcfg -m 1 | \ |
55 | sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"` | 58 | sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"` |
56 | 59 | ||
57 | echo "default 0" | 60 | echo "default 0" |
58 | echo "timeout 30" | 61 | echo "timeout 30" |
@@ -87,5 +90,16 @@ pkg_postinst_kernel-image_prepend () { | |||
87 | mv $grubcfgtmp $grubcfg | 90 | mv $grubcfgtmp $grubcfg |
88 | echo "Caution! Update kernel may affect kernel-module!" | 91 | echo "Caution! Update kernel may affect kernel-module!" |
89 | fi | 92 | fi |
93 | ''' | ||
94 | |||
95 | imagetypes = d.getVar('KERNEL_IMAGETYPES', True) | ||
96 | imagetypes = re.sub(r'\.gz$', '', imagetypes) | ||
97 | |||
98 | for type in imagetypes.split(): | ||
99 | typelower = type.lower() | ||
100 | preinst_append = preinst.replace('KERNEL_IMAGETYPE', type) | ||
101 | postinst_prepend = postinst.replace('KERNEL_IMAGETYPE', type) | ||
102 | d.setVar('pkg_preinst_kernel-image-' + typelower + '_append', preinst_append) | ||
103 | d.setVar('pkg_postinst_kernel-image-' + typelower + '_prepend', postinst_prepend) | ||
90 | } | 104 | } |
91 | 105 | ||