Fix some issues of kernel/image recipes
cover Fix some issues of kernel/image recipes
From: Ming Liu <[email protected]>
The changes include:
kernel.bbclass: introduce INITRAMFS_IMAGE_NAME kernel.bbclass: handle kernel-vmlinux in KERNEL_IMAGETYPES image.bbclass: remove initramfs bundle related code
kernel-initramfs: add recipe
Ming Liu (4):
kernel.bbclass: introduce INITRAMFS_IMAGE_NAME kernel.bbclass: handle kernel-vmlinux in KERNEL_IMAGETYPES image.bbclass: remove initramfs bundle related code
kernel-initramfs: add recipe
meta/classes/image.bbclass | 13 ---- meta/classes/kernel-fitimage.bbclass | 10 +-- meta/classes/kernel.bbclass | 68 ++++++++---------- meta/recipes-kernel/linux/kernel-initramfs.bb | 100 ++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 55 deletions(-) create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb
Signature · 1 line
2.7.4
PATCH 1/4 kernel.bbclass: introduce INITRAMFS_IMAGE_NAME
From: Ming Liu <[email protected]>
It defaults to ${INITRAMFS_IMAGE}-${MACHINE} if INITRAMFS_IMAGE is not empty.
This allows the end users to be able to override the initramfs image name with a customized value.
--- meta/classes/kernel-fitimage.bbclass | 10 +++++----- meta/classes/kernel.bbclass | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-)
meta/classes/kernel-fitimage.bbclass +5 -5
@@ -362,7 +362,7 @@ fitimage_assemble() { if [ "x${ramdiskcount}" = "x1" ] ; then # Find and use the first initramfs image archive type we find for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz cpio; do - initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${img}" + initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}" echo "Using $initramfs_path" if [ -e "${initramfs_path}" ]; then fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
@@ -445,11 +445,11 @@ kernel_do_deploy_append() { if [ -n "${INITRAMFS_IMAGE}" ]; then echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." - its_initramfs_base_name="fitImage-its-${INITRAMFS_IMAGE}-${PV}-${PR}-${MACHINE}-${DATETIME}" - its_initramfs_symlink_name=fitImage-its-${INITRAMFS_IMAGE}-${MACHINE} + its_initramfs_base_name="fitImage-its-${INITRAMFS_IMAGE_NAME}-${PV}-${PR}-${DATETIME}" + its_initramfs_symlink_name=fitImage-its-${INITRAMFS_IMAGE_NAME} install -m 0644 fit-image-${INITRAMFS_IMAGE}.its ${DEPLOYDIR}/${its_initramfs_base_name}.its - fit_initramfs_base_name="fitImage-${INITRAMFS_IMAGE}-${PV}-${PR}-${MACHINE}-${DATETIME}" - fit_initramfs_symlink_name=fitImage-${INITRAMFS_IMAGE}-${MACHINE} + fit_initramfs_base_name="fitImage-${INITRAMFS_IMAGE_NAME}-${PV}-${PR}-${DATETIME}" + fit_initramfs_symlink_name=fitImage-${INITRAMFS_IMAGE_NAME} install -m 0644 arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} ${DEPLOYDIR}/${fit_initramfs_base_name}.bin fi
meta/classes/kernel.bbclass +11 -10
@@ -16,6 +16,7 @@ INHIBIT_DEFAULT_DEPS = "1" KERNEL_IMAGETYPE ?= "zImage" INITRAMFS_IMAGE ?= "" +INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}" INITRAMFS_TASK ?= "" INITRAMFS_IMAGE_BUNDLE ?= ""
@@ -167,34 +168,34 @@ copy_initramfs() { # In case the directory is not created yet from the first pass compile: mkdir -p ${B}/usr # Find and use the first initramfs image archive type we find - rm -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio + rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz; do - if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then - cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img ${B}/usr/. + if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then + cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/. case $img in *gz) echo "gzip decompressing image" - gunzip -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img + gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img break ;; *lz4) echo "lz4 decompressing image" - lz4 -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img + lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img break ;; *lzo) echo "lzo decompressing image" - lzop -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img + lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img break ;; *lzma) echo "lzma decompressing image" - lzma -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img + lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img break ;; *xz) echo "xz decompressing image" - xz -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img + xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img break ;; esac
@@ -222,7 +223,7 @@ do_bundle_initramfs () { tmp_path=$tmp_path" "$type"##" fi done - use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio + use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio kernel_do_compile # Restoring kernel image for tp in $tmp_path ; do
@@ -261,7 +262,7 @@ kernel_do_compile() { # The old style way of copying an prebuilt image and building it # is turned on via INTIRAMFS_TASK != "" copy_initramfs - use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio + use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio fi for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
Signature · 1 line
2.7.4
PATCH 2/4 kernel.bbclass: handle kernel-vmlinux in KERNEL_IMAGETYPES
In reply to [email protected]From: Ming Liu <[email protected]>
There is a mess after KERNEL_IMAGETYPES was introduced in commit 849b67b2:
[ kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time ]
There are two packages both providing vmlinux image if 'vmlinux' is set in KERNEL_IMAGETYPES, they are kernel-vmlinux and kernel-image-vmlinux, to let them to be able to coexist, kernel-image-vmlinux was set to empty allowable, but its postinst/postrm scripts still remain trying to install/rm a update-alternatives link to /boot/vmlinux-${KERNEL_VERSION_NAME} but that file is actually being provided by the other package kernel-vmlinux.
Fixed this mess by appending vmlinux to KERNEL_IMAGETYPES and process it in anonymous python function. It would not change the original behavior, all the generated packages would be same with before except that the ALLOW_EMPTY variable, it is removed in this patch.
--- meta/classes/kernel.bbclass | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-)
meta/classes/kernel.bbclass +20 -27
@@ -14,6 +14,7 @@ OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" # we include gcc above, we dont need virtual/libc INHIBIT_DEFAULT_DEPS = "1" +KERNEL_IMAGETYPES_append = " vmlinux" KERNEL_IMAGETYPE ?= "zImage" INITRAMFS_IMAGE ?= "" INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
@@ -35,38 +36,33 @@ python __anonymous () { import re # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES - type = d.getVar('KERNEL_IMAGETYPE') or "" - alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or "" - types = d.getVar('KERNEL_IMAGETYPES') or "" - if type not in types.split(): - types = (type + ' ' + types).strip() - if alttype not in types.split(): - types = (alttype + ' ' + types).strip() + types = set((d.getVar('KERNEL_IMAGETYPES') or "").split()) + types.add(d.getVar('KERNEL_IMAGETYPE') or "") + types.add(d.getVar('KERNEL_ALT_IMAGETYPE') or "") + types = ' '.join(sorted(types)).strip() d.setVar('KERNEL_IMAGETYPES', types) - - typeformake = re.sub(r'\.gz', '', types) - d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake) + d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', re.sub(r'\.gz', '', types)) for type in types.split(): - typelower = type.lower() imagedest = d.getVar('KERNEL_IMAGEDEST') + if type == "vmlinux": + typelower = type.lower() + else: + typelower = "image-%s" % type.lower() - d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower) - - d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}') - - d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower) - - d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}') + d.appendVar('PACKAGES', ' kernel-%s' % typelower) + if type != 'vmlinux' or d.getVar('KERNEL_IMAGETYPE') == 'vmlinux': + d.appendVar('RDEPENDS_kernel-image', ' kernel-%s' % typelower) - d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1') + d.setVar('FILES_kernel-%s' % typelower, '/%s/%s-${KERNEL_VERSION_NAME}' % (imagedest, type)) + d.setVar('PKG_kernel-%s' % typelower, 'kernel-%s-${KERNEL_VERSION_PKG_NAME}' % typelower) priority = d.getVar('KERNEL_PRIORITY') - postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n' - d.setVar('pkg_postinst_kernel-image-' + typelower, postinst) + postinst = '#!/bin/sh\nupdate-alternatives --install /%s/%s %s %s-${KERNEL_VERSION_NAME} %s || true\n' % (imagedest, type, type, type, priority) + d.setVar('pkg_postinst_kernel-%s' % typelower, postinst) - postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n' - d.setVar('pkg_postrm_kernel-image-' + typelower, postrm) + postrm = '#!/bin/sh\nupdate-alternatives --remove %s %s-${KERNEL_VERSION_NAME} || true\n' % (type, type) + d.setVar('pkg_postrm_kernel-%s' % typelower, postrm) image = d.getVar('INITRAMFS_IMAGE') if image:
@@ -319,7 +315,6 @@ kernel_do_install() { done install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} - install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} install -d ${D}${sysconfdir}/modules-load.d install -d ${D}${sysconfdir}/modprobe.d
@@ -484,19 +479,17 @@ EXPORT_FUNCTIONS do_compile do_install do_configure # kernel-base becomes kernel-${KERNEL_VERSION} # kernel-image becomes kernel-image-${KERNEL_VERSION} -PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules" +PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-modules" FILES_${PN} = "" FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin" FILES_kernel-image = "" FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build" -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}" FILES_kernel-modules = "" RDEPENDS_kernel = "kernel-base" # Allow machines to override this dependency if kernel image files are # not wanted in images as standard RDEPENDS_kernel-base ?= "kernel-image" PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}" PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}" RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}" ALLOW_EMPTY_kernel = "1"
Signature · 1 line
2.7.4
Re: [PATCH 2/4] kernel.bbclass: handle kernel-vmlinux in KERNEL_IMAGETYPES
Quoted 12 lines · On Sun, Mar 19, 2017 at 2:13 PM, <[email protected]> wrote:
From: Ming Liu <[email protected]>
There is a mess after
KERNEL_IMAGETYPESwas introduced in commit849b67b2:
[ kernel: AddKERNEL_IMAGETYPESto build multi types kernel at one time ]There are two packages both providing vmlinux image if 'vmlinux' is set in
KERNEL_IMAGETYPES, they are kernel-vmlinux and kernel-image-vmlinux, to let them to be able to coexist, kernel-image-vmlinux was set to empty allowable, but its postinst/postrm scripts still remain trying to install/rm a update-alternatives link to/boot/vmlinux-${KERNEL_VERSION_NAME}but that file is actually being provided by the other package kernel-vmlinux.
Quoted 4 lines
Fixed this mess by appending vmlinux to
KERNEL_IMAGETYPESand process it in anonymous python function. It would not change the original behavior, all the generated packages would be same with before except that theALLOW_EMPTYvariable, it is removed in this patch.
Hi,
I am testing the 'old-style' of embedding the initramfs in the images [1]. Your patch does add 'vmlinux' even if we have KERNEL_IMAGETYPE ?= "zImage" so it leads to the following error:
| DEBUG: Python function extend_recipe_sysroot finished | DEBUG: Executing shell function do_deploy | install: cannot stat 'arch/arm/boot/vmlinux': No such file or director
The solution for our custom kernel recipe is:
inherit kernel
addtask kernel_link_images after do_compile before do_strip
as done in linux-yocto.inc.
So with this little adjustment it is still possible to build in the old-way.
I didn't test yet the other part of the patchset so I cannot fully ack it. FWIW I never liked the *BUNDLE framework for the need of specifying the INITRAMFS_IMAGE in a conf file and not in the kernel recipe as done with the old framework.
Cheers
Andrea
[1] http://cgit.openembedded.org/meta-handheld/tree/recipes-kernel/linux/linux-gcw0-kexecboot_4.7.bb
Quoted 112 lines
Signed-off-by Ming Liu <[email protected]>--- meta/classes/kernel.bbclass | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-)meta/classes/kernel.bbclass +20
-28@@ -14,6 +14,7 @@ OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" # we include gcc above, we dont need virtual/libc INHIBIT_DEFAULT_DEPS = "1" +KERNEL_IMAGETYPES_append = " vmlinux" KERNEL_IMAGETYPE ?= "zImage" INITRAMFS_IMAGE ?= "" INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"@@ -35,38 +36,33 @@ python __anonymous () { import re # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES - type = d.getVar('KERNEL_IMAGETYPE') or "" - alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or "" - types = d.getVar('KERNEL_IMAGETYPES') or "" - if type not in types.split(): - types = (type + ' ' + types).strip() - if alttype not in types.split(): - types = (alttype + ' ' + types).strip() + types = set((d.getVar('KERNEL_IMAGETYPES') or "").split()) + types.add(d.getVar('KERNEL_IMAGETYPE') or "") + types.add(d.getVar('KERNEL_ALT_IMAGETYPE') or "") + types = ' '.join(sorted(types)).strip() d.setVar('KERNEL_IMAGETYPES', types) - - typeformake = re.sub(r'\.gz', '', types) - d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake) + d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', re.sub(r'\.gz', '', types)) for type in types.split(): - typelower = type.lower() imagedest = d.getVar('KERNEL_IMAGEDEST') + if type == "vmlinux": + typelower = type.lower() + else: + typelower = "image-%s" % type.lower() - d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower) - - d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}') - - d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower) - - d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}') + d.appendVar('PACKAGES', ' kernel-%s' % typelower) + if type != 'vmlinux' or d.getVar('KERNEL_IMAGETYPE') == 'vmlinux': + d.appendVar('RDEPENDS_kernel-image', ' kernel-%s' % typelower) - d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1') + d.setVar('FILES_kernel-%s' % typelower, '/%s/%s-${KERNEL_VERSION_NAME}' % (imagedest, type)) + d.setVar('PKG_kernel-%s' % typelower, 'kernel-%s-${KERNEL_VERSION_PKG_NAME}' % typelower) priority = d.getVar('KERNEL_PRIORITY') - postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n' - d.setVar('pkg_postinst_kernel-image-' + typelower, postinst) + postinst = '#!/bin/sh\nupdate-alternatives --install /%s/%s %s %s-${KERNEL_VERSION_NAME} %s || true\n' % (imagedest, type, type, type, priority) + d.setVar('pkg_postinst_kernel-%s' % typelower, postinst) - postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n' - d.setVar('pkg_postrm_kernel-image-' + typelower, postrm) + postrm = '#!/bin/sh\nupdate-alternatives --remove %s %s-${KERNEL_VERSION_NAME} || true\n' % (type, type) + d.setVar('pkg_postrm_kernel-%s' % typelower, postrm) image = d.getVar('INITRAMFS_IMAGE') if image:@@ -319,7 +315,6 @@ kernel_do_install() { done install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} - install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} install -d ${D}${sysconfdir}/modules-load.d install -d ${D}${sysconfdir}/modprobe.d@@ -484,19 +479,17 @@ EXPORT_FUNCTIONS do_compile do_install do_configure # kernel-base becomes kernel-${KERNEL_VERSION} # kernel-image becomes kernel-image-${KERNEL_VERSION} -PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules" +PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-modules" FILES_${PN} = "" FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin" FILES_kernel-image = "" FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build" -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}" FILES_kernel-modules = "" RDEPENDS_kernel = "kernel-base" # Allow machines to override this dependency if kernel image files are # not wanted in images as standard RDEPENDS_kernel-base ?= "kernel-image" PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}" PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}" RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}" ALLOW_EMPTY_kernel = "1" --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
A message that is not in the archive (sent off-list or not yet received): VI1PR0301MB19197C37AD0A002E5A5FFCCBE33A0@VI1PR0301MB1919.eurprd03.prod.outlook.com
Re: [PATCH 2/4] kernel.bbclass: handle kernel-vmlinux in KERNEL_IMAGETYPES
Quoted 23 lines · Peter Liu
Hi, Andrea:
Thanks for your testing.
I think you are absolutely right, actually I think you had found a fix for a potential defect,
do_kernel_link_imagesneeds to run afterdo_compile, and this SHOULD be set up in kernel.bbclass but not in linux-yocto.inc, since a dependent chain exists in kernel.bbclass as following:
do_package->do_install->do_sizecheck->do_strip->do_kernel_link_vmlinux, sodo_kernel_link_vmlinux->do_compileneeds to set up in kernel.bbclass as well, am I correct? Or else the recipes inheriting kernel.bbclass might have a explicit dependency betweendo_kernel_link_vmlinuxanddo_compile. But why this did not show up before? Maybe because there is another incorrect addtask statement? As it is in kernel.bbclass:563 addtask
do_stripbeforedo_sizecheckafterdo_kernel_link_images
Quoted 7 lines
it should be:
addtask strip before
do_sizecheckafterdo_kernel_link_imagesI am just curious how it worked before without running into errors, but anyway I will send a V2 to also address that issue.
Without your last patchset it worked just fine for the case KERNEL_IMAGETYPE ?= "zImage"
But for the mips target I discovered recently that the kernel_link_images task was needed and I actually extended it in order to consder vmlinuz.bin.
If we apply your patchset then this task is an absolute must and it should be in kernel.bbclass. Our recipe does skip do_install so we have to readd the task.
Cheers
Andrea
Quoted 202 lines
the best,
thank you
________________________________
From: Andrea Adami <[email protected]>
Sent: Monday, March 20, 2017 10:38:19 AM
To: openembedded-core
Cc: Bruce Ashfield; Tao, Yue; Peter Liu
Subject: Re: [OE-core] [PATCH 2/4] kernel.bbclass: handle kernel-vmlinux inKERNEL_IMAGETYPESQuoted 14 lines · On Sun, Mar 19, 2017 at 2:13 PM, <[email protected]> wrote:
From: Ming Liu <[email protected]>
There is a mess after
KERNEL_IMAGETYPESwas introduced in commit849b67b2:
[ kernel: AddKERNEL_IMAGETYPESto build multi types kernel at one time ]There are two packages both providing vmlinux image if 'vmlinux' is set in
KERNEL_IMAGETYPES, they are kernel-vmlinux and kernel-image-vmlinux, to let them to be able to coexist, kernel-image-vmlinux was set to empty allowable, but its postinst/postrm scripts still remain trying to install/rm
a update-alternatives link to/boot/vmlinux-${KERNEL_VERSION_NAME}but that
file is actually being provided by the other package kernel-vmlinux.Quoted 4 lines
Fixed this mess by appending vmlinux to
KERNEL_IMAGETYPESand process it in anonymous python function. It would not change the original behavior, all the generated packages would be same with before except that theALLOW_EMPTYvariable, it is removed in this patch.Hi,
I am testing the 'old-style' of embedding the initramfs in the images [1]. Your patch does add 'vmlinux' even if we have
KERNEL_IMAGETYPE?= "zImage" so it leads to the following error:| DEBUG: Python function extend_recipe_sysroot finished | DEBUG: Executing shell function do_deploy | install: cannot stat 'arch/arm/boot/vmlinux': No such file or directorThe solution for our custom kernel recipe is:
inherit kernel
addtaskkernel_link_imagesafterdo_compilebeforedo_stripas done in linux-yocto.inc.
So with this little adjustment it is still possible to build in the old-way.
I didn't test yet the other part of the patchset so I cannot fully ack it. FWIW I never liked the *BUNDLE framework for the need of specifying the
INITRAMFS_IMAGEin a conf file and not in the kernel recipe as done with the old framework.Cheers
Andrea[1]
http://cgit.openembedded.org/meta-handheld/tree/recipes-kernel/linux/linux-gcw0-kexecboot_4.7.bbQuoted 135 lines
Signed-off-by Ming Liu <[email protected]>--- meta/classes/kernel.bbclass | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-)meta/classes/kernel.bbclass +1
-0@@ -14,6 +14,7 @@ OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" # we include gcc above, we dont need virtual/libc INHIBIT_DEFAULT_DEPS = "1" +KERNEL_IMAGETYPES_append = " vmlinux" KERNEL_IMAGETYPE ?= "zImage" INITRAMFS_IMAGE ?= "" INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}',''][d.getVar('INITRAMFS_IMAGE') == '']}"
meta/classes/kernel.bbclass +0
-0@@ -35,38 +36,33 @@ python __anonymous () { import re # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
KERNEL_IMAGETYPESmeta/classes/kernel.bbclass +10
-16- type = d.getVar('KERNEL_IMAGETYPE') or "" - alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or "" - types = d.getVar('KERNEL_IMAGETYPES') or "" - if type not in types.split(): - types = (type + ' ' + types).strip() - if alttype not in types.split(): - types = (alttype + ' ' + types).strip() + types = set((d.getVar('KERNEL_IMAGETYPES') or "").split()) + types.add(d.getVar('KERNEL_IMAGETYPE') or "") + types.add(d.getVar('KERNEL_ALT_IMAGETYPE') or "") + types = ' '.join(sorted(types)).strip() d.setVar('KERNEL_IMAGETYPES', types) - - typeformake = re.sub(r'\.gz', '', types) - d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake) + d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', re.sub(r'\.gz', '', types)) for type in types.split(): - typelower = type.lower() imagedest = d.getVar('KERNEL_IMAGEDEST') + if type == "vmlinux": + typelower = type.lower() + else: + typelower = "image-%s" % type.lower() - d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower) - - d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}') - - d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +typelower)
meta/classes/kernel.bbclass +0
-2- - d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +typelower + '-${KERNEL_VERSION_PKG_NAME}')
meta/classes/kernel.bbclass +2
-0+ d.appendVar('PACKAGES', ' kernel-%s' % typelower) + if type != 'vmlinux' or d.getVar('KERNEL_IMAGETYPE') =='vmlinux':
+ d.appendVar('RDEPENDS_kernel-image', ' kernel-%s' %
typelower)meta/classes/kernel.bbclass +1
-1- d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1') + d.setVar('FILES_kernel-%s' % typelower,'/%s/%s-${KERNEL_VERSION_NAME}' % (imagedest, type))
+ d.setVar('PKG_kernel-%s' % typelower,
'kernel-%s-${KERNEL_VERSION_PKG_NAME}' % typelower)priority =
d.getVar('KERNEL_PRIORITY')
- postinst = '#!/bin/sh\n' + 'update-alternatives --install /' +
imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'meta/classes/kernel.bbclass +1
-1- d.setVar('pkg_postinst_kernel-image-' + typelower, postinst) + postinst = '#!/bin/sh\nupdate-alternatives --install /%s/%s %s%s-${KERNEL_VERSION_NAME} %s || true\n' % (imagedest, type, type, type, priority)
meta/classes/kernel.bbclass +1
-1+ d.setVar('pkg_postinst_kernel-%s' % typelower, postinst) - postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' +type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
meta/classes/kernel.bbclass +1
-1- d.setVar('pkg_postrm_kernel-image-' + typelower, postrm) + postrm = '#!/bin/sh\nupdate-alternatives --remove %s%s-${KERNEL_VERSION_NAME} || true\n' % (type, type)
meta/classes/kernel.bbclass +1
-1+ d.setVar('pkg_postrm_kernel-%s' % typelower, postrm) image = d.getVar('INITRAMFS_IMAGE') if image:@@ -319,7 +315,6 @@ kernel_do_install() { done install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} - install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} install -d ${D}${sysconfdir}/modules-load.dinstall -d ${D}${sysconfdir}/modprobe.dmeta/classes/kernel.bbclass +0
-1@@ -484,19 +479,17 @@ EXPORT_FUNCTIONS do_compile do_install do_configure # kernel-base becomes kernel-${KERNEL_VERSION} # kernel-image becomes kernel-image-${KERNEL_VERSION} -PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-devkernel-modules"
+PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-modules"
FILES_${PN} = ""
FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order/lib/modules/${KERNEL_VERSION}/modules.builtin"
FILES_kernel-image = ""
FILES_kernel-dev = "/boot/System.map*/boot/Module.symvers*/boot/config*
${KERNEL_SRC_PATH}/lib/modules/${KERNEL_VERSION}/build" -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
FILES_kernel-modules = ""
RDEPENDS_kernel= "kernel-base"
# Allow machines to override this dependency if kernel image files are# not wanted in images as standard RDEPENDS_kernel-base ?= "kernel-image" PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}" PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}" RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}" ALLOW_EMPTY_kernel = "1" -- 2.7.4--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
PATCH 3/4 image.bbclass: remove initramfs bundle related code
In reply to [email protected]From: Ming Liu <[email protected]>
The original purpose of these code was to repackage initramfs bundled kernel before image do_build, but it does not really work because the initramfs bundled kernel images are not packaged at all after commit a49569e3a7534779bbe3f01a0647fd076c95798d:
[ kernel.bbclass: do not copy bundled initramfs to /boot ]
--- meta/classes/image.bbclass | 13 ------------- 1 file changed, 13 deletions(-)
meta/classes/image.bbclass +0 -13
@@ -184,10 +184,6 @@ python () { d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features)))) check_image_features(d) - initramfs_image = d.getVar('INITRAMFS_IMAGE') or "" - if initramfs_image != "": - d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN')) - d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_image_complete" % initramfs_image) } IMAGE_CLASSES += "image_types"
@@ -608,12 +604,3 @@ do_packagedata[noexec] = "1" do_package_write_ipk[noexec] = "1" do_package_write_deb[noexec] = "1" do_package_write_rpm[noexec] = "1" - -# Allow the kernel to be repacked with the initramfs and boot image file as a single file -do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs" -do_bundle_initramfs[nostamp] = "1" -do_bundle_initramfs[noexec] = "1" -do_bundle_initramfs () { - : -} -addtask bundle_initramfs after do_image_complete
Signature · 1 line
2.7.4
PATCH 4/4 kernel-initramfs: add recipe
In reply to [email protected]From: Ming Liu <[email protected]>
To implement initramfs bundled kernel packaging.
The kernel images are copied from DEPLOY_DIR_IMAGE, and a list of packages will be generated according to KERNEL_IMAGETYPES setting.
For instance:
For KERNEL_IMAGETYPES = "bzImage vmlinux"
the generated packages would be:
- kernel-initramfs (Base package, RDEPENDS on kernel-initramfs-image)
- kernel-initramfs-image (Image package, RDEPENDS on all sub images)
- kernel-initramfs-image-bzimage (Contains bzImage image)
- kernel-initramfs-vmlinux (Contains vmlinux image)
This recipe would be skipped if INITRAMFS_IMAGE_BUNDLE or INITRAMFS_IMAGE is not being set correctly.
--- meta/recipes-kernel/linux/kernel-initramfs.bb | 100 ++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb
meta/recipes-kernel/linux/kernel-initramfs.bb new file +100 -0
@@ -0,0 +1,100 @@ +SUMMARY = "Initramfs bundled kernel images" +DESCRIPTION = "When built, it packages initramfs bundled kernel images of the \ +preferred virtual/kernel provider." +SECTION = "kernel" +LICENSE = "GPLv2" + +inherit linux-kernel-base + +# Whilst not a module, this ensures we don't get multilib extended. (which would make no sense) +inherit module-base + +S = "${STAGING_KERNEL_DIR}" +B = "${WORKDIR}/build" + +# we dont need the default dependencies. +INHIBIT_DEFAULT_DEPS = "1" + +KERNEL_ALT_IMAGETYPE ??= "" +KERNEL_IMAGETYPES_append = " vmlinux" +KERNEL_IMAGETYPE ?= "zImage" +KERNEL_IMAGEDEST ?= "boot" +KERNEL_VERSION = "${@['1.0.0', get_kernelversion_file('${STAGING_KERNEL_BUILDDIR}')][get_kernelversion_file('${STAGING_KERNEL_BUILDDIR}') != None]}" +KERNEL_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" +KERNEL_PRIORITY ?= "${@int(d.getVar('KERNEL_VERSION').split('-')[0].split('+')[0].split('.')[0]) * 10000 + \ + int(d.getVar('KERNEL_VERSION').split('-')[0].split('+')[0].split('.')[1]) * 100 + \ + int(d.getVar('KERNEL_VERSION').split('-')[0].split('+')[0].split('.')[-1])}" + +PACKAGES = "${PN} ${PN}-image" + +FILES_${PN} = "" +FILES_${PN}-image = "" +RDEPENDS_${PN} = "${PN}-image" +PKG_${PN} = "${PN}-${KERNEL_PKG_NAME}" +PKG_${PN}-image = "${PN}-image-${KERNEL_PKG_NAME}" +RPROVIDES_${PN} += "${PN}-${KERNEL_VERSION}" +ALLOW_EMPTY_${PN} = "1" +ALLOW_EMPTY_${PN}-image = "1" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +PACKAGES_DYNAMIC = "^kernel-initramfs-image-.*" + +python __anonymous () { + # Skip processing of this recipe if INITRAMFS_IMAGE or INITRAMFS_IMAGE_BUNDLE + # is not set correctly, to avoid generating only empty packages which makes + # no sense. + if not d.getVar('INITRAMFS_IMAGE') or d.getVar('INITRAMFS_IMAGE_BUNDLE') != '1': + raise bb.parse.SkipPackage("Set INITRAMFS_IMAGE and INITRAMFS_IMAGE_BUNDLE to enable it") + + # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES + types = set((d.getVar('KERNEL_IMAGETYPES') or "").split()) + types.add(d.getVar('KERNEL_IMAGETYPE') or "") + types.add(d.getVar('KERNEL_ALT_IMAGETYPE') or "") + types = ' '.join(sorted(types)).strip() + d.setVar('KERNEL_IMAGETYPES', types) + + for type in types.split(): + pn = d.getVar('PN') + imagedest = d.getVar('KERNEL_IMAGEDEST') + if type == "vmlinux": + typelower = type.lower() + else: + typelower = "image-%s" % type.lower() + + d.appendVar('PACKAGES', ' %s-%s' % (pn, typelower)) + if type != 'vmlinux' or d.getVar('KERNEL_IMAGETYPE') == 'vmlinux': + d.appendVar('RDEPENDS_%s-image' % pn, ' %s-%s' % (pn, typelower)) + + d.setVar('FILES_%s-%s' % (pn, typelower), '/%s/%s-initramfs-${KERNEL_VERSION}' % (imagedest, type)) + d.setVar('PKG_%s-%s' % ( pn, typelower), '%s-%s-${KERNEL_PKG_NAME}' % (pn, typelower)) + + priority = d.getVar('KERNEL_PRIORITY') + postinst = '#!/bin/sh\nupdate-alternatives --install /%s/%s-initramfs %s-initramfs %s-initramfs-${KERNEL_VERSION} %s || true\n' % (imagedest, type, type, type, priority) + d.setVar('pkg_postinst_%s-%s' % (pn, typelower), postinst) + + postrm = '#!/bin/sh\nupdate-alternatives --remove %s-initramfs %s-initramfs-${KERNEL_VERSION} || true\n' % (type, type) + d.setVar('pkg_postrm_%s-%s' % (pn, typelower), postrm) +} + +# Need the output of deploy. +do_install[depends] += "virtual/kernel:do_deploy" + +# We only need the packaging tasks - disable the rest +do_fetch[noexec] = "1" +do_unpack[noexec] = "1" +do_patch[noexec] = "1" +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_populate_sysroot[noexec] = "1" + +do_install() { + if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then + echo "Copying initramfs bundled kernel images from ${DEPLOY_DIR_IMAGE}..." + install -d ${D}/${KERNEL_IMAGEDEST} + for type in ${KERNEL_IMAGETYPES}; do + echo "Copying initramfs bundled kernel image: $type-initramfs-${MACHINE}.bin" + install -m 0644 ${DEPLOY_DIR_IMAGE}/$type-initramfs-${MACHINE}.bin ${D}/${KERNEL_IMAGEDEST}/$type-initramfs-${KERNEL_VERSION} + done + fi +}
Signature · 1 line
2.7.4