mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
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>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user