Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/functions/general/schedule_deletion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2025 tabris <tabris@tabris.net>
# This file is a part of the Armbian Build Framework https://github.com/armbian/build/

declare -a schedule_deletion_files_to_delete

function schedule_deletion() {
local file="$1"
local source="${BASH_SOURCE[1]}"
local func="${FUNCNAME[1]}"
local line="${BASH_LINENO[0]}"

schedule_deletion_files_to_delete+=("$file;$source;$func;$line")
}

function pre_umount_final_image__schedule_deletion_delete_now() {
local file source func line deletion_info
local had_errexit=0
case $- in *e*) had_errexit=1;; esac
for deletion_info in "${schedule_deletion_files_to_delete[@]}"; do
IFS=';' read -r file source func line <<< "$deletion_info"
local reason="scheduled from $source $func line#$line"
local message=""
local failure=0

[[ $had_errexit ]] && set +e # don't bail out, let us bail out ourselves more verbosely
if [[ ! -e "$file" ]]; then
message="FILE DELETION FAILED (missing): '${file}'"
((failure++))
elif rm -- "$file"; then
message="deleted file '${file}'"
else
message="FILE DELETION FAILED: '${file}'"
((failure++))
fi
[[ $had_errexit ]] && set -e # restore the previous behaviour
if [[ $failure ]]; then
exit_with_error "$message; $reason"
else
display_alert "$message" "$reason" "info"
fi
done
}
2 changes: 1 addition & 1 deletion lib/functions/rootfs/create-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function extract_rootfs_artifact() {

wait_for_disk_sync "after restoring rootfs cache"

run_host_command_logged rm -v "${SDCARD}"/etc/resolv.conf
run_host_command_logged rm -fv "${SDCARD}"/etc/resolv.conf
run_host_command_logged echo "nameserver ${NAMESERVER}" ">" "${SDCARD}"/etc/resolv.conf

# all sources etc.
Expand Down
2 changes: 1 addition & 1 deletion lib/functions/rootfs/rootfs-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function create_new_rootfs_cache_via_debootstrap() {
# please reinitialize this to uninitialized. Do note that systemd will start all services then by
# default and that has to be handled by setting system presets.
run_host_command_logged echo -n ">" "${SDCARD}/etc/machine-id"
run_host_command_logged rm -fv "${SDCARD}/var/lib/dbus/machine-id"
schedule_deletion "${SDCARD}/var/lib/dbus/machine-id"

# Mask `systemd-firstboot.service` which will prompt locale, timezone and root-password too early.
# `armbian-first-run` will do the same thing later
Expand Down
13 changes: 11 additions & 2 deletions lib/library-functions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This file is/was autogenerated by ./lib/tools/gen-library.sh; don't modify manually
# This file is/was autogenerated by lib/tools/gen-library.sh; don't modify manually

# no errors tolerated. invoked before each sourced file to make sure.
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
Expand Down Expand Up @@ -748,6 +748,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
# shellcheck source=lib/functions/general/retry.sh
source "${SRC}"/lib/functions/general/retry.sh

# no errors tolerated. invoked before each sourced file to make sure.
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
set -o errtrace # trace ERR through - enabled
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
### lib/functions/general/schedule_deletion.sh
# shellcheck source=lib/functions/general/schedule_deletion.sh
source "${SRC}"/lib/functions/general/schedule_deletion.sh

# no errors tolerated. invoked before each sourced file to make sure.
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
Expand Down Expand Up @@ -1176,4 +1185,4 @@ source "${SRC}"/lib/functions/rootfs/trap-rootfs.sh
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
set -o errtrace # trace ERR through - enabled
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
# This file is/was autogenerated by ./lib/tools/gen-library.sh; don't modify manually
# This file is/was autogenerated by lib/tools/gen-library.sh; don't modify manually