diff mbox series

[1/3] image_types: use IMAGE_FILE_MAXSIZE variable for ext2/3/4 image types

Message ID 20230604123755.2541295-2-charles-antoine.couret@mind.be
State New
Headers show
Series image_types: use IMAGE_FILE_MAXSIZE variable to create fixed partition size | expand

Commit Message

Charles-Antoine Couret June 4, 2023, 12:37 p.m. UTC
If defined, this variable value overrides the size of ext* partition file created by mkfs.
Otherwise previous logic based on ROOTFS_SIZE variable is used.

It should be set when the final file size would not be above a specific value due to fixed
partitionning for example.

Signed-off-by: Charles-Antoine Couret <charles-antoine.couret@mind.be>
---
 meta/classes-recipe/image_types.bbclass | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Comments

Alexandre Belloni June 7, 2023, 12:30 p.m. UTC | #1
This fails on the autobuilders:

https://autobuilder.yoctoproject.org/typhoon/#/builders/69/builds/7219/steps/11/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/120/builds/2859/steps/14/logs/stdio

ERROR: core-image-minimal-1.0-r0 do_image_ext4: ExecutionError('/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/temp/run.do_image_ext4.266360', 2, None, None)
NOTE: recipe core-image-minimal-1.0-r0: task do_image_tar: Succeeded
ERROR: Logfile of failure stored in: /home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/temp/log.do_image_ext4.266360
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are ['/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-core/glibc/cross-localedef-native_2.37.bb:do_populate_sysroot', '/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-core/glibc/ldconfig-native_2.12.1.bb:do_populate_sysroot', '/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb:do_populate_sysroot', '/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-core/update-rc.d/update-rc.d_0.8.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/createrepo-c/createrepo-c_0.21.1.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/dnf/dnf_4.14.0.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.47.0.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/makedevs/makedevs_1.0.1.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/opkg-utils/opkg-utils_0.5.0.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/opkg/opkg_0.6.1.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-devtools/rpm/rpm_4.18.1.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-extended/pbzip2/pbzip2_1.1.13.bb:do_populate_sysroot', 'virtual:native:/home/pokybuild/yocto-worker/qa-extras/build/meta/recipes-extended/pigz/pigz_2.7.bb:do_populate_sysroot']
| NOTE: Installed into sysroot: ['e2fsprogs-native']
| NOTE: Skipping as already exists in sysroot: ['cross-localedef-native', 'ldconfig-native', 'qemuwrapper-cross', 'depmodwrapper-cross', 'update-rc.d-native', 'createrepo-c-native', 'dnf-native', 'makedevs-native', 'opkg-utils-native', 'opkg-native', 'pseudo-native', 'rpm-native', 'pbzip2-native', 'pigz-native', 'librepo-native', 'libcomps-native', 'gettext-minimal-native', 'python3-native', 'python3-iniparse-native', 'libdnf-native', 'cmake-native', 'kmod-native', 'openssl-native', 'debianutils-native', 'libtool-native', 'attr-native', 'util-linux-native', 'texinfo-dummy-native', 'bzip2-native', 'sqlite3-native', 'file-native', 'xz-native', 'zstd-native', 'popt-native', 'lua-native', 'elfutils-native', 'libgcrypt-native', 'qemu-native', 'zlib-native', 'libxml2-native', 'expat-native', 'curl-native', 'glib-2.0-native', 'perl-native', 'shadow-native', 'libarchive-native', 'libsolv-native', 'gpgme-native', 'libffi-native', 'libtirpc-native', 'libedit-native', 'ncurses-native', 'util-linux-libuuid-native', 'libnsl2-native', 'gdbm-native', 'python3-wheel-native', 'python3-six-native', 'python3-build-native', 'python3-installer-native', 'python3-setuptools-native', 'libcheck-native', 'gobject-introspection-native', 'json-c-native', 'swig-native', 'libmodulemd-native', 'libpcre2-native', 'libcap-ng-native', 'readline-native', 'libmicrohttpd-native', 'libgpg-error-native', 'libcap-native', 'gettext-native', 'make-native', 'libassuan-native', 'python3-flit-core-native', 'python3-pyproject-hooks-native', 'python3-packaging-native', 'flex-native', 'libyaml-native', 'gnutls-native', 'unzip-native', 'm4-native', 'libtasn1-native', 'gmp-native', 'libidn2-native', 'libunistring-native', 'nettle-native', 'gnu-config-native']
| DEBUG: sed -e 's:^[^/]*/:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot-native/:g' /home/pokybuild/yocto-worker/qa-extras/build/build/tmp/sysroots-components/x86_64/e2fsprogs-native/fixmepath | xargs sed -i -e 's:FIXMESTAGINGDIRTARGET:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot:g; s:FIXMESTAGINGDIRHOST:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot-native:g' -e 's:FIXME_PSEUDO_SYSROOT:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/sysroots-components/x86_64/pseudo-native:g' -e 's:FIXME_HOSTTOOLS_DIR:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/hosttools:g' -e 's:FIXME_PKGDATA_DIR:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/pkgdata/qemux86-64:g' -e 's:FIXME_PSEUDO_LOCALSTATEDIR:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/pseudo/:g' -e 's:FIXME_LOGFIFO:/home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/temp/fifo.266360:g'
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing python function set_image_size
| DEBUG: 33737.600000 = 25952 * 1.300000
| DEBUG: 33737.600000 = max(33737.600000, 8192)[33737.600000] + 0
| DEBUG: 33738.000000 = int(33737.600000)
| DEBUG: 33738 = aligned(33738)
| DEBUG: returning 33738
| DEBUG: Python function set_image_size finished
| DEBUG: Executing shell function do_image_ext4
| /home/pokybuild/yocto-worker/qa-extras/build/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/temp/run.do_image_ext4.266360: 151: Bad substitution
| WARNING: exit code 2 from a shell command.
NOTE: recipe core-image-minimal-1.0-r0: task do_image_ext4: Failed

On 04/06/2023 14:37:53+0200, Charles-Antoine Couret via lists.openembedded.org wrote:
> If defined, this variable value overrides the size of ext* partition file created by mkfs.
> Otherwise previous logic based on ROOTFS_SIZE variable is used.
> 
> It should be set when the final file size would not be above a specific value due to fixed
> partitionning for example.
> 
> Signed-off-by: Charles-Antoine Couret <charles-antoine.couret@mind.be>
> ---
>  meta/classes-recipe/image_types.bbclass | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass
> index e4939af459..cebbb61545 100644
> --- a/meta/classes-recipe/image_types.bbclass
> +++ b/meta/classes-recipe/image_types.bbclass
> @@ -68,24 +68,33 @@ IMAGE_CMD:cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${I
>  
>  oe_mkext234fs () {
>  	fstype=$1
> +	image_file_maxsize=$2
>  	extra_imagecmd=""
> +	rootfs_file_size=$ROOTFS_SIZE
>  
> -	if [ $# -gt 1 ]; then
> -		shift
> +	if [ $# -gt 2 ]; then
> +		shift 2
>  		extra_imagecmd=$@
>  	fi
>  
> +
> +	if [[ "${image_file_maxsize}" != "\"\"" ]]; then
> +		# Remove quotes to get numbers only
> +		rootfs_file_size=$(echo "${image_file_maxsize}" | tr -d '"')
> +	fi
> +
>  	# If generating an empty image the size of the sparse block should be large
>  	# enough to allocate an ext4 filesystem using 4096 bytes per inode, this is
>  	# about 60K, so dd needs a minimum count of 60, with bs=1024 (bytes per IO)
>  	eval local COUNT=\"0\"
>  	eval local MIN_COUNT=\"60\"
> -	if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
> +	if [ $rootfs_file_size -lt $MIN_COUNT ]; then
>  		eval COUNT=\"$MIN_COUNT\"
>  	fi
> +
>  	# Create a sparse image block
> -	bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024"
> -	dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024
> +	bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024"
> +	dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024
>  	bbdebug 1 "Actual Rootfs size:  `du -s ${IMAGE_ROOTFS}`"
>  	bbdebug 1 "Actual Partition size: `stat -c '%s' ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype`"
>  	bbdebug 1 Executing "mkfs.$fstype -F $extra_imagecmd ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype -d ${IMAGE_ROOTFS}"
> @@ -94,9 +103,9 @@ oe_mkext234fs () {
>  	fsck.$fstype -pvfD ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype || [ $? -le 3 ]
>  }
>  
> -IMAGE_CMD:ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}"
> -IMAGE_CMD:ext3 = "oe_mkext234fs ext3 ${EXTRA_IMAGECMD}"
> -IMAGE_CMD:ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}"
> +IMAGE_CMD:ext2 = "oe_mkext234fs ext2 \"${IMAGE_FILE_MAXSIZE:ext2}\" ${EXTRA_IMAGECMD}"
> +IMAGE_CMD:ext3 = "oe_mkext234fs ext3 \"${IMAGE_FILE_MAXSIZE:ext3}\" ${EXTRA_IMAGECMD}"
> +IMAGE_CMD:ext4 = "oe_mkext234fs ext4 \"${IMAGE_FILE_MAXSIZE:ext4}\" ${EXTRA_IMAGECMD}"
>  
>  MIN_BTRFS_SIZE ?= "16384"
>  IMAGE_CMD:btrfs () {
> -- 
> 2.40.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#182360): https://lists.openembedded.org/g/openembedded-core/message/182360
> Mute This Topic: https://lists.openembedded.org/mt/99320004/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass
index e4939af459..cebbb61545 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -68,24 +68,33 @@  IMAGE_CMD:cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${I
 
 oe_mkext234fs () {
 	fstype=$1
+	image_file_maxsize=$2
 	extra_imagecmd=""
+	rootfs_file_size=$ROOTFS_SIZE
 
-	if [ $# -gt 1 ]; then
-		shift
+	if [ $# -gt 2 ]; then
+		shift 2
 		extra_imagecmd=$@
 	fi
 
+
+	if [[ "${image_file_maxsize}" != "\"\"" ]]; then
+		# Remove quotes to get numbers only
+		rootfs_file_size=$(echo "${image_file_maxsize}" | tr -d '"')
+	fi
+
 	# If generating an empty image the size of the sparse block should be large
 	# enough to allocate an ext4 filesystem using 4096 bytes per inode, this is
 	# about 60K, so dd needs a minimum count of 60, with bs=1024 (bytes per IO)
 	eval local COUNT=\"0\"
 	eval local MIN_COUNT=\"60\"
-	if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
+	if [ $rootfs_file_size -lt $MIN_COUNT ]; then
 		eval COUNT=\"$MIN_COUNT\"
 	fi
+
 	# Create a sparse image block
-	bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024"
-	dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024
+	bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024"
+	dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024
 	bbdebug 1 "Actual Rootfs size:  `du -s ${IMAGE_ROOTFS}`"
 	bbdebug 1 "Actual Partition size: `stat -c '%s' ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype`"
 	bbdebug 1 Executing "mkfs.$fstype -F $extra_imagecmd ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype -d ${IMAGE_ROOTFS}"
@@ -94,9 +103,9 @@  oe_mkext234fs () {
 	fsck.$fstype -pvfD ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype || [ $? -le 3 ]
 }
 
-IMAGE_CMD:ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}"
-IMAGE_CMD:ext3 = "oe_mkext234fs ext3 ${EXTRA_IMAGECMD}"
-IMAGE_CMD:ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext2 = "oe_mkext234fs ext2 \"${IMAGE_FILE_MAXSIZE:ext2}\" ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext3 = "oe_mkext234fs ext3 \"${IMAGE_FILE_MAXSIZE:ext3}\" ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext4 = "oe_mkext234fs ext4 \"${IMAGE_FILE_MAXSIZE:ext4}\" ${EXTRA_IMAGECMD}"
 
 MIN_BTRFS_SIZE ?= "16384"
 IMAGE_CMD:btrfs () {