armbian-next: introduce assert_prepared_host() and assert before using any Python, to un-mask any further fallacies

This commit is contained in:
Ricardo Pardini
2023-01-29 22:32:49 +01:00
parent 956ef9ac7d
commit 19aa7e95cf
3 changed files with 10 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
function assert_requires_aggregation() {
if [[ ${aggregation_has_already_run:-0} -lt 1 ]]; then
exit_with_error "assert_requires_aggregation: Aggregation has not been run"
exit_with_error "assert_requires_aggregation: Aggregation has not been run. This is a bug in armbian-next code. Please report!"
fi
}

View File

@@ -15,6 +15,7 @@ function early_prepare_pip3_dependencies_for_python_tools() {
# call: prepare_python_and_pip # this defines global PYTHON3_INFO dict and PYTHON3_VARS array
function prepare_python_and_pip() {
assert_prepared_host # this needs a prepared host to work; avoid fake errors about "python3-pip" not being installed
# First determine with python3 to use; requires knowing the HOSTRELEASE.
[[ -z "${HOSTRELEASE}" ]] && exit_with_error "HOSTRELEASE is not set"

View File

@@ -10,6 +10,12 @@ function prepare_host() {
return 0
}
function assert_prepared_host() {
if [[ ${prepare_host_has_already_run:-0} -lt 1 ]]; then
exit_with_error "assert_prepared_host: Host has not yet been prepared. This is a bug in armbian-next code. Please report!"
fi
}
function check_basic_host() {
display_alert "Checking" "basic host setup" "info"
obtain_and_check_host_release_and_arch # sets HOSTRELEASE and validates it for sanity; also HOSTARCH
@@ -185,6 +191,8 @@ function prepare_host_noninteractive() {
# Reset owner of userpatches if so required
reset_uid_owner "${USERPATCHES_PATH}" # Fix owner of files in the final destination
declare -i -g -r prepare_host_has_already_run=1 # global, readonly.
return 0
}