VERSION_FILE="$FOTA_UPDATE_PREFIX/opt/etc/version"
DO_RW_UPDATE_FILE="$FOTA_UPDATE_PREFIX/opt/.do_rw_update"
-SCRIPT_NAME="update-fota.sh"
+SCRIPT_NAME="upgrade-fota.sh"
LOG_FILE="/tmp/update-fota.log"
untrap() {
done
CLEANUP_PARTITION=()
+ cleanup_files
+}
+
+cleanup_files() {
+ rm -f -- "$FOTA_DIR"/upgrade-common.inc
+ rm -f -- "$FOTA_DIR/$SCRIPT_NAME"
+ rm -f -- "$FOTA_DIR/$CONFIG_FILE"
+ rm -f -- "$FOTA_DIR/upgrade-trigger.sh"
}
should_mount_rootfs() {
critical_flog "[Error] Failed to switch board slot to $NEXT_AB"
exit 1
fi
+ cleanup_files
/bin/sync
flog "[Info] Rebooting to fota"
if ! /sbin/reboot fota; then
flog "[Info] Using <$DELTA_TAR> delta file."
+cleanup_files() {
+ rm -f -- "$DELTA_TAR"
+ rm -f -- "$FOTA_DIR/$SCRIPT_NAME"
+ rm -f -- "$FOTA_DIR/$CONFIG_FILE"
+ rm -f -- "$FOTA_DIR/upgrade-trigger.sh"
+}
+
reboot_to_fota() {
flog "[Info] Write paths..."
touch "$DO_RW_UPDATE_FILE"
critical_flog "[Error] Failed to switch board slot to $NEXT_AB"
exit 1
fi
+ cleanup_files
/bin/sync
flog "[Info] Rebooting to fota"
if ! /sbin/reboot fota; then
upgrade_images "$DOWNLOAD_DELTA"
set_upgrade_status 80
reboot_to_fota
+cleanup_files
flog "[Info] delta.tar[.gz] is already placed in correct directory."
elif [ "$DELTA_TAR_GZ" != "TRUE" ]; then
# skip copying .tar.gz to fota dir beacause it will have to be extracted, so there is no point in doing so
- flog "[Info] Copy delta.tar[.gz]..."
- /bin/cp "$DOWNLOAD_DELTA" "$DELTA_TAR"
+ flog "[Info] Move delta.tar[.gz] from $DOWNLOAD_DELTA to $DELTA_TAR"
+ /bin/mv "$DOWNLOAD_DELTA" "$DELTA_TAR"
fi
# delta.tar.gz has to be uncompressed to .tar beacause ua and libtota does not support .tar.gz
done
CLEANUP_PARTITION=()
+ cleanup_files
+}
+
+cleanup_files() {
+ rm -f -- "$DELTA_TAR"
+ rm -f -- "$FOTA_DIR/delta.ua"
+ rm -f -- "$FOTA_DIR/$SCRIPT_NAME"
+ rm -f -- "$FOTA_DIR/patchfile.file"
}
should_mount_rootfs() {
exit "$exit_code"
}
+cleanup_files() {
+ rm -f -- "$FOTA_DIR/$SCRIPT_NAME"
+}
+
check_ab_partition_scheme
check_used_block_device
load_background_copy_list
background_copy
+cleanup_files
SCRIPT_UPGRADE_FOTA="upgrade-fota.sh"
prepare_fota_dir() {
- if [ ! -d "$FOTA_DIR" ]; then
+ if [ -d "$FOTA_DIR" ]; then
+ # Cleanup FOTA_DIR
+ if [ "$(dirname $DOWNLOAD_DELTA)" = "$FOTA_DIR" ]; then
+ # If provided delta is from inside the FOTA_DIR, delete everything else
+ DELTA_FILE_NAME=$(basename $DOWNLOAD_DELTA)
+ rm -rf -- "$FOTA_DIR/!($DELTA_FILE_NAME)"
+ else
+ # If provided delta is from outside the FOTA_DIR delete everything
+ rm -rf -- "$FOTA_DIR/*"
+ fi
+ else
log "[Info] Create fota dir..." "$LOG_FILE"
mkdir -p "$FOTA_DIR"
fi