mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Split lib/general.sh
This commit is contained in:
35
lib/functions/logging/traps.sh
Normal file
35
lib/functions/logging/traps.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
# exit_with_error <message> <highlight>
|
||||
#
|
||||
# a way to terminate build process
|
||||
# with verbose error message
|
||||
#
|
||||
|
||||
exit_with_error()
|
||||
{
|
||||
local _file
|
||||
local _line=${BASH_LINENO[0]}
|
||||
local _function=${FUNCNAME[1]}
|
||||
local _description=$1
|
||||
local _highlight=$2
|
||||
_file=$(basename "${BASH_SOURCE[1]}")
|
||||
local stacktrace="$(get_extension_hook_stracktrace "${BASH_SOURCE[*]}" "${BASH_LINENO[*]}")"
|
||||
|
||||
display_alert "ERROR in function $_function" "$stacktrace" "err"
|
||||
display_alert "$_description" "$_highlight" "err"
|
||||
display_alert "Process terminated" "" "info"
|
||||
|
||||
if [[ "${ERROR_DEBUG_SHELL}" == "yes" ]]; then
|
||||
display_alert "MOUNT" "${MOUNT}" "err"
|
||||
display_alert "SDCARD" "${SDCARD}" "err"
|
||||
display_alert "Here's a shell." "debug it" "err"
|
||||
bash < /dev/tty || true
|
||||
fi
|
||||
|
||||
# TODO: execute run_after_build here?
|
||||
overlayfs_wrapper "cleanup"
|
||||
# unlock loop device access in case of starvation
|
||||
exec {FD}>/var/lock/armbian-debootstrap-losetup
|
||||
flock -u "${FD}"
|
||||
|
||||
exit 255
|
||||
}
|
||||
Reference in New Issue
Block a user