extract_utils: Support extracting from super.img
Change-Id: I2a30da25f2d55df1080b1795e08a14195c1e3ec0
diff --git a/extract_utils.sh b/extract_utils.sh
index 45afe2e..34eb8c3 100644
--- a/extract_utils.sh
+++ b/extract_utils.sh
@@ -97,6 +97,7 @@
export BINARIES_LOCATION="$ANDROID_ROOT"/prebuilts/extract-tools/${HOST}-x86/bin
export SIMG2IMG="$BINARIES_LOCATION"/simg2img
+ export LPUNPACK="$BINARIES_LOCATION"/lpunpack
for version in 0_8 0_9; do
export PATCHELF_${version}="$BINARIES_LOCATION"/patchelf-"${version}"
@@ -1415,6 +1416,26 @@
SRC="$DUMPDIR"
fi
+ if [ -d "$SRC" ] && [ -f "$SRC"/super.img ]; then
+ DUMPDIR="$TMPDIR"/super_dump
+ mkdir -p "$DUMPDIR"
+
+ echo "Unpacking super.img"
+ "$SIMG2IMG" "$SRC"/super.img "$DUMPDIR"/super.raw
+
+ for PARTITION in "system" "odm" "product" "system_ext" "vendor"
+ do
+ echo "Preparing "$PARTITION""
+ if "$LPUNPACK" -p "$PARTITION"_a "$DUMPDIR"/super.raw "$DUMPDIR" ; then
+ mv "$DUMPDIR"/"$PARTITION"_a.img "$DUMPDIR"/"$PARTITION".img
+ else
+ "$LPUNPACK" -p "$PARTITION" "$DUMPDIR"/super.raw "$DUMPDIR"
+ fi
+ done
+
+ SRC="$DUMPDIR"
+ fi
+
if [ -d "$SRC" ] && [ -f "$SRC"/system.img ]; then
DUMPDIR="$TMPDIR"/system_dump
mkdir -p "$DUMPDIR"