artifacts/cli: introduce CLI command artifact-config-dump-json (alias to artifact, but sets CONFIG_DEFS_ONLY=yes)

- if CONFIG_DEFS_ONLY during `obtain_complete_artifact()`, just dump JSON to stdout after calculating version/coordinates
- don't prepare ORAS tooling if CONFIG_DEFS_ONLY
- don't run in standard build (and thus don't prepare_host()) if under CONFIG_DEFS_ONLY
- if CONFIG_DEFS_ONLY, don't run `check_basic_host()`
This commit is contained in:
Ricardo Pardini 2023-04-09 12:44:59 +02:00
parent 439882ce7a
commit 538b8c2b79
4 changed files with 45 additions and 7 deletions

View File

@ -141,8 +141,6 @@ function obtain_complete_artifact() {
debug_var artifact_final_file_basename
debug_var artifact_file_relative
# @TODO: possibly stop here if only for up-to-date-checking
# Determine OCI coordinates. OCI_TARGET_BASE overrides the default proposed by the artifact.
declare artifact_oci_target_base="undetermined"
if [[ -n "${OCI_TARGET_BASE}" ]]; then
@ -155,6 +153,35 @@ function obtain_complete_artifact() {
declare -g artifact_full_oci_target="${artifact_oci_target_base}${artifact_name}:${artifact_version}"
# if CONFIG_DEFS_ONLY, dump JSON and exit
if [[ "${CONFIG_DEFS_ONLY}" == "yes" ]]; then
display_alert "artifact" "CONFIG_DEFS_ONLY is set, skipping artifact creation" "warn"
declare -a wanted_vars=(
artifact_name
artifact_type
artifact_version
artifact_version_reason
artifact_base_dir
artifact_final_file
artifact_final_file_basename
artifact_file_relative
artifact_full_oci_target
)
declare -A ARTIFACTS_VAR_DICT=()
for var in "${wanted_vars[@]}"; do
ARTIFACTS_VAR_DICT["${var}"]="$(declare -p "${var}")"
done
display_alert "Dumping JSON" "for ${#ARTIFACTS_VAR_DICT[@]} variables" "ext"
python3 "${SRC}/lib/tools/configdump2json.py" "--args" "${ARTIFACTS_VAR_DICT[@]}" # to stdout
exit 0
fi
declare -g artifact_exists_in_local_cache="undetermined"
declare -g artifact_exists_in_remote_cache="undetermined"

View File

@ -17,8 +17,10 @@ function cli_artifact_run() {
: "${chosen_artifact:?chosen_artifact is not set}"
: "${chosen_artifact_impl:?chosen_artifact_impl is not set}"
# Make sure ORAS tooling is installed before starting.
run_tool_oras
if [[ "${CONFIG_DEFS_ONLY}" != "yes" ]]; then
# Make sure ORAS tooling is installed before starting.
run_tool_oras
fi
display_alert "artifact" "${chosen_artifact}" "debug"
display_alert "artifact" "${chosen_artifact} :: ${chosen_artifact_impl}()" "debug"
@ -62,5 +64,9 @@ function cli_artifact_run() {
skip_unpack_if_found_in_caches="no"
fi
do_with_default_build obtain_complete_artifact # @TODO: < /dev/null -- but what about kernel configure?
if [[ "${CONFIG_DEFS_ONLY}" != "yes" ]]; then
do_with_default_build obtain_complete_artifact # @TODO: < /dev/null -- but what about kernel configure?
else
obtain_complete_artifact
fi
}

View File

@ -35,7 +35,8 @@ function armbian_register_commands() {
["oras-upload"]="oras" # implemented in cli_oras_pre_run and cli_oras_run; up/down/info are the same, see vars below
# all-around artifact wrapper
["artifact"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
["artifact"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
["artifact-config-dump-json"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
# shortcuts, see vars set below. the use legacy single build, and try to control it via variables
["rootfs"]="artifact"
@ -72,6 +73,8 @@ function armbian_register_commands() {
["generate-dockerfile"]="DOCKERFILE_GENERATE_ONLY='yes'"
["artifact-config-dump-json"]='CONFIG_DEFS_ONLY="yes"'
# artifact shortcuts
["rootfs"]="WHAT='rootfs' ${common_cli_artifact_vars}"

View File

@ -53,7 +53,9 @@ function prep_conf_main_minimal_ni() {
# needed for most stuff, but not for configdump
if [[ "${skip_host_config:-"no"}" != "yes" ]]; then
check_basic_host
if [[ "${CONFIG_DEFS_ONLY}" != "yes" ]]; then
check_basic_host
fi
fi
# needed for BOARD= builds.