mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Update scripts to support Pixel (XL)
This commit is contained in:
parent
3a2262dfb3
commit
46c91f923d
3
build.py
3
build.py
@ -238,6 +238,9 @@ def zip_main(args):
|
|||||||
source = os.path.join('libs', lib_dir, binary)
|
source = os.path.join('libs', lib_dir, binary)
|
||||||
target = os.path.join(zip_dir, binary)
|
target = os.path.join(zip_dir, binary)
|
||||||
zip_with_msg(zipf, source, target)
|
zip_with_msg(zipf, source, target)
|
||||||
|
source = os.path.join('libs', 'arm64-v8a', 'magiskinit')
|
||||||
|
target = os.path.join('arm64', 'magiskinit')
|
||||||
|
zip_with_msg(zipf, source, target)
|
||||||
|
|
||||||
# APK
|
# APK
|
||||||
source = os.path.join('MagiskManager', 'app', 'build', 'outputs', 'apk',
|
source = os.path.join('MagiskManager', 'app', 'build', 'outputs', 'apk',
|
||||||
|
@ -200,23 +200,54 @@ esac
|
|||||||
|
|
||||||
ui_print_wrap "- Patching ramdisk"
|
ui_print_wrap "- Patching ramdisk"
|
||||||
|
|
||||||
# Add magisk entrypoint
|
|
||||||
./magiskboot --cpio-patch ramdisk.cpio $KEEPVERITY $KEEPFORCEENCRYPT
|
|
||||||
|
|
||||||
# sepolicy patches
|
|
||||||
cpio_extract sepolicy sepolicy
|
|
||||||
./magisk magiskpolicy --load sepolicy --save sepolicy --minimal
|
|
||||||
cpio_add 644 sepolicy sepolicy
|
|
||||||
rm -f sepolicy
|
|
||||||
|
|
||||||
# Add new items
|
|
||||||
if [ ! -z $SHA1 ]; then
|
if [ ! -z $SHA1 ]; then
|
||||||
cp init.magisk.rc init.magisk.rc.bak
|
cp init.magisk.rc init.magisk.rc.bak
|
||||||
echo "# STOCKSHA1=$SHA1" >> init.magisk.rc
|
echo "# STOCKSHA1=$SHA1" >> init.magisk.rc
|
||||||
fi
|
fi
|
||||||
cpio_add 750 init.magisk.rc init.magisk.rc
|
|
||||||
|
if $SKIP_INITRAMFS; then
|
||||||
|
# First check precompiled ones
|
||||||
|
[ -f /system_root/sepolicy ] && cp /system_root/sepolicy sepolicy
|
||||||
|
if [ ! -f sepolicy -a -f /vendor/etc/selinux/precompiled_sepolicy ]; then
|
||||||
|
# Check SHA256
|
||||||
|
SYSTEMSHA256=`find /system/etc/selinux -name '*.sha256' -exec cat {} \; 2>/dev/null`
|
||||||
|
VENDORSHA256=`find /vendor/etc/selinux -name '*.sha256' -exec cat {} \; 2>/dev/null`
|
||||||
|
[ "$SYSTEMSHA256" = "$VENDORSHA256" ] && cp /vendor/etc/selinux/precompiled_sepolicy sepolicy
|
||||||
|
fi
|
||||||
|
if [ ! -f sepolicy ]; then
|
||||||
|
ui_print_wrap "- Compiling split cil policies"
|
||||||
|
# Compile the split policies
|
||||||
|
POLICY_VER=`cat /sys/fs/selinux/policyvers`
|
||||||
|
PLAT_CIL=/system/etc/selinux/plat_sepolicy.cil
|
||||||
|
NONPLAT_CIL=`find /vendor/etc/selinux -name '*.cil' 2>/dev/null`
|
||||||
|
VENDOR_PLAT_VER=`cat /vendor/etc/selinux/plat_sepolicy_vers.txt`
|
||||||
|
MAPPING_CIL=/system/etc/selinux/mapping/${VENDOR_PLAT_VER}.cil
|
||||||
|
./magisk magisksecilc -M true -c $POLICY_VER -o sepolicy -f /dev/null $PLAT_CIL $NONPLAT_CIL $MAPPING_CIL
|
||||||
|
fi
|
||||||
|
[ -f sepolicy ] || abort_wrap "! Cannot get sepolicy"
|
||||||
|
|
||||||
|
# TODO: Patch dm-verity
|
||||||
|
|
||||||
|
cpio_add 750 init ./magiskinit
|
||||||
|
cpio_mkdir 000 overlay
|
||||||
|
cpio_add 750 overlay/init.magisk.rc init.magisk.rc
|
||||||
|
cpio_mkdir 750 overlay/sbin
|
||||||
|
cpio_add 755 overlay/sbin/magisk magisk
|
||||||
|
else
|
||||||
|
./magiskboot --cpio-patch ramdisk.cpio $KEEPVERITY $KEEPFORCEENCRYPT
|
||||||
|
|
||||||
|
cpio_extract sepolicy sepolicy
|
||||||
|
|
||||||
|
cpio_add 750 init.magisk.rc init.magisk.rc
|
||||||
|
cpio_add 755 sbin/magisk magisk
|
||||||
|
fi
|
||||||
|
|
||||||
mv init.magisk.rc.bak init.magisk.rc 2>/dev/null
|
mv init.magisk.rc.bak init.magisk.rc 2>/dev/null
|
||||||
cpio_add 755 sbin/magisk magisk
|
|
||||||
|
# sepolicy patches
|
||||||
|
./magisk magiskpolicy --load sepolicy --save sepolicy --minimal
|
||||||
|
$SKIP_INITRAMFS && cpio_add 644 overlay/sepolicy sepolicy || cpio_add 644 sepolicy sepolicy
|
||||||
|
rm -f sepolicy
|
||||||
|
|
||||||
# Create ramdisk backups
|
# Create ramdisk backups
|
||||||
./magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig
|
./magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig
|
||||||
@ -234,6 +265,11 @@ rm -f ramdisk.cpio.orig
|
|||||||
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
||||||
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
||||||
|
|
||||||
|
# skip_initramfs -> want_initramfs
|
||||||
|
./magiskboot --hexpatch kernel \
|
||||||
|
736B69705F696E697472616D6673 \
|
||||||
|
77616E745F696E697472616D6673
|
||||||
|
|
||||||
ui_print_wrap "- Repacking boot image"
|
ui_print_wrap "- Repacking boot image"
|
||||||
./magiskboot --repack "$BOOTIMAGE" || abort_wrap "! Unable to repack boot image!"
|
./magiskboot --repack "$BOOTIMAGE" || abort_wrap "! Unable to repack boot image!"
|
||||||
|
|
||||||
|
@ -49,13 +49,8 @@ ui_print "************************"
|
|||||||
ui_print "* Magisk v$MAGISK_VER Installer"
|
ui_print "* Magisk v$MAGISK_VER Installer"
|
||||||
ui_print "************************"
|
ui_print "************************"
|
||||||
|
|
||||||
ui_print "- Mounting /system, /vendor, /cache, /data"
|
is_mounted /data || mount /data
|
||||||
mount -o ro /system 2>/dev/null
|
mount_partitions
|
||||||
mount -o ro /vendor 2>/dev/null
|
|
||||||
mount /cache 2>/dev/null
|
|
||||||
mount /data 2>/dev/null
|
|
||||||
|
|
||||||
[ -f /system/build.prop ] || abort "! /system could not be mounted!"
|
|
||||||
|
|
||||||
# read override variables
|
# read override variables
|
||||||
getvar KEEPVERITY
|
getvar KEEPVERITY
|
||||||
|
@ -37,6 +37,36 @@ ui_print() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mount_partitions() {
|
||||||
|
# Check A/B slot
|
||||||
|
SLOT=`getprop ro.boot.slot_suffix`
|
||||||
|
[ -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
|
||||||
|
SYSTEMBLOCK=`find /dev/block -iname system$SLOT | head -n 1`
|
||||||
|
mount -t ext4 -o ro $SYSTEMBLOCK /system
|
||||||
|
fi
|
||||||
|
is_mounted /system || [ -f /system/build.prop ] || abort "! Cannot mount /system"
|
||||||
|
cat /proc/mounts | grep /dev/root >/dev/null && SKIP_INITRAMFS=true || SKIP_INITRAMFS=false
|
||||||
|
if [ -f /system/init.rc ]; then
|
||||||
|
SKIP_INITRAMFS=true
|
||||||
|
mkdir /system_root 2>/dev/null
|
||||||
|
mount --move /system /system_root
|
||||||
|
mount -o bind /system_root/system /system
|
||||||
|
fi
|
||||||
|
$SKIP_INITRAMFS && ui_print "- Device skip_initramfs detected"
|
||||||
|
if [ -L /system/vendor ]; then
|
||||||
|
# Seperate /vendor partition
|
||||||
|
is_mounted /vendor || mount -o ro /vendor 2>/dev/null
|
||||||
|
if ! is_mounted /vendor; then
|
||||||
|
VENDORBLOCK=`find /dev/block -iname vendor$SLOT | head -n 1`
|
||||||
|
mount -t ext4 -o ro $VENDORBLOCK /vendor
|
||||||
|
fi
|
||||||
|
is_mounted /vendor || abort "! Cannot mount /vendor"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
grep_prop() {
|
grep_prop() {
|
||||||
REGEX="s/^$1=//p"
|
REGEX="s/^$1=//p"
|
||||||
shift
|
shift
|
||||||
@ -58,10 +88,14 @@ getvar() {
|
|||||||
|
|
||||||
find_boot_image() {
|
find_boot_image() {
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
for BLOCK in boot_a kern-a android_boot kernel boot lnx; do
|
if [ ! -z $SLOT ]; then
|
||||||
BOOTIMAGE=`find /dev/block -iname $BLOCK | head -n 1` 2>/dev/null
|
BOOTIMAGE=`find /dev/block -iname boot$SLOT | head -n 1` 2>/dev/null
|
||||||
[ ! -z $BOOTIMAGE ] && break
|
else
|
||||||
done
|
for BLOCK in boot_a kern-a android_boot kernel boot lnx; do
|
||||||
|
BOOTIMAGE=`find /dev/block -iname $BLOCK | head -n 1` 2>/dev/null
|
||||||
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Recovery fallback
|
# Recovery fallback
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
@ -180,6 +214,7 @@ recovery_cleanup() {
|
|||||||
export LD_LIBRARY_PATH=$OLD_LD_PATH
|
export LD_LIBRARY_PATH=$OLD_LD_PATH
|
||||||
[ -z $OLD_PATH ] || export PATH=$OLD_PATH
|
[ -z $OLD_PATH ] || export PATH=$OLD_PATH
|
||||||
ui_print "- Unmounting partitions"
|
ui_print "- Unmounting partitions"
|
||||||
|
umount -l /system_root 2>/dev/null
|
||||||
umount -l /system 2>/dev/null
|
umount -l /system 2>/dev/null
|
||||||
umount -l /vendor 2>/dev/null
|
umount -l /vendor 2>/dev/null
|
||||||
umount -l /dev/random 2>/dev/null
|
umount -l /dev/random 2>/dev/null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user