Update scripts, MagiskSU now works fine

This commit is contained in:
topjohnwu 2017-04-16 02:49:01 +08:00
parent 8a2f0063d4
commit c079c598f2
4 changed files with 71 additions and 58 deletions

View File

@ -53,10 +53,14 @@ EXIT /B %ERRORLEVEL%
ECHO ************************ ECHO ************************
ECHO * Copying binaries ECHO * Copying binaries
ECHO ************************ ECHO ************************
CALL :mkcp libs\armeabi-v7a\* zip_static\arm CALL :mkcp libs\armeabi-v7a\magisk zip_static\arm
CALL :mkcp libs\arm64-v8a\* zip_static\arm64 CALL :mkcp libs\armeabi-v7a\magiskboot zip_static\arm
CALL :mkcp libs\x86\* zip_static\x86 CALL :mkcp libs\arm64-v8a\magisk zip_static\arm64
CALL :mkcp libs\x86_64\* zip_static\x64 CALL :mkcp libs\arm64-v8a\magiskboot zip_static\arm64
CALL :mkcp libs\x86\magisk zip_static\x86
CALL :mkcp libs\x86\magiskboot zip_static\x86
CALL :mkcp libs\x86_64\magisk zip_static\x64
CALL :mkcp libs\x86_64\magiskboot zip_static\x64
CALL :mkcp libs\armeabi-v7a\magiskboot uninstaller\arm CALL :mkcp libs\armeabi-v7a\magiskboot uninstaller\arm
CALL :mkcp libs\arm64-v8a\magiskboot uninstaller\arm64 CALL :mkcp libs\arm64-v8a\magiskboot uninstaller\arm64
CALL :mkcp libs\x86\magiskboot uninstaller\x86 CALL :mkcp libs\x86\magiskboot uninstaller\x86

View File

@ -55,13 +55,17 @@ build_bin() {
echo "************************" echo "************************"
echo "* Copying binaries" echo "* Copying binaries"
echo "************************" echo "************************"
mkcp "libs/armeabi-v7a/*" zip_static/arm mkcp libs/armeabi-v7a/magisk zip_static/arm
mkcp libs/armeabi-v7a/magiskboot zip_static/arm
mkcp libs/arm64-v8a/magisk zip_static/arm64
mkcp libs/arm64-v8a/magiskboot zip_static/arm64
mkcp libs/x86/magisk zip_static/x86
mkcp libs/x86/magiskboot zip_static/x86
mkcp libs/x86_64/magisk zip_static/x64
mkcp libs/x86_64/magiskboot zip_static/x64
mkcp libs/armeabi-v7a/magiskboot uninstaller/arm mkcp libs/armeabi-v7a/magiskboot uninstaller/arm
mkcp "libs/arm64-v8a/*" zip_static/arm64
mkcp libs/arm64-v8a/magiskboot uninstaller/arm64 mkcp libs/arm64-v8a/magiskboot uninstaller/arm64
mkcp "libs/x86/*" zip_static/x86
mkcp libs/x86/magiskboot uninstaller/x86 mkcp libs/x86/magiskboot uninstaller/x86
mkcp "libs/x86_64/*" zip_static/x64
mkcp libs/x86_64/magiskboot uninstaller/x64 mkcp libs/x86_64/magiskboot uninstaller/x64
} }

View File

@ -256,65 +256,69 @@ fi
# Environment # Environment
########################################################################################## ##########################################################################################
ui_print "- Constructing environment" # TODO: Environment
is_mounted /data && MAGISKBIN=/data/magisk || MAGISKBIN=/cache/data_bin # ui_print "- Constructing environment"
# Copy required files # is_mounted /data && MAGISKBIN=/data/magisk || MAGISKBIN=/cache/data_bin
rm -rf $MAGISKBIN 2>/dev/null
mkdir -p $MAGISKBIN
cp -af $BINDIR/busybox $BINDIR/magiskboot $BINDIR/magiskpolicy $COMMONDIR/magisk.apk \
$COMMONDIR/init.magisk.rc $COMMONDIR/custom_ramdisk_patch.sh $COMMONDIR/magic_mask.sh $MAGISKBIN
# Legacy support
ln -sf /data/magisk/magiskpolicy $MAGISKBIN/sepolicy-inject
chmod -R 755 $MAGISKBIN # # Copy required files
chcon -h u:object_r:system_file:s0 $MAGISKBIN $MAGISKBIN/* # rm -rf $MAGISKBIN 2>/dev/null
# mkdir -p $MAGISKBIN
# cp -af $BINDIR/busybox $BINDIR/magiskboot $BINDIR/magiskpolicy $COMMONDIR/magisk.apk \
# $COMMONDIR/init.magisk.rc $COMMONDIR/custom_ramdisk_patch.sh $COMMONDIR/magic_mask.sh $MAGISKBIN
# # Legacy support
# ln -sf /data/magisk/magiskpolicy $MAGISKBIN/sepolicy-inject
# Temporary busybox for installation # chmod -R 755 $MAGISKBIN
rm -rf $TMPDIR/busybox 2>/dev/null # chcon -h u:object_r:system_file:s0 $MAGISKBIN $MAGISKBIN/*
mkdir -p $TMPDIR/busybox
$BINDIR/busybox --install -s $TMPDIR/busybox # # Temporary busybox for installation
rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot # rm -rf $TMPDIR/busybox 2>/dev/null
PATH=$TMPDIR/busybox:$PATH # mkdir -p $TMPDIR/busybox
# $BINDIR/busybox --install -s $TMPDIR/busybox
# rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot
# PATH=$TMPDIR/busybox:$PATH
########################################################################################## ##########################################################################################
# Magisk Image # Magisk Image
########################################################################################## ##########################################################################################
# Fix SuperSU..... # TODO: Magisk Image
$BOOTMODE && $BINDIR/magiskpolicy --live "allow fsck * * *"
if (is_mounted /data); then # # Fix SuperSU.....
IMG=/data/magisk.img # $BOOTMODE && $BINDIR/magiskpolicy --live "allow fsck * * *"
else
IMG=/cache/magisk.img
ui_print "- Data unavailable, use cache workaround"
fi
if [ -f $IMG ]; then # if (is_mounted /data); then
ui_print "- $IMG detected!" # IMG=/data/magisk.img
else # else
ui_print "- Creating $IMG" # IMG=/cache/magisk.img
make_ext4fs -l 64M -a /magisk -S $COMMONDIR/file_contexts_image $IMG # ui_print "- Data unavailable, use cache workaround"
fi # fi
mount_image $IMG /magisk # if [ -f $IMG ]; then
if (! is_mounted /magisk); then # ui_print "- $IMG detected!"
ui_print "! Magisk image mount failed..." # else
exit 1 # ui_print "- Creating $IMG"
fi # make_ext4fs -l 64M -a /magisk -S $COMMONDIR/file_contexts_image $IMG
MAGISKLOOP=$LOOPDEVICE # fi
# Core folders and scripts # mount_image $IMG /magisk
mkdir -p $COREDIR/bin $COREDIR/props $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null # if (! is_mounted /magisk); then
cp -af $COMMONDIR/magiskhide/. $COREDIR/magiskhide # ui_print "! Magisk image mount failed..."
cp -af $BINDIR/resetprop $BINDIR/magiskhide $BINDIR/su $BINDIR/magiskpolicy $COREDIR/bin # exit 1
# Legacy support # fi
ln -sf $COREDIR/bin/resetprop $MAGISKBIN/resetprop # MAGISKLOOP=$LOOPDEVICE
chmod -R 755 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d # # Core folders and scripts
chown -R 0.0 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d # mkdir -p $COREDIR/bin $COREDIR/props $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null
# cp -af $COMMONDIR/magiskhide/. $COREDIR/magiskhide
# cp -af $BINDIR/resetprop $BINDIR/magiskhide $BINDIR/su $BINDIR/magiskpolicy $COREDIR/bin
# # Legacy support
# ln -sf $COREDIR/bin/resetprop $MAGISKBIN/resetprop
# chmod -R 755 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
# chown -R 0.0 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
########################################################################################## ##########################################################################################
# Unpack boot # Unpack boot
@ -445,7 +449,7 @@ else
# sepolicy patches # sepolicy patches
cpio_extract sepolicy sepolicy cpio_extract sepolicy sepolicy
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magiskpolicy --load sepolicy --save sepolicy --minimal LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magisk magiskpolicy --load sepolicy --save sepolicy --minimal
cpio_add 644 sepolicy sepolicy cpio_add 644 sepolicy sepolicy
# Add new items # Add new items
@ -454,7 +458,8 @@ else
[ ! -z $SHA1 ] && echo "# STOCKSHA1=$SHA1" >> $COMMONDIR/init.magisk.rc [ ! -z $SHA1 ] && echo "# STOCKSHA1=$SHA1" >> $COMMONDIR/init.magisk.rc
cpio_add 750 init.magisk.rc $COMMONDIR/init.magisk.rc cpio_add 750 init.magisk.rc $COMMONDIR/init.magisk.rc
cpio_add 750 sbin/magic_mask.sh $COMMONDIR/magic_mask.sh # cpio_add 750 sbin/magic_mask.sh $COMMONDIR/magic_mask.sh
cpio_add 755 sbin/magisk $BINDIR/magisk
# Create ramdisk backups # Create ramdisk backups
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/magiskboot --cpio-backup ramdisk.cpio ramdisk.cpio.orig

View File

@ -16,19 +16,19 @@ on property:magisk.restart_pfsd=1
# Services # Services
# launch post-fs script # launch post-fs script
service magisk_pfs /sbin/magic_mask.sh post-fs service magisk_pfs /sbin/magisk --post-fs
user root user root
seclabel u:r:su:s0 seclabel u:r:su:s0
oneshot oneshot
# launch post-fs-data script # launch post-fs-data script
service magisk_pfsd /sbin/magic_mask.sh post-fs-data service magisk_pfsd /sbin/magisk --post-fs-data
user root user root
seclabel u:r:su:s0 seclabel u:r:su:s0
oneshot oneshot
# launch late_start script # launch late_start script
service magisk_service /sbin/magic_mask.sh service service magisk_service /sbin/magisk --service
class late_start class late_start
user root user root
seclabel u:r:su:s0 seclabel u:r:su:s0