phoenix_firmware_dumper: Generate TWRP Tree if possible.

This commit is contained in:
Box In a Box 2022-04-30 00:53:08 +05:30
parent df550b8829
commit d0323f36c6

View File

@ -89,6 +89,13 @@ for tool_slug in "${EXTERNAL_TOOLS[@]}"; do
fi
done
# Clone SebaUbuntu's TWRP Tree Generator.
if [[ -d "$PROJECT_DIR/TWRP-device-tree-generator" ]]; then
git -C "$PROJECT_DIR"/TWRP-device-tree-generator pull --recurse-submodules
else
git clone -q https://github.com/SebaUbuntu/TWRP-device-tree-generator "$PROJECT_DIR/TWRP-device-tree-generator"
fi
# Always Use update_metadata_pb2.py from Android's update_engine Git Repository
curl -sL https://android.googlesource.com/platform/system/update_engine/+/refs/heads/master/scripts/update_payload/update_metadata_pb2.py?format=TEXT | base64 --decode > "${UTILSDIR}"/ota_payload_extractor/update_metadata_pb2.py
@ -1000,6 +1007,23 @@ printf "## %s\n- Manufacturer: %s\n- Platform: %s\n- Codename: %s\n- Brand: %s\n
printf "\n\n>Dumped by [Phoenix Firmware Dumper](https://github.com/DroidDumps/phoenix_firmware_dumper)\n" >> "${OUTDIR}"/README.md
cat "${OUTDIR}"/README.md
# create TWRP device tree if possible
cd "$PROJECT_DIR"/TWRP-device-tree-generator
pip3 install .
if [[ "$is_ab" = true ]]; then
twrpimg=boot.img
else
twrpimg=recovery.img
fi
if [[ -f "${OUTDIR}"/"${twrpimg}" ]]; then
python3 -m twrpdtgen "${OUTDIR}"/"${twrpimg}"
if [[ "$?" = 0 ]]; then
mkdir -p "${OUTDIR}"/twrp-device-tree
mv "$PROJECT_DIR"/TWRP-device-tree-generator/working/* "${OUTDIR}"/twrp-device-tree
[[ ! -e "$OUTDIR"/twrp-device-tree/README.md ]] && curl https://raw.githubusercontent.com/wiki/SebaUbuntu/TWRP-device-tree-generator/4.-Build-TWRP-from-source.md > "$OUTDIR"/twrp-device-tree/README.md
fi
fi
cd "${OUTDIR}"/ || exit
# copy file names
chown "$(whoami)" ./* -R