Fix #19 uninstaller issues
This commit is contained in:
parent
1e3586621b
commit
cdb8ee3946
@ -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,7 +238,7 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user