aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-grub.bbclass
diff options
context:
space:
mode:
authorHe Zhe <zhe.he@windriver.com>2016-05-25 04:47:16 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-30 09:30:30 +0100
commit849b67b2e4820564b5e5c9bd4bb293c44351c5f3 (patch)
tree41a83ed3ff34e8e9c7c8effbbc09b666fa971ee7 /meta/classes/kernel-grub.bbclass
parentfb3457a454b045abf1fa6b560b8f96257a4405c1 (diff)
downloadopenembedded-core-contrib-849b67b2e4820564b5e5c9bd4bb293c44351c5f3.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. Signed-off-by: He Zhe <zhe.he@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/classes/kernel-grub.bbclass')
-rw-r--r--meta/classes/kernel-grub.bbclass44
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 @@
# updates the new kernel as the boot priority.
#
-pkg_preinst_kernel-image_append () {
+python __anonymous () {
+ import re
+
+ preinst = '''
# Parsing confliction
[ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
[ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
if [ -n "$grubcfg" ]; then
# Dereference symlink to avoid confliction with new kernel name.
- if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
- if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
- kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 2>/dev/null`
+ if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
+ if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
+ kimage=`realpath $D/boot/KERNEL_IMAGETYPE 2>/dev/null`
if [ -f "$D$kimage" ]; then
- sed -i "s:${KERNEL_IMAGETYPE} \+root=:${kimage##*/} root=:" $grubcfg
+ sed -i "s:KERNEL_IMAGETYPE \+root=:${kimage##*/} root=:" $grubcfg
fi
fi
fi
# Rename old kernel if it conflicts with new kernel name.
- if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=" $grubcfg; then
- if [ -f "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" ]; then
+ if grep -q "/KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=" $grubcfg; then
+ if [ -f "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" ]; then
timestamp=`date +%s`
- kimage="$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back"
- sed -i "s:${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg
- mv "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" "$kimage"
+ kimage="$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}-$timestamp-back"
+ sed -i "s:KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg
+ mv "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" "$kimage"
fi
fi
fi
-}
+'''
-pkg_postinst_kernel-image_prepend () {
+ postinst = '''
get_new_grub_cfg() {
grubcfg="$1"
old_image="$2"
- title="Update ${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-${PV}"
+ title="Update KERNEL_IMAGETYPE-${KERNEL_VERSION}-${PV}"
if [ "${grubcfg##*/}" = "grub.cfg" ]; then
rootfs=`grep " *linux \+[^ ]\+ \+root=" $grubcfg -m 1 | \
- sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"`
+ sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"`
echo "menuentry \"$title\" {"
echo " set root=(hd0,1)"
@@ -52,7 +55,7 @@ pkg_postinst_kernel-image_prepend () {
echo "}"
elif [ "${grubcfg##*/}" = "menu.list" ]; then
rootfs=`grep "kernel \+[^ ]\+ \+root=" $grubcfg -m 1 | \
- sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"`
+ sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"`
echo "default 0"
echo "timeout 30"
@@ -87,5 +90,16 @@ pkg_postinst_kernel-image_prepend () {
mv $grubcfgtmp $grubcfg
echo "Caution! Update kernel may affect kernel-module!"
fi
+'''
+
+ imagetypes = d.getVar('KERNEL_IMAGETYPES', True)
+ imagetypes = re.sub(r'\.gz$', '', imagetypes)
+
+ for type in imagetypes.split():
+ typelower = type.lower()
+ preinst_append = preinst.replace('KERNEL_IMAGETYPE', type)
+ postinst_prepend = postinst.replace('KERNEL_IMAGETYPE', type)
+ d.setVar('pkg_preinst_kernel-image-' + typelower + '_append', preinst_append)
+ d.setVar('pkg_postinst_kernel-image-' + typelower + '_prepend', postinst_prepend)
}