armbian-next: aggregate_packages out of main_default_start_build(); introduce assert_requires_aggregation()

This commit is contained in:
Ricardo Pardini
2023-01-27 13:07:36 +01:00
parent 67e6b010f2
commit 16eb5eb50b
5 changed files with 34 additions and 11 deletions

View File

@@ -64,6 +64,9 @@ function cli_rootfs_run() {
# This is run inside do_with_default_build(), above.
function cli_rootfs_only_in_default_build() {
assert_requires_aggregation # Bombs if aggregation has not run
declare -g rootfs_cache_id="none_yet"
LOG_SECTION="prepare_rootfs_build_params_and_trap" do_with_logging prepare_rootfs_build_params_and_trap

View File

@@ -1,9 +1,26 @@
#!/usr/bin/env bash
function assert_requires_aggregation() {
if [[ ${aggregation_has_already_run:-0} -lt 1 ]]; then
exit_with_error "assert_requires_aggregation: Aggregation has not been run"
fi
}
function aggregate_packages_in_logging_section() {
# Aggregate packages, in its own logging section; this decides internally on KERNEL_ONLY=no
# We need aggregation to be able to build bsp packages, which contain scripts coming from the aggregation.
LOG_SECTION="aggregate_packages" do_with_logging aggregate_packages
}
# This used to be called from config (main-config), but now it's moved default-build, after prepare_host, so Python hostdeps are available.
# So the aggregation results (hash, etc) are not available for config-dump.
function aggregate_packages() {
if [[ "${KERNEL_ONLY}" != "yes" ]]; then
if [[ "${KERNEL_ONLY}" != "yes" ]]; then # @TODO: remove, this is not the right place to decide this.
if [[ ${aggregation_has_already_run:-0} -gt 0 ]]; then
exit_with_error "aggregate_packages: Aggregation has already run"
fi
display_alert "Aggregating packages" "rootfs" "info"
aggregate_all_packages_python
call_extension_method "post_aggregate_packages" "user_config_post_aggregate_packages" <<- 'POST_AGGREGATE_PACKAGES'
@@ -11,6 +28,9 @@ function aggregate_packages() {
Called after aggregating all package lists.
Packages will still be installed after this is called. It is not possible to change anything, though.
POST_AGGREGATE_PACKAGES
declare -i -g -r aggregation_has_already_run=1 # global, readonly.
fi
}

View File

@@ -28,6 +28,8 @@ function prep_conf_main_build_single() {
LOG_SECTION="config_post_main" do_with_conditional_logging config_post_main
aggregate_packages_in_logging_section
display_alert "Configuration prepared for BOARD build" "${BOARD}.${BOARD_TYPE}" "info"
}
@@ -46,6 +48,8 @@ function prep_conf_main_only_rootfs() {
skip_kernel="yes" \
LOG_SECTION="config_post_main" do_with_conditional_logging config_post_main
aggregate_packages_in_logging_section
display_alert "Configuration prepared for non-BOARD build" "prep_conf_main_only_rootfs" "info"
}

View File

@@ -1,5 +1,8 @@
# This does NOT run under the logging manager.
# This does NOT run under the logging manager.
function full_build_packages_rootfs_and_image() {
assert_requires_aggregation # Bombs if aggregation has not run
main_default_build_packages # has its own logging sections # requires aggregation
# build rootfs, if not only kernel. Again, read "KERNEL_ONLY" as if it was "PACKAGES_ONLY"

View File

@@ -32,10 +32,7 @@ function main_default_start_build() {
# Check and install dependencies, directory structure and settings
prepare_host # this has its own logging sections, and is possibly interactive.
# Aggregate packages, in its own logging section; this decides internally on KERNEL_ONLY=no
# We need aggregation to be able to build bsp packages, which contain scripts coming from the aggregation.
LOG_SECTION="aggregate_packages" do_with_logging aggregate_packages
# @TODO: what if there is no python2? bookworm/sid, currently. not long until more
# Create a directory inside WORKDIR with a "python" symlink to "/usr/bin/python2"; add it to PATH first.
BIN_WORK_DIR="${WORKDIR}/bin"
# No cleanup of this is necessary, since it's inside WORKDIR.
@@ -43,10 +40,7 @@ function main_default_start_build() {
ln -s "/usr/bin/python2" "${BIN_WORK_DIR}/python"
export PATH="${BIN_WORK_DIR}:${PATH}"
if [[ "${JUST_INIT}" == "yes" ]]; then
exit 0 # @TODO: is this used? if not, remove
fi
return 0
}
function main_default_end_build() {
@@ -65,7 +59,6 @@ function main_default_end_build() {
return 0
}
function trap_handler_cleanup_workdir() {
display_alert "Cleanup WORKDIR: $WORKDIR" "trap_handler_cleanup_workdir" "cleanup"
unset TMPDIR