Skip to content
Draft
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
19 changes: 19 additions & 0 deletions lib/functions/logging/traps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ function add_cleanup_handler() {
trap_manager_cleanup_handlers=("${callback}" "${trap_manager_cleanup_handlers[@]}")
}

# Like add_cleanup_handler but appends to the tail of the list, so the
# registered callback runs AFTER everything added with add_cleanup_handler
# at the time run_cleanup_handlers fires. Use this when a handler needs to
# observe a fully-torn-down state — e.g. it can't safely re-mutate a
# kernel-global resource while subshells of the build are still alive and
# may have inherited the resource's fd.
function add_cleanup_handler_last() {
if [[ $# -gt 1 ]]; then
exit_with_error "add_cleanup_handler_last: too many params"
fi
local callback="$1"
if [[ -z "${callback}" ]]; then
exit_with_error "add_cleanup_handler_last: no callback specified"
fi

display_alert "Add callback as last cleanup handler" "${callback}" "cleanup"
trap_manager_cleanup_handlers+=("${callback}")
}

function execute_and_remove_cleanup_handler() {
local callback="$1"
display_alert "Execute and remove cleanup handler" "${callback}" "cleanup"
Expand Down
5 changes: 5 additions & 0 deletions lib/functions/main/rootfs-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function build_rootfs_and_image() {
# get a basic rootfs, either from cache or from scratch
get_or_create_rootfs_cache_chroot_sdcard # only occurrence of this; has its own logging sections

# Cache-hit path also benefits — the extracted rootfs has libc/ld-linux, so kernel
# binfmt_elf can run 32-bit ARM ELF natively. Idempotent on cache-miss path where
# create_new_rootfs_cache_via_debootstrap already activated this.
_native_armhf_setup_binfmt_elf || true

# deploy the qemu binary, no matter where the rootfs came from (built or cached)
LOG_SECTION="deploy_qemu_binary_to_chroot_image" do_with_logging deploy_qemu_binary_to_chroot "${SDCARD}" "image" # undeployed at end of this function

Expand Down
Loading
Loading