Always cleanup on failure
This commit is contained in:
@@ -23,22 +23,29 @@ ui_print() {
|
||||
|
||||
cleanup() {
|
||||
ui_print "Cleaning up files"
|
||||
cd ../
|
||||
rm -rf system
|
||||
rm -rf bin
|
||||
rm toybox
|
||||
rm -rf $TMP/system
|
||||
rm -rf $TMP/bin
|
||||
rm $TMP/toybox
|
||||
|
||||
ui_print "Unmounting partitions"
|
||||
umount -l "$SYSTEM_MNT"
|
||||
umount -l /product || true
|
||||
}
|
||||
|
||||
error_no_space() {
|
||||
ui_print "Not enough space for GApps! Aborting"
|
||||
error() {
|
||||
ui_print "$1"
|
||||
cleanup
|
||||
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() {
|
||||
grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s [:blank:] ' ' | cut -d' ' -f1
|
||||
}
|
||||
@@ -143,8 +150,7 @@ mkdir -p "$SYSTEM_MNT" || true
|
||||
if mount -o rw "$SYSTEM_BLOCK" "$SYSTEM_MNT"; then
|
||||
ui_print "$SYSTEM_MNT mounted"
|
||||
else
|
||||
ui_print "Could not mount $SYSTEM_MNT! Aborting"
|
||||
exit 1
|
||||
error_mounting "$SYSTEM_MNT"
|
||||
fi
|
||||
SYSTEM_OUT="${SYSTEM_MNT}/system"
|
||||
|
||||
@@ -160,8 +166,7 @@ if [ -n "$PRODUCT_BLOCK" ]; then
|
||||
if mount -o rw "$PRODUCT_BLOCK" /product; then
|
||||
ui_print "/product mounted"
|
||||
else
|
||||
ui_print "Could not mount /product"
|
||||
exit 1
|
||||
error_mounting "/product"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user