image-artifact-names: introduce new bbclass and move some variables into it
PATCH 1/5 image-artifact-names: introduce new bbclass and move some variables into it
* similar to kernel-artifact-names for other recipes/bbclasses which need to use some deployed artifacts
* bitbake.conf: move IMAGE_BASENAME, IMAGE_VERSION_SUFFIX, IMAGE_NAME, IMAGE_LINK_NAME variables
* image_types.bbclass: move IMAGE_NAME_SUFFIX variable
* currently IMAGE_NAME_SUFFIX is used only by image.bbclass, image_types.bbclass and meta/recipes-core/images/build-appliance-image_15.0.0.bb but if it's needed by some recipe which isn't itself an image, then it's useful in bitbake.conf, e.g. we have a recipe for creating VirtualBox appliances which combines .wic.vmdk with .ovf file to create .zip with appliance, but for that we need the filename of .wic.vmdk which now contains IMAGE_NAME_SUFFIX
https://github.com/webOS-ports/meta-webos-ports/blob/4980ce52a43ac6897657602810313af359f0b839/meta-luneos/recipes-core/images/luneos-emulator-appliance.inc#L24
* we were hardcoding .rootfs suffix where needed, but for quite long time it's configurable with IMAGE_NAME_SUFFIX since:
commit 380ee36811939d947024bf78de907e3c071b834f
Author: Patrick Ohly <[email protected]>
Date: Mon Mar 7 18:07:52 2016 +0100
image creation: allow overriding .rootfs suffix
and might not match with hardcoded .rootfs, so make it easier to use IMAGE_NAME_SUFFIX where needed even without inheritting whole image_types.bbclass
[YOCTO #12937]
--- meta/classes/buildhistory.bbclass | 2 ++ meta/classes/image-artifact-names.bbclass | 15 +++++++++++++++ meta/classes/image-live.bbclass | 2 +- meta/classes/image_types.bbclass | 9 ++------- meta/classes/kernel-artifact-names.bbclass | 8 ++++++++ meta/classes/qemuboot.bbclass | 2 ++ meta/classes/rootfs-postcommands.bbclass | 2 ++ meta/classes/testimage.bbclass | 2 ++ meta/conf/bitbake.conf | 5 ----- 9 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 meta/classes/image-artifact-names.bbclass
meta/classes/buildhistory.bbclass +2 -0
@@ -7,6 +7,8 @@ # Copyright (C) 2007-2011 Koen Kooi <[email protected]> # +inherit image-artifact-names + BUILDHISTORY_FEATURES ?= "image package sdk" BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
meta/classes/image-artifact-names.bbclass new file +15 -0
@@ -0,0 +1,15 @@ +################################################################## +# Specific image creation and rootfs population info. +################################################################## + +IMAGE_BASENAME = "${PN}" +IMAGE_VERSION_SUFFIX = "-${DATETIME}" +IMAGE_VERSION_SUFFIX[vardepsexclude] += "DATETIME" +IMAGE_NAME = "${IMAGE_BASENAME}-${MACHINE}${IMAGE_VERSION_SUFFIX}" +IMAGE_LINK_NAME = "${IMAGE_BASENAME}-${MACHINE}" + +# IMAGE_NAME is the base name for everything produced when building images. +# The actual image that contains the rootfs has an additional suffix (.rootfs +# by default) followed by additional suffices which describe the format (.ext4, +# .ext4.xz, etc.). +IMAGE_NAME_SUFFIX ??= ".rootfs"
meta/classes/image-live.bbclass +1 -1
@@ -22,7 +22,7 @@ # ${HDDIMG_ID} - FAT image volume-id # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional) -inherit live-vm-common +inherit live-vm-common image-artifact-names do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ mtools-native:do_populate_sysroot \
meta/classes/image_types.bbclass +2 -7
@@ -1,9 +1,3 @@ -# IMAGE_NAME is the base name for everything produced when building images. -# The actual image that contains the rootfs has an additional suffix (.rootfs -# by default) followed by additional suffices which describe the format (.ext4, -# .ext4.xz, etc.). -IMAGE_NAME_SUFFIX ??= ".rootfs" - # The default aligment of the size of the rootfs is set to 1KiB. In case # you're using the SD card emulation of a QEMU system simulator you may # set this value to 2048 (2MiB alignment).
@@ -231,7 +225,8 @@ IMAGE_CMD_f2fs () { EXTRA_IMAGECMD = "" -inherit siteinfo kernel-arch +inherit siteinfo kernel-arch image-artifact-names + JFFS2_ENDIANNESS ?= "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', '-l', '-b', d)}" JFFS2_ERASEBLOCK ?= "0x40000" EXTRA_IMAGECMD_jffs2 ?= "--pad ${JFFS2_ENDIANNESS} --eraseblock=${JFFS2_ERASEBLOCK} --no-cleanmarkers"
meta/classes/kernel-artifact-names.bbclass +8 -0
@@ -1,3 +1,11 @@ +################################################################## +# Specific kernel creation info +# for recipes/bbclasses which need to reuse some of the kernel +# artifacts, but aren't kernel recipes themselves +################################################################## + +inherit image-artifact-names + KERNEL_ARTIFACT_NAME ?= "${PKGE}-${PKGV}-${PKGR}-${MACHINE}${IMAGE_VERSION_SUFFIX}" KERNEL_ARTIFACT_LINK_NAME ?= "${MACHINE}"
meta/classes/qemuboot.bbclass +2 -0
@@ -86,6 +86,8 @@ QB_ROOTFS_EXTRA_OPT ?= "" # This should be kept align with ROOT_VM QB_DRIVE_TYPE ?= "/dev/sd" +inherit image-artifact-names + # Create qemuboot.conf addtask do_write_qemuboot_conf after do_rootfs before do_image
meta/classes/rootfs-postcommands.bbclass +2 -0
@@ -39,6 +39,8 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd" ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile;' +inherit image-artifact-names + # Sort the user and group entries in /etc by ID in order to make the content # deterministic. Package installs are not deterministic, causing the ordering # of entries to change between builds. In case that this isn't desired,
meta/classes/testimage.bbclass +2 -0
@@ -3,6 +3,8 @@ # Released under the MIT license (see COPYING.MIT) inherit metadata_scm +inherit image-artifact-names + # testimage.bbclass enables testing of qemu images using python unittests. # Most of the tests are commands run on target image over ssh. # To use it add testimage to global inherit and call your target image with -c testimage
meta/conf/bitbake.conf +0 -5
@@ -452,11 +452,6 @@ STAGING_KERNEL_BUILDDIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-build-artifac ################################################################## IMAGE_ROOTFS = "${WORKDIR}/rootfs" -IMAGE_BASENAME = "${PN}" -IMAGE_VERSION_SUFFIX = "-${DATETIME}" -IMAGE_VERSION_SUFFIX[vardepsexclude] += "DATETIME" -IMAGE_NAME = "${IMAGE_BASENAME}-${MACHINE}${IMAGE_VERSION_SUFFIX}" -IMAGE_LINK_NAME = "${IMAGE_BASENAME}-${MACHINE}" # This option allows for a percentage overage of the actual image size rather than a # fixed extra space, this is space needed for initial startup and basic operations.
Signature · 1 line
2.25.1
PATCH 2/5 kernel.bbclass: use bash variables like imageType, base_name without {}
* just to make sure it looks like bash variable not bitbake variable in run.do_* scripts
[YOCTO #12937]
--- meta/classes/kernel.bbclass | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/kernel.bbclass +10 -10
@@ -407,7 +407,7 @@ kernel_do_install() { install -d ${D}/${KERNEL_IMAGEDEST} install -d ${D}/boot for imageType in ${KERNEL_IMAGETYPES} ; do - install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType} ${D}/${KERNEL_IMAGEDEST}/${imageType}-${KERNEL_VERSION} + install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION} done install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
@@ -716,11 +716,11 @@ kernel_do_deploy() { fi for imageType in ${KERNEL_IMAGETYPES} ; do - base_name=${imageType}-${KERNEL_IMAGE_NAME} - install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType} $deployDir/${base_name}.bin - symlink_name=${imageType}-${KERNEL_IMAGE_LINK_NAME} - ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin - ln -sf ${base_name}.bin $deployDir/${imageType} + base_name=$imageType-${KERNEL_IMAGE_NAME} + install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$base_name.bin + symlink_name=$imageType-${KERNEL_IMAGE_LINK_NAME} + ln -sf $base_name.bin $deployDir/$symlink_name.bin + ln -sf $base_name.bin $deployDir/$imageType done if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
@@ -741,10 +741,10 @@ kernel_do_deploy() { if [ "$imageType" = "fitImage" ] ; then continue fi - initramfs_base_name=${imageType}-${INITRAMFS_NAME} - initramfs_symlink_name=${imageType}-${INITRAMFS_LINK_NAME} - install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType}.initramfs $deployDir/${initramfs_base_name}.bin - ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin + initramfs_base_name=$imageType-${INITRAMFS_NAME} + initramfs_symlink_name=$imageType-${INITRAMFS_LINK_NAME} + install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfs_base_name.bin + ln -sf $initramfs_base_name.bin $deployDir/$initramfs_symlink_name.bin done fi }
Signature · 1 line
2.25.1
PATCH 3/5 kernel.bbclass: eliminate (initramfs_)symlink_name variables
In reply to Martin Jansa* they are used only once, we can use the value directly
* notice that .bin extension isn't part of the variable values
[YOCTO #12937]
--- meta/classes/kernel.bbclass | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
meta/classes/kernel.bbclass +2 -4
@@ -718,8 +718,7 @@ kernel_do_deploy() { for imageType in ${KERNEL_IMAGETYPES} ; do base_name=$imageType-${KERNEL_IMAGE_NAME} install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$base_name.bin - symlink_name=$imageType-${KERNEL_IMAGE_LINK_NAME} - ln -sf $base_name.bin $deployDir/$symlink_name.bin + ln -sf $base_name.bin $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}.bin ln -sf $base_name.bin $deployDir/$imageType done
@@ -742,9 +741,8 @@ kernel_do_deploy() { continue fi initramfs_base_name=$imageType-${INITRAMFS_NAME} - initramfs_symlink_name=$imageType-${INITRAMFS_LINK_NAME} install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfs_base_name.bin - ln -sf $initramfs_base_name.bin $deployDir/$initramfs_symlink_name.bin + ln -sf $initramfs_base_name.bin $deployDir/$imageType-${INITRAMFS_LINK_NAME}.bin done fi }
Signature · 1 line
2.25.1
PATCH 4/5 kernel.bbclass: use camelCase notation for bash variables in do_deploy
In reply to Martin Jansa* to match other variables there like deployDir imageType
[YOCTO #12937]
--- meta/classes/kernel.bbclass | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
meta/classes/kernel.bbclass +7 -7
@@ -716,10 +716,10 @@ kernel_do_deploy() { fi for imageType in ${KERNEL_IMAGETYPES} ; do - base_name=$imageType-${KERNEL_IMAGE_NAME} - install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$base_name.bin - ln -sf $base_name.bin $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}.bin - ln -sf $base_name.bin $deployDir/$imageType + baseName=$imageType-${KERNEL_IMAGE_NAME} + install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName.bin + ln -sf $baseName.bin $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}.bin + ln -sf $baseName.bin $deployDir/$imageType done if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
@@ -740,9 +740,9 @@ kernel_do_deploy() { if [ "$imageType" = "fitImage" ] ; then continue fi - initramfs_base_name=$imageType-${INITRAMFS_NAME} - install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfs_base_name.bin - ln -sf $initramfs_base_name.bin $deployDir/$imageType-${INITRAMFS_LINK_NAME}.bin + initramfsBaseName=$imageType-${INITRAMFS_NAME} + install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName.bin + ln -sf $initramfsBaseName.bin $deployDir/$imageType-${INITRAMFS_LINK_NAME}.bin done fi }
Signature · 1 line
2.25.1
PATCH 5/5 *-initramfs: don't use .rootfs IMAGE_NAME_SUFFIX
In reply to Martin Jansa* fixes the issue when image-live.bbclass expects the image
ending with just INITRAMFS_FSTYPES:
image-live.bbclass:INITRD_LIVE ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_LIVE}-${MACHINE}.${INITRAMFS_FSTYPES}"
while by default it now was with .rootfs suffix:
-rw-r--r-- 2 bitbake bitbake 1.5K Oct 25 16:12 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs.env
-rw-r--r-- 4 bitbake bitbake 11M Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.cpio.gz -rw-r--r-- 4 bitbake bitbake 1.2K Oct 25 16:11 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.manifest -rw-r--r-- 4 bitbake bitbake 1.3K Oct 25 16:12 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.qemuboot.conf -rw-r--r-- 4 bitbake bitbake 196K Oct 25 16:11 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.testdata.json -rw-r--r-- 4 bitbake bitbake 118M Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.wic -rw-r--r-- 4 bitbake bitbake 3.1K Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64-1.0-r0-20191025154349.wic.bmap -rw-r--r-- 4 bitbake bitbake 1.3K Oct 25 16:12 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.qemuboot.conf -rw-r--r-- 4 bitbake bitbake 11M Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.rootfs.cpio.gz -rw-r--r-- 4 bitbake bitbake 1.2K Oct 25 16:11 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.rootfs.manifest -rw-r--r-- 4 bitbake bitbake 118M Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.rootfs.wic -rw-r--r-- 4 bitbake bitbake 3.1K Oct 25 16:13 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.rootfs.wic.bmap -rw-r--r-- 4 bitbake bitbake 196K Oct 25 16:11 /OE/build/oe-core/tmp/deploy/images/genericx86-64/core-image-minimal-initramfs-genericx86-64.testdata.json
initramfs images aren't normally used for rootfs, so just set the suffix to empty, people using different artifact names might still need to set INITRD_LIVE (e.g. when their images don't end with "-${MACHINE}" as well)
--- meta/recipes-core/images/core-image-minimal-initramfs.bb | 1 + meta/recipes-core/images/core-image-tiny-initramfs.bb | 1 + meta/recipes-extended/images/core-image-testmaster-initramfs.bb | 1 + 3 files changed, 3 insertions(+)
meta/recipes-core/images/core-image-minimal-initramfs.bb +1 -0
@@ -17,6 +17,7 @@ PACKAGE_INSTALL = "${INITRAMFS_SCRIPTS} ${VIRTUAL-RUNTIME_base-utils} udev base- IMAGE_FEATURES = "" export IMAGE_BASENAME = "${MLPREFIX}core-image-minimal-initramfs" +IMAGE_NAME_SUFFIX ?= "" IMAGE_LINGUAS = "" LICENSE = "MIT"
meta/recipes-core/images/core-image-tiny-initramfs.bb +1 -0
@@ -13,6 +13,7 @@ PACKAGE_INSTALL = "initramfs-live-boot-tiny packagegroup-core-boot dropbear ${VI IMAGE_FEATURES = "" export IMAGE_BASENAME = "core-image-tiny-initramfs" +IMAGE_NAME_SUFFIX ?= "" IMAGE_LINGUAS = "" LICENSE = "MIT"
meta/recipes-extended/images/core-image-testmaster-initramfs.bb +1 -0
@@ -8,6 +8,7 @@ PACKAGE_INSTALL = "initramfs-live-boot initramfs-live-install-testfs initramfs-l IMAGE_FEATURES = "" export IMAGE_BASENAME = "core-image-testmaster-initramfs" +IMAGE_NAME_SUFFIX ?= "" IMAGE_LINGUAS = "" LICENSE = "MIT"
Signature · 1 line
2.25.1