Re: [oe] [meta-oe][PATCH v1] image_types_sparse: switch ext* conversion to ext2simg_android

Gyorgy Sarvari
2026-03-20T08:25:01Z

I have added a few notes - I would recommend to wait a couple of days
before sending a v2, there might be further feedback from others (and
maybe I will forget also something)

On 3/20/26 06:28, Ashish Kumar Mishra via lists.openembedded.org wrote:
> We have RFC discussion at
> https://lists.openembedded.org/g/openembedded-devel/message/124499
>
> Move ext* sparse image generation from 'img2simg' to ' ext2simg_android'
> Summary of changes:
> - android-tools: Export libsparse/libbase/liblog headers and libs to
> sysroot to allow external linking. Masked v5.1.1.
>
> - image_types_sparse.bbclass: Update CONVERSION_CMD to use ext2simg_android
> for ext* types
>
> - layer.conf: Sync BBMASK and add dynamic-layer paths.

BBMASK doesn't sound something that belongs to meta-oe. There are other
ways to ignore recipes - PREFERRED_VERSION variable for example. Also,
there are/were some discussions[1] on dropping one of the android-tools
recipes - you may want to chime in and speed it up?

[1]: https://lists.openembedded.org/g/openembedded-devel/topic/117415388

>
> - Add a custom do_compile step to build the ext2simg_android utility (ext2simg)
> when building for the native class.
>
> - Added 'image_types_sparse' to IMAGE_CLASSES and enabled 'ext4.sparse'
> in IMAGE_FSTYPES.
> This allows the build system to generate Android-style sparse image
>
> - Switch to using $ORIGIN/../${baselib}.
> $ORIGIN is a special variable recognized by the dynamic linker that represents
> the directory containing the executable.
>

This might useful to also mention the motivation for specifying the
rpath (I still have some vague memories, but it fades by the minute)

> Signed-off-by: AshishKumar Mishra <ashishkumar.mishra@bmwtechworks.in>
> ---
> meta-oe/classes/image_types_sparse.bbclass | 15 +++-
> meta-oe/conf/layer.conf | 11 ++-
> .../android-tools/android-tools_29.0.6.r14.bb | 44 ++++++++++++
> .../e2fsprogs-ext4sparse.inc | 26 +++++++
> ...inode.c-Fix-for-file-larger-than-2GB.patch | 40 +++++++++++
> ...-missing-check-for-permission-denied.patch | 32 +++++++++
> .../e2fsprogs-ext4sparse/mkdir_p.patch | 28 ++++++++
> .../e2fsprogs-ext4sparse/quiet-debugfs.patch | 27 ++++++++
> .../remove.ldconfig.call.patch | 41 +++++++++++
> .../e2fsprogs-ext4sparse_1.0.bb | 68 +++++++++++++++++++
> 10 files changed, 328 insertions(+), 4 deletions(-)
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse.inc
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse/0001-misc-create_inode.c-Fix-for-file-larger-than-2GB.patch
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse/e2fsprogs-fix-missing-check-for-permission-denied.patch
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse/mkdir_p.patch
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse/quiet-debugfs.patch
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse/remove.ldconfig.call.patch
> create mode 100644 meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse_1.0.bb
>
> diff --git a/meta-oe/classes/image_types_sparse.bbclass b/meta-oe/classes/image_types_sparse.bbclass
> index 5416c2a019..75f0d00703 100644
> --- a/meta-oe/classes/image_types_sparse.bbclass
> +++ b/meta-oe/classes/image_types_sparse.bbclass
> @@ -13,11 +13,20 @@ DELETE_RAWIMAGE_AFTER_SPARSE_CMD ??= "0"
>
> CONVERSION_CMD:sparse = " \
> truncate --no-create --size=%${SPARSE_BLOCK_SIZE} "${IMAGE_NAME}.${type}"; \
> - img2simg -s "${IMAGE_NAME}.${type}" "${IMAGE_NAME}.${type}.sparse" ${SPARSE_BLOCK_SIZE}; \
> + case '${type}' in \
> + ext*) \
> + bbwarn 'Running e2fsprogs-derived ext2simg_android..' ; \

Please do not use bbwarn for generic logging in final patches. This
should be bbdebug or bbnote most probably. Same for the other usages also
(bberror usages look appropriate at the first sight)

> + ext2simg_android '${IMAGE_NAME}.${type}' '${IMAGE_NAME}.simg' || bberror 'ext2simg_android failed' \
> + ;; \
> + *) \
> + bbwarn 'Generating sparse image for non-ext filesystem...'; \
> + img2simg -s '${IMAGE_NAME}.${type}' '${IMAGE_NAME}.${type}.sparse' ${SPARSE_BLOCK_SIZE}; \
> + ;; \
> + esac; \
> if [ "${DELETE_RAWIMAGE_AFTER_SPARSE_CMD}" = "1" ]; then \
> rm -f ${IMAGE_NAME}.${type};\
> bbwarn "Raw file ${IMAGE_NAME}.${type} removed" ;\
> fi;\
> "
> -
> -CONVERSION_DEPENDS_sparse = "android-tools-native"
> +CONVERSION_DEPENDS:sparse = "android-tools-native e2fsprogs-ext4sparse-native"
> +do_image_ext4[depends] += "e2fsprogs-ext4sparse-native:do_populate_sysroot"

... snip ...

> diff --git a/meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse_1.0.bb b/meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse_1.0.bb
> new file mode 100644
> index 0000000000..96f1f08177
> --- /dev/null
> +++ b/meta-oe/recipes-devtools/e2fsprogs-ext4sparse/e2fsprogs-ext4sparse_1.0.bb
> @@ -0,0 +1,68 @@
> +require e2fsprogs-ext4sparse.inc
> +
> +inherit native
> +
> +SRC_URI += "file://remove.ldconfig.call.patch \
> + file://mkdir_p.patch \
> + file://0001-misc-create_inode.c-Fix-for-file-larger-than-2GB.patch \
> + "
> +SRC_URI:append:class-native = " \
> + file://e2fsprogs-fix-missing-check-for-permission-denied.patch \
> + file://quiet-debugfs.patch \
> + "
> +
> +SRCREV = "da631e117dcf8797bfda0f48bdaa05ac0fbcf7af"
> +
> +EXTRA_OECONF = " \
> + --libdir=${base_libdir} \
> + --sbindir=${base_sbindir} \
> + --enable-elf-shlibs \
> + --enable-largefile \
> + --disable-libuuid \
> + --disable-libblkid \
> + --disable-uuidd \
> + --disable-fuse2fs \
> + --with-crond-dir=no \
> +"
> +
> +DEPENDS += "util-linux-native"
> +
> +# Fix e2fsprogs-native do_compile error with old kernel such as 5.10
> +CACHED_CONFIGUREVARS:class-native = "ac_cv_header_linux_fsverity_h=no"
> +
> +do_install () {
> +}

Why empty install for class-target? Is this a native-only recipe?

> +
> +
> +RDEPENDS:${PN} = ""
> +RRECOMMENDS:${PN} = ""
> +ALTERNATIVE:${PN} = ""

Are this overriding something?

> +
> +PACKAGES = "${PN}"
> +FILES:${PN} = "${bindir}/ext2simg_android"
> +FILES:${PN}:class-native += "${bindir}/ext2simg_android"

Does this need to be repeated? I'd expect that the first FILES
assignment would take ffect for class-native also. Is this not the case?

> +
> +DEPENDS:append:class-native = " android-tools-native "
> +
> +do_compile:append:class-native() {
> + oe_runmake -C ${B}/lib/et
> + oe_runmake -C ${B}/lib/ext2fs
> +
> + # Source directory for ext2simg.c in the e2fsprogs tree
> + SRC_EXT2SIMG="${S}/contrib/android"
> +
> + INCLUDES="-I${S}/lib -I${B}/lib -I${SRC_EXT2SIMG}/lib"
> +
> + # STAGING_LIBDIR_NATIVE: where android-tools-native installed libsparse
> + LIBS="-L${B}/lib -L${STAGING_LIBDIR_NATIVE} -lsparse -lext2fs -lz -lcom_err"
> +
> + ${CC} ${CFLAGS} ${LDFLAGS} -o "${B}/ext2simg_android" "${SRC_EXT2SIMG}/ext2simg.c" ${INCLUDES} ${LIBS}
> +}
> +
> +do_install:append:class-native() {
> + install -d ${D}${bindir}
> + install -m 0755 ${B}/ext2simg_android ${D}${bindir}/ext2simg_android
> +}
> +
> +BUILD_LDFLAGS += "-Wl,-rpath,'\$ORIGIN/../${baselib}'"
> +TARGET_LDFLAGS += "-Wl,-rpath,'\$ORIGIN/../${baselib}'"
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#125420): https://lists.openembedded.org/g/openembedded-devel/message/125420
> Mute This Topic: https://lists.openembedded.org/mt/118413954/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>