mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 13:35:27 +00:00
Update default flag logic, fix S9/S9+ DTB patches
This commit is contained in:
parent
d93fc67a75
commit
835ece5469
2
app
2
app
@ -1 +1 @@
|
|||||||
Subproject commit e6c1dd532d2910285d503f271183839446495360
|
Subproject commit 77430a282f8a2dbea79e8ddc0df8f463dbb70767
|
@ -4,18 +4,25 @@
|
|||||||
# Magisk Boot Image Patcher
|
# Magisk Boot Image Patcher
|
||||||
# by topjohnwu
|
# 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:
|
# This script should be placed in a directory with the following files:
|
||||||
#
|
#
|
||||||
# File name type Description
|
# File name Type Description
|
||||||
#
|
#
|
||||||
# boot_patch.sh script A script to patch boot. Expect path to boot image as parameter.
|
# 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
|
# (this file) The script will use binaries and files in its same directory
|
||||||
# to complete the patching process
|
# to complete the patching process
|
||||||
# monogisk binary The monolithic binary to replace /init
|
# util_functions.sh script A script which hosts all functions requires for this script
|
||||||
# magiskboot binary A tool to unpack boot image, decompress ramdisk, extract ramdisk
|
# to work properly
|
||||||
# , and patch the ramdisk for Magisk support
|
# magiskinit binary The binary to replace /init, which has the magisk binary embedded
|
||||||
# chromeos folder This folder should store all the utilities and keys to sign
|
# magiskboot binary A tool to unpack boot image, decompress ramdisk, extract ramdisk,
|
||||||
# (optional) a chromeos device, used in the tablet Pixel C
|
# 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 for Pixel C
|
||||||
#
|
#
|
||||||
# If the script is not running as root, then the input boot image should be a stock image
|
# 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
|
# or have a backup included in ramdisk internally, since we cannot access the stock boot
|
||||||
@ -27,51 +34,32 @@
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
# Pure bash dirname implementation
|
# Pure bash dirname implementation
|
||||||
dirname_wrap() {
|
getdir() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*/*)
|
*/*) dir=${1%/*}; [ -z $dir ] && echo "/" || echo $dir ;;
|
||||||
dir=${1%/*}
|
*) echo "." ;;
|
||||||
[ -z $dir ] && echo "/" || echo $dir
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "."
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pure bash basename implementation
|
|
||||||
basename_wrap() {
|
|
||||||
echo ${1##*/}
|
|
||||||
}
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Initialization
|
# Initialization
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
if [ -z $SOURCEDMODE ]; then
|
if [ -z $SOURCEDMODE ]; then
|
||||||
# Switch to the location of the script file
|
# Switch to the location of the script file
|
||||||
cd "`dirname_wrap "${BASH_SOURCE:-$0}"`"
|
cd "`getdir "${BASH_SOURCE:-$0}"`"
|
||||||
# Load utility functions
|
# Load utility functions
|
||||||
. ./util_functions.sh
|
. ./util_functions.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BOOTIMAGE="$1"
|
BOOTIMAGE="$1"
|
||||||
|
|
||||||
[ -e "$BOOTIMAGE" ] || abort "$BOOTIMAGE does not exist!"
|
[ -e "$BOOTIMAGE" ] || abort "$BOOTIMAGE does not exist!"
|
||||||
|
|
||||||
# Presets
|
# Flags
|
||||||
[ -z $KEEPVERITY ] && KEEPVERITY=false
|
[ -z $KEEPVERITY ] && KEEPVERITY=false
|
||||||
|
[ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false
|
||||||
[ -z $HIGHCOMP ] && HIGHCOMP=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 .
|
chmod -R 755 .
|
||||||
|
|
||||||
# Extract magisk if doesn't exist
|
# Extract magisk if doesn't exist
|
||||||
|
@ -51,24 +51,16 @@ mount_partitions
|
|||||||
find_boot_image
|
find_boot_image
|
||||||
find_dtbo_image
|
find_dtbo_image
|
||||||
|
|
||||||
# read override variables
|
get_flags
|
||||||
getvar KEEPVERITY
|
|
||||||
getvar KEEPFORCEENCRYPT
|
|
||||||
getvar BOOTIMAGE
|
|
||||||
|
|
||||||
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
||||||
ui_print "- Found boot/ramdisk image: $BOOTIMAGE"
|
ui_print "- Found boot/ramdisk image: $BOOTIMAGE"
|
||||||
|
[ -z $DTBOIMAGE ] || ui_print "- Found dtbo image: $DTBOIMAGE"
|
||||||
if [ ! -z $DTBOIMAGE ]; then
|
|
||||||
ui_print "- Found dtbo image: $DTBOIMAGE"
|
|
||||||
# Disable dtbo patch by default
|
|
||||||
[ -z $KEEPVERITY ] && KEEPVERITY=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect version and architecture
|
# Detect version and architecture
|
||||||
api_level_arch_detect
|
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"
|
ui_print "- Device platform: $ARCH"
|
||||||
|
|
||||||
|
@ -82,6 +82,32 @@ mount_partitions() {
|
|||||||
fi
|
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() {
|
grep_cmdline() {
|
||||||
REGEX="s/^$1=//p"
|
REGEX="s/^$1=//p"
|
||||||
sed -E 's/ +/\n/g' /proc/cmdline | sed -n "$REGEX" 2>/dev/null
|
sed -E 's/ +/\n/g' /proc/cmdline | sed -n "$REGEX" 2>/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user