mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-03-28 11:32:15 +00:00
Fix shared library linking error
This commit is contained in:
parent
0b4baad78b
commit
4e801788d7
@ -29,7 +29,7 @@ cd `dirname $1`
|
|||||||
BOOTIMAGE="`pwd`/`basename $1`"
|
BOOTIMAGE="`pwd`/`basename $1`"
|
||||||
cd "$CWD"
|
cd "$CWD"
|
||||||
|
|
||||||
if [ -z $BOOTIMAGE ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
ui_print_wrap "This script requires a boot image as a parameter"
|
ui_print_wrap "This script requires a boot image as a parameter"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -59,17 +59,17 @@ grep_prop() {
|
|||||||
|
|
||||||
# --cpio-add <incpio> <mode> <entry> <infile>
|
# --cpio-add <incpio> <mode> <entry> <infile>
|
||||||
cpio_add() {
|
cpio_add() {
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-add ramdisk.cpio $1 $2 $3
|
./magiskboot --cpio-add ramdisk.cpio $1 $2 $3
|
||||||
}
|
}
|
||||||
|
|
||||||
# --cpio-extract <incpio> <entry> <outfile>
|
# --cpio-extract <incpio> <entry> <outfile>
|
||||||
cpio_extract() {
|
cpio_extract() {
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-extract ramdisk.cpio $1 $2
|
./magiskboot --cpio-extract ramdisk.cpio $1 $2
|
||||||
}
|
}
|
||||||
|
|
||||||
# --cpio-mkdir <incpio> <mode> <entry>
|
# --cpio-mkdir <incpio> <mode> <entry>
|
||||||
cpio_mkdir() {
|
cpio_mkdir() {
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-mkdir ramdisk.cpio $1 $2
|
./magiskboot --cpio-mkdir ramdisk.cpio $1 $2
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@ -80,11 +80,8 @@ cpio_mkdir() {
|
|||||||
[ -z $SOURCEDMODE ] && cd "`dirname "${BASH_SOURCE:-$0}"`"
|
[ -z $SOURCEDMODE ] && cd "`dirname "${BASH_SOURCE:-$0}"`"
|
||||||
chmod +x ./*
|
chmod +x ./*
|
||||||
|
|
||||||
# Detect ARCH
|
|
||||||
[ -d /system/lib64 ] && SYSTEMLIB=/system/lib64 || SYSTEMLIB=/system/lib
|
|
||||||
|
|
||||||
ui_print_wrap "- Unpacking boot image"
|
ui_print_wrap "- Unpacking boot image"
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --unpack $BOOTIMAGE
|
./magiskboot --unpack "$BOOTIMAGE"
|
||||||
|
|
||||||
case $? in
|
case $? in
|
||||||
1 )
|
1 )
|
||||||
@ -108,28 +105,28 @@ esac
|
|||||||
|
|
||||||
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
|
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
|
||||||
ui_print_wrap "- Checking ramdisk status"
|
ui_print_wrap "- Checking ramdisk status"
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-test ramdisk.cpio
|
./magiskboot --cpio-test ramdisk.cpio
|
||||||
case $? in
|
case $? in
|
||||||
0 ) # Stock boot
|
0 ) # Stock boot
|
||||||
ui_print_wrap "- Stock boot image detected!"
|
ui_print_wrap "- Stock boot image detected!"
|
||||||
ui_print_wrap "- Backing up stock boot image"
|
ui_print_wrap "- Backing up stock boot image"
|
||||||
SHA1=`LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --sha1 $BOOTIMAGE | tail -n 1`
|
SHA1=`./magiskboot --sha1 "$BOOTIMAGE" | tail -n 1`
|
||||||
STOCKDUMP=stock_boot_${SHA1}.img
|
STOCKDUMP=stock_boot_${SHA1}.img
|
||||||
dd if=$BOOTIMAGE of=$STOCKDUMP
|
dd if="$BOOTIMAGE" of=$STOCKDUMP
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --compress $STOCKDUMP
|
./magiskboot --compress $STOCKDUMP
|
||||||
cp -af ramdisk.cpio ramdisk.cpio.orig
|
cp -af ramdisk.cpio ramdisk.cpio.orig
|
||||||
;;
|
;;
|
||||||
1 ) # Magisk patched
|
1 ) # Magisk patched
|
||||||
ui_print_wrap "- Magisk patched image detected!"
|
ui_print_wrap "- Magisk patched image detected!"
|
||||||
# Find SHA1 of stock boot image
|
# Find SHA1 of stock boot image
|
||||||
if [ -z $SHA1 ]; then
|
if [ -z $SHA1 ]; then
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-extract ramdisk.cpio init.magisk.rc init.magisk.rc.old
|
./magiskboot --cpio-extract ramdisk.cpio init.magisk.rc init.magisk.rc.old
|
||||||
SHA1=`grep_prop "# STOCKSHA1" init.magisk.rc.old`
|
SHA1=`grep_prop "# STOCKSHA1" init.magisk.rc.old`
|
||||||
rm -f init.magisk.rc.old
|
rm -f init.magisk.rc.old
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OK=false
|
OK=false
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-restore ramdisk.cpio
|
./magiskboot --cpio-restore ramdisk.cpio
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
ui_print_wrap "- Ramdisk restored from internal backup"
|
ui_print_wrap "- Ramdisk restored from internal backup"
|
||||||
OK=true
|
OK=true
|
||||||
@ -141,8 +138,8 @@ case $? in
|
|||||||
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
||||||
if [ -f ${STOCKDUMP}.gz ]; then
|
if [ -f ${STOCKDUMP}.gz ]; then
|
||||||
ui_print_wrap "- Stock boot image backup found"
|
ui_print_wrap "- Stock boot image backup found"
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --decompress ${STOCKDUMP}.gz stock_boot.img
|
./magiskboot --decompress ${STOCKDUMP}.gz stock_boot.img
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --unpack stock_boot.img
|
./magiskboot --unpack stock_boot.img
|
||||||
rm -f stock_boot.img
|
rm -f stock_boot.img
|
||||||
OK=true
|
OK=true
|
||||||
fi
|
fi
|
||||||
@ -168,8 +165,8 @@ esac
|
|||||||
ui_print_wrap "- Patching ramdisk"
|
ui_print_wrap "- Patching ramdisk"
|
||||||
|
|
||||||
# The common patches
|
# The common patches
|
||||||
$KEEPVERITY || LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-patch-dmverity ramdisk.cpio
|
$KEEPVERITY || ./magiskboot --cpio-patch-dmverity ramdisk.cpio
|
||||||
$KEEPFORCEENCRYPT || LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-patch-forceencrypt ramdisk.cpio
|
$KEEPFORCEENCRYPT || ./magiskboot --cpio-patch-forceencrypt ramdisk.cpio
|
||||||
|
|
||||||
# Add magisk entrypoint
|
# Add magisk entrypoint
|
||||||
cpio_extract init.rc init.rc
|
cpio_extract init.rc init.rc
|
||||||
@ -180,7 +177,7 @@ rm -f init.rc
|
|||||||
|
|
||||||
# sepolicy patches
|
# sepolicy patches
|
||||||
cpio_extract sepolicy sepolicy
|
cpio_extract sepolicy sepolicy
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magisk magiskpolicy --load sepolicy --save sepolicy --minimal
|
./magisk magiskpolicy --load sepolicy --save sepolicy --minimal
|
||||||
cpio_add 644 sepolicy sepolicy
|
cpio_add 644 sepolicy sepolicy
|
||||||
rm -f sepolicy
|
rm -f sepolicy
|
||||||
|
|
||||||
@ -194,7 +191,7 @@ cpio_add 750 init.magisk.rc init.magisk.rc
|
|||||||
cpio_add 755 sbin/magisk magisk
|
cpio_add 755 sbin/magisk magisk
|
||||||
|
|
||||||
# Create ramdisk backups
|
# Create ramdisk backups
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig
|
./magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig
|
||||||
|
|
||||||
rm -f ramdisk.cpio.orig
|
rm -f ramdisk.cpio.orig
|
||||||
|
|
||||||
@ -205,16 +202,16 @@ rm -f ramdisk.cpio.orig
|
|||||||
# Hexpatches
|
# Hexpatches
|
||||||
|
|
||||||
# Remove Samsung RKP in stock kernel
|
# Remove Samsung RKP in stock kernel
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --hexpatch kernel \
|
./magiskboot --hexpatch kernel \
|
||||||
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
||||||
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
||||||
|
|
||||||
ui_print_wrap "- Repacking boot image"
|
ui_print_wrap "- Repacking boot image"
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --repack $BOOTIMAGE
|
./magiskboot --repack "$BOOTIMAGE"
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
ui_print_wrap "! Unable to repack boot image!"
|
ui_print_wrap "! Unable to repack boot image!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB ./magiskboot --cleanup
|
./magiskboot --cleanup
|
||||||
|
@ -11,16 +11,15 @@
|
|||||||
|
|
||||||
# Detect whether in boot mode
|
# Detect whether in boot mode
|
||||||
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
||||||
$BOOTMODE || ps -A | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
||||||
|
|
||||||
# This path should work in any cases
|
# This path should work in any cases
|
||||||
TMPDIR=/dev/tmp
|
TMPDIR=/dev/tmp
|
||||||
|
|
||||||
INSTALLER=$TMPDIR/magisk
|
INSTALLER=$TMPDIR/magisk
|
||||||
COMMONDIR=$INSTALLER/common
|
COMMONDIR=$INSTALLER/common
|
||||||
BOOTTMP=$TMPDIR/boottmp
|
|
||||||
COREDIR=/magisk/.core
|
|
||||||
CHROMEDIR=$INSTALLER/chromeos
|
CHROMEDIR=$INSTALLER/chromeos
|
||||||
|
COREDIR=/magisk/.core
|
||||||
|
|
||||||
# Default permissions
|
# Default permissions
|
||||||
umask 022
|
umask 022
|
||||||
@ -81,16 +80,19 @@ getvar() {
|
|||||||
|
|
||||||
find_boot_image() {
|
find_boot_image() {
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
for PARTITION in kern-a KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX; do
|
for PARTITION in kern-a android_boot kernel boot lnx; do
|
||||||
BOOTIMAGE=`readlink /dev/block/by-name/$PARTITION || readlink /dev/block/platform/*/by-name/$PARTITION || readlink /dev/block/platform/*/*/by-name/$PARTITION`
|
BOOTIMAGE=`find /dev -iname "$PARTITION"`
|
||||||
if [ ! -z "$BOOTIMAGE" ]; then break; fi
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
# Recovery fallback
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
FSTAB="/etc/recovery.fstab"
|
for FSTAB in /etc/*fstab*; do
|
||||||
[ ! -f "$FSTAB" ] && FSTAB="/etc/recovery.fstab.bak"
|
BOOTIMAGE=`grep -E '\b/boot\b' $FSTAB | grep -oE '/dev/[a-zA-Z0-9_./-]*'`
|
||||||
[ -f "$FSTAB" ] && BOOTIMAGE=`grep -E '\b/boot\b' "$FSTAB" | grep -oE '/dev/[a-zA-Z0-9_./-]*'`
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
[ -L "$BOOTIMAGE" ] && BOOTIMAGE=`readlink $BOOTIMAGE`
|
||||||
}
|
}
|
||||||
|
|
||||||
is_mounted() {
|
is_mounted() {
|
||||||
@ -194,6 +196,12 @@ if [ ! -f '/system/build.prop' ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Prefer binaries and libs in /system
|
||||||
|
[ -e /vendor ] || ln -s /system/vendor /vendor
|
||||||
|
export PATH=/system/bin:/system/xbin:/vendor/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=/system/lib:/vendor/lib:/sbin
|
||||||
|
[ -d /system/lib64 ] && export LD_LIBRARY_PATH=/system/lib64:/vendor/lib64:/sbin
|
||||||
|
|
||||||
# read override variables
|
# read override variables
|
||||||
getvar KEEPVERITY
|
getvar KEEPVERITY
|
||||||
getvar KEEPFORCEENCRYPT
|
getvar KEEPFORCEENCRYPT
|
||||||
@ -295,23 +303,23 @@ ui_print "- Found Boot Image: $BOOTIMAGE"
|
|||||||
|
|
||||||
# Update our previous backup to new format if exists
|
# Update our previous backup to new format if exists
|
||||||
if [ -f /data/stock_boot.img ]; then
|
if [ -f /data/stock_boot.img ]; then
|
||||||
SHA1=`LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magiskboot --sha1 /data/stock_boot.img | tail -n 1`
|
SHA1=`$BINDIR/magiskboot --sha1 /data/stock_boot.img | tail -n 1`
|
||||||
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
||||||
mv /data/stock_boot.img $STOCKDUMP
|
mv /data/stock_boot.img $STOCKDUMP
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magiskboot --compress $STOCKDUMP
|
$BINDIR/magiskboot --compress $STOCKDUMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SOURCEDMODE=true
|
SOURCEDMODE=true
|
||||||
cd $MAGISKBIN
|
cd $MAGISKBIN
|
||||||
|
|
||||||
# Source the boot patcher
|
# Source the boot patcher
|
||||||
. $COMMONDIR/boot_patch.sh $BOOTIMAGE
|
. $COMMONDIR/boot_patch.sh "$BOOTIMAGE"
|
||||||
|
|
||||||
# Sign chromeos boot
|
# Sign chromeos boot
|
||||||
if [ -f chromeos ]; then
|
if [ -f chromeos ]; then
|
||||||
echo > empty
|
echo > empty
|
||||||
|
|
||||||
LD_LIBRARY_PATH=$SYSTEMLIB $CHROMEDIR/futility vbutil_kernel --pack new-boot.img.signed \
|
$CHROMEDIR/futility vbutil_kernel --pack new-boot.img.signed \
|
||||||
--keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk \
|
--keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk \
|
||||||
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
||||||
|
|
||||||
@ -320,15 +328,15 @@ if [ -f chromeos ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if is_mounted /data; then
|
if is_mounted /data; then
|
||||||
rm -f /data/stock_boot*
|
rm -f /data/stock_boot* 2>/dev/null
|
||||||
mv stock_boot* /data
|
mv stock_boot* /data 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "- Flashing new boot image"
|
ui_print "- Flashing new boot image"
|
||||||
if [ -L $BOOTIMAGE ]; then
|
if [ -L "$BOOTIMAGE" ]; then
|
||||||
dd if=new-boot.img of=$BOOTIMAGE bs=4096
|
dd if=new-boot.img of="$BOOTIMAGE" bs=4096
|
||||||
else
|
else
|
||||||
cat new-boot.img /dev/zero | dd of=$BOOTIMAGE bs=4096
|
cat new-boot.img /dev/zero | dd of="$BOOTIMAGE" bs=4096
|
||||||
fi
|
fi
|
||||||
rm -f new-boot.img
|
rm -f new-boot.img
|
||||||
|
|
||||||
@ -339,7 +347,7 @@ if ! $BOOTMODE; then
|
|||||||
umount /magisk
|
umount /magisk
|
||||||
losetup -d $MAGISKLOOP 2>/dev/null
|
losetup -d $MAGISKLOOP 2>/dev/null
|
||||||
rmdir /magisk
|
rmdir /magisk
|
||||||
umount /system
|
umount -l /system
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "- Done"
|
ui_print "- Done"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user