update-binary: refactor into cleanup()

This commit is contained in:
FriendlyNeighborhoodShane 2022-08-14 20:34:13 +05:30
parent 48e4d058f3
commit 7c40dd091c

View File

@ -48,18 +48,21 @@ file_getprop() {
grep "^$2" "$1" | head -n1 | select_word 1 | cut -d= -f2; grep "^$2" "$1" | head -n1 | select_word 1 | cut -d= -f2;
} }
cleanup() {
rm -rf "$filedir" "$bbdir";
$bootmode || {
if [ "$sysroot" ]; then umount "$sysroot"; else umount "/system"; fi;
}
sync;
}
abort() { abort() {
ui_print " "; ui_print " ";
ui_print "!!! FATAL ERROR: $1"; ui_print "!!! FATAL ERROR: $1";
ui_print " "; ui_print " ";
ui_print "Stopping installation and Uninstalling..."; ui_print "Stopping installation and Uninstalling...";
uninstall_pack; uninstall_pack;
[ -d "$filedir" ] && rm -rf "$filedir"; cleanup;
[ -d "$bbdir" ] && rm -rf "$bbdir";
$bootmode || {
if [ "$sysroot" ]; then umount "/$sysroot"; else umount "/system"; fi;
}
sync;
ui_print " "; ui_print " ";
ui_print "Installation failed!"; ui_print "Installation failed!";
ui_print " "; ui_print " ";
@ -551,12 +554,7 @@ fi;
ui_print " "; ui_print " ";
ui_print "Unmounting..."; ui_print "Unmounting...";
$bootmode || { cleanup;
if [ "$sysroot" ]; then umount "/$sysroot"; else umount /system; fi;
}
rm -rf "$filedir";
[ -d "$bbdir" ] && rm -rf "$bbdir";
sync;
ui_print " "; ui_print " ";
ui_print "Done!"; ui_print "Done!";