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
912c188b
Commit
912c188b
authored
Nov 10, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dtbo.img patch support
parent
e9d0f615
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
35 deletions
+86
-35
addon.d.sh
scripts/addon.d.sh
+11
-4
boot_patch.sh
scripts/boot_patch.sh
+13
-12
flash_script.sh
scripts/flash_script.sh
+10
-3
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+6
-9
util_functions.sh
scripts/util_functions.sh
+46
-7
No files found.
scripts/addon.d.sh
View file @
912c188b
...
...
@@ -43,7 +43,7 @@ main() {
find_boot_image
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
ui_print
"- Found
Boot I
mage:
$BOOTIMAGE
"
ui_print
"- Found
boot i
mage:
$BOOTIMAGE
"
SOURCEDMODE
=
true
cd
$MAGISKBIN
...
...
@@ -51,13 +51,20 @@ main() {
# Source the boot patcher
.
$MAGISKBIN
/boot_patch.sh
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
rm
-f
new-boot.img
if
[
-f
stock_boot
*
]
;
then
rm
-f
/data/stock_boot
*
2>/dev/null
mv
stock_boot
*
/data
is_mounted /data
&&
mv
stock_boot
*
/data
fi
flash_boot_image new-boot.img
$BOOTIMAGE
rm
-f
new-boot.img
patch_dtbo_image
if
[
-f
stock_dtbo
*
]
;
then
rm
-f
/data/stock_dtbo
*
2>/dev/null
is_mounted /data
&&
mv
stock_dtbo
*
/data
fi
cd
/
recovery_cleanup
...
...
scripts/boot_patch.sh
View file @
912c188b
...
...
@@ -110,9 +110,8 @@ case $? in
ui_print
"- Stock boot image detected!"
ui_print
"- Backing up stock boot image"
SHA1
=
`
./magiskboot
--sha1
"
$BOOTIMAGE
"
2>/dev/null
`
STOCKDUMP
=
stock_boot_
${
SHA1
}
.img
dd
if
=
"
$BOOTIMAGE
"
of
=
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
STOCKDUMP
=
stock_boot_
${
SHA1
}
.img.gz
./magiskboot
--compress
"
$BOOTIMAGE
"
$STOCKDUMP
cp
-af
ramdisk.cpio ramdisk.cpio.orig
;;
1
)
# Magisk patched
...
...
@@ -129,10 +128,10 @@ case $? in
ui_print
"! Cannot restore from internal backup"
# If we are root and SHA1 known, we try to find the stock backup
if
[
!
-z
$SHA1
]
;
then
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
if
[
-f
$
{
STOCKDUMP
}
.gz
]
;
then
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
.gz
if
[
-f
$
STOCKDUMP
]
;
then
ui_print
"- Stock boot image backup found"
./magiskboot
--decompress
$
{
STOCKDUMP
}
.gz
stock_boot.img
./magiskboot
--decompress
$
STOCKDUMP
stock_boot.img
./magiskboot
--unpack
stock_boot.img
rm
-f
stock_boot.img
OK
=
true
...
...
@@ -163,17 +162,15 @@ ui_print "- Patching ramdisk"
# Create ramdisk backups
./magiskboot
--cpio-backup
ramdisk.cpio ramdisk.cpio.orig
$SHA1
if
!
$KEEPVERITY
&&
[
-f
dtb
]
;
then
./magiskboot
--dtb-patch
dtb
&&
ui_print
"- Patching fstab in dtb to remove dm-verity"
fi
rm
-f
ramdisk.cpio.orig
##########################################################################################
#
Repack and flash
#
Binary patches
##########################################################################################
# Hexpatches
if
!
$KEEPVERITY
&&
[
-f
dtb
]
;
then
./magiskboot
--dtb-patch
dtb
&&
ui_print
"- Patching fstab in dtb to remove dm-verity"
fi
# Remove Samsung RKP in stock kernel
./magiskboot
--hexpatch
kernel
\
...
...
@@ -185,6 +182,10 @@ A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
736B69705F696E697472616D6673
\
77616E745F696E697472616D6673
##########################################################################################
# Repack and flash
##########################################################################################
ui_print
"- Repacking boot image"
./magiskboot
--repack
"
$BOOTIMAGE
"
||
abort
"! Unable to repack boot image!"
...
...
scripts/flash_script.sh
View file @
912c188b
...
...
@@ -115,13 +115,20 @@ cd $MAGISKBIN
# Source the boot patcher
.
$COMMONDIR
/boot_patch.sh
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
rm
-f
new-boot.img
if
[
-f
stock_boot
*
]
;
then
rm
-f
/data/stock_boot
*
2>/dev/null
mv
stock_boot
*
/data
is_mounted /data
&&
mv
stock_boot
*
/data
fi
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
rm
-f
new-boot.img
patch_dtbo_image
if
[
-f
stock_dtbo
*
]
;
then
rm
-f
/data/stock_dtbo
*
2>/dev/null
is_mounted /data
&&
mv
stock_dtbo
*
/data
fi
cd
/
# Cleanups
...
...
scripts/magisk_uninstaller.sh
View file @
912c188b
...
...
@@ -79,17 +79,16 @@ case $? in
ui_print
"- Magisk patched image detected!"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio-stocksha1
ramdisk.cpio 2>/dev/null
`
[
!
-z
$SHA1
]
&&
STOCKBOOT
=
/data/stock_boot_
${
SHA1
}
.img.gz
if
[
-f
"
$STOCKBOOT
"
]
;
then
ui_print
"- Boot image backup found!"
else
OK
=
false
[
!
-z
$SHA1
]
&&
restore_imgs
$SHA1
&&
OK
=
true
if
!
$OK
;
then
ui_print
"! Boot image backup unavailable"
ui_print
"- Restoring ramdisk with internal backup"
./magiskboot
--cpio-restore
ramdisk.cpio
./magiskboot
--repack
$BOOTIMAGE
# Sign chromeos boot
$CHROMEOS
&&
sign_chromeos
STOCKBOOT
=
new-boot.img
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
fi
;;
2
)
# Other patched
...
...
@@ -98,13 +97,11 @@ case $? in
;;
esac
flash_boot_image
$STOCKBOOT
"
$BOOTIMAGE
"
cd
/
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/
app/com.topjohnwu.magisk
*
/data/user
*
/
*
/com.topjohnwu.magisk 2>/dev/null
/data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh
/data/app/com.topjohnwu.magisk
*
\
/data/
user
*
/
*
/magisk.db
/data/user
*
/
*
/com.topjohnwu.magisk 2>/dev/null
$BOOTMODE
&&
reboot
scripts/util_functions.sh
View file @
912c188b
...
...
@@ -41,8 +41,11 @@ ui_print() {
mount_partitions
()
{
# Check A/B slot
SLOT
=
`
getprop ro.boot.slot_suffix
`
[
-z
$SLOT
]
&&
SLOT
=
_
`
getprop ro.boot.slot
`
[
$SLOT
=
"_"
]
||
ui_print
"- A/B partition detected, current slot:
$SLOT
"
if
[
-z
$SLOT
]
;
then
SLOT
=
_
`
getprop ro.boot.slot
`
[
$SLOT
=
"_"
]
&&
SLOT
=
fi
[
-z
$SLOT
]
||
ui_print
"- A/B partition detected, current slot:
$SLOT
"
ui_print
"- Mounting /system, /vendor"
is_mounted /system
||
[
-f
/system/build.prop
]
||
mount
-o
ro /system 2>/dev/null
if
!
is_mounted /system
&&
!
[
-f
/system/build.prop
]
;
then
...
...
@@ -136,24 +139,60 @@ migrate_boot_backup() {
flash_boot_image
()
{
# Make sure all blocks are writable
$MAGISKBIN
/magisk
--unlock-blocks
$MAGISKBIN
/magisk
--unlock-blocks
2>/dev/null
case
"
$1
"
in
*
.gz
)
COMMAND
=
"gzip -d <
\"
$1
\"
"
;;
*
)
COMMAND
=
"cat
\"
$1
\"
"
;;
*
.gz
)
COMMAND
=
"gzip -d <
'
$1
'
"
;;
*
)
COMMAND
=
"cat
'
$1
'
"
;;
esac
$BOOTSIGNED
&&
SIGNCOM
=
"
$BOOTSIGNER
-sign"
||
SIGNCOM
=
"cat -"
case
"
$2
"
in
/dev/block/
*
)
ui_print
"- Flashing new boot image"
eval
$COMMAND
|
eval
$SIGNCOM
|
cat
- /dev/zero
|
dd
of
=
"
$2
"
bs
=
4096
>
/dev/null 2>&1
eval
$COMMAND
|
eval
$SIGNCOM
|
cat
- /dev/zero
2>/dev/null |
dd
of
=
"
$2
"
bs
=
4096 2>/dev/null
;;
*
)
ui_print
"- Storing new boot image"
eval
$COMMAND
|
eval
$SIGNCOM
|
dd
of
=
"
$2
"
bs
=
4096
>
/dev/null 2>&1
eval
$COMMAND
|
eval
$SIGNCOM
|
dd
of
=
"
$2
"
bs
=
4096
2>/dev/null
;;
esac
}
find_dtbo_image
()
{
DTBOIMAGE
=
`
find /dev/block
-iname
dtbo
$SLOT
|
head
-n
1
`
2>/dev/null
[
!
-z
$DTBOIMAGE
]
&&
DTBOIMAGE
=
`
resolve_link
$DTBOIMAGE
`
}
patch_dtbo_image
()
{
find_dtbo_image
if
[
!
-z
$DTBOIMAGE
]
;
then
ui_print
"- Found 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
ui_print
"- Patching fstab in dtbo to remove avb-verity"
$MAGISKBIN
/magiskboot
--dtb-patch
$DTBOIMAGE
fi
fi
}
restore_imgs
()
{
STOCKBOOT
=
/data/stock_boot_
${
1
}
.img.gz
STOCKDTBO
=
/data/stock_dtbo.img.gz
find_dtbo_image
if
[
!
-z
"
$DTBOIMAGE
"
-a
-f
"
$STOCKDTBO
"
]
;
then
ui_print
"- Restoring stock dtbo image"
gzip
-d
<
$STOCKDTBO
|
dd
of
=
$DTBOIMAGE
fi
BOOTSIGNED
=
false
find_boot_image
if
[
!
-z
"
$BOOTIMAGE
"
-a
-f
"
$STOCKBOOT
"
]
;
then
ui_print
"- Restoring stock boot image"
flash_boot_image
$STOCKBOOT
"
$BOOTIMAGE
"
return
0
fi
return
1
}
sign_chromeos
()
{
ui_print
"- Signing ChromeOS boot image"
...
...
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