mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Update scripts to use BusyBox standalone mode
This commit is contained in:
parent
409cb06ea0
commit
db9a4b31f9
@ -56,10 +56,9 @@ initialize() {
|
||||
if $BOOTMODE; then
|
||||
# Override ui_print when booted
|
||||
ui_print() { log -t Magisk -- "$1"; }
|
||||
else
|
||||
OUTFD=
|
||||
setup_flashable
|
||||
fi
|
||||
OUTFD=
|
||||
setup_flashable
|
||||
}
|
||||
|
||||
main() {
|
||||
@ -73,9 +72,9 @@ main() {
|
||||
|
||||
$BOOTMODE || recovery_actions
|
||||
|
||||
ui_print "************************"
|
||||
ui_print "* Magisk v$MAGISK_VER addon.d"
|
||||
ui_print "************************"
|
||||
PRETTY_VER=$MAGISK_VER
|
||||
echo $PRETTY_VER | grep -q '\.' && PRETTY_VER=v$PRETTY_VER
|
||||
print_title "Magisk $PRETTY_VER addon.d"
|
||||
|
||||
mount_partitions
|
||||
check_data
|
||||
|
@ -1,17 +1,14 @@
|
||||
#MAGISK
|
||||
##########################################################################################
|
||||
############################################
|
||||
#
|
||||
# Magisk Flash Script (updater-script)
|
||||
# by topjohnwu
|
||||
#
|
||||
# This script will detect, construct the environment for Magisk
|
||||
# It will then call boot_patch.sh to patch the boot image
|
||||
#
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Preparation
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
COMMONDIR=$INSTALLER/common
|
||||
APK=$COMMONDIR/magisk.apk
|
||||
@ -33,13 +30,13 @@ fi
|
||||
|
||||
setup_flashable
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Detection
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
ui_print "************************"
|
||||
ui_print "* Magisk v$MAGISK_VER Installer"
|
||||
ui_print "************************"
|
||||
PRETTY_VER=$MAGISK_VER
|
||||
echo $PRETTY_VER | grep -q '\.' && PRETTY_VER=v$PRETTY_VER
|
||||
print_title "Magisk $PRETTY_VER Installer"
|
||||
|
||||
is_mounted /data || mount /data || is_mounted /cache || mount /cache
|
||||
mount_partitions
|
||||
@ -63,16 +60,16 @@ chmod -R 755 $CHROMEDIR $BINDIR
|
||||
# Check if system root is installed and remove
|
||||
remove_system_su
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Environment
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
ui_print "- Constructing environment"
|
||||
|
||||
# Copy required files
|
||||
rm -rf $MAGISKBIN/* 2>/dev/null
|
||||
mkdir -p $MAGISKBIN 2>/dev/null
|
||||
cp -af $BINDIR/. $COMMONDIR/. $CHROMEDIR $BBDIR/busybox $MAGISKBIN
|
||||
cp -af $BINDIR/. $COMMONDIR/. $CHROMEDIR $BBBIN $MAGISKBIN
|
||||
chmod -R 755 $MAGISKBIN
|
||||
|
||||
# addon.d
|
||||
@ -86,9 +83,9 @@ fi
|
||||
|
||||
$BOOTMODE || recovery_actions
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Boot/DTBO Patching
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
install_magisk
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
#MAGISK
|
||||
##########################################################################################
|
||||
############################################
|
||||
#
|
||||
# Magisk Uninstaller
|
||||
# by topjohnwu
|
||||
#
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Preparation
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
# This path should work in any cases
|
||||
TMPDIR=/dev/tmp
|
||||
@ -33,9 +33,7 @@ fi
|
||||
|
||||
setup_flashable
|
||||
|
||||
ui_print "************************"
|
||||
ui_print " Magisk Uninstaller "
|
||||
ui_print "************************"
|
||||
print_title "Magisk Uninstaller"
|
||||
|
||||
is_mounted /data || mount /data || abort "! Unable to mount partitions"
|
||||
is_mounted /cache || mount /cache 2>/dev/null
|
||||
@ -53,9 +51,9 @@ $DATA_DE || abort "! Cannot access /data, please uninstall with Magisk Manager"
|
||||
$BOOTMODE || recovery_actions
|
||||
run_migrations
|
||||
|
||||
##########################################################################################
|
||||
############################################
|
||||
# Uninstall
|
||||
##########################################################################################
|
||||
############################################
|
||||
|
||||
get_flags
|
||||
find_boot_image
|
||||
|
@ -7,32 +7,30 @@ extract_bb() {
|
||||
"$BBBIN" >/dev/null 2>&1 || dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1))
|
||||
}
|
||||
setup_bb() {
|
||||
export BBDIR=$TMPDIR/bin
|
||||
BBBIN=$BBDIR/busybox
|
||||
mkdir -p $BBDIR 2>/dev/null
|
||||
mkdir -p $TMPDIR 2>/dev/null
|
||||
BBBIN=$TMPDIR/busybox
|
||||
extract_bb
|
||||
$BBBIN --install -s $BBDIR
|
||||
export PATH=$BBDIR:$PATH
|
||||
}
|
||||
export BBBIN
|
||||
case "$1" in
|
||||
"extract"|"-x")
|
||||
[ -z "$2" ] && BBBIN=./busybox || BBBIN="$2"
|
||||
extract_bb
|
||||
;;
|
||||
"indep"|"sh")
|
||||
"sh")
|
||||
TMPDIR=.
|
||||
setup_bb
|
||||
shift
|
||||
exec /system/bin/sh "$@"
|
||||
exec ./busybox sh -o standalone "$@"
|
||||
;;
|
||||
*)
|
||||
export TMPDIR=/dev/tmp
|
||||
TMPDIR=/dev/tmp
|
||||
rm -rf $TMPDIR 2>/dev/null
|
||||
setup_bb
|
||||
export INSTALLER=$TMPDIR/install
|
||||
mkdir -p $INSTALLER
|
||||
unzip -o "$3" -d $INSTALLER >&2
|
||||
exec sh $INSTALLER/META-INF/com/google/android/updater-script "$@"
|
||||
$BBBIN mkdir -p $INSTALLER
|
||||
$BBBIN unzip -o "$3" -d $INSTALLER >&2
|
||||
exec $BBBIN sh -o standalone $INSTALLER/META-INF/com/google/android/updater-script "$@"
|
||||
;;
|
||||
esac
|
||||
exit
|
||||
|
@ -56,13 +56,20 @@ resolve_vars() {
|
||||
SERVICED=$NVBASE/service.d
|
||||
}
|
||||
|
||||
print_title() {
|
||||
local len=$(echo -n $1 | wc -c)
|
||||
len=$((len + 2))
|
||||
local pounds=$(printf "%${len}s" | tr ' ' '*')
|
||||
ui_print "$pounds"
|
||||
ui_print " $1 "
|
||||
ui_print "$pounds"
|
||||
}
|
||||
|
||||
######################
|
||||
# Environment Related
|
||||
######################
|
||||
|
||||
setup_flashable() {
|
||||
# Preserve environment varibles
|
||||
OLD_PATH=$PATH
|
||||
ensure_bb
|
||||
$BOOTMODE && return
|
||||
if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then
|
||||
@ -79,18 +86,23 @@ setup_flashable() {
|
||||
}
|
||||
|
||||
ensure_bb() {
|
||||
if [ -x $MAGISKTMP/busybox/busybox ]; then
|
||||
[ -z $BBDIR ] && BBDIR=$MAGISKTMP/busybox
|
||||
elif [ -x $TMPDIR/bin/busybox ]; then
|
||||
[ -z $BBDIR ] && BBDIR=$TMPDIR/bin
|
||||
[ -o standalone ] && return
|
||||
set -o standalone 2>/dev/null && return
|
||||
|
||||
# At this point, we are not running in BusyBox ash
|
||||
# Find our busybox binary
|
||||
local BUSYBOX
|
||||
if [ -f $TMPDIR/busybox ]; then
|
||||
BUSYBOX=$TMPDIR/busybox
|
||||
elif [ -f $MAGISKBIN/busybox ]; then
|
||||
BUSYBOX=$MAGISKBIN/busybox
|
||||
else
|
||||
# Construct the PATH
|
||||
[ -z $BBDIR ] && BBDIR=$TMPDIR/bin
|
||||
mkdir -p $BBDIR
|
||||
ln -s $MAGISKBIN/busybox $BBDIR/busybox
|
||||
$MAGISKBIN/busybox --install -s $BBDIR
|
||||
abort "! Cannot find BusyBox"
|
||||
fi
|
||||
echo $PATH | grep -q "^$BBDIR" || export PATH=$BBDIR:$PATH
|
||||
|
||||
# Re-exec our script
|
||||
chmod 755 $BUSYBOX
|
||||
exec $BUSYBOX sh -o standalone $0 "$@"
|
||||
}
|
||||
|
||||
recovery_actions() {
|
||||
@ -103,9 +115,6 @@ recovery_actions() {
|
||||
unset LD_LIBRARY_PATH
|
||||
unset LD_PRELOAD
|
||||
unset LD_CONFIG_FILE
|
||||
# Force our own busybox path to be in the front
|
||||
# and do not use anything in recovery's sbin
|
||||
export PATH=$BBDIR:/system/bin:/vendor/bin
|
||||
}
|
||||
|
||||
recovery_cleanup() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user