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
835ece54
Commit
835ece54
authored
Jun 17, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update default flag logic, fix S9/S9+ DTB patches
parent
d93fc67a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
46 deletions
+52
-46
app
app
+1
-1
boot_patch.sh
scripts/boot_patch.sh
+22
-34
flash_script.sh
scripts/flash_script.sh
+3
-11
util_functions.sh
scripts/util_functions.sh
+26
-0
No files found.
app
@
77430a28
Subproject commit
e6c1dd532d2910285d503f271183839446495360
Subproject commit
77430a282f8a2dbea79e8ddc0df8f463dbb70767
scripts/boot_patch.sh
View file @
835ece54
...
...
@@ -4,18 +4,25 @@
# Magisk Boot Image Patcher
# by topjohnwu
#
# Usage: sh boot_patch.sh <bootimage>
#
# The following additional flags can be set in environment variables:
# KEEPVERITY, KEEPFORCEENCRYPT, HIGHCOMP
#
# This script should be placed in a directory with the following files:
#
# File name
t
ype Description
# File name
T
ype Description
#
# boot_patch.sh script A script to patch boot. Expect path to boot image as parameter.
# (this file) The script will use binaries and files in its same directory
# to complete the patching process
# monogisk binary The monolithic binary to replace /init
# magiskboot binary A tool to unpack boot image, decompress ramdisk, extract ramdisk
# , and patch the ramdisk for Magisk support
# util_functions.sh script A script which hosts all functions requires for this script
# to work properly
# magiskinit binary The binary to replace /init, which has the magisk binary embedded
# magiskboot binary A tool to unpack boot image, decompress ramdisk, extract ramdisk,
# and patch the ramdisk for Magisk support
# chromeos folder This folder should store all the utilities and keys to sign
#
(optional) a chromeos device, used in the tablet
Pixel C
#
(optional) a chromeos device. Used for
Pixel C
#
# If the script is not running as root, then the input boot image should be a stock image
# or have a backup included in ramdisk internally, since we cannot access the stock boot
...
...
@@ -27,51 +34,32 @@
##########################################################################################
# Pure bash dirname implementation
dirname_wrap
()
{
getdir
()
{
case
"
$1
"
in
*
/
*
)
dir
=
${
1
%/*
}
[
-z
$dir
]
&&
echo
"/"
||
echo
$dir
;;
*
)
echo
"."
;;
*
/
*
)
dir
=
${
1
%/*
}
;
[
-z
$dir
]
&&
echo
"/"
||
echo
$dir
;;
*
)
echo
"."
;;
esac
}
# Pure bash basename implementation
basename_wrap
()
{
echo
${
1
##*/
}
}
##########################################################################################
# Initialization
##########################################################################################
if
[
-z
$SOURCEDMODE
]
;
then
# Switch to the location of the script file
cd
"
`
dirname_wrap
"
${
BASH_SOURCE
:-
$0
}
"
`
"
cd
"
`
getdir
"
${
BASH_SOURCE
:-
$0
}
"
`
"
# Load utility functions
.
./util_functions.sh
fi
BOOTIMAGE
=
"
$1
"
[
-e
"
$BOOTIMAGE
"
]
||
abort
"
$BOOTIMAGE
does not exist!"
#
Preset
s
#
Flag
s
[
-z
$KEEPVERITY
]
&&
KEEPVERITY
=
false
[
-z
$KEEPFORCEENCRYPT
]
&&
KEEPFORCEENCRYPT
=
false
[
-z
$HIGHCOMP
]
&&
HIGHCOMP
=
false
if
[
-z
$KEEPFORCEENCRYPT
]
;
then
if
[
"
`
getprop ro.crypto.state
`
"
=
"encrypted"
]
;
then
KEEPFORCEENCRYPT
=
true
ui_print
"- Encrypted data detected, keep forceencrypt"
else
KEEPFORCEENCRYPT
=
false
fi
fi
chmod
-R
755
.
# Extract magisk if doesn't exist
...
...
scripts/flash_script.sh
View file @
835ece54
...
...
@@ -51,24 +51,16 @@ mount_partitions
find_boot_image
find_dtbo_image
# read override variables
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
getvar BOOTIMAGE
get_flags
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
ui_print
"- Found boot/ramdisk image:
$BOOTIMAGE
"
if
[
!
-z
$DTBOIMAGE
]
;
then
ui_print
"- Found dtbo image:
$DTBOIMAGE
"
# Disable dtbo patch by default
[
-z
$KEEPVERITY
]
&&
KEEPVERITY
=
true
fi
[
-z
$DTBOIMAGE
]
||
ui_print
"- Found dtbo image:
$DTBOIMAGE
"
# Detect version and architecture
api_level_arch_detect
[
$API
-lt
21
]
&&
abort
"! Magisk is only for
Lollipop 5.0+
(SDK 21+)"
[
$API
-lt
21
]
&&
abort
"! Magisk is only for
Android higher than Lollipop (5.0+)
(SDK 21+)"
ui_print
"- Device platform:
$ARCH
"
...
...
scripts/util_functions.sh
View file @
835ece54
...
...
@@ -82,6 +82,32 @@ mount_partitions() {
fi
}
get_flags
()
{
# override variables
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
HIGHCOMP
=
false
if
[
-z
$KEEPVERITY
]
;
then
KEEPVERITY
=
false
hardware
=
`
grep_cmdline androidboot.hardware
`
for
hw
in
taimen walleye
;
do
if
[
"
$hw
"
=
"
$hardware
"
]
;
then
KEEPVERITY
=
true
ui_print
"- Device on whitelist, keep avb-verity"
break
fi
done
fi
if
[
-z
$KEEPFORCEENCRYPT
]
;
then
if
[
"
`
getprop ro.crypto.state
`
"
=
"encrypted"
]
;
then
KEEPFORCEENCRYPT
=
true
ui_print
"- Encrypted data detected, keep forceencrypt"
else
KEEPFORCEENCRYPT
=
false
fi
fi
}
grep_cmdline
()
{
REGEX
=
"s/^
$1
=//p"
sed
-E
's/ +/\n/g'
/proc/cmdline |
sed
-n
"
$REGEX
"
2>/dev/null
...
...
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