* Rename default-build.sh -> build-tasks.sh This commit is just a file rename without any further code change before this script will be refactored to improve build task structure for partial building. Refers to #4421 * Prepare build-tasks.sh for moving each build step to a dedicated function This commit is an intermediate update to reflect NO functional code changes of the particular build steps before moving the unmodified code into the appropriate function by copy/paste. Only build_get_boot_sources() has slightly changed to an appropriate if / fi structure. Note: This .sh file is bash syntactically not correct. The purpose of this commit is to leverage code review. Refers to #4421 * Update build-tasks.sh function do_default() for filtered function calls Function do_default(): - Add $1 function parameter for filtering build tasks and assign this to local variable $_buildOnly - move "pseudo inline"-functions to the beginning of the script - replace the "inline functions" by filtered function calls - add BUILD_ONLY variable to the build epilog print Refers to #4421 * Complete refactoring of build-tasks.sh for BUILD_ONLY support - update indentation of functions build_get_boot_sources() and build_get_kernel_sources() to meet code style - rename original function do_default() -> build_main() - create new do_default() for backward compatibility and comment this one as deprecated - call build_main "" from this deprecated do_default() - cli-entrypoint.sh: - update call of do_default by build_main "${BUILD_ONLY}" closes #4421 * Print final runtime as min:seconds As with filtered build runtimes may get below a minute, we would like to get the runtime printed with seconds. * Delete duplicate messages * Fix the confusion of the choice of building the kernel * Fix a typo in comment on do_default() * Backward compatibility of KERNEL_ONLY and new BUILD_ONLY keys. * interactive_config: replace KERNEL_ONLY on BUILD_ONLY * Fix: Correct verification when an image is created * Abort with error if BUILD_ONLY contains invalid build task names - add function build_validate_buildOnly() - call this function from build_main - fix position of KERNEL_ONLY / BUILD_ONLY contradiction message (did log empty _buildOnly content all time) - improve local variable names * Improve final error message to list valid BUILD_ONLY task names * Improve error message logging - collect multiple invalid BUILD_ONLY task names in a single error message - log final message for valid BUILD_ONLY task names on ext level - simple exit with exit code 1 in case of error * The RELEASE variable cannot be empty. Additional conditions for checking RELEASE are unacceptable. * Fix build_main() to use BUILD_ONLY inside instead of local var set from parameter $1 - build-tasks.sh: - build_main(): - don't take parameter $1 - replace usage of $_buildOnly by $BUILD_ONLY - added info messages on KERNEL_ONLY cases in case BUILD_ONLY was propagated - build_validate_buildOnly(): - remove parameter $2 - assign _buildOnly from global BUILD_ONLY accordingly - cli-entrypoint.sh: - call build_main without parameter * Choosing interactive_config if the goal is bootstrap * fix: order of selection backward_compatibility_build_only * Update function comments to match current state - removed obsolete parameter of build_main call do_default() - replaced :space: by :comma: in _kernel_buildOnly to leverage copy / paste for final repeatable command line printed after build * Improve logic coding to filter build tasks - build-tasks.sh: - added functions: - build_task_is_enabled() - build_task_one_of_is_enabled() - build_task_each_of_is_enabled() - updated existing build task filter logic to use function build_task_is_enabled - config-prepare.sh, prepare-host.sh: - replaced existing build task filter logic to use function build_task_is_enabled * Remove unused functions - remove function build_task_one_of_is_enabled() and build_task_each_of_is_enabled() according to code review Co-authored-by: The-going <48602507+The-going@users.noreply.github.com>
210 lines
7.1 KiB
Bash
210 lines
7.1 KiB
Bash
function interactive_config_prepare_terminal() {
|
|
if [[ -z $ROOT_FS_CREATE_ONLY ]]; then
|
|
# override stty size
|
|
[[ -n $COLUMNS ]] && stty cols $COLUMNS
|
|
[[ -n $LINES ]] && stty rows $LINES
|
|
TTY_X=$(($(stty size | awk '{print $2}') - 6)) # determine terminal width
|
|
TTY_Y=$(($(stty size | awk '{print $1}') - 6)) # determine terminal height
|
|
fi
|
|
|
|
# We'll use this title on all menus
|
|
backtitle="Armbian building script, https://www.armbian.com | https://docs.armbian.com | (c) 2013-2021 Igor Pecovnik "
|
|
}
|
|
|
|
function interactive_config_ask_kernel() {
|
|
# interactive_config_ask_kernel_only
|
|
interactive_config_ask_kernel_configure
|
|
}
|
|
|
|
function interactive_config_ask_kernel_only() {
|
|
if [[ -z $KERNEL_ONLY ]]; then
|
|
|
|
options+=("yes" "U-boot and kernel packages")
|
|
options+=("no" "Full OS image for flashing")
|
|
KERNEL_ONLY=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags \
|
|
--menu "Select what to build" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
unset options
|
|
[[ -z $KERNEL_ONLY ]] && exit_with_error "No option selected"
|
|
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_kernel_configure() {
|
|
if [[ -z $KERNEL_CONFIGURE ]]; then
|
|
|
|
options+=("no" "Do not change the kernel configuration")
|
|
options+=("yes" "Show a kernel configuration menu before compilation")
|
|
options+=("prebuilt" "Use precompiled packages from Armbian repository")
|
|
KERNEL_CONFIGURE=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags \
|
|
--menu "Select the kernel configuration" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
unset options
|
|
[[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"
|
|
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_board_list() {
|
|
if [[ -z $BOARD ]]; then
|
|
|
|
WIP_STATE=supported
|
|
WIP_BUTTON='CSC/WIP/EOS/TVB'
|
|
STATE_DESCRIPTION=' - boards with high level of software maturity'
|
|
temp_rc=$(mktemp)
|
|
|
|
while true; do
|
|
options=()
|
|
if [[ $WIP_STATE == supported ]]; then
|
|
|
|
for board in "${SRC}"/config/boards/*.conf; do
|
|
options+=("$(basename "${board}" | cut -d'.' -f1)" "$(head -1 "${board}" | cut -d'#' -f2)")
|
|
done
|
|
|
|
else
|
|
|
|
for board in "${SRC}"/config/boards/*.wip; do
|
|
options+=("$(basename "${board}" | cut -d'.' -f1)" "\Z1(WIP)\Zn $(head -1 "${board}" | cut -d'#' -f2)")
|
|
done
|
|
for board in "${SRC}"/config/boards/*.csc; do
|
|
options+=("$(basename "${board}" | cut -d'.' -f1)" "\Z1(CSC)\Zn $(head -1 "${board}" | cut -d'#' -f2)")
|
|
done
|
|
for board in "${SRC}"/config/boards/*.eos; do
|
|
options+=("$(basename "${board}" | cut -d'.' -f1)" "\Z1(EOS)\Zn $(head -1 "${board}" | cut -d'#' -f2)")
|
|
done
|
|
for board in "${SRC}"/config/boards/*.tvb; do
|
|
options+=("$(basename "${board}" | cut -d'.' -f1)" "\Z1(TVB)\Zn $(head -1 "${board}" | cut -d'#' -f2)")
|
|
done
|
|
|
|
fi
|
|
|
|
if [[ $WIP_STATE != supported ]]; then
|
|
cat <<- 'EOF' > "${temp_rc}"
|
|
dialog_color = (RED,WHITE,OFF)
|
|
screen_color = (WHITE,RED,ON)
|
|
tag_color = (RED,WHITE,ON)
|
|
item_selected_color = (WHITE,RED,ON)
|
|
tag_selected_color = (WHITE,RED,ON)
|
|
tag_key_selected_color = (WHITE,RED,ON)
|
|
EOF
|
|
else
|
|
echo > "${temp_rc}"
|
|
fi
|
|
BOARD=$(DIALOGRC=$temp_rc dialog --stdout --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)) "${options[@]}")
|
|
STATUS=$?
|
|
if [[ $STATUS == 3 ]]; then
|
|
if [[ $WIP_STATE == supported ]]; then
|
|
|
|
[[ $SHOW_WARNING == yes ]] && show_developer_warning
|
|
STATE_DESCRIPTION=' - \Z1(CSC)\Zn - Community Supported Configuration\n - \Z1(WIP)\Zn - Work In Progress
|
|
\n - \Z1(EOS)\Zn - End Of Support\n - \Z1(TVB)\Zn - TV boxes'
|
|
WIP_STATE=unsupported
|
|
WIP_BUTTON='matured'
|
|
EXPERT=yes
|
|
|
|
else
|
|
|
|
STATE_DESCRIPTION=' - boards with high level of software maturity'
|
|
WIP_STATE=supported
|
|
WIP_BUTTON='CSC/WIP/EOS'
|
|
EXPERT=no
|
|
|
|
fi
|
|
continue
|
|
elif [[ $STATUS == 0 ]]; then
|
|
break
|
|
fi
|
|
unset options
|
|
[[ -z $BOARD ]] && exit_with_error "No board selected"
|
|
done
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_branch() {
|
|
if [[ -z $BRANCH ]]; then
|
|
|
|
options=()
|
|
[[ $KERNEL_TARGET == *current* ]] && options+=("current" "Recommended. Come with best support")
|
|
[[ $KERNEL_TARGET == *legacy* ]] && options+=("legacy" "Old stable / Legacy")
|
|
[[ $KERNEL_TARGET == *edge* && $EXPERT = yes ]] && options+=("edge" "\Z1Bleeding edge from @kernel.org\Zn")
|
|
|
|
# do not display selection dialog if only one kernel branch is available
|
|
if [[ "${#options[@]}" == 2 ]]; then
|
|
BRANCH="${options[0]}"
|
|
else
|
|
BRANCH=$(dialog --stdout --title "Choose a kernel" --backtitle "$backtitle" --colors \
|
|
--menu "Select the target kernel branch\nExact kernel versions depend on selected board" \
|
|
$TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
fi
|
|
unset options
|
|
[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"
|
|
[[ $BRANCH == dev && $SHOW_WARNING == yes ]] && show_developer_warning
|
|
|
|
else
|
|
|
|
[[ $BRANCH == next ]] && KERNEL_TARGET="next"
|
|
# next = new legacy. Should stay for backward compatibility, but be removed from menu above
|
|
# or we left definitions in board configs and only remove menu
|
|
[[ $KERNEL_TARGET != *$BRANCH* ]] && exit_with_error "Kernel branch not defined for this board" "$BRANCH"
|
|
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_release() {
|
|
if [[ -z "$RELEASE" ]]; then
|
|
|
|
options=()
|
|
|
|
distros_options
|
|
|
|
RELEASE=$(dialog --stdout --title "Choose a release package base" --backtitle "$backtitle" \
|
|
--menu "Select the target OS release package base" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
[[ -z $RELEASE ]] && exit_with_error "No release selected"
|
|
|
|
unset options
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_desktop_build() {
|
|
# don't show desktop option if we choose minimal build
|
|
if [[ $HAS_VIDEO_OUTPUT == no || $BUILD_MINIMAL == yes ]]; then
|
|
BUILD_DESKTOP=no
|
|
elif [[ -z "$BUILD_DESKTOP" ]]; then
|
|
|
|
# read distribution support status which is written to the armbian-release file
|
|
set_distribution_status
|
|
|
|
options=()
|
|
options+=("no" "Image with console interface (server)")
|
|
options+=("yes" "Image with desktop environment")
|
|
BUILD_DESKTOP=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags \
|
|
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
unset options
|
|
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
|
|
if [[ ${BUILD_DESKTOP} == "yes" ]]; then
|
|
BUILD_MINIMAL=no
|
|
SELECTED_CONFIGURATION="desktop"
|
|
fi
|
|
|
|
fi
|
|
}
|
|
|
|
function interactive_config_ask_standard_or_minimal() {
|
|
if [[ $BUILD_DESKTOP == no && -z $BUILD_MINIMAL ]]; then
|
|
|
|
options=()
|
|
options+=("no" "Standard image with console interface")
|
|
options+=("yes" "Minimal image with console interface")
|
|
BUILD_MINIMAL=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags \
|
|
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
|
|
unset options
|
|
[[ -z $BUILD_MINIMAL ]] && exit_with_error "No option selected"
|
|
if [[ $BUILD_MINIMAL == "yes" ]]; then
|
|
SELECTED_CONFIGURATION="cli_minimal"
|
|
else
|
|
SELECTED_CONFIGURATION="cli_standard"
|
|
fi
|
|
|
|
fi
|
|
}
|