classes/kernel: Use a copy of image for kernel*.rpm if fs doesn't support symlinks
This patch can make ensure that unversioned kernel image symlink will be added to the rootfs during do_install by post install and it can fall back to make a copy if the unversioned kernel image symlink creation fails on target.
I have done the basic test on my board and the oe-selftest for this patch. The test passed.
$ oe-selftest -r efibootpartition.GenericEFITest.test_boot_efi 2020-07-03 10:16:29,211 - oe-selftest - INFO - Adding layer libraries: 2020-07-03 10:16:29,211 - oe-selftest - INFO - /buildarea/raid0/yxu2/repo/poky/poky/meta/lib
2020-07-03 10:16:29,211 - oe-selftest - INFO - /buildarea/raid0/yxu2/repo/poky/poky/meta-yocto-bsp/lib
2020-07-03 10:16:29,212 - oe-selftest - INFO - /buildarea/raid0/yxu2/repo/poky/poky/meta-selftest/lib
2020-07-03 10:16:29,212 - oe-selftest - INFO - Running bitbake -e to test the configuration is valid/parsable
2020-07-03 10:16:43,055 - oe-selftest - INFO - Adding: "include selftest.inc" in /buildarea/raid0/yxu2/repo/poky/poky/1285-st/conf/local.conf
2020-07-03 10:16:43,055 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2020-07-03 10:16:43,056 - oe-selftest - INFO - test_boot_efi (efibootpartition.GenericEFITest)
2020-07-03 11:40:03,056 - oe-selftest - INFO - Keepalive message
2020-07-03 12:29:28,901 - oe-selftest - INFO - ... ok 2020-07-03 12:30:46,074 - oe-selftest - INFO - ----------------------------------------------------------------------
2020-07-03 12:30:46,074 - oe-selftest - INFO - Ran 1 test in 8055.415s 2020-07-03 12:30:46,074 - oe-selftest - INFO - OK 2020-07-03 12:30:51,602 - oe-selftest - INFO - RESULTS: 2020-07-03 12:30:51,602 - oe-selftest - INFO - RESULTS - efibootpartition.GenericEFITest.test_boot_efi: PASSED (7965.85s)
2020-07-03 12:30:51,617 - oe-selftest - INFO - SUMMARY: 2020-07-03 12:30:51,617 - oe-selftest - INFO - oe-selftest () - Ran 1 test in 8055.416s 2020-07-03 12:30:51,617 - oe-selftest - INFO - oe-selftest - OK - All required tests passed (successes=1, skipped=0, failures=0, errors=0)
Cheers,
Yanfei
Quoted 57 lines · Yanfei
From: Yanfei Xu <[email protected]>
Some filesystems don't support symlink, then you will get failure wh you install or update the kernel rpm package. Now we use a copy of image for these filesystems instead of symlink.
Suggested-by Bruce Ashfield <[email protected]>Suggested-by Richard Purdie <[email protected]>Signed-off-by Yanfei Xu <[email protected]>--- meta/classes/kernel.bbclass | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)meta/classes/kernel.bbclass +19
-3@@ -94,6 +94,25 @@ python __anonymous () { d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower)) d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower)) d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1') + d.setVar('pkg_postinst_%s-image-%s' % (kname,typelower), """set +e +if [ -n "$D" ]; then + ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 +else + ln -sf %s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Filesystem on ${KERNEL_IMAGEDEST}/ doesn't support symlinks, falling back to copied image (%s)." + install -m 0644 ${KERNEL_IMAGEDEST}/%s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s + fi +fi +set -e +""" % (type, type, type, type, type, type, type)) + d.setVar('pkg_postrm_%s-image-%s' % (kname,typelower), """set +e +if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then + rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 +fi +set -e +""" % (type, type, type)) + image = d.getVar('INITRAMFS_IMAGE') # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0,@@ -385,9 +404,6 @@ kernel_do_install() { install -d ${D}/boot for imageType in ${KERNEL_IMAGETYPES} ; do install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType} ${D}/${KERNEL_IMAGEDEST}/${imageType}-${KERNEL_VERSION} - if [ "${KERNEL_PACKAGE_NAME}" = "kernel" ]; then - ln -sf ${imageType}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${imageType} - fi done install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}