Skip to contentSkip to conversation

rust-android-sparse: add lightweight simg2img/img2simg implementation

PATCH Superseded Dmitry Baryshkov 3 participants 5 messages Feb 11, 2023 – Feb 14, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rust-android-sparse: add lightweight simg2img/img2simg implementation

The Android's simg2img/img2simg comes from android-tools, which is a huge package with lots of dependencies on its own. It resides inside meta-oe rather than OE-Core. Add lightweight tool to handle sparse images, which is small enough to be pushed into OE-Core.

---
 .../rust-android-sparse_0.6.0.bb              | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb
meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb new file +68 -0
new file mode 100644
index 000000000000..83652b9d452f
@@ -0,0 +1,68 @@
+# Auto-Generated by cargo-bitbake 0.3.16
+#
+inherit cargo
+
+# how to get android-sparse could be as easy as but default to a git checkout:
+SRC_URI += "crate://crates.io/android-sparse/0.6.0"
+S= "${CARGO_VENDORING_DIRECTORY}/android-sparse-${PV}"
+
+# please note if you have entries that do not begin with crate://
+# you must change them to how that package can be fetched
+SRC_URI += " \
+    crate://crates.io/aho-corasick/0.7.18 \
+    crate://crates.io/assert_cmd/0.9.1 \
+    crate://crates.io/autocfg/1.0.1 \
+    crate://crates.io/bitflags/1.3.2 \
+    crate://crates.io/build_const/0.2.2 \
+    crate://crates.io/byteorder/1.4.3 \
+    crate://crates.io/cfg-if/1.0.0 \
+    crate://crates.io/clap/2.34.0 \
+    crate://crates.io/crc/1.8.1 \
+    crate://crates.io/difference/2.0.0 \
+    crate://crates.io/escargot/0.3.1 \
+    crate://crates.io/float-cmp/0.4.0 \
+    crate://crates.io/getrandom/0.2.3 \
+    crate://crates.io/itoa/0.4.8 \
+    crate://crates.io/libc/0.2.109 \
+    crate://crates.io/memchr/2.4.1 \
+    crate://crates.io/normalize-line-endings/0.2.2 \
+    crate://crates.io/num-traits/0.2.14 \
+    crate://crates.io/ppv-lite86/0.2.15 \
+    crate://crates.io/predicates-core/0.9.0 \
+    crate://crates.io/predicates-tree/0.9.0 \
+    crate://crates.io/predicates/0.9.1 \
+    crate://crates.io/proc-macro2/1.0.33 \
+    crate://crates.io/quote/1.0.10 \
+    crate://crates.io/rand/0.8.4 \
+    crate://crates.io/rand_core/0.6.3 \
+    crate://crates.io/rand_chacha/0.3.1 \
+    crate://crates.io/rand_hc/0.3.1 \
+    crate://crates.io/redox_syscall/0.2.10 \
+    crate://crates.io/regex-syntax/0.6.25 \
+    crate://crates.io/regex/1.5.4 \
+    crate://crates.io/remove_dir_all/0.5.3 \
+    crate://crates.io/ryu/1.0.6 \
+    crate://crates.io/serde/1.0.130 \
+    crate://crates.io/serde_derive/1.0.130 \
+    crate://crates.io/serde_json/1.0.72 \
+    crate://crates.io/syn/1.0.82 \
+    crate://crates.io/tempfile/3.2.0 \
+    crate://crates.io/textwrap/0.11.0 \
+    crate://crates.io/treeline/0.1.0 \
+    crate://crates.io/unicode-width/0.1.9 \
+    crate://crates.io/unicode-xid/0.2.2 \
+    crate://crates.io/wasi/0.10.2+wasi-snapshot-preview1 \
+    crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi/0.3.9 \
+"
+
+LIC_FILES_CHKSUM = " \
+    file://LICENSE;md5=0ffe68749328daf57dd85d5ca6ee981f \
+"
+
+SUMMARY = "An implementation of Android's sparse file format."
+HOMEPAGE = "https://gitlab.com/ra_kete/android-sparse-rs"
+LICENSE = "MIT"
+
+BBCLASSEXTEND += "native"
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 image_types.bbclass: add support for sparse images

Add Support for sparse conversion to be able to generate sparse images.

---
 meta/classes-recipe/image_types.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes-recipe/image_types.bbclass +3 -1
index ae00728a74da..cf8cc27e87e7 100644
@@ -308,7 +308,7 @@ IMAGE_TYPES:append:x86-64 = " hddimg iso"
 # CONVERSION_CMD/DEPENDS.
 COMPRESSIONTYPES ?= ""
 
-CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip 7zip zst sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap u-boot vmdk vhd vhdx vdi qcow2 base64 gzsync zsync ${COMPRESSIONTYPES}"
+CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip 7zip zst sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap u-boot vmdk vhd vhdx vdi qcow2 base64 gzsync zsync sparse ${COMPRESSIONTYPES}"
 CONVERSION_CMD:lzma = "lzma -k -f -7 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
 CONVERSION_CMD:gz = "gzip -f -9 -n -c --rsyncable ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.gz"
 CONVERSION_CMD:bz2 = "pbzip2 -f -k ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
@@ -335,6 +335,7 @@ CONVERSION_CMD:qcow2 = "qemu-img convert -O qcow2 ${IMAGE_NAME}${IMAGE_NAME_SUFF
 CONVERSION_CMD:base64 = "base64 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.base64"
 CONVERSION_CMD:zsync = "zsyncmake_curl ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
 CONVERSION_CMD:gzsync = "zsyncmake_curl -z ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
+CONVERSION_CMD:sparse = "img2simg -c ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sparse"
 CONVERSION_DEPENDS_lzma = "xz-native"
 CONVERSION_DEPENDS_gz = "pigz-native"
 CONVERSION_DEPENDS_bz2 = "pbzip2-native"
@@ -355,6 +356,7 @@ CONVERSION_DEPENDS_vhdx = "qemu-system-native"
 CONVERSION_DEPENDS_vhd = "qemu-system-native"
 CONVERSION_DEPENDS_zsync = "zsync-curl-native"
 CONVERSION_DEPENDS_gzsync = "zsync-curl-native"
+CONVERSION_DEPENDS_sparse = "rust-android-sparse-native"
 
 RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4"
 RUNNABLE_MACHINE_PATTERNS ?= "qemu"
Signature · 1 line
2.30.2
#2 lore raw
In reply to Dmitry Baryshkov

But is it necessary or desirable to have it in core? This does seem like something that belongs in meta-oe rather.

Alex

Quoted 98 lines · Dmitry Baryshkov

The Android's simg2img/img2simg comes from android-tools, which is a huge package with lots of dependencies on its own. It resides inside meta-oe rather than OE-Core. Add lightweight tool to handle sparse images, which is small enough to be pushed into OE-Core.

---
 .../rust-android-sparse_0.6.0.bb              | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb
meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb new file +68 -1
new file mode 100644
index 000000000000..83652b9d452f
@@ -0,0 +1,68 @@
+# Auto-Generated by cargo-bitbake 0.3.16
+#
+inherit cargo
+
+# how to get android-sparse could be as easy as but default to a git checkout:
+SRC_URI += "crate://crates.io/android-sparse/0.6.0"
+S= "${CARGO_VENDORING_DIRECTORY}/android-sparse-${PV}"
+
+# please note if you have entries that do not begin with crate://
+# you must change them to how that package can be fetched
+SRC_URI += " \
+    crate://crates.io/aho-corasick/0.7.18 \
+    crate://crates.io/assert_cmd/0.9.1 \
+    crate://crates.io/autocfg/1.0.1 \
+    crate://crates.io/bitflags/1.3.2 \
+    crate://crates.io/build_const/0.2.2 \
+    crate://crates.io/byteorder/1.4.3 \
+    crate://crates.io/cfg-if/1.0.0 \
+    crate://crates.io/clap/2.34.0 \
+    crate://crates.io/crc/1.8.1 \
+    crate://crates.io/difference/2.0.0 \
+    crate://crates.io/escargot/0.3.1 \
+    crate://crates.io/float-cmp/0.4.0 \
+    crate://crates.io/getrandom/0.2.3 \
+    crate://crates.io/itoa/0.4.8 \
+    crate://crates.io/libc/0.2.109 \
+    crate://crates.io/memchr/2.4.1 \
+    crate://crates.io/normalize-line-endings/0.2.2 \
+    crate://crates.io/num-traits/0.2.14 \
+    crate://crates.io/ppv-lite86/0.2.15 \
+    crate://crates.io/predicates-core/0.9.0 \
+    crate://crates.io/predicates-tree/0.9.0 \
+    crate://crates.io/predicates/0.9.1 \
+    crate://crates.io/proc-macro2/1.0.33 \
+    crate://crates.io/quote/1.0.10 \
+    crate://crates.io/rand/0.8.4 \
+    crate://crates.io/rand_core/0.6.3 \
+    crate://crates.io/rand_chacha/0.3.1 \
+    crate://crates.io/rand_hc/0.3.1 \
+    crate://crates.io/redox_syscall/0.2.10 \
+    crate://crates.io/regex-syntax/0.6.25 \
+    crate://crates.io/regex/1.5.4 \
+    crate://crates.io/remove_dir_all/0.5.3 \
+    crate://crates.io/ryu/1.0.6 \
+    crate://crates.io/serde/1.0.130 \
+    crate://crates.io/serde_derive/1.0.130 \
+    crate://crates.io/serde_json/1.0.72 \
+    crate://crates.io/syn/1.0.82 \
+    crate://crates.io/tempfile/3.2.0 \
+    crate://crates.io/textwrap/0.11.0 \
+    crate://crates.io/treeline/0.1.0 \
+    crate://crates.io/unicode-width/0.1.9 \
+    crate://crates.io/unicode-xid/0.2.2 \
+    crate://crates.io/wasi/0.10.2+wasi-snapshot-preview1 \
+    crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi/0.3.9 \
+"
+
+LIC_FILES_CHKSUM = " \
+    file://LICENSE;md5=0ffe68749328daf57dd85d5ca6ee981f \
+"
+
+SUMMARY = "An implementation of Android's sparse file format."
+HOMEPAGE = "https://gitlab.com/ra_kete/android-sparse-rs"
+LICENSE = "MIT"
+
+BBCLASSEXTEND += "native"
--

2.30.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#177007): https://lists.openembedded.org/g/openembedded-core/message/177007
Mute This Topic: https://lists.openembedded.org/mt/96898285/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 3 lines · Alexander Kanavin

But is it necessary or desirable to have it in core? This does seem like something that belongs in meta-oe rather.

My goal was to move sparse image handling in a way to be able to generate them from the BSP layers, removing dependency on the meta-oe layer. This way it is possible to generate sparse images unconditionally and then let the user feed them to fastboot.

But yeah, if it's recommended to keep it in meta-oe, I can move my recipe there.

Quoted 94 lines

Alex

Quoted 90 lines · Dmitry Baryshkov

The Android's simg2img/img2simg comes from android-tools, which is a huge package with lots of dependencies on its own. It resides inside meta-oe rather than OE-Core. Add lightweight tool to handle sparse images, which is small enough to be pushed into OE-Core.

---
 .../rust-android-sparse_0.6.0.bb              | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb
meta/recipes-extended/rust-android-sparse/rust-android-sparse_0.6.0.bb new file +68 -1
new file mode 100644
index 000000000000..83652b9d452f
@@ -0,0 +1,68 @@
+# Auto-Generated by cargo-bitbake 0.3.16
+#
+inherit cargo
+
+# how to get android-sparse could be as easy as but default to a git checkout:
+SRC_URI += "crate://crates.io/android-sparse/0.6.0"
+S= "${CARGO_VENDORING_DIRECTORY}/android-sparse-${PV}"
+
+# please note if you have entries that do not begin with crate://
+# you must change them to how that package can be fetched
+SRC_URI += " \
+    crate://crates.io/aho-corasick/0.7.18 \
+    crate://crates.io/assert_cmd/0.9.1 \
+    crate://crates.io/autocfg/1.0.1 \
+    crate://crates.io/bitflags/1.3.2 \
+    crate://crates.io/build_const/0.2.2 \
+    crate://crates.io/byteorder/1.4.3 \
+    crate://crates.io/cfg-if/1.0.0 \
+    crate://crates.io/clap/2.34.0 \
+    crate://crates.io/crc/1.8.1 \
+    crate://crates.io/difference/2.0.0 \
+    crate://crates.io/escargot/0.3.1 \
+    crate://crates.io/float-cmp/0.4.0 \
+    crate://crates.io/getrandom/0.2.3 \
+    crate://crates.io/itoa/0.4.8 \
+    crate://crates.io/libc/0.2.109 \
+    crate://crates.io/memchr/2.4.1 \
+    crate://crates.io/normalize-line-endings/0.2.2 \
+    crate://crates.io/num-traits/0.2.14 \
+    crate://crates.io/ppv-lite86/0.2.15 \
+    crate://crates.io/predicates-core/0.9.0 \
+    crate://crates.io/predicates-tree/0.9.0 \
+    crate://crates.io/predicates/0.9.1 \
+    crate://crates.io/proc-macro2/1.0.33 \
+    crate://crates.io/quote/1.0.10 \
+    crate://crates.io/rand/0.8.4 \
+    crate://crates.io/rand_core/0.6.3 \
+    crate://crates.io/rand_chacha/0.3.1 \
+    crate://crates.io/rand_hc/0.3.1 \
+    crate://crates.io/redox_syscall/0.2.10 \
+    crate://crates.io/regex-syntax/0.6.25 \
+    crate://crates.io/regex/1.5.4 \
+    crate://crates.io/remove_dir_all/0.5.3 \
+    crate://crates.io/ryu/1.0.6 \
+    crate://crates.io/serde/1.0.130 \
+    crate://crates.io/serde_derive/1.0.130 \
+    crate://crates.io/serde_json/1.0.72 \
+    crate://crates.io/syn/1.0.82 \
+    crate://crates.io/tempfile/3.2.0 \
+    crate://crates.io/textwrap/0.11.0 \
+    crate://crates.io/treeline/0.1.0 \
+    crate://crates.io/unicode-width/0.1.9 \
+    crate://crates.io/unicode-xid/0.2.2 \
+    crate://crates.io/wasi/0.10.2+wasi-snapshot-preview1 \
+    crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \
+    crate://crates.io/winapi/0.3.9 \
+"
+
+LIC_FILES_CHKSUM = " \
+    file://LICENSE;md5=0ffe68749328daf57dd85d5ca6ee981f \
+"
+
+SUMMARY = "An implementation of Android's sparse file format."
+HOMEPAGE = "https://gitlab.com/ra_kete/android-sparse-rs"
+LICENSE = "MIT"
+
+BBCLASSEXTEND += "native"
--

2.30.2

Quoted 8 lines
Quoted 8 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#177007): https://lists.openembedded.org/g/openembedded-core/message/177007
Mute This Topic: https://lists.openembedded.org/mt/96898285/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

--
With best wishes
Dmitry

#4 lore raw
Quoted 6 lines · Dmitry Baryshkov

My goal was to move sparse image handling in a way to be able to generate them from the BSP layers, removing dependency on the meta-oe layer. This way it is possible to generate sparse images unconditionally and then let the user feed them to fastboot.

But yeah, if it's recommended to keep it in meta-oe, I can move my recipe there.

Just to clarify, to get something into core, you need to explain what are those 'android sparse images', what is consuming them, and whether supporting them fulfils a broadly useful scenario (this is the hardest part, as there has not been interest from others). There should also be testing, and commitment to maintain the pieces.

Alex