Skip to contentSkip to conversation

kernel.bbclass: avoids installing kernel image in do_bundle_initramfs

PATCH In review Ming Liu 1 participant 3 messages Dec 29, 2015 – Dec 30, 2015

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH 1/2 kernel.bbclass: avoids installing kernel image in do_bundle_initramfs

From: Ming Liu <[email protected]>

It makes no sense to install a initramfs bundled kernel image since do_package does not depend on do_bundle_initramfs at all, it leads to a implicit kernel-image package depending on do_package run before or after do_bundle_initramfs.

---
 meta/classes/kernel.bbclass | 4 ----
 1 file changed, 4 deletions(-)
meta/classes/kernel.bbclass +0 -4
index 4ce1611..d1ca614 100644
@@ -179,10 +179,6 @@ do_bundle_initramfs () {
 		kernel_do_compile
 		mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
 		mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
-		# Update install area
-		echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
-		install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
-		echo "${B}/${KERNEL_OUTPUT}.initramfs"
 	fi
 }
 
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 kernel-initramfs: new recipe, creates initramfs bundled kernel packaging

From: Ming Liu <[email protected]>

So far, there is not a workable way to package the initramfs bundled kernel image, the only place is tmp/deploy from where we could get it, but if a user want to add it into a certain image, there is no guarantee that he will achieve it because a explicit dependency is missing between package and bundle_initramfs, and this was designed to avoid introducing circular dependencies when using kernel modules in the initramfs image.bb that is caused by kernel.bbclass trying to build the initramfs before the kernel packaging.

To fix this problem, the idea is to split the initramfs bundled kernel packaging to a new recipe, make the do_install depend on kernel's deploy task, then with the following config:

IMAGE_INSTALL_append = "kernel-initramfs"

The initramfs bundled kernel could be added to the image without introducing any circular dependencies.

---
 meta/recipes-kernel/linux/kernel-initramfs.bb | 50 +++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb
meta/recipes-kernel/linux/kernel-initramfs.bb new file +50 -0
new file mode 100644
index 0000000..481b142
@@ -0,0 +1,50 @@
+SUMMARY = "Initramfs bundled kernel image"
+DESCRIPTION = "When built, it packages a initramfs bundled kernel image of the \
+preferred virtual/kernel provider."
+
+SECTION = "kernel"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
+
+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"
+
+KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
+
+PACKAGES = "kernel-initramfs"
+FILES_${PN} = "/boot/${KERNEL_IMAGETYPE}*"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+# Skip processing of this recipe if INITRAMFS_IMAGE or INITRAMFS_IMAGE_BUNDLE
+# is not set correctly, to avoid generate a single empty package which makes
+# no sense.
+python __anonymous () {
+    if not d.getVar('INITRAMFS_IMAGE', True) or d.getVar('INITRAMFS_IMAGE_BUNDLE', True) != '1':
+        raise bb.parse.SkipPackage("Set INITRAMFS_IMAGE and INITRAMFS_IMAGE_BUNDLE to enable it")
+}
+
+# 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 image from ${DEPLOY_DIR_IMAGE}..."
+		install -d ${D}/boot
+		install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin ${D}/boot
+	fi
+}
Signature · 1 line
1.9.1
author
#2 lore raw

Re: [PATCH 2/2] kernel-initramfs: new recipe, creates initramfs bundled kernel packaging

Hi,

I need do more work on this patch, and will send the V1 soon, please ignore this for now.

//Ming Liu

2015-12-30 0:05 GMT+01:00 Ming Liu <[email protected]>:

Quoted 98 lines

From: Ming Liu <[email protected]>

So far, there is not a workable way to package the initramfs bundled kernel image, the only place is tmp/deploy from where we could get it, but if a user want to add it into a certain image, there is no guarantee that he will achieve it because a explicit dependency is missing between package and bundle_initramfs, and this was designed to avoid introducing circular dependencies when using kernel modules in the initramfs image.bb that is caused by kernel.bbclass trying to build the initramfs before the kernel packaging.

To fix this problem, the idea is to split the initramfs bundled kernel packaging to a new recipe, make the do_install depend on kernel's deploy task, then with the following config:

IMAGE_INSTALL_append = "kernel-initramfs"

The initramfs bundled kernel could be added to the image without introducing any circular dependencies.

---
 meta/recipes-kernel/linux/kernel-initramfs.bb | 50
+++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb
meta/recipes-kernel/linux/kernel-initramfs.bb new file +2 -0
new file mode 100644
index 0000000..481b142
@@ -0,0 +1,50 @@
+SUMMARY = "Initramfs bundled kernel image"
+DESCRIPTION = "When built, it packages a initramfs bundled kernel image

of the \

meta/recipes-kernel/linux/kernel-initramfs.bb new file +6 -0
+preferred virtual/kernel provider."
+
+SECTION = "kernel"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM =

"file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

meta/recipes-kernel/linux/kernel-initramfs.bb new file +4 -0
+
+inherit linux-kernel-base
+
+# Whilst not a module, this ensures we don't get multilib extended (which

would make no sense)

meta/recipes-kernel/linux/kernel-initramfs.bb new file +13 -0
+inherit module-base
+
+S = "${STAGING_KERNEL_DIR}"
+B = "${WORKDIR}/build"
+
+KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
+
+PACKAGES = "kernel-initramfs"
+FILES_${PN} = "/boot/${KERNEL_IMAGETYPE}*"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+# Skip processing of this recipe if INITRAMFS_IMAGE or

INITRAMFS_IMAGE_BUNDLE
+# is not set correctly, to avoid generate a single empty package which makes

meta/recipes-kernel/linux/kernel-initramfs.bb new file +3 -0
+# no sense.
+python __anonymous () {
+    if not d.getVar('INITRAMFS_IMAGE', True) or

d.getVar('INITRAMFS_IMAGE_BUNDLE', True) != '1':
+ raise bb.parse.SkipPackage("Set INITRAMFS_IMAGE and
INITRAMFS_IMAGE_BUNDLE to enable it")

meta/recipes-kernel/linux/kernel-initramfs.bb new file +15 -0
+}
+
+# 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 image from
${DEPLOY_DIR_IMAGE}..."

meta/recipes-kernel/linux/kernel-initramfs.bb new file +2 -0
+               install -d ${D}/boot
+               install -m 0644

${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin ${D}/boot

meta/recipes-kernel/linux/kernel-initramfs.bb new file +2 -1
+       fi
+}
--

1.9.1