feat: Add script for extracting the boot.img from an OTA update
This commit is contained in:
parent
b49dd02360
commit
082bc175c0
49
src/android/extract-bootimg.sh
Normal file
49
src/android/extract-bootimg.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# I keep forgetting how to extract the boot.img from an Android OTA update
|
||||
# for patching by Magisk.
|
||||
set -e
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--payload-dumper)
|
||||
# Specify the path to the payload_dumper binary
|
||||
PAYLOAD_DUMPER=$2
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--diff)
|
||||
PAYLOAD_DUMPER_EXTRA_ARGS="${PAYLOAD_DUMPER_EXTRA_ARGS} --diff"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# The last argument is the file
|
||||
UPDATE_FILE=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -f "$UPDATE_FILE" ]]; then
|
||||
echo "Android update file $UPDATE_FILE does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
out_dir=./payload-dumper-output
|
||||
if [[ -d "$out_dir" ]]; then
|
||||
echo "Output path $out_dir already exists. Refusing to work!"
|
||||
exit 1
|
||||
fi
|
||||
mkdir "$out_dir"
|
||||
|
||||
# Print some basic info
|
||||
PAYLOAD_DUMPER=${PAYLOAD_DUMPER:-payload_dumper}
|
||||
echo "INFO: payload_dumper: $PAYLOAD_DUMPER"
|
||||
echo
|
||||
|
||||
# Extract only the payload.bin file
|
||||
echo "Extracting payload..."
|
||||
unzip -q -C "$UPDATE_FILE" -d "$out_dir" payload.bin
|
||||
|
||||
# Use payload_dumper to get to the boot.img
|
||||
echo "Dumping data from payload..."
|
||||
${PAYLOAD_DUMPER} ${PAYLOAD_DUMPER_EXTRA_ARGS} --out "$out_dir" "${out_dir}/payload.bin"
|
Loading…
Reference in New Issue
Block a user