All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V6 0/2] Fix some issues of kernel/image recipes (initramfs bundled kernel packaging)
@ 2017-04-08 16:43 liu.ming50
  2017-04-08 16:43 ` [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code liu.ming50
  2017-04-08 16:43 ` [PATCH V6 2/2] kernel-initramfs: add recipe liu.ming50
  0 siblings, 2 replies; 5+ messages in thread
From: liu.ming50 @ 2017-04-08 16:43 UTC (permalink / raw)
  To: openembedded-core; +Cc: Ming Liu

From: Ming Liu <liu.ming50@gmail.com>

Changes in patch set V6:
1 Change "d.getVar('KERNEL_PRIORITY')" > "d.getVar('KERNEL_PRIORITY', False)"
  to avoid running into a "basehash value changed" error, which is caused by
  KERNEL_VERSION is extracted from kernel headers at run time.

Ming Liu (2):
  image.bbclass: remove initramfs bundle related code
  kernel-initramfs: add recipe

 meta/classes/image.bbclass                    | 13 ----
 meta/recipes-kernel/linux/kernel-initramfs.bb | 95 +++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 13 deletions(-)
 create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb

-- 
2.7.4



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code
  2017-04-08 16:43 [PATCH V6 0/2] Fix some issues of kernel/image recipes (initramfs bundled kernel packaging) liu.ming50
@ 2017-04-08 16:43 ` liu.ming50
  2017-04-09 11:00   ` Andreas Oberritter
  2017-04-08 16:43 ` [PATCH V6 2/2] kernel-initramfs: add recipe liu.ming50
  1 sibling, 1 reply; 5+ messages in thread
From: liu.ming50 @ 2017-04-08 16:43 UTC (permalink / raw)
  To: openembedded-core; +Cc: Ming Liu

From: Ming Liu <peter.x.liu@external.atlascopco.com>

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 ]

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
---
 meta/classes/image.bbclass | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 405fd73..bc00884 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -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
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V6 2/2] kernel-initramfs: add recipe
  2017-04-08 16:43 [PATCH V6 0/2] Fix some issues of kernel/image recipes (initramfs bundled kernel packaging) liu.ming50
  2017-04-08 16:43 ` [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code liu.ming50
@ 2017-04-08 16:43 ` liu.ming50
  2017-04-09 11:18   ` Andreas Oberritter
  1 sibling, 1 reply; 5+ messages in thread
From: liu.ming50 @ 2017-04-08 16:43 UTC (permalink / raw)
  To: openembedded-core; +Cc: Ming Liu

From: Ming Liu <peter.x.liu@external.atlascopco.com>

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-image-vmlinux (Contains vmlinux image)

This recipe would be skipped if INITRAMFS_IMAGE_BUNDLE or
INITRAMFS_IMAGE is not being set correctly.

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
---
 meta/recipes-kernel/linux/kernel-initramfs.bb | 95 +++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb

diff --git a/meta/recipes-kernel/linux/kernel-initramfs.bb b/meta/recipes-kernel/linux/kernel-initramfs.bb
new file mode 100644
index 0000000..8bb7fbe
--- /dev/null
+++ b/meta/recipes-kernel/linux/kernel-initramfs.bb
@@ -0,0 +1,95 @@
+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_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')
+        typelower = "image-%s" % type.lower()
+
+        d.appendVar('PACKAGES', ' %s-%s' % (pn, typelower))
+        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', False)
+        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
+}
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code
  2017-04-08 16:43 ` [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code liu.ming50
@ 2017-04-09 11:00   ` Andreas Oberritter
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Oberritter @ 2017-04-09 11:00 UTC (permalink / raw)
  To: liu.ming50; +Cc: Ming Liu, openembedded-core

On Sat,  8 Apr 2017 18:43:44 +0200
liu.ming50@gmail.com wrote:

> From: Ming Liu <peter.x.liu@external.atlascopco.com>
> 
> 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 ]

Note that deploying the bundled image works. Installing a bundled image to
/boot seems unnecessary, because if a bootloader is able to load a kernel
from the filesystem containing /boot, then it should be able to load an
unbundled initramfs from there, too.

Regards,
Andreas

> 
> Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
> ---
>  meta/classes/image.bbclass | 13 -------------
>  1 file changed, 13 deletions(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 405fd73..bc00884 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V6 2/2] kernel-initramfs: add recipe
  2017-04-08 16:43 ` [PATCH V6 2/2] kernel-initramfs: add recipe liu.ming50
@ 2017-04-09 11:18   ` Andreas Oberritter
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Oberritter @ 2017-04-09 11:18 UTC (permalink / raw)
  To: liu.ming50; +Cc: Ming Liu, openembedded-core

On Sat,  8 Apr 2017 18:43:45 +0200
liu.ming50@gmail.com wrote:

> From: Ming Liu <peter.x.liu@external.atlascopco.com>
> 
> 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-image-vmlinux (Contains vmlinux image)
> 
> This recipe would be skipped if INITRAMFS_IMAGE_BUNDLE or
> INITRAMFS_IMAGE is not being set correctly.

This requires setting global variables, which makes it impossible to
create multiple initramfs images for different purposes using this recipe.

How about implementing this as a bbclass instead, which people inherit
in their own initramfs recipes? This would result in more meaningful
package names, too.

> 
> Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
> ---
>  meta/recipes-kernel/linux/kernel-initramfs.bb | 95 +++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)
>  create mode 100644 meta/recipes-kernel/linux/kernel-initramfs.bb
> 
> diff --git a/meta/recipes-kernel/linux/kernel-initramfs.bb b/meta/recipes-kernel/linux/kernel-initramfs.bb
> new file mode 100644
> index 0000000..8bb7fbe
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/kernel-initramfs.bb
> @@ -0,0 +1,95 @@
> +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_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')
> +        typelower = "image-%s" % type.lower()
> +
> +        d.appendVar('PACKAGES', ' %s-%s' % (pn, typelower))
> +        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', False)
> +        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)
> +}

This duplicates code from kernel.bbclass. Would it be possible to
move this to a shared location, at least partially?

Regards,
Andreas


> +
> +# 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
> +}



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-09 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-08 16:43 [PATCH V6 0/2] Fix some issues of kernel/image recipes (initramfs bundled kernel packaging) liu.ming50
2017-04-08 16:43 ` [PATCH V6 1/2] image.bbclass: remove initramfs bundle related code liu.ming50
2017-04-09 11:00   ` Andreas Oberritter
2017-04-08 16:43 ` [PATCH V6 2/2] kernel-initramfs: add recipe liu.ming50
2017-04-09 11:18   ` Andreas Oberritter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.