#!/usr/bin/env sh # extract zip dumpdir="$(pwd)/dump_$(date +%m%d%y)" mkdir -pv "${dumpdir}" unzip -j "$1" "payload.bin" -d "${dumpdir}" payload-dumper-go "${dumpdir}/payload.bin" -o "${dumpdir}" PARTITIONS="system systemex system_ext system_other vendor cust odm odm_ext oem factory product modem xrom oppo_product opproduct reserve india my_preload my_odm my_stock my_operator my_country my_product my_company my_engineering my_heytap my_custom my_manifest my_carrier my_region my_bigball my_version special_preload vendor_dlkm odm_dlkm" for p in $PARTITIONS; do if [[ -e "$p.img" ]]; then mkdir "$p" 2> /dev/null || rm -rf "${p:?}"/* echo "Extracting $p partition" 7z x "$p".img -y -o"$p"/ > /dev/null 2>&1 if [ $? -eq 0 ]; then rm "$p".img > /dev/null 2>&1 else #handling erofs images, which can't be handled by 7z if [ -f $p.img ] && [ $p != "modem" ]; then echo "Couldn't extract $p partition by 7z. Using fsck.erofs." rm -rf "${p}"/* fsck.erofs --extract="$p" "$p".img if [ $? -eq 0 ]; then rm -fv "$p".img > /dev/null 2>&1 else echo "Couldn't extract $p partition by fsck.erofs. Using mount loop" sudo mount -o loop -t auto "$p".img "$p" mkdir "${p}_" sudo cp -rf "${p}/"* "${p}_" sudo umount "${p}" sudo cp -rf "${p}_/"* "${p}" sudo rm -rf "${p}_" if [ $? -eq 0 ]; then rm -fv "$p".img > /dev/null 2>&1 else echo "Couldn't extract $p partition. It might use an unsupported filesystem." echo "For EROFS: make sure you're using Linux 5.4+ kernel." echo "For F2FS: make sure you're using Linux 5.15+ kernel." fi fi fi fi fi done # Fix permissions sudo chown "$(whoami)" "$DUMPDIR"/./* -fR sudo chmod -fR u+rwX "$DUMPDIR"/./*