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
Show 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() {
...
@@ -56,10 +56,9 @@ initialize() {
if
$BOOTMODE
;
then
if
$BOOTMODE
;
then
# Override ui_print when booted
# Override ui_print when booted
ui_print
()
{
log
-t
Magisk
--
"
$1
"
;
}
ui_print
()
{
log
-t
Magisk
--
"
$1
"
;
}
else
fi
OUTFD
=
OUTFD
=
setup_flashable
setup_flashable
fi
}
}
main
()
{
main
()
{
...
@@ -73,9 +72,9 @@ main() {
...
@@ -73,9 +72,9 @@ main() {
$BOOTMODE
||
recovery_actions
$BOOTMODE
||
recovery_actions
ui_print
"************************"
PRETTY_VER
=
$MAGISK_VER
ui_print
"* Magisk v
$MAGISK_VER
addon.d"
echo
$PRETTY_VER
|
grep
-q
'\.'
&&
PRETTY_VER
=
v
$PRETTY_VER
ui_print
"************************
"
print_title
"Magisk
$PRETTY_VER
addon.d
"
mount_partitions
mount_partitions
check_data
check_data
...
...
scripts/flash_script.sh
View file @
db9a4b31
#MAGISK
#MAGISK
############################################
##############################################
############################################
#
#
# Magisk Flash Script (updater-script)
# Magisk Flash Script (updater-script)
# by topjohnwu
# by topjohnwu
#
#
# This script will detect, construct the environment for Magisk
############################################
# It will then call boot_patch.sh to patch the boot image
#
##########################################################################################
############################################
##############################################
############################################
# Preparation
# Preparation
############################################
##############################################
############################################
COMMONDIR
=
$INSTALLER
/common
COMMONDIR
=
$INSTALLER
/common
APK
=
$COMMONDIR
/magisk.apk
APK
=
$COMMONDIR
/magisk.apk
...
@@ -33,13 +30,13 @@ fi
...
@@ -33,13 +30,13 @@ fi
setup_flashable
setup_flashable
############################################
##############################################
############################################
# Detection
# Detection
############################################
##############################################
############################################
ui_print
"************************"
PRETTY_VER
=
$MAGISK_VER
ui_print
"* Magisk v
$MAGISK_VER
Installer"
echo
$PRETTY_VER
|
grep
-q
'\.'
&&
PRETTY_VER
=
v
$PRETTY_VER
ui_print
"************************
"
print_title
"Magisk
$PRETTY_VER
Installer
"
is_mounted /data
||
mount /data
||
is_mounted /cache
||
mount /cache
is_mounted /data
||
mount /data
||
is_mounted /cache
||
mount /cache
mount_partitions
mount_partitions
...
@@ -63,16 +60,16 @@ chmod -R 755 $CHROMEDIR $BINDIR
...
@@ -63,16 +60,16 @@ chmod -R 755 $CHROMEDIR $BINDIR
# Check if system root is installed and remove
# Check if system root is installed and remove
remove_system_su
remove_system_su
############################################
##############################################
############################################
# Environment
# Environment
############################################
##############################################
############################################
ui_print
"- Constructing environment"
ui_print
"- Constructing environment"
# Copy required files
# Copy required files
rm
-rf
$MAGISKBIN
/
*
2>/dev/null
rm
-rf
$MAGISKBIN
/
*
2>/dev/null
mkdir
-p
$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
chmod
-R
755
$MAGISKBIN
# addon.d
# addon.d
...
@@ -86,9 +83,9 @@ fi
...
@@ -86,9 +83,9 @@ fi
$BOOTMODE
||
recovery_actions
$BOOTMODE
||
recovery_actions
############################################
##############################################
############################################
# Boot/DTBO Patching
# Boot/DTBO Patching
############################################
##############################################
############################################
install_magisk
install_magisk
...
...
scripts/magisk_uninstaller.sh
View file @
db9a4b31
#MAGISK
#MAGISK
############################################
##############################################
############################################
#
#
# Magisk Uninstaller
# Magisk Uninstaller
# by topjohnwu
# by topjohnwu
#
#
############################################
##############################################
############################################
############################################
##############################################
############################################
# Preparation
# Preparation
############################################
##############################################
############################################
# This path should work in any cases
# This path should work in any cases
TMPDIR
=
/dev/tmp
TMPDIR
=
/dev/tmp
...
@@ -33,9 +33,7 @@ fi
...
@@ -33,9 +33,7 @@ fi
setup_flashable
setup_flashable
ui_print
"************************"
print_title
"Magisk Uninstaller"
ui_print
" Magisk Uninstaller "
ui_print
"************************"
is_mounted /data
||
mount /data
||
abort
"! Unable to mount partitions"
is_mounted /data
||
mount /data
||
abort
"! Unable to mount partitions"
is_mounted /cache
||
mount /cache 2>/dev/null
is_mounted /cache
||
mount /cache 2>/dev/null
...
@@ -53,9 +51,9 @@ $DATA_DE || abort "! Cannot access /data, please uninstall with Magisk Manager"
...
@@ -53,9 +51,9 @@ $DATA_DE || abort "! Cannot access /data, please uninstall with Magisk Manager"
$BOOTMODE
||
recovery_actions
$BOOTMODE
||
recovery_actions
run_migrations
run_migrations
############################################
##############################################
############################################
# Uninstall
# Uninstall
############################################
##############################################
############################################
get_flags
get_flags
find_boot_image
find_boot_image
...
...
scripts/update_binary.sh
View file @
db9a4b31
...
@@ -7,32 +7,30 @@ extract_bb() {
...
@@ -7,32 +7,30 @@ extract_bb() {
"
$BBBIN
"
>
/dev/null 2>&1
||
dd
if
=
"
$0
"
of
=
"
$BBBIN
"
bs
=
1024
skip
=
$((
$X86_CNT
+
1
))
"
$BBBIN
"
>
/dev/null 2>&1
||
dd
if
=
"
$0
"
of
=
"
$BBBIN
"
bs
=
1024
skip
=
$((
$X86_CNT
+
1
))
}
}
setup_bb
()
{
setup_bb
()
{
export
BBDIR
=
$TMPDIR
/bin
mkdir
-p
$TMPDIR
2>/dev/null
BBBIN
=
$BBDIR
/busybox
BBBIN
=
$TMPDIR
/busybox
mkdir
-p
$BBDIR
2>/dev/null
extract_bb
extract_bb
$BBBIN
--install
-s
$BBDIR
export
PATH
=
$BBDIR
:
$PATH
}
}
export
BBBIN
case
"
$1
"
in
case
"
$1
"
in
"extract"
|
"-x"
)
"extract"
|
"-x"
)
[
-z
"
$2
"
]
&&
BBBIN
=
./busybox
||
BBBIN
=
"
$2
"
[
-z
"
$2
"
]
&&
BBBIN
=
./busybox
||
BBBIN
=
"
$2
"
extract_bb
extract_bb
;;
;;
"
indep"
|
"
sh"
)
"sh"
)
TMPDIR
=
.
TMPDIR
=
.
setup_bb
setup_bb
shift
shift
exec
/system/bin/sh
"
$@
"
exec
./busybox sh
-o
standalone
"
$@
"
;;
;;
*
)
*
)
export
TMPDIR
=
/dev/tmp
TMPDIR
=
/dev/tmp
rm
-rf
$TMPDIR
2>/dev/null
rm
-rf
$TMPDIR
2>/dev/null
setup_bb
setup_bb
export
INSTALLER
=
$TMPDIR
/install
export
INSTALLER
=
$TMPDIR
/install
mkdir
-p
$INSTALLER
$BBBIN
mkdir
-p
$INSTALLER
unzip
-o
"
$3
"
-d
$INSTALLER
>
&2
$BBBIN
unzip
-o
"
$3
"
-d
$INSTALLER
>
&2
exec
sh
$INSTALLER
/META-INF/com/google/android/updater-script
"
$@
"
exec
$BBBIN
sh
-o
standalone
$INSTALLER
/META-INF/com/google/android/updater-script
"
$@
"
;;
;;
esac
esac
exit
exit
scripts/util_functions.sh
View file @
db9a4b31
...
@@ -56,13 +56,20 @@ resolve_vars() {
...
@@ -56,13 +56,20 @@ resolve_vars() {
SERVICED
=
$NVBASE
/service.d
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
# Environment Related
######################
######################
setup_flashable
()
{
setup_flashable
()
{
# Preserve environment varibles
OLD_PATH
=
$PATH
ensure_bb
ensure_bb
$BOOTMODE
&&
return
$BOOTMODE
&&
return
if
[
-z
$OUTFD
]
||
readlink
/proc/
$$
/fd/
$OUTFD
|
grep
-q
/tmp
;
then
if
[
-z
$OUTFD
]
||
readlink
/proc/
$$
/fd/
$OUTFD
|
grep
-q
/tmp
;
then
...
@@ -79,18 +86,23 @@ setup_flashable() {
...
@@ -79,18 +86,23 @@ setup_flashable() {
}
}
ensure_bb
()
{
ensure_bb
()
{
if
[
-x
$MAGISKTMP
/busybox/busybox
]
;
then
[
-o
standalone
]
&&
return
[
-z
$BBDIR
]
&&
BBDIR
=
$MAGISKTMP
/busybox
set
-o
standalone 2>/dev/null
&&
return
elif
[
-x
$TMPDIR
/bin/busybox
]
;
then
[
-z
$BBDIR
]
&&
BBDIR
=
$TMPDIR
/bin
# 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
else
# Construct the PATH
abort
"! Cannot find BusyBox"
[
-z
$BBDIR
]
&&
BBDIR
=
$TMPDIR
/bin
mkdir
-p
$BBDIR
ln
-s
$MAGISKBIN
/busybox
$BBDIR
/busybox
$MAGISKBIN
/busybox
--install
-s
$BBDIR
fi
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
()
{
recovery_actions
()
{
...
@@ -103,9 +115,6 @@ recovery_actions() {
...
@@ -103,9 +115,6 @@ recovery_actions() {
unset
LD_LIBRARY_PATH
unset
LD_LIBRARY_PATH
unset
LD_PRELOAD
unset
LD_PRELOAD
unset
LD_CONFIG_FILE
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
()
{
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