armbian-next: extensions: move 'extensions.sh' into library; replace manual source with init function

- wraps globals in `extension_manager_declare_globals()` -- and make them actually global
- whoever wrote this original code is insane, add copyright
This commit is contained in:
Ricardo Pardini
2023-01-21 05:15:19 +01:00
parent 092f9ad3b2
commit eb30aac310
5 changed files with 39 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
# Helper function, to get clean "stack traces" that do not include the hook/extension infrastructure code.
# @TODO this in practice is only used... ?
function get_extension_hook_stracktrace() {
[[ "${CONFIG_DEFS_ONLY}" == "yes" ]] && return 0 # don't waste time here
local sources_str="$1" # Give this ${BASH_SOURCE[*]} - expanded
@@ -10,8 +11,8 @@ function get_extension_hook_stracktrace() {
local source="${sources[index]}" line="${lines[((index - 1))]}"
# skip extension infrastructure sources, these only pollute the trace and add no insight to users
[[ ${source} == */extension_function_definition.sh ]] && continue
[[ ${source} == *lib/extensions.sh ]] && continue
[[ ${source} == *lib/functions/logging.sh ]] && continue
[[ ${source} == *lib/functions/general/extensions.sh ]] && continue
[[ ${source} == *lib/functions/logging.sh ]] && continue # @TODO this doesnt match for a looong time
[[ ${source} == */compile.sh ]] && continue
[[ ${line} -lt 1 ]] && continue
# relativize the source, otherwise too long to display