Install one single ABI in ramdisk

This commit is contained in:
topjohnwu
2024-03-31 22:01:22 -07:00
parent 30bf5c8448
commit fb5ee86615
10 changed files with 72 additions and 89 deletions

View File

@@ -52,12 +52,18 @@ unzip -oj magisk.apk 'assets/util_functions.sh' 'assets/stub.apk'
api_level_arch_detect
unzip -oj magisk.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so"
unzip -oj magisk.apk "lib/$ABI/*" -x "lib/$ABI/libbusybox.so"
for file in lib*.so; do
chmod 755 $file
mv "$file" "${file:3:${#file}-6}"
done
if $IS64BIT; then
unzip -oj magisk.apk "lib/$ABI32/libmagisk.so"
mv libmagisk.so magisk32
chmod 755 magisk32
fi
# Stop zygote (and previous setup if exists)
magisk --stop 2>/dev/null
stop
@@ -109,8 +115,9 @@ else
# Android Q+ without sbin
MAGISKTMP=/debug_ramdisk
# If a file name 'magisk' is in current directory, mount will fail
rm -f magisk
mv magisk magisk.tmp
mount -t tmpfs -o 'mode=0755' magisk /debug_ramdisk
mv magisk.tmp magisk
fi
# Magisk stuff
@@ -120,7 +127,7 @@ mkdir $NVBASE/modules 2>/dev/null
mkdir $NVBASE/post-fs-data.d 2>/dev/null
mkdir $NVBASE/service.d 2>/dev/null
for file in magisk32 magisk64 magiskpolicy stub.apk; do
for file in magisk magisk32 magiskpolicy stub.apk; do
chmod 755 ./$file
cp -af ./$file $MAGISKTMP/$file
cp -af ./$file $MAGISKBIN/$file
@@ -129,11 +136,6 @@ cp -af ./magiskboot $MAGISKBIN/magiskboot
cp -af ./magiskinit $MAGISKBIN/magiskinit
cp -af ./busybox $MAGISKBIN/busybox
if $IS64BIT; then
ln -s ./magisk64 $MAGISKTMP/magisk
else
ln -s ./magisk32 $MAGISKTMP/magisk
fi
ln -s ./magisk $MAGISKTMP/su
ln -s ./magisk $MAGISKTMP/resetprop
ln -s ./magiskpolicy $MAGISKTMP/supolicy

View File

@@ -43,7 +43,7 @@ unzip -oj magisk.apk 'assets/util_functions.sh' 'assets/stub.apk'
api_level_arch_detect
unzip -oj magisk.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so"
unzip -oj magisk.apk "lib/$ABI/*" -x "lib/$ABI/libbusybox.so"
for file in lib*.so; do
chmod 755 $file
mv "$file" "${file:3:${#file}-6}"
@@ -57,34 +57,20 @@ export KEEPFORCEENCRYPT=true
echo "KEEPVERITY=$KEEPVERITY" > config
echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
if [ -f magisk64 ]; then
echo "PREINITDEVICE=$(./magisk64 --preinit-device)" >> config
else
echo "PREINITDEVICE=$(./magisk32 --preinit-device)" >> config
fi
echo "PREINITDEVICE=$(./magisk --preinit-device)" >> config
# For API 28, we also patch advancedFeatures.ini to disable SAR
# Manually override skip_initramfs by setting RECOVERYMODE=true
[ $API = "28" ] && echo 'RECOVERYMODE=true' >> config
cat config
SKIP32="#"
SKIP64="#"
if [ -f magisk64 ]; then
./magiskboot compress=xz magisk64 magisk64.xz
unset SKIP64
fi
if [ -e "/system/bin/linker" ]; then
./magiskboot compress=xz magisk32 magisk32.xz
unset SKIP32
fi
./magiskboot compress=xz magisk magisk.xz
./magiskboot compress=xz stub.apk stub.xz
./magiskboot cpio ramdisk.cpio \
"add 0750 init magiskinit" \
"mkdir 0750 overlay.d" \
"mkdir 0750 overlay.d/sbin" \
"$SKIP32 add 0644 overlay.d/sbin/magisk32.xz magisk32.xz" \
"$SKIP64 add 0644 overlay.d/sbin/magisk64.xz magisk64.xz" \
"add 0644 overlay.d/sbin/magisk.xz magisk.xz" \
"add 0644 overlay.d/sbin/stub.xz stub.xz" \
"patch" \
"backup ramdisk.cpio.orig" \

View File

@@ -18,7 +18,7 @@
# util_functions.sh script A script which hosts all functions required
# for this script to work properly.
# magiskinit binary The binary to replace /init.
# magisk(32/64) binary The magisk binaries.
# magisk binary The magisk binary.
# magiskboot binary A tool to manipulate boot images.
# stub.apk binary The stub Magisk app to embed into ramdisk.
# chromeos folder This folder includes the utility and keys to sign
@@ -156,19 +156,10 @@ fi
ui_print "- Patching ramdisk"
$BOOTMODE && [ -z "$PREINITDEVICE" ] && PREINITDEVICE=$(./magisk --preinit-device)
# Compress to save precious ramdisk space
SKIP32="#"
SKIP64="#"
if [ -f magisk64 ]; then
$BOOTMODE && [ -z "$PREINITDEVICE" ] && PREINITDEVICE=$(./magisk64 --preinit-device)
./magiskboot compress=xz magisk64 magisk64.xz
unset SKIP64
fi
if [ -f magisk32 ]; then
$BOOTMODE && [ -z "$PREINITDEVICE" ] && PREINITDEVICE=$(./magisk32 --preinit-device)
./magiskboot compress=xz magisk32 magisk32.xz
unset SKIP32
fi
./magiskboot compress=xz magisk magisk.xz
./magiskboot compress=xz stub.apk stub.xz
echo "KEEPVERITY=$KEEPVERITY" > config
@@ -184,8 +175,7 @@ fi
"add 0750 init magiskinit" \
"mkdir 0750 overlay.d" \
"mkdir 0750 overlay.d/sbin" \
"$SKIP32 add 0644 overlay.d/sbin/magisk32.xz magisk32.xz" \
"$SKIP64 add 0644 overlay.d/sbin/magisk64.xz magisk64.xz" \
"add 0644 overlay.d/sbin/magisk.xz magisk.xz" \
"add 0644 overlay.d/sbin/stub.xz stub.xz" \
"patch" \
"$SKIP_BACKUP backup ramdisk.cpio.orig" \

View File

@@ -55,7 +55,7 @@ BINDIR=$INSTALLER/lib/$ABI
cd $BINDIR
for file in lib*.so; do mv "$file" "${file:3:${#file}-6}"; done
cd /
cp -af $INSTALLER/lib/$ABI32/libmagisk32.so $BINDIR/magisk32 2>/dev/null
cp -af $INSTALLER/lib/$ABI32/libmagisk.so $BINDIR/magisk32 2>/dev/null
# Check if system root is installed and remove
$BOOTMODE || remove_system_su