Support Magisk Manager boot image file patch

This commit is contained in:
topjohnwu 2017-08-31 03:08:09 +08:00
parent 189c671ce2
commit f63af0601c
3 changed files with 21 additions and 15 deletions

View File

@ -553,18 +553,17 @@ void post_fs_data(int client) {
char *bin_path = NULL;
if (access("/cache/data_bin", F_OK) == 0)
bin_path = "/cache/data_bin";
else if (access("/data/local/tmp/magisk_inject", F_OK) == 0)
bin_path = "/data/local/tmp/magisk_inject";
else if (access("/data/data/com.topjohnwu.magisk/install", F_OK) == 0)
bin_path = "/data/data/com.topjohnwu.magisk/install";
if (bin_path) {
exec_command_sync("rm", "-rf", DATABIN, NULL);
exec_command_sync("cp", "-r", bin_path, DATABIN, NULL);
exec_command_sync("rm", "-rf", bin_path, NULL);
exec_command_sync("chmod", "-R", "755", bin_path, NULL);
// Lazy.... use shell blob to match files
exec_command_sync("sh", "-c", "mv /data/magisk/stock_boot* /data", NULL);
}
// Lazy.... use shell blob to match files
exec_command_sync("sh", "-c", "mv /data/magisk/stock_boot* /data", NULL);
// Link busybox
mount_mirrors();
link_busybox();

View File

@ -49,12 +49,15 @@ abort_wrap() {
# Pure bash dirname implementation
dirname_wrap() {
if echo $1 | grep "/" >/dev/null 2>&1; then
RES=${1%/*}
[ -z $RES ] && echo "/" || echo $RES
else
echo "."
fi
case "$1" in
*/*)
dir=${1%/*}
[ -z $dir ] && echo "/" || echo $dir
;;
*)
echo "."
;;
esac
}
# Pure bash basename implementation
@ -93,10 +96,8 @@ cpio_mkdir() {
[ -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"
[ -e "$BOOTIMAGE" ] || abort_wrap "$BOOTIMAGE does not exist!"

View File

@ -1,6 +1,12 @@
# EX_ARM, EX_X86, BB_ARM, and BB_X86 should be generated in build.py
dirname_wrap() {
case "$1" in
*/*) dir=${1%/*}; [ -z $dir ] && echo "/" || echo $dir ;;
*) echo "." ;;
esac
}
[ "$1" = "indep" ] && INDEP=true || INDEP=false
$INDEP && TMPDIR=/data/local/tmp || TMPDIR=/dev/tmp
$INDEP && TMPDIR="`cd "\`dirname_wrap "${BASH_SOURCE:-$0}"\`" && pwd`" || TMPDIR=/dev/tmp
INSTALLER=$TMPDIR/install; BBDIR=$TMPDIR/bin
EXBIN=$BBDIR/b64xz; BBBIN=$BBDIR/busybox
$INDEP || rm -rf $TMPDIR 2>/dev/null;
@ -17,7 +23,7 @@ $BBBIN --install -s $TMPDIR/bin
export PATH=$BBDIR:$PATH
if $INDEP; then
shift
exec sh $@
exec sh "$@"
else
mkdir -p $INSTALLER
unzip -o "$3" -d $INSTALLER