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)
Change-Id: I23e413e3c950f6daed923c69b882993a214dd49c
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>
Signed-off-by: Rick Altherr <raltherr@google.com>
diff --git a/import-layers/yocto-poky/meta/classes/kernel-grub.bbclass b/import-layers/yocto-poky/meta/classes/kernel-grub.bbclass
index a63f482..f7dcc07 100644
--- a/import-layers/yocto-poky/meta/classes/kernel-grub.bbclass
+++ b/import-layers/yocto-poky/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 @@
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 @@
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)
}