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
8833d21a
Commit
8833d21a
authored
Mar 12, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts for MagiskBoot
parent
1a3c522c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
331 additions
and
514 deletions
+331
-514
.gitignore
.gitignore
+2
-4
build.cmd
build.cmd
+3
-5
build.sh
build.sh
+3
-5
custom_ramdisk_patch.sh
scripts/custom_ramdisk_patch.sh
+0
-70
flash_script.sh
scripts/flash_script.sh
+188
-290
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+73
-114
ramdisk_patch.sh
scripts/ramdisk_patch.sh
+57
-0
update-binary
uninstaller/META-INF/com/google/android/update-binary
+5
-26
No files found.
.gitignore
View file @
8833d21a
...
@@ -17,8 +17,6 @@ ziptools/zipadjust
...
@@ -17,8 +17,6 @@ ziptools/zipadjust
# Generated scripts
# Generated scripts
uninstaller/common/
uninstaller/common/
zip_static/common/magic_mask.sh
zip_static/common/*.sh
zip_static/common/magisksu.sh
zip_static/common/*.rc
zip_static/common/init.magisk.rc
zip_static/common/custom_ramdisk_patch.sh
zip_static/META-INF/com/google/android/update-binary
zip_static/META-INF/com/google/android/update-binary
build.cmd
View file @
8833d21a
...
@@ -75,10 +75,8 @@ EXIT /B %ERRORLEVEL%
...
@@ -75,10 +75,8 @@ EXIT /B %ERRORLEVEL%
2>NUL RMDIR /S /Q zip_static\x64
2>NUL RMDIR /S /Q zip_static\x64
2>NUL RMDIR /S /Q zip_static\chromeos
2>NUL RMDIR /S /Q zip_static\chromeos
2>NUL DEL zip_static\META-INF\com\google\android\update-binary
2>NUL DEL zip_static\META-INF\com\google\android\update-binary
2>NUL DEL zip_static\common\custom_ramdisk_patch.sh
2>NUL DEL zip_static\common\*.sh
2>NUL DEL zip_static\common\magisksu.sh
2>NUL DEL zip_static\common\*.rc
2>NUL DEL zip_static\common\init.magisk.rc
2>NUL DEL zip_static\common\magic_mask.sh
2>NUL RMDIR /S /Q uninstaller\common
2>NUL RMDIR /S /Q uninstaller\common
2>NUL RMDIR /S /Q uninstaller\arm
2>NUL RMDIR /S /Q uninstaller\arm
2>NUL RMDIR /S /Q uninstaller\arm64
2>NUL RMDIR /S /Q uninstaller\arm64
...
@@ -104,7 +102,7 @@ EXIT /B %ERRORLEVEL%
...
@@ -104,7 +102,7 @@ EXIT /B %ERRORLEVEL%
ECHO ************************
ECHO ************************
ECHO * Copying Files
ECHO * Copying Files
ECHO ************************
ECHO ************************
COPY /Y scripts\
custom_ramdisk_patch.sh zip_static\common\custom_
ramdisk_patch.sh
COPY /Y scripts\
ramdisk_patch.sh zip_static\common\
ramdisk_patch.sh
COPY /Y scripts\magisksu.sh zip_static\common\magisksu.sh
COPY /Y scripts\magisksu.sh zip_static\common\magisksu.sh
COPY /Y scripts\init.magisk.rc zip_static\common\init.magisk.rc
COPY /Y scripts\init.magisk.rc zip_static\common\init.magisk.rc
COPY /Y binaries\busybox-arm zip_static\arm\busybox
COPY /Y binaries\busybox-arm zip_static\arm\busybox
...
...
build.sh
View file @
8833d21a
...
@@ -26,10 +26,8 @@ cleanup() {
...
@@ -26,10 +26,8 @@ cleanup() {
rm
-rfv
zip_static/x64
rm
-rfv
zip_static/x64
rm
-rfv
zip_static/chromeos
rm
-rfv
zip_static/chromeos
rm
-rfv
zip_static/META-INF/com/google/android/update-binary
rm
-rfv
zip_static/META-INF/com/google/android/update-binary
rm
-rfv
zip_static/common/custom_ramdisk_patch.sh
rm
-rfv
zip_static/common/
*
.sh
rm
-rfv
zip_static/common/magisksu.sh
rm
-rfv
zip_static/common/
*
.rc
rm
-rfv
zip_static/common/init.magisk.rc
rm
-rfv
zip_static/common/magic_mask.sh
rm
-rfv
uninstaller/common
rm
-rfv
uninstaller/common
rm
-rfv
uninstaller/arm
rm
-rfv
uninstaller/arm
rm
-rfv
uninstaller/arm64
rm
-rfv
uninstaller/arm64
...
@@ -77,7 +75,7 @@ zip_package() {
...
@@ -77,7 +75,7 @@ zip_package() {
echo
"************************"
echo
"************************"
echo
"* Copying files"
echo
"* Copying files"
echo
"************************"
echo
"************************"
cp
-afv
scripts/
custom_ramdisk_patch.sh zip_static/common/custom_
ramdisk_patch.sh
cp
-afv
scripts/
ramdisk_patch.sh zip_static/common/
ramdisk_patch.sh
cp
-afv
scripts/magisksu.sh zip_static/common/magisksu.sh
cp
-afv
scripts/magisksu.sh zip_static/common/magisksu.sh
cp
-afv
scripts/init.magisk.rc zip_static/common/init.magisk.rc
cp
-afv
scripts/init.magisk.rc zip_static/common/init.magisk.rc
cp
-afv
binaries/busybox-arm zip_static/arm/busybox
cp
-afv
binaries/busybox-arm zip_static/arm/busybox
...
...
scripts/custom_ramdisk_patch.sh
deleted
100644 → 0
View file @
1a3c522c
#!/system/bin/sh
RAMDISK
=
$1
BINDIR
=
/data/magisk
[
!
-e
$BINDIR
]
&&
BINDIR
=
/cache/data_bin
[
!
-e
$BINDIR
]
&&
exit
SYSTEMLIB
=
/system/lib
[
-d
/system/lib64
]
&&
SYSTEMLIB
=
/system/lib64
cpio_add
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-add
$RAMDISK
$RAMDISK
$2
$1
$1
}
cpio_extract
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-extract
$RAMDISK
$1
$1
}
cpio_mkdir
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-mkdir
$RAMDISK
$RAMDISK
$2
$1
}
# Recursive
cpio_rm
()
{
if
[
"
$1
"
=
"-r"
]
;
then
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-ls
$RAMDISK
|
grep
"^
$2
/"
|
while
read
i
;
do
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-rm
$RAMDISK
$RAMDISK
$i
done
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-rmdir
$RAMDISK
$RAMDISK
$2
else
LD_LIBRARY_PATH
=
$SYSTEMLIB
/su/bin/sukernel
--cpio-rm
$RAMDISK
$RAMDISK
$1
fi
}
file_contain
()
{
grep
"
$1
"
"
$2
"
>
/dev/null 2>&1
return
$?
}
rm
-rf
/tmp/magisk/ramdisk 2>/dev/null
mkdir
-p
/tmp/magisk/ramdisk
cd
/tmp/magisk/ramdisk
cat
$RAMDISK
| cpio
-i
# Cleanup SuperSU backups
cpio_rm
-r
.subackup
# Add magisk entrypoint
for
RC
in
init
*
.rc
;
do
if
file_contain
"import /init.environ.rc"
$RC
&&
!
file_contain
"import /init.magisk.rc"
$RC
;
then
sed
-i
"/import
\/
init
\.
environ
\.
rc/iimport /init.magisk.rc"
$RC
cpio_add
$RC
750
fi
if
file_contain
"selinux.reload_policy"
$RC
;
then
sed
-i
"/selinux.reload_policy/d"
$RC
cpio_add
$RC
750
fi
done
# sepolicy patches
LD_LIBRARY_PATH
=
$SYSTEMLIB
$BINDIR
/sepolicy-inject
--load
sepolicy
--save
sepolicy
--minimal
cpio_add sepolicy 644
# Add new items
cp
-af
$BINDIR
/init.magisk.rc init.magisk.rc
cp
-af
$BINDIR
/magic_mask.sh sbin/magic_mask.sh
cpio_mkdir magisk 755
cpio_add init.magisk.rc 750
cpio_add sbin/magic_mask.sh 750
scripts/flash_script.sh
View file @
8833d21a
This diff is collapsed.
Click to expand it.
scripts/magisk_uninstaller.sh
View file @
8833d21a
#!/system/bin/sh
# Detect whether in boot mode
ps |
grep
zygote |
grep
-v
grep
>
/dev/null
&&
BOOTMODE
=
true
||
BOOTMODE
=
false
[
-z
$BOOTMODE
]
&&
BOOTMODE
=
false
# This path should work in any cases
TMPDIR
=
/tmp
TMPDIR
=
/dev/tmp
(
$BOOTMODE
)
&&
TMPDIR
=
/dev/tmp
BINDIR
=
/data/magisk
BOOTTMP
=
$TMPDIR
/boottmp
CHROMEDIR
=
$BINDIR
/chromeos
MAGISKBIN
=
/data/magisk
CHROMEDIR
=
$MAGISKBIN
/chromeos
NEWBOOT
=
$TMPDIR
/boottmp/new-boot.img
UNPACKDIR
=
$TMPDIR
/boottmp/bootunpack
RAMDISK
=
$TMPDIR
/boottmp/ramdisk
SYSTEMLIB
=
/system/lib
SYSTEMLIB
=
/system/lib
[
-d
/system/lib64
]
&&
SYSTEMLIB
=
/system/lib64
[
-d
/system/lib64
]
&&
SYSTEMLIB
=
/system/lib64
ui_print
()
{
# Default permissions
echo
"
$1
"
umask
022
ui_print_wrapper
()
{
type
ui_print_wrapper
>
/dev/null
&&
ui_print
"
$1
"
||
echo
"
$1
"
}
}
grep_prop
()
{
grep_prop
()
{
...
@@ -25,7 +25,7 @@ grep_prop() {
...
@@ -25,7 +25,7 @@ grep_prop() {
if
[
-z
"
$FILES
"
]
;
then
if
[
-z
"
$FILES
"
]
;
then
FILES
=
'/system/build.prop'
FILES
=
'/system/build.prop'
fi
fi
cat
$FILES
2>/dev/null |
sed
-n
$REGEX
|
head
-n
1
cat
$FILES
2>/dev/null |
sed
-n
"
$REGEX
"
|
head
-n
1
}
}
find_boot_image
()
{
find_boot_image
()
{
...
@@ -42,135 +42,94 @@ find_boot_image() {
...
@@ -42,135 +42,94 @@ find_boot_image() {
fi
fi
}
}
unpack_boot
()
{
rm
-rf
$UNPACKDIR
$RAMDISK
2>/dev/null
mkdir
-p
$UNPACKDIR
mkdir
-p
$RAMDISK
cd
$UNPACKDIR
LD_LIBRARY_PATH
=
$SYSTEMLIB
$BINDIR
/bootimgtools
--extract
$1
[
!
-f
$UNPACKDIR
/ramdisk.gz
]
&&
return
1
cd
$RAMDISK
gunzip
-c
<
$UNPACKDIR
/ramdisk.gz | cpio
-i
}
repack_boot
()
{
cd
$RAMDISK
find
.
| cpio
-o
-H
newc 2>/dev/null |
gzip
-9
>
$UNPACKDIR
/ramdisk.gz
cd
$UNPACKDIR
LD_LIBRARY_PATH
=
$SYSTEMLIB
$BINDIR
/bootimgtools
--repack
$BOOTIMAGE
if
[
-f
chromeos
]
;
then
echo
" "
>
config
echo
" "
>
bootloader
LD_LIBRARY_PATH
=
$SYSTEMLIB
$CHROMEDIR
/futility vbutil_kernel
--pack
new-boot.img.signed
--keyblock
$CHROMEDIR
/kernel.keyblock
--signprivate
$CHROMEDIR
/kernel_data_key.vbprivk
--version
1
--vmlinuz
new-boot.img
--config
config
--arch
arm
--bootloader
bootloader
--flags
0x1
rm
-f
new-boot.img
mv
new-boot.img.signed new-boot.img
fi
if
(
$SAMSUNG
)
;
then
SAMSUNG_CHECK
=
$(
cat
new-boot.img |
grep
SEANDROIDENFORCE
)
if
[
$?
-ne
0
]
;
then
echo
-n
"SEANDROIDENFORCE"
>>
new-boot.img
fi
fi
if
(
$LGE_G
)
;
then
# Prevent secure boot error on LG G2/G3.
# Just for know, It's a pattern which bootloader verifies at boot. Thanks to LG hackers.
echo
-n
-e
"
\x
41
\x
a9
\x
e4
\x
67
\x
74
\x
4d
\x
1d
\x
1b
\x
a4
\x
29
\x
f2
\x
ec
\x
ea
\x
65
\x
52
\x
79"
>>
new-boot.img
fi
mv
new-boot.img
$NEWBOOT
}
# Environments
# Environments
# Set permissions
# Set permissions
chmod
-R
755
$CHROMEDIR
/futility
$
BINDIR
2>/dev/null
chmod
-R
755
$CHROMEDIR
/futility
$
MAGISKBIN
2>/dev/null
# Temporary busybox for installation
# Temporary busybox for installation
mkdir
-p
$TMPDIR
/busybox
mkdir
-p
$TMPDIR
/busybox
$
BINDIR
/busybox
--install
-s
$TMPDIR
/busybox
$
MAGISKBIN
/busybox
--install
-s
$TMPDIR
/busybox
rm
-f
$TMPDIR
/busybox/su
$TMPDIR
/busybox/sh
$TMPDIR
/busybox/reboot
rm
-f
$TMPDIR
/busybox/su
$TMPDIR
/busybox/sh
$TMPDIR
/busybox/reboot
PATH
=
$TMPDIR
/busybox:
$PATH
PATH
=
$TMPDIR
/busybox:
$PATH
# Find the boot image
# Find the boot image
find_boot_image
find_boot_image
if
[
-z
"
$BOOTIMAGE
"
]
;
then
if
[
-z
"
$BOOTIMAGE
"
]
;
then
ui_print
"! Unable to detect boot image"
ui_print
_wrapper
"! Unable to detect boot image"
exit
1
exit
1
fi
fi
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
ui_print
_wrapper
"- Found Boot Image:
$BOOTIMAGE
"
# Detect special vendors
rm
-rf
$BOOTTMP
2>/dev/null
SAMSUNG
=
false
mkdir
-p
$BOOTTMP
SAMSUNG_CHECK
=
$(
cat
/system/build.prop |
grep
"ro.build.fingerprint="
|
grep
-i
"samsung"
)
cd
$BOOTTMP
if
[
$?
-eq
0
]
;
then
SAMSUNG
=
true
fi
LGE_G
=
false
RBRAND
=
$(
grep_prop ro.product.brand
)
RMODEL
=
$(
grep_prop ro.product.device
)
if
[
"
$RBRAND
"
=
"lge"
]
||
[
"
$RBRAND
"
=
"LGE"
]
;
then
if
[
"
$RMODEL
"
=
"d800"
]
||
[
"
$RMODEL
"
=
"d801"
]
||
[
"
$RMODEL
"
=
"d802"
]
||
[
"
$RMODEL
"
=
"d803"
]
||
[
"
$RMODEL
"
=
"ls980"
]
||
[
"
$RMODEL
"
=
"vs980"
]
||
[
"
$RMODEL
"
=
"l01f"
]
||
[
"
$RMODEL
"
=
"d850"
]
||
[
"
$RMODEL
"
=
"d852"
]
||
[
"
$RMODEL
"
=
"d855"
]
||
[
"
$RMODEL
"
=
"ls990"
]
||
[
"
$RMODEL
"
=
"vs985"
]
||
[
"
$RMODEL
"
=
"f400"
]
;
then
LGE_G
=
true
ui_print
"! Bump device detected"
fi
fi
# First unpack the boot image
ui_print_wrapper
"- Unpacking boot image"
unpack_boot
$BOOTIMAGE
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--unpack
$BOOTIMAGE
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
ui_print
"! Unable to unpack boot image"
ui_print
_wrapper
"! Unable to unpack boot image"
exit
1
exit
1
fi
fi
#
Detect boot image state
#
Update our previous backup to new format if exists
SUPERSU
=
false
if
[
-f
/data/stock_boot.img
]
;
then
[
-f
sbin/launch_daemonsu.sh
]
&&
SUPERSU
=
true
SHA1
=
`
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--sha1
/data/stock_boot.img |
tail
-n
1
`
if
[
!
-f
init.magisk.rc
]
;
then
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
ui_print
"! Magisk is not installed!"
mv
/data/stock_boot.img
$STOCKDUMP
exit
1
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--compress
$STOCKDUMP
fi
fi
if
(
$SUPERSU
)
;
then
# Detect boot image state
ui_print
"- SuperSU patched image detected"
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-test
ramdisk.cpio
rm
-rf
magisk init.magisk.rc sbin/magic_mask.sh
case
$?
in
repack_boot
0
)
else
ui_print_wrapper
"! Magisk is not installed!"
if
[
-f
/data/stock_boot.img
]
;
then
ui_print_wrapper
"! Nothing to uninstall"
ui_print
"- Boot image backup found!"
exit
NEWBOOT
=
/data/stock_boot.img
;;
else
1
)
ui_print
"! Boot image backup unavailable"
# Find SHA1 of stock boot image
if
[
-d
".backup"
]
;
then
if
[
-z
$SHA1
]
;
then
ui_print
"- Restoring ramdisk with backup"
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-extract
ramdisk.cpio init.magisk.rc init.magisk.rc
cp
-af
.backup/.
.
SHA1
=
`
grep_prop
"# STOCKSHA1"
init.magisk.rc
`
[
!
-z
$SHA1
]
&&
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
rm
-f
init.magisk.rc
fi
fi
rm
-rf
magisk init.magisk.rc sbin/magic_mask.sh .backup
if
[
-f
${
STOCKDUMP
}
.gz
]
;
then
repack_boot
ui_print_wrapper
"- Boot image backup found!"
fi
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--decompress
${
STOCKDUMP
}
.gz stock_boot.img
else
ui_print_wrapper
"! Boot image backup unavailable"
ui_print_wrapper
"- Restoring ramdisk with backup"
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-restore
ramdisk.cpio
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--repack
$BOOTIMAGE
stock_boot.img
fi
;;
2
)
ui_print_wrapper
"- SuperSU patched image detected"
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-restore
ramdisk.cpio
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--repack
$BOOTIMAGE
stock_boot.img
;;
esac
# Sign chromeos boot
if
[
-f
chromeos
]
;
then
cp
-af
$CHROMEDIR
/.
$MAGISKBIN
/chromeos
echo
>
config
echo
>
bootloader
LD_LIBRARY_PATH
=
$SYSTEMLIB
$CHROMEDIR
/futility vbutil_kernel
--pack
new-boot.img.signed
--keyblock
$CHROMEDIR
/kernel.keyblock
--signprivate
$CHROMEDIR
/kernel_data_key.vbprivk
--version
1
--vmlinuz
new-boot.img
--config
config
--arch
arm
--bootloader
bootloader
--flags
0x1
rm
-f
new-boot.img
mv
new-boot.img.signed new-boot.img
fi
fi
chmod
644
$NEWBOOT
ui_print_wrapper
"- Flashing stock/reverted image"
ui_print
"- Flashing stock/reverted image"
[
!
-L
"
$BOOTIMAGE
"
]
&&
dd
if
=
/dev/zero
of
=
$BOOTIMAGE
bs
=
4096 2>/dev/null
[
!
-L
"
$BOOTIMAGE
"
]
&&
dd
if
=
/dev/zero
of
=
$BOOTIMAGE
bs
=
4096 2>/dev/null
dd
if
=
$NEWBOOT
of
=
$BOOTIMAGE
bs
=
4096
dd
if
=
stock_boot.img
of
=
$BOOTIMAGE
bs
=
4096
ui_print
"- Removing Magisk files"
ui_print
_wrapper
"- Removing Magisk files"
rm
-rf
/cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk
\
rm
-rf
/cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk
\
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock /cache/magisk_uninstaller.sh
\
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock /cache/magisk_uninstaller.sh
\
/data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img
\
/data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img
\
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh 2>/dev/null
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh 2>/dev/null
(
$BOOTMODE
)
&&
reboot
$BOOTMODE
&&
reboot
scripts/ramdisk_patch.sh
0 → 100644
View file @
8833d21a
# This file will be sourced by Magisk patch zip, so all variables in the main script should be present
# However, this file may also be called by SuperSU, so we still have to find our own variables in this case
RAMDISK
=
$1
if
[
-z
$MAGISK
]
;
then
TMPDIR
=
/dev/tmp
MAGISKBIN
=
/data/magisk
[
!
-e
$MAGISKBIN
]
&&
MAGISKBIN
=
/cache/data_bin
[
!
-e
$MAGISKBIN
]
&&
exit
1
SYSTEMLIB
=
/system/lib
[
-d
/system/lib64
]
&&
SYSTEMLIB
=
/system/lib64
KEEPVERITY
=
true
KEEPFORCEENCRYPT
=
true
fi
cd
$TMPDIR
# --cpio-add <incpio> <mode> <entry> <infile>
cpio_add
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-add
$RAMDISK
$1
$2
$3
}
# --cpio-extract <incpio> <entry> <outfile>
cpio_extract
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-extract
$RAMDISK
$1
$2
}
# --cpio-mkdir <incpio> <mode> <entry>
cpio_mkdir
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-mkdir
$RAMDISK
$1
$2
}
# The common patches
$KEEPVERITY
||
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-patch-dmverity
$RAMDISK
$KEEPFORCEENCRYPT
||
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/magiskboot
--cpio-patch-forceencrypt
$RAMDISK
# Add magisk entrypoint
cpio_extract init.rc init.rc
grep
"import /init.magisk.rc"
init.rc
>
/dev/null
||
sed
-i
'1,/.*import.*/s/.*import.*/import \/init.magisk.rc\n&/'
init.rc
sed
-i
"/selinux.reload_policy/d"
init.rc
cpio_add 750 init.rc init.rc
# sepolicy patches
cpio_extract sepolicy sepolicy
LD_LIBRARY_PATH
=
$SYSTEMLIB
$MAGISKBIN
/sepolicy-inject
--load
sepolicy
--save
sepolicy
--minimal
cpio_add 644 sepolicy sepolicy
# Add new items
cpio_mkdir 755 magisk
cp
-af
$MAGISKBIN
/init.magisk.rc init.magisk.rc
[
!
-z
$SHA1
]
&&
echo
"# STOCKSHA1=
$SHA1
"
>>
init.magisk.rc
cpio_add 750 init.magisk.rc init.magisk.rc
cpio_add 750 sbin/magic_mask.sh
$MAGISKBIN
/magic_mask.sh
uninstaller/META-INF/com/google/android/update-binary
View file @
8833d21a
...
@@ -49,20 +49,6 @@ ui_print() {
...
@@ -49,20 +49,6 @@ ui_print() {
echo
-n
-e
"ui_print
\n
"
>>
/proc/self/fd/
$OUTFD
echo
-n
-e
"ui_print
\n
"
>>
/proc/self/fd/
$OUTFD
}
}
getvar
()
{
local
VARNAME
=
$1
local
VALUE
=
$(
eval echo
\$
"
$VARNAME
"
)
;
for
FILE
in
/data/.magisk /cache/.magisk /system/.magisk
;
do
if
[
-z
"
$VALUE
"
]
;
then
LINE
=
$(
cat
$FILE
2>/dev/null |
grep
"
$VARNAME
="
)
if
[
!
-z
"
$LINE
"
]
;
then
VALUE
=
${
LINE
#*=
}
fi
fi
done
eval
$VARNAME
=
\$
VALUE
}
is_mounted
()
{
is_mounted
()
{
if
[
!
-z
"
$2
"
]
;
then
if
[
!
-z
"
$2
"
]
;
then
cat
/proc/mounts |
grep
$1
|
grep
$2
,
>
/dev/null
cat
/proc/mounts |
grep
$1
|
grep
$2
,
>
/dev/null
...
@@ -105,10 +91,10 @@ if [ ! -f '/system/build.prop' ]; then
...
@@ -105,10 +91,10 @@ if [ ! -f '/system/build.prop' ]; then
exit
1
exit
1
fi
fi
API
=
$(
grep_prop ro.build.version.sdk
)
API
=
`
grep_prop ro.build.version.sdk
`
ABI
=
$(
grep_prop ro.product.cpu.abi |
cut
-c-3
)
ABI
=
`
grep_prop ro.product.cpu.abi |
cut
-c-3
`
ABI2
=
$(
grep_prop ro.product.cpu.abi2 |
cut
-c-3
)
ABI2
=
`
grep_prop ro.product.cpu.abi2 |
cut
-c-3
`
ABILONG
=
$(
grep_prop ro.product.cpu.abi
)
ABILONG
=
`
grep_prop ro.product.cpu.abi
`
ARCH
=
arm
ARCH
=
arm
IS64BIT
=
false
IS64BIT
=
false
...
@@ -129,15 +115,8 @@ cp -af $BINDIR/* $CHROMEDIR /data/magisk
...
@@ -129,15 +115,8 @@ cp -af $BINDIR/* $CHROMEDIR /data/magisk
# Detection all done, start installing
# Detection all done, start installing
##########################################################################################
##########################################################################################
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
if
(
is_mounted /data
)
;
then
if
(
is_mounted /data
)
;
then
ui_print
"- Running uninstaller scripts"
.
$INSTALLER
/common/magisk_uninstaller.sh
sh
$INSTALLER
/common/magisk_uninstaller.sh
if
[
$?
-ne
0
]
;
then
ui_print
"! Magisk is not installed or an error occurred"
exit
1
fi
else
else
ui_print
"! Data unavailable"
ui_print
"! Data unavailable"
ui_print
"! Placing uninstall script to /cache"
ui_print
"! Placing uninstall script to /cache"
...
...
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