mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
interactive: better Repeat Build Options [by @mhoffrog, squashed, rebased]
Add interactive configurations to Repeat Build Options
Simplify function produce_repeat_args_array()
- make use of $ARMBIAN_NON_PARAM_ARGS and $ARMBIAN_PARSED_CMDLINE_PARAMS (associated array)
- quote parameter values to be on the safe side
Move "Repeat Build Options" logs to start-end.sh
- cli-build.sh, start-end.sh:
- move function function produce_repeat_args_array() to start-end.sh
- add $WHAT as first arg to produce_repeat_args_array() if
$WHAT is not empty
- move early display log of "Repeat Build Options" to
function main_default_start_build()
- move last log of "Repeat Build Options" to
function main_default_end_build()
- add last log of "Repeat Build Options" to
LOG_SECTION="repeat_build_options"
This commit is contained in:
committed by
Ricardo Pardini
parent
c837ed2c2e
commit
d1252fc0ee
@@ -21,32 +21,7 @@ function cli_standard_build_run() {
|
||||
# configuration etc - it initializes the extension manager; handles its own logging sections
|
||||
prep_conf_main_build_single
|
||||
|
||||
# 1x: show interactively-selected as soon as possible, after config
|
||||
produce_repeat_args_array
|
||||
display_alert "Repeat Build Options (early)" "${repeat_args[*]}" "ext"
|
||||
|
||||
# the full build. It has its own logging sections.
|
||||
do_with_default_build full_build_packages_rootfs_and_image
|
||||
|
||||
# 1x: show interactively-selected as soon as possible, after config
|
||||
produce_repeat_args_array
|
||||
display_alert "Repeat Build Options" "${repeat_args[*]}" "ext" # * = expand array, space delimited, single-word.
|
||||
|
||||
}
|
||||
|
||||
function produce_repeat_args_array() {
|
||||
# Make it easy to repeat build by displaying build options used. Prepare array.
|
||||
declare -a -g repeat_args=("./compile.sh")
|
||||
# @TODO: missing the config file name, if any.
|
||||
# @TODO: missing the original cli command, if different from build/docker
|
||||
[[ -n ${BOARD} ]] && repeat_args+=("BOARD=${BOARD}")
|
||||
[[ -n ${BRANCH} ]] && repeat_args+=("BRANCH=${BRANCH}")
|
||||
[[ -n ${RELEASE} ]] && repeat_args+=("RELEASE=${RELEASE}")
|
||||
[[ -n ${BUILD_MINIMAL} ]] && repeat_args+=("BUILD_MINIMAL=${BUILD_MINIMAL}")
|
||||
[[ -n ${BUILD_DESKTOP} ]] && repeat_args+=("BUILD_DESKTOP=${BUILD_DESKTOP}")
|
||||
[[ -n ${KERNEL_CONFIGURE} ]] && repeat_args+=("KERNEL_CONFIGURE=${KERNEL_CONFIGURE}")
|
||||
[[ -n ${DESKTOP_ENVIRONMENT} ]] && repeat_args+=("DESKTOP_ENVIRONMENT=${DESKTOP_ENVIRONMENT}")
|
||||
[[ -n ${DESKTOP_ENVIRONMENT_CONFIG_NAME} ]] && repeat_args+=("DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME}")
|
||||
[[ -n ${DESKTOP_APPGROUPS_SELECTED} ]] && repeat_args+=("DESKTOP_APPGROUPS_SELECTED=\"${DESKTOP_APPGROUPS_SELECTED:-"none"}\"")
|
||||
[[ -n ${COMPRESS_OUTPUTIMAGE} ]] && repeat_args+=("COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE}")
|
||||
}
|
||||
|
||||
@@ -21,6 +21,15 @@ function interactive_config_prepare_terminal() {
|
||||
fi
|
||||
# We'll use this title on all menus
|
||||
declare -g -r backtitle="Armbian building script, https://www.armbian.com | https://docs.armbian.com | (c) 2013-2023 Igor Pecovnik "
|
||||
declare -A -g ARMBIAN_INTERACTIVE_CONFIGS=() # An associative array of all interactive configurations
|
||||
}
|
||||
|
||||
# Set config variable and ARMBIAN_INTERACTIVE_CONFIGS in a consistent way
|
||||
# $1: variable name
|
||||
# $2: variable value
|
||||
function set_interactive_config_value() {
|
||||
eval "$1"='$2'
|
||||
eval "ARMBIAN_INTERACTIVE_CONFIGS[${1}]"='$2'
|
||||
}
|
||||
|
||||
function interactive_finish() {
|
||||
@@ -42,7 +51,7 @@ function interactive_config_ask_kernel_configure() {
|
||||
options+=("yes" "Show a kernel configuration menu before compilation")
|
||||
#options+=("prebuilt" "Use precompiled packages (maintained hardware only)") # @TODO armbian-next does not support this, I think.
|
||||
dialog_if_terminal_set_vars --title "Choose an option" --backtitle "$backtitle" --no-tags --menu "Select the kernel configuration" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
|
||||
KERNEL_CONFIGURE="${DIALOG_RESULT}"
|
||||
set_interactive_config_value KERNEL_CONFIGURE "${DIALOG_RESULT}"
|
||||
[[ ${DIALOG_EXIT_CODE} != 0 ]] && exit_with_error "You cancelled interactive during kernel configuration" "Build cancelled"
|
||||
unset options
|
||||
}
|
||||
@@ -141,7 +150,7 @@ function interactive_config_ask_board_list() {
|
||||
dialog_if_terminal_set_vars --title "Choose a board" --backtitle "$backtitle" --scrollbar \
|
||||
--colors --extra-label "Show $WIP_BUTTON" --extra-button \
|
||||
--menu "Select the target board. Displaying:\n$STATE_DESCRIPTION" $TTY_Y $TTY_X $((TTY_Y - 8)) "${arr_all_board_options[@]}"
|
||||
BOARD="${DIALOG_RESULT}"
|
||||
set_interactive_config_value BOARD "${DIALOG_RESULT}"
|
||||
declare STATUS=${DIALOG_EXIT_CODE}
|
||||
|
||||
if [[ $STATUS == 3 ]]; then
|
||||
@@ -182,7 +191,7 @@ function interactive_config_ask_branch() {
|
||||
--menu "Select the target kernel branch.\nSelected BOARD='${BOARD}'\nExact kernel versions depend on selected board and its family." \
|
||||
$TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
|
||||
|
||||
BRANCH="${DIALOG_RESULT}"
|
||||
set_interactive_config_value BRANCH "${DIALOG_RESULT}"
|
||||
|
||||
[[ -z ${BRANCH} ]] && exit_with_error "No kernel branch selected"
|
||||
return 0
|
||||
@@ -194,7 +203,7 @@ function interactive_config_ask_release() {
|
||||
declare -a options=()
|
||||
distros_options
|
||||
dialog_if_terminal_set_vars --title "Choose a release package base" --backtitle "$backtitle" --menu "Select the target OS release package base; selected BRANCH='${BRANCH}'" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
|
||||
RELEASE="${DIALOG_RESULT}"
|
||||
set_interactive_config_value RELEASE "${DIALOG_RESULT}"
|
||||
[[ -z ${RELEASE} ]] && exit_with_error "No release selected"
|
||||
|
||||
return 0 # shortcircuit above!
|
||||
@@ -213,11 +222,11 @@ function interactive_config_ask_desktop_build() {
|
||||
options+=("yes" "Image with desktop environment")
|
||||
dialog_if_terminal_set_vars --title "Choose image type" --backtitle "$backtitle" --no-tags \
|
||||
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
|
||||
BUILD_DESKTOP="${DIALOG_RESULT}"
|
||||
set_interactive_config_value BUILD_DESKTOP "${DIALOG_RESULT}"
|
||||
unset options
|
||||
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No image type selected"
|
||||
if [[ ${BUILD_DESKTOP} == "yes" ]]; then
|
||||
BUILD_MINIMAL=no
|
||||
set_interactive_config_value BUILD_MINIMAL no
|
||||
SELECTED_CONFIGURATION="desktop"
|
||||
fi
|
||||
return 0
|
||||
@@ -232,7 +241,7 @@ function interactive_config_ask_standard_or_minimal() {
|
||||
options+=("yes" "Minimal image with console interface")
|
||||
dialog_if_terminal_set_vars --title "Choose image type" --backtitle "$backtitle" --no-tags \
|
||||
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
|
||||
BUILD_MINIMAL="${DIALOG_RESULT}"
|
||||
set_interactive_config_value BUILD_MINIMAL "${DIALOG_RESULT}"
|
||||
unset options
|
||||
[[ -z $BUILD_MINIMAL ]] && exit_with_error "No standard/minimal selected"
|
||||
if [[ $BUILD_MINIMAL == "yes" ]]; then
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
# Common start/end build functions. Used by the default build and others
|
||||
|
||||
function main_default_start_build() {
|
||||
# 1x: show interactively-selected as soon as possible, after config
|
||||
produce_repeat_args_array
|
||||
display_alert "Repeat Build Options (early)" "${repeat_args[*]}" "ext"
|
||||
|
||||
|
||||
if [[ "${PRE_PREPARED_HOST:-"no"}" != "yes" ]]; then
|
||||
prepare_host_init # this has its own logging sections, and is possibly interactive.
|
||||
fi
|
||||
@@ -82,6 +87,9 @@ function main_default_end_build() {
|
||||
# display_alert in its own logging section.
|
||||
LOG_SECTION="runtime_total" do_with_logging display_alert "Runtime" "$(printf "%d:%02d min" $((runtime_seconds / 60)) $((runtime_seconds % 60)))" "info"
|
||||
|
||||
produce_repeat_args_array
|
||||
LOG_SECTION="repeat_build_options" do_with_logging display_alert "Repeat Build Options" "${repeat_args[*]}" "ext" # * = expand array, space delimited, single-word.
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -101,3 +109,18 @@ function trap_handler_cleanup_workdir() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function produce_repeat_args_array() {
|
||||
# Make it easy to repeat build by displaying build options used. Prepare array.
|
||||
declare -a -g repeat_args=("./compile.sh")
|
||||
# @TODO: missing the config file name, if any.
|
||||
repeat_args+=(${ARMBIAN_NON_PARAM_ARGS[*]})
|
||||
for param_name in "${!ARMBIAN_PARSED_CMDLINE_PARAMS[@]}"; do
|
||||
# Parameter values are quoted to be on the safe side.
|
||||
repeat_args+=("${param_name}=${ARMBIAN_PARSED_CMDLINE_PARAMS[$param_name]@Q}")
|
||||
done
|
||||
for param_name in "${!ARMBIAN_INTERACTIVE_CONFIGS[@]}"; do
|
||||
# Parameter values are quoted to be on the safe side.
|
||||
repeat_args+=("${param_name}=${ARMBIAN_INTERACTIVE_CONFIGS[$param_name]@Q}")
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user