Created
July 30, 2021 19:31
-
-
Save z3ntu/3b5d21163711d7e309af0a5952bc1189 to your computer and use it in GitHub Desktop.
repack boot.img unpacked with unpackbootimg -- https://github.com/osm0sis/mkbootimg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
prefix="$1" | |
shift | |
if [ -z "$prefix" ]; then | |
echo "ERROR: provide prefix!" | |
exit 1 | |
fi | |
files=$(grep "write_.*_to_file" unpackbootimg.c | grep -v "void write_" | sed 's/.*write_\(\w\+\)_to_file("\(\w\+\)",.*/\1 \2/' | sort | uniq) | |
cmd="mkbootimg" | |
while IFS= read -r line; do | |
arr=($line) | |
argtype=${arr[0]} | |
filename=${arr[1]} | |
if [ ! -f $prefix$filename ]; then | |
continue | |
fi | |
if [ "$argtype" == "string" ]; then | |
cmd="$cmd --$filename \"$(cat $prefix$filename)\"" | |
elif [ "$argtype" == "buffer" ]; then | |
cmd="$cmd --$filename $prefix$filename" | |
else | |
echo "ERROR: Unknown argtype $argtype!" | |
exit 1 | |
fi | |
done <<< "$files" | |
cmd="$cmd $@" | |
eval $cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment