Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
db9a4b31
Commit
db9a4b31
authored
Mar 09, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts to use BusyBox standalone mode
parent
409cb06e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
58 deletions
+59
-58
addon.d.sh
scripts/addon.d.sh
+5
-6
flash_script.sh
scripts/flash_script.sh
+14
-17
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+7
-9
update_binary.sh
scripts/update_binary.sh
+9
-11
util_functions.sh
scripts/util_functions.sh
+24
-15
No files found.
scripts/addon.d.sh
View file @
db9a4b31
...
...
@@ -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
...
...
scripts/flash_script.sh
View file @
db9a4b31
#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
$BB
DIR
/busybox
$MAGISKBIN
cp
-af
$BINDIR
/.
$COMMONDIR
/.
$CHROMEDIR
$BB
BIN
$MAGISKBIN
chmod
-R
755
$MAGISKBIN
# addon.d
...
...
@@ -86,9 +83,9 @@ fi
$BOOTMODE
||
recovery_actions
############################################
##############################################
############################################
# Boot/DTBO Patching
############################################
##############################################
############################################
install_magisk
...
...
scripts/magisk_uninstaller.sh
View file @
db9a4b31
#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
...
...
scripts/update_binary.sh
View file @
db9a4b31
...
...
@@ -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
scripts/util_functions.sh
View file @
db9a4b31
...
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment