1
mirror of https://github.com/topjohnwu/Magisk synced 2024-11-13 20:54:12 +01:00

Fix #19 uninstaller issues

This commit is contained in:
topjohnwu 2016-12-08 01:24:27 -08:00
parent 1e3586621b
commit cdb8ee3946

View File

@ -10,6 +10,12 @@
INSTALLER=/tmp/uninstall
# Boot Image Variables
CHROMEDIR=$INSTALLER/chromeos
NEWBOOT=$TMPDIR/boottmp/new-boot.img
UNPACKDIR=$TMPDIR/boottmp/bootunpack
RAMDISK=$TMPDIR/boottmp/ramdisk
# Default permissions
umask 022
@ -73,7 +79,7 @@ find_boot_image() {
if [ -z "$BOOTIMAGE" ]; then
FSTAB="/etc/recovery.fstab"
[ ! -f "$FSTAB" ] && FSTAB="/etc/recovery.fstab.bak"
[ -f "$FSTAB" ] 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_./-]*'`
fi
}
@ -101,7 +107,7 @@ unpack_boot() {
mkdir -p $UNPACKDIR
mkdir -p $RAMDISK
cd $UNPACKDIR
$BINDIR/bootimgtools --extract $1
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/bootimgtools --extract $1
cd $RAMDISK
gunzip -c < $UNPACKDIR/ramdisk.gz | cpio -i
@ -111,11 +117,11 @@ repack_boot() {
cd $RAMDISK
find . | cpio -o -H newc 2>/dev/null | gzip -9 > $UNPACKDIR/ramdisk.gz
cd $UNPACKDIR
$BINDIR/bootimgtools --repack $ORIGBOOT
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/bootimgtools --repack $ORIGBOOT
if [ -f chromeos ]; then
echo " " > config
echo " " > bootloader
$CHROMEDIR/futility vbutil_kernel --pack new-boot.img.signed --keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk --version 1 --vmlinuz new-boot.img --config config --arch arm --bootloader bootloader --flags 0x1
LD_LIBRARY_PATH=$SYSTEMLIB $CHROMEDIR/futility vbutil_kernel --pack new-boot.img.signed --keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk --version 1 --vmlinuz new-boot.img --config config --arch arm --bootloader bootloader --flags 0x1
rm -f new-boot.img
mv new-boot.img.signed new-boot.img
fi
@ -132,11 +138,6 @@ revert_boot() {
rm -rf $TMPDIR/boottmp 2>/dev/null
mkdir -p $TMPDIR/boottmp
CHROMEDIR=$INSTALLER/chromeos
NEWBOOT=$TMPDIR/boottmp/new-boot.img
UNPACKDIR=$TMPDIR/boottmp/bootunpack
RAMDISK=$TMPDIR/boottmp/ramdisk
ORIGBOOT=$BOOTIMAGE
ui_print "- Unpacking boot image"
@ -145,8 +146,7 @@ revert_boot() {
if [ -d ".backup" ]; then
ui_print "- Restoring ramdisk with backup"
cp -af .backup/. .
rm -rf magisk init.magisk.rc sbin/magic_mask.sh 2>/dev/null
rm -rf .backup
rm -rf magisk init.magisk.rc sbin/magic_mask.sh .backup 2>/dev/null
else
ui_print "! No ramdisk backup found"
ui_print "! Unable to revert completely"
@ -205,6 +205,9 @@ ui_print "- Device platform: $ARCH"
BINDIR=$INSTALLER/$ARCH
chmod -R 755 $CHROMEDIR/futility $BINDIR
SYSTEMLIB=/system/lib
($IS64BIT) && SYSTEMLIB=/system/lib64
find_boot_image
if [ -z "$BOOTIMAGE" ]; then
ui_print "! Unable to detect boot image"
@ -215,7 +218,10 @@ fi
# Detection all done, start installing
##########################################################################################
ui_print "- Found Boot Image: $BOOTIMAGE"
if (is_mounted /data); then
PATH=/data/busybox:$PATH
cp -af /data/stock_boot_*.gz /data/stock_boot.img.gz 2>/dev/null
gzip -d /data/stock_boot.img.gz 2>/dev/null
rm -rf /data/stock_boot.img.gz 2>/dev/null
@ -232,13 +238,13 @@ if (is_mounted /data); then
/data/Magisk.apk /data/magisk.img /data/magisk_merge.img \
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh 2>/dev/null
else
ui_print "! Data unavalible"
ui_print "! Data unavailable"
ui_print "! Impossible to restore original boot image"
ui_print "! Try using ramdisk backup"
revert_boot
ui_print "- Removing Magisk files"
rm -rf /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log \
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock 2>/dev/null
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock 2>/dev/null
ui_print "*****************************************"
ui_print " Magisk is not fully removed yet "
ui_print " Please manually remove /data/magisk.img "