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
defbbdfe
Commit
defbbdfe
authored
Feb 24, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts
parent
0f464934
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
87 deletions
+74
-87
MagiskInstaller.java
...main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
+2
-2
RootUtils.java
...e/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java
+1
-1
utils.sh
app-core/src/main/res/raw/utils.sh
+13
-19
build.py
build.py
+3
-4
addon.d.sh
scripts/addon.d.sh
+2
-6
flash_script.sh
scripts/flash_script.sh
+1
-3
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+3
-7
update_binary.sh
scripts/update_binary.sh
+4
-2
util_functions.sh
scripts/util_functions.sh
+45
-43
No files found.
app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
View file @
defbbdfe
...
...
@@ -215,7 +215,7 @@ public abstract class MagiskInstaller {
// Patch boot image
if
(!
Shell
.
sh
(
Utils
.
fmt
(
"cd %s; KEEPFORCEENCRYPT=%b KEEPVERITY=%b "
+
"sh update-binary
indep
boot_patch.sh %s"
,
"sh update-binary
sh
boot_patch.sh %s"
,
installDir
,
Config
.
keepEnc
,
Config
.
keepVerity
,
srcBoot
))
.
to
(
console
,
logs
).
exec
().
isSuccess
())
return
false
;
...
...
@@ -245,7 +245,7 @@ public abstract class MagiskInstaller {
.
to
(
console
,
logs
).
exec
().
isSuccess
())
return
false
;
if
(!
Config
.
keepVerity
)
Shell
.
su
(
"
find_dtbo_image"
,
"
patch_dtbo_image"
).
to
(
console
,
logs
).
exec
();
Shell
.
su
(
"patch_dtbo_image"
).
to
(
console
,
logs
).
exec
();
return
true
;
}
...
...
app-core/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java
View file @
defbbdfe
...
...
@@ -16,7 +16,7 @@ import androidx.annotation.NonNull;
public
class
RootUtils
extends
Shell
.
Initializer
{
public
static
void
rmAndLaunch
(
String
rm
,
String
launch
)
{
Shell
.
su
(
Utils
.
fmt
(
"(rm_launch %
d %s %s)&"
,
Const
.
USER_ID
,
rm
,
launch
)).
exec
();
Shell
.
su
(
Utils
.
fmt
(
"(rm_launch %
s %s)&"
,
rm
,
launch
)).
exec
();
}
@Override
...
...
app-core/src/main/res/raw/utils.sh
View file @
defbbdfe
env_check
()
{
for
file
in
busybox magisk magiskboot magiskinit util_functions.sh boot_patch.sh
;
do
[
-f
/data/adb/magisk
/
$file
]
||
return
1
[
-f
$MAGISKBIN
/
$file
]
||
return
1
done
return
0
}
fix_env
()
{
cd
/data/adb/magisk
cd
$MAGISKBIN
local
OLDPATH
=
"
$PATH
"
PATH
=
/sbin:/system/bin:/vendor/bin
sh update-binary
extract
sh update-binary
-x
PATH
=
"
$OLDPATH
"
./busybox
rm
-f
/sbin/.magisk
/busybox/
*
/sbin/.magisk/mirror/bin/busybox
--install
-s
/sbin/.magisk
/busybox
./busybox
rm
-f
$MAGISKTMP
/busybox/
*
$MAGISKTMP
/mirror/bin/busybox
--install
-s
$MAGISKTMP
/busybox
rm
-f
update-binary magisk.apk
cd
/
}
...
...
@@ -31,11 +31,11 @@ run_migrations() {
}
direct_install
()
{
rm
-rf
/data/adb/magisk
/
*
2>/dev/null
mkdir
-p
/data/adb/magisk
2>/dev/null
chmod
700
/data/adb
cp
-
rf
$1
/
*
/data/adb/magisk
rm
-
rf
/data/adb/magisk
/new-boot.img
rm
-rf
$MAGISKBIN
/
*
2>/dev/null
mkdir
-p
$MAGISKBIN
2>/dev/null
chmod
700
$NVBASE
cp
-
af
$1
/.
$MAGISKBIN
rm
-
f
$MAGISKBIN
/new-boot.img
echo
"- Flashing new boot image"
flash_image
$1
/new-boot.img
$2
if
[
$?
-ne
0
]
;
then
...
...
@@ -47,12 +47,7 @@ direct_install() {
}
mm_patch_dtbo
()
{
if
$KEEPVERITY
;
then
return
1
else
find_dtbo_image
patch_dtbo_image
fi
$KEEPVERITY
&&
return
1
||
patch_dtbo_image
}
restore_imgs
()
{
...
...
@@ -114,8 +109,7 @@ EOF
}
rm_launch
()
{
db_clean
$1
pm uninstall
$2
am start
-n
${
3
}
/a.c
pm uninstall
$1
am start
-n
${
2
}
/a.c
exit
}
build.py
View file @
defbbdfe
...
...
@@ -374,9 +374,8 @@ def zip_uninstaller(args):
# Binaries
for
lib_dir
,
zip_dir
in
[(
'armeabi-v7a'
,
'arm'
),
(
'x86'
,
'x86'
)]:
for
bin
in
[
'magisk'
,
'magiskboot'
]:
source
=
os
.
path
.
join
(
'native'
,
'out'
,
lib_dir
,
bin
)
target
=
os
.
path
.
join
(
zip_dir
,
bin
)
source
=
os
.
path
.
join
(
'native'
,
'out'
,
lib_dir
,
'magiskboot'
)
target
=
os
.
path
.
join
(
zip_dir
,
'magiskboot'
)
zip_with_msg
(
zipf
,
source
,
target
)
# Scripts
...
...
scripts/addon.d.sh
View file @
defbbdfe
...
...
@@ -33,8 +33,6 @@ initialize() {
# Load utility functions
.
$MAGISKBIN
/util_functions.sh
find_manager_apk
}
show_logo
()
{
...
...
@@ -44,6 +42,7 @@ show_logo() {
}
installation
()
{
find_manager_apk
find_boot_image
find_dtbo_image
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect target image"
...
...
@@ -98,7 +97,6 @@ main_v1() {
}
main_v2
()
{
boot_actions
show_logo
mount_partitions
# Swap the slot
...
...
@@ -137,9 +135,7 @@ case "$1" in
addond-v2
)
initialize
# Override ui_print
ui_print
()
{
log
-t
Magisk
--
"
$1
"
}
ui_print
()
{
log
-t
Magisk
--
"
$1
"
;
}
# addon.d-v2
main_v2
;;
...
...
scripts/flash_script.sh
View file @
defbbdfe
...
...
@@ -45,14 +45,12 @@ is_mounted /data || mount /data || is_mounted /cache || mount /cache || abort "!
mount_partitions
find_boot_image
find_dtbo_image
check_data
get_flags
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect target image"
ui_print
"- Target image:
$BOOTIMAGE
"
[
-z
$DTBOIMAGE
]
||
ui_print
"- DTBO image:
$DTBOIMAGE
"
# Detect version and architecture
api_level_arch_detect
...
...
@@ -76,7 +74,7 @@ ui_print "- Constructing environment"
# Copy required files
rm
-rf
$MAGISKBIN
/
*
2>/dev/null
mkdir
-p
$MAGISKBIN
2>/dev/null
cp
-af
$BINDIR
/.
$COMMONDIR
/.
$CHROMEDIR
$
TMPDIR
/bin
/busybox
$MAGISKBIN
cp
-af
$BINDIR
/.
$COMMONDIR
/.
$CHROMEDIR
$
BBDIR
/busybox
$MAGISKBIN
chmod
-R
755
$MAGISKBIN
# addon.d
...
...
scripts/magisk_uninstaller.sh
View file @
defbbdfe
...
...
@@ -59,7 +59,7 @@ find_boot_image
find_dtbo_image
[
-e
$BOOTIMAGE
]
||
abort
"! Unable to detect boot image"
ui_print
"- Found
boot/ramdisk
image:
$BOOTIMAGE
"
ui_print
"- Found
target
image:
$BOOTIMAGE
"
[
-z
$DTBOIMAGE
]
||
ui_print
"- Found dtbo image:
$DTBOIMAGE
"
cd
$MAGISKBIN
...
...
@@ -125,18 +125,14 @@ esac
ui_print
"- Removing Magisk files"
rm
-rf
/cache/
*
magisk
*
/cache/unblock /data/
*
magisk
*
/data/cache/
*
magisk
*
/data/property/
*
magisk
*
\
/data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh /data/adb/
*
magisk
*
2>/dev/null
/data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh /data/adb/
*
magisk
*
\
/data/adb/post-fs-data.d /data/adb/service.d /data/adb/modules
*
2>/dev/null
if
[
-f
/system/addon.d/99-magisk.sh
]
;
then
mount
-o
rw,remount /system
rm
-f
/system/addon.d/99-magisk.sh
fi
# Remove persist props (for Android P+ using protobuf)
for
prop
in
`
./magisk resetprop
-p
|
grep
-E
'persist.*magisk'
|
grep
-oE
'^\[[a-zA-Z0-9.@:_-]+\]'
|
tr
-d
'[]'
`
;
do
./magisk resetprop
-p
--delete
$prop
done
cd
/
if
$BOOTMODE
;
then
...
...
scripts/update_binary.sh
View file @
defbbdfe
...
...
@@ -7,7 +7,7 @@ extract_bb() {
"
$BBBIN
"
>
/dev/null
||
dd
if
=
"
$0
"
of
=
"
$BBBIN
"
bs
=
1024
skip
=
1
count
=
$X86_CNT
}
setup_bb
()
{
BBDIR
=
$TMPDIR
/bin
export
BBDIR
=
$TMPDIR
/bin
BBBIN
=
$BBDIR
/busybox
mkdir
-p
$BBDIR
2>/dev/null
extract_bb
...
...
@@ -20,7 +20,9 @@ case "$1" in
extract_bb
;;
"indep"
|
"sh"
)
TMPDIR
=
.
;
setup_bb
;
shift
TMPDIR
=
.
setup_bb
shift
exec
/system/bin/sh
"
$@
"
;;
*
)
...
...
scripts/util_functions.sh
View file @
defbbdfe
...
...
@@ -7,6 +7,27 @@
#
##########################################################################################
##########
# Presets
##########
#MAGISK_VERSION_STUB
# Detect whether in boot mode
[
-z
$BOOTMODE
]
&&
BOOTMODE
=
false
$BOOTMODE
||
ps |
grep
zygote |
grep
-qv
grep
&&
BOOTMODE
=
true
$BOOTMODE
||
ps
-A
2>/dev/null |
grep
zygote |
grep
-qv
grep
&&
BOOTMODE
=
true
# Presets
MAGISKTMP
=
/sbin/.magisk
NVBASE
=
/data/adb
[
-z
$TMPDIR
]
&&
TMPDIR
=
/dev/tmp
# Bootsigner related stuff
BOOTSIGNERCLASS
=
a.a
BOOTSIGNER
=
"/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp
\$
APK
\$
BOOTSIGNERCLASS"
BOOTSIGNED
=
false
###################
# Helper Functions
###################
...
...
@@ -61,10 +82,10 @@ resolve_vars() {
######################
setup_flashable
()
{
$BOOTMODE
&&
return
# Preserve environment varibles
OLD_PATH
=
$PATH
setup_bb
ensure_bb
$BOOTMODE
&&
return
if
[
-z
$OUTFD
]
||
readlink
/proc/
$$
/fd/
$OUTFD
|
grep
-q
/tmp
;
then
# We will have to manually find out OUTFD
for
FD
in
`
ls
/proc/
$$
/fd
`
;
do
...
...
@@ -78,48 +99,41 @@ setup_flashable() {
fi
}
setup
_bb
()
{
ensure
_bb
()
{
if
[
-x
$MAGISKTMP
/busybox/busybox
]
;
then
# Make sure this path is in the front
echo
$PATH
|
grep
-q
"^
$MAGISKTMP
/busybox"
||
export
PATH
=
$MAGISKTMP
/busybox:
$PATH
[
-z
$BBDIR
]
&&
BBDIR
=
$MAGISKTMP
/busybox
elif
[
-x
$TMPDIR
/bin/busybox
]
;
then
# Make sure this path is in the front
echo
$PATH
|
grep
-q
"^
$TMPDIR
/bin"
||
export
PATH
=
$TMPDIR
/bin:
$PATH
[
-z
$BBDIR
]
&&
BBDIR
=
$TMPDIR
/bin
else
# Construct the PATH
mkdir
-p
$TMPDIR
/bin
ln
-s
$MAGISKBIN
/busybox
$TMPDIR
/bin/busybox
$MAGISKBIN
/busybox
--install
-s
$TMPDIR
/bin
export
PATH
=
$TMPDIR
/bin:
$PATH
[
-z
$BBDIR
]
&&
BBDIR
=
$TMPDIR
/bin
mkdir
-p
$BBDIR
ln
-s
$MAGISKBIN
/busybox
$BBDIR
/busybox
$MAGISKBIN
/busybox
--install
-s
$BBDIR
fi
}
boot_actions
()
{
if
[
!
-d
$MAGISKTMP
/mirror/bin
]
;
then
mkdir
-p
$MAGISKTMP
/mirror/bin
mount
-o
bind
$MAGISKBIN
$MAGISKTMP
/mirror/bin
fi
MAGISKBIN
=
$MAGISKTMP
/mirror/bin
setup_bb
echo
$PATH
|
grep
-q
"^
$BBDIR
"
||
export
PATH
=
$BBDIR
:
$PATH
}
recovery_actions
()
{
#
TWRP bug fix
#
Make sure random don't get blocked
mount
-o
bind
/dev/urandom /dev/random
# Temporarily block out all custom recovery binaries/libs
mv
/sbin /sbin_tmp
# Unset library paths
OLD_LD_LIB
=
$LD_LIBRARY_PATH
OLD_LD_PRE
=
$LD_PRELOAD
OLD_LD_CFG
=
$LD_CONFIG_FILE
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
()
{
mv
/sbin_tmp /sbin 2>/dev/null
[
-z
$OLD_PATH
]
||
export
PATH
=
$OLD_PATH
export
PATH
=
$OLD_PATH
[
-z
$OLD_LD_LIB
]
||
export
LD_LIBRARY_PATH
=
$OLD_LD_LIB
[
-z
$OLD_LD_PRE
]
||
export
LD_PRELOAD
=
$OLD_LD_PRE
[
-z
$OLD_LD_CFG
]
||
export
LD_CONFIG_FILE
=
$OLD_LD_CFG
ui_print
"- Unmounting partitions"
umount
-l
/system_root 2>/dev/null
umount
-l
/system 2>/dev/null
...
...
@@ -257,7 +271,9 @@ find_dtbo_image() {
}
patch_dtbo_image
()
{
find_dtbo_image
if
[
!
-z
$DTBOIMAGE
]
;
then
ui_print
"- DTBO image:
$DTBOIMAGE
"
if
$MAGISKBIN
/magiskboot
--dtb-test
$DTBOIMAGE
;
then
ui_print
"- Backing up stock DTBO image"
$MAGISKBIN
/magiskboot
--compress
$DTBOIMAGE
$MAGISKBIN
/stock_dtbo.img.gz
...
...
@@ -397,24 +413,10 @@ unmount_magisk_img() {
rm
-f
$MODULEPATH
2>/dev/null
}
#######
# main
#######
#MAGISK_VERSION_STUB
# Detect whether in boot mode
[
-z
$BOOTMODE
]
&&
BOOTMODE
=
false
$BOOTMODE
||
ps |
grep
zygote |
grep
-qv
grep
&&
BOOTMODE
=
true
$BOOTMODE
||
ps
-A
|
grep
zygote |
grep
-qv
grep
&&
BOOTMODE
=
true
# Presets
MAGISKTMP
=
/sbin/.magisk
NVBASE
=
/data/adb
boot_actions
()
{
return
;
}
# Bootsigner related stuff
BOOTSIGNERCLASS
=
a.a
BOOTSIGNER
=
"/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp
\$
APK
\$
BOOTSIGNERCLASS"
BOOTSIGNED
=
false
########
# Setup
########
resolve_vars
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