Always cleanup on failure
This commit is contained in:
@@ -23,10 +23,9 @@ ui_print() {
|
|||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
ui_print "Cleaning up files"
|
ui_print "Cleaning up files"
|
||||||
cd ../
|
rm -rf $TMP/system
|
||||||
rm -rf system
|
rm -rf $TMP/bin
|
||||||
rm -rf bin
|
rm $TMP/toybox
|
||||||
rm toybox
|
|
||||||
|
|
||||||
ui_print "Unmounting partitions"
|
ui_print "Unmounting partitions"
|
||||||
umount -l "$SYSTEM_MNT"
|
umount -l "$SYSTEM_MNT"
|
||||||
@@ -34,12 +33,20 @@ cleanup() {
|
|||||||
umount -l /system_ext || true
|
umount -l /system_ext || true
|
||||||
}
|
}
|
||||||
|
|
||||||
error_no_space() {
|
error() {
|
||||||
ui_print "Not enough space for GApps! Aborting"
|
ui_print "$1"
|
||||||
cleanup
|
cleanup
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_no_space() {
|
||||||
|
error "Not enough space for GApps! Aborting"
|
||||||
|
}
|
||||||
|
|
||||||
|
error_mounting() {
|
||||||
|
error "Could not mount $1! Aborting"
|
||||||
|
}
|
||||||
|
|
||||||
get_block_for_mount_point() {
|
get_block_for_mount_point() {
|
||||||
grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s [:blank:] ' ' | cut -d' ' -f1
|
grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s [:blank:] ' ' | cut -d' ' -f1
|
||||||
}
|
}
|
||||||
@@ -170,8 +177,7 @@ mkdir -p "$SYSTEM_MNT" || true
|
|||||||
if mount -o rw "$SYSTEM_BLOCK" "$SYSTEM_MNT"; then
|
if mount -o rw "$SYSTEM_BLOCK" "$SYSTEM_MNT"; then
|
||||||
ui_print "$SYSTEM_MNT mounted"
|
ui_print "$SYSTEM_MNT mounted"
|
||||||
else
|
else
|
||||||
ui_print "Could not mount $SYSTEM_MNT! Aborting"
|
error_mounting "$SYSTEM_MNT"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
SYSTEM_OUT="${SYSTEM_MNT}/system"
|
SYSTEM_OUT="${SYSTEM_MNT}/system"
|
||||||
|
|
||||||
@@ -190,8 +196,7 @@ if [ -n "$PRODUCT_BLOCK" ]; then
|
|||||||
if mount -o rw "$PRODUCT_BLOCK" /product; then
|
if mount -o rw "$PRODUCT_BLOCK" /product; then
|
||||||
ui_print "/product mounted"
|
ui_print "/product mounted"
|
||||||
else
|
else
|
||||||
ui_print "Could not mount /product"
|
error_mounting "/product"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$SYSTEM_EXT_BLOCK" ]; then
|
if [ -n "$SYSTEM_EXT_BLOCK" ]; then
|
||||||
@@ -199,8 +204,7 @@ if [ -n "$SYSTEM_EXT_BLOCK" ]; then
|
|||||||
if mount -o rw "$SYSTEM_EXT_BLOCK" /system_ext; then
|
if mount -o rw "$SYSTEM_EXT_BLOCK" /system_ext; then
|
||||||
ui_print "/system_ext mounted"
|
ui_print "/system_ext mounted"
|
||||||
else
|
else
|
||||||
ui_print "Could not mount /system_ext"
|
error_mounting "/system_ext"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user