Proper magisk manual injection support

This commit is contained in:
topjohnwu 2017-08-17 03:46:01 +08:00
parent 2a22fa694e
commit 9522255e3a
2 changed files with 17 additions and 10 deletions

View File

@ -91,15 +91,14 @@ cpio_mkdir() {
# Initialization
##########################################################################################
[ -z $1 ] && abort_wrap "This script requires a boot image as a parameter"
CWD=`pwd`
cd "`dirname_wrap $1`"
BOOTIMAGE="`pwd`/`basename_wrap $1`"
cd "$CWD"
if [ -z "$BOOTIMAGE" ]; then
ui_print_wrap "This script requires a boot image as a parameter"
exit 1
fi
[ -e "$BOOTIMAGE" ] || abort_wrap "$BOOTIMAGE does not exist!"
# Presets
[ -z $KEEPVERITY ] && KEEPVERITY=false
@ -115,11 +114,11 @@ chmod +x ./*
##########################################################################################
# Unpack
##########################################################################################
CHROMEOS=false
ui_print_wrap "- Unpacking boot image"
./magiskboot --unpack "$BOOTIMAGE"
CHROMEOS=false
case $? in
1 )
abort_wrap "! Unable to unpack boot image"

View File

@ -1,7 +1,10 @@
# EX_ARM, EX_X86, BB_ARM, and BB_X86 should be generated in build.py
TMPDIR=/dev/tmp; INSTALLER=$TMPDIR/install; BBDIR=$TMPDIR/bin
[ "$1" = "indep" ] && INDEP=true || INDEP=false
$INDEP && TMPDIR=/data/local/tmp || TMPDIR=/dev/tmp
INSTALLER=$TMPDIR/install; BBDIR=$TMPDIR/bin
EXBIN=$BBDIR/b64xz; BBBIN=$BBDIR/busybox
rm -rf $TMPDIR 2>/dev/null; mkdir -p $BBDIR
$INDEP || rm -rf $TMPDIR 2>/dev/null;
mkdir -p $BBDIR 2>/dev/null
touch $EXBIN $BBBIN; chmod 755 $EXBIN $BBBIN
echo -ne $EX_ARM > $EXBIN
if $EXBIN --test 2>/dev/null; then
@ -12,6 +15,11 @@ else
fi
$BBBIN --install -s $TMPDIR/bin
export PATH=$BBDIR:$PATH
mkdir -p $INSTALLER
unzip -o "$3" -d $INSTALLER
exec sh $INSTALLER/META-INF/com/google/android/updater-script $@
if $INDEP; then
shift
exec sh $@
else
mkdir -p $INSTALLER
unzip -o "$3" -d $INSTALLER
exec sh $INSTALLER/META-INF/com/google/android/updater-script $@
fi