From ff968a751e1cc6efb89716b792c5f15c9762358c Mon Sep 17 00:00:00 2001 From: Pablo Castellano Date: Wed, 2 Aug 2017 18:21:50 +0200 Subject: [PATCH] Implement sparse system images (fix #299) (#303) * Packaged libsparse libsparse from the Android project provides multiple tools like img2simg and simg2img. These are used to split a large image for the system partition into separate smaller chunks with sparse headers This is required for several devices (at least bullhead, fp2 and titan) because it fixes the "Invalid sparse file format at header magi" error https://github.com/postmarketOS/pmbootstrap/issues/299 * Added new variable deviceinfo_flash_sparse (fixes #299) Right after the system image is generated, pmbootstrap checks this variable. In case it is true, run img2simg on it * motorola-titan: enable deviceinfo_flash_sparse * libsparse: use source from github: anestisb/android-simg2img It is not that easy to use the upstream archive because everytime you download it, the files have the current date as creation date and that makes the file have a different checksum every download https://github.com/postmarketOS/pmbootstrap/pull/303#issuecomment-319017197 --- device/device-motorola-titan/APKBUILD | 4 ++-- device/device-motorola-titan/deviceinfo | 1 + main/libsparse/APKBUILD | 29 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 main/libsparse/APKBUILD diff --git a/device/device-motorola-titan/APKBUILD b/device/device-motorola-titan/APKBUILD index cbdc306a1..127e3b299 100644 --- a/device/device-motorola-titan/APKBUILD +++ b/device/device-motorola-titan/APKBUILD @@ -1,6 +1,6 @@ pkgname=device-motorola-titan pkgver=1 -pkgrel=9 +pkgrel=10 pkgdesc="Motorola Moto G 2014" url="https://github.com/postmarketOS" arch="noarch" @@ -27,7 +27,7 @@ package() { "$pkgdir"/etc/profile.d/00-$pkgname.sh } -sha512sums="e090f4cb7ef2641c6c89ba4ed4f9d4be95eee716c7a3e8690f069bdbe2a88155fd19b63e849cebc501846ef6f58d7cfa63d331c43b4aded964f1261f6083cd95 deviceinfo +sha512sums="09abd5f4681d9479650cfa64fcbc58528827017757539c3faf142ca92e8537691f9fb88f5d84ece086af7f23be2ac03e196f49ae708a832f1331f40cc96bab29 deviceinfo f37e6324abf0b0fc8a3d360d6d11bb0648090a438a55ca7f04a9d494719e687ce445ae107ace642edf293afb6ca82615bcb5d0ddb6c46c1a7f8ee3c213b7c5c4 90-android-touch-dev.rules 8590967fa10388a890fdfafdb1070b9ab22dc89e06a3a8834806c772191e3b67de7b914b0d68e5ddf581cee715cb90f3f24abcb8762c415ff328c6da23e55d52 initfs-hook.sh 2f7cdf558a6bff56fd343d29a1ca6c27e75715bedfad661700dfcfb01acd1bdfcfecdfccf619f1e56c1e6331be146f8882a14d3a2cd33830e9d00bb6118971a3 profile.sh" diff --git a/device/device-motorola-titan/deviceinfo b/device/device-motorola-titan/deviceinfo index cb6e40902..e6012beac 100644 --- a/device/device-motorola-titan/deviceinfo +++ b/device/device-motorola-titan/deviceinfo @@ -26,6 +26,7 @@ deviceinfo_flash_offset_tags="0x00000100" deviceinfo_flash_pagesize="2048" deviceinfo_kernel_cmdline="androidboot.bootdevice=msm_sdcc.1 androidboot.hardware=qcom vmalloc=400M utags.blkdev=/dev/block/platform/msm_sdcc.1/by-name/utags buildvariant=userdebug" deviceinfo_generate_bootimg="true" +deviceinfo_flash_sparse="true" # Weston red screen workaround (see issue #54) deviceinfo_weston_pixman_type="2" diff --git a/main/libsparse/APKBUILD b/main/libsparse/APKBUILD new file mode 100644 index 000000000..c8100b575 --- /dev/null +++ b/main/libsparse/APKBUILD @@ -0,0 +1,29 @@ +pkgname=libsparse +pkgver="1.0.0" +pkgrel=1 +pkgdesc="Android Sparse library" +url="https://android.googlesource.com" +arch="all" +license="APACHE2" +depends="python3" +makedepends="zlib-dev" +subpackages="" +source="$pkgname-$pkgver.tar.gz::https://github.com/anestisb/android-simg2img/archive/${pkgver}.tar.gz" +options="!check" + +build() { + cd "$srcdir"/android-simg2img-"$pkgver" + sed -i -e 's./usr/bin/env python./usr/bin/env python3.' simg_dump.py + make sparse + make +} + +package() { + cd "$srcdir"/android-simg2img-"$pkgver" + + for i in append2simg img2simg simg2img simg2simg simg_dump.py; do + install -D -m755 "$i" "$pkgdir"/usr/bin/"$i" || return 1 + done +} + +sha512sums="e43ad20760243ee88441d3016dea776224373377a5f0d367fca2da8b44f4dcc17c779ad2aed79b2f04861f4e56ec3472c0f2dc5c8fc12dc87f57d608cfc8faf6 libsparse-1.0.0.tar.gz"