diff options
author | Chirayu Desai <chirayudesai1@gmail.com> | 2021-11-26 05:47:25 +0530 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2021-12-09 01:24:49 +0200 |
commit | 4af145c186a1c6a05d430ef1a52a23c6308bf9c7 (patch) | |
tree | 721b24d5482689cb3ea03e794bc4e8c9f64116ce | |
parent | 376460eac24e77dc6a393ceee390e7a910152f48 (diff) |
extract_utils: Support images as a source
* Handles both sparse images as well as filesystem images
* Uses debugfs to extract, no root needed!
* Usecase: Factory images
Change-Id: I3e1bc3834dea108e63ab707a1a89dc2d0743913e
-rw-r--r-- | extract_utils.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/extract_utils.sh b/extract_utils.sh index eaf8f1c..f06d3c6 100644 --- a/extract_utils.sh +++ b/extract_utils.sh @@ -1550,6 +1550,29 @@ function extract() { SRC="$DUMPDIR" fi + if [ -d "$SRC" ] && [ -f "$SRC"/system.img ]; then + DUMPDIR="$TMPDIR"/system_dump + mkdir -p "$DUMPDIR" + + for PARTITION in "system" "odm" "product" "system_ext" "vendor" + do + echo "Extracting "$PARTITION"" + local IMAGE="$SRC"/"$PARTITION".img + if [ -f "$IMAGE" ]; then + if [[ $(file -b "$IMAGE") == Linux* ]]; then + extract_img_data "$IMAGE" "$DUMPDIR"/"$PARTITION" + elif [[ $(file -b "$IMAGE") == Android* ]]; then + simg2img "$IMAGE" "$DUMPDIR"/"$PARTITION".raw + extract_img_data "$DUMPDIR"/"$PARTITION".raw "$DUMPDIR"/"$PARTITION"/ + else + echo "Unsupported "$IMAGE"" + fi + fi + done + + SRC="$DUMPDIR" + fi + if [ "$VENDOR_STATE" -eq "0" ]; then echo "Cleaning output directory ($OUTPUT_ROOT).." rm -rf "${OUTPUT_TMP:?}" |