diff --git a/lib/functions/configuration/change-tracking.sh b/lib/functions/configuration/change-tracking.sh index 6a6e8e868..38c169aae 100644 --- a/lib/functions/configuration/change-tracking.sh +++ b/lib/functions/configuration/change-tracking.sh @@ -41,7 +41,7 @@ function track_config_variables() { } function track_general_config_variables() { - track_config_variables "${1}" BOARDFAMILY KERNELSOURCE KERNEL_MAJOR_MINOR KERNELBRANCH LINUXFAMILY LINUXCONFIG KERNELPATCHDIR KERNEL_PATCH_ARCHIVE_BASE + track_config_variables "${1}" BOARDFAMILY KERNELSOURCE KERNEL_MAJOR_MINOR KERNELBRANCH KERNEL_DESCRIPTION LINUXFAMILY LINUXCONFIG KERNELPATCHDIR KERNEL_PATCH_ARCHIVE_BASE array_values="yes" track_config_variables "${1}" KERNEL_DRIVERS_SKIP track_config_variables "${1}" BOOTSOURCE BOOTSOURCEDIR BOOTBRANCH BOOTPATCHDIR BOOTDIR BOOTCONFIG BOOTBRANCH_BOARD BOOTPATCHDIR_BOARD track_config_variables "${1}" ATFSOURCEDIR ATFDIR ATFBRANCH CRUSTSOURCEDIR CRUSTDIR CRUSTBRANCH LINUXSOURCEDIR diff --git a/lib/functions/configuration/interactive.sh b/lib/functions/configuration/interactive.sh index 3e9cc552b..5e9836946 100644 --- a/lib/functions/configuration/interactive.sh +++ b/lib/functions/configuration/interactive.sh @@ -176,43 +176,93 @@ function interactive_config_ask_board_list() { done } +function get_kernel_info_for_branch() { + local search_branch="$1" + local conf_file="${SRC}/config/sources/families/${BOARDFAMILY}.conf" + + awk -v branch="$search_branch" ' + BEGIN { found=0; major_minor=""; desc="" } + /^[[:space:]]*[a-zA-Z0-9_-]+\)/ { + if ($0 ~ "^[[:space:]]*" branch "\\)") { + found=1 + next + } else if (found) { + exit + } + } + found && /declare[[:space:]]+-g[[:space:]]+KERNEL_MAJOR_MINOR=/ { + if (match($0, /"([^"]+)"/, arr)) { + major_minor=arr[1] + } + } + found && /declare[[:space:]]+-g[[:space:]]+KERNEL_DESCRIPTION=/ { + if (match($0, /"([^"]+)"/, arr)) { + desc=arr[1] + } + } + END { + print major_minor "|" desc + } + ' "$conf_file" +} + function interactive_config_ask_branch() { - # if BRANCH not set, display selection menu - if [[ -n $BRANCH ]]; then - display_alert "Already set BRANCH, skipping interactive" "${BRANCH}" "debug" - return 0 - fi - declare -a options=() - # Loop over the kernel targets and add them to the options array. They're comma separated. - declare one_kernel_target - for one_kernel_target in $(echo "${KERNEL_TARGET}" | tr "," "\n"); do - case $one_kernel_target in - "current") - options+=("current" "Recommended. Usually an LTS kernel") - ;; - "legacy") - options+=("legacy" "Old stable / Legacy / Vendor kernel") - ;; - "edge") - options+=("edge" "Bleeding edge / latest possible") - ;; - "cloud") - options+=("cloud" "Cloud optimised minimal LTS kernel") - ;; - *) - options+=("${one_kernel_target}" "Experimental ${one_kernel_target} kernel / for Developers") - ;; - esac - done + if [[ -n $BRANCH ]]; then + display_alert "Already set BRANCH, skipping interactive" "${BRANCH}" "debug" + return 0 + fi - dialog_if_terminal_set_vars --title "Choose a kernel" --backtitle "$backtitle" --colors \ - --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[@]}" + declare -a options=() + declare one_kernel_target - set_interactive_config_value BRANCH "${DIALOG_RESULT}" + for one_kernel_target in $(echo "${KERNEL_TARGET}" | tr "," "\n"); do - [[ -z ${BRANCH} ]] && exit_with_error "No kernel branch selected" - return 0 + + local version="" + local description="" + + local info + info="$(get_kernel_info_for_branch "$one_kernel_target")" + version="${info%%|*}" + description="${info#*|}" + + # Fallback if description is empty + if [[ -z "$description" ]]; then + case "$one_kernel_target" in + current) + description="Recommended. Usually an LTS kernel" + ;; + legacy) + description="Old stable / Legacy / Vendor kernel" + ;; + edge) + description="Bleeding edge / latest possible" + ;; + cloud) + description="Cloud optimised minimal LTS kernel" + ;; + *) + description="Experimental ${one_kernel_target} kernel / for Developers" + ;; + esac + fi + + # Append version if found + if [[ -n "$version" ]]; then + description="${description} (${version})" + fi + + options+=("${one_kernel_target}" "${description}") + done + + dialog_if_terminal_set_vars --title "Choose a kernel" --backtitle "$backtitle" --colors \ + --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[@]}" + + set_interactive_config_value BRANCH "${DIALOG_RESULT}" + + [[ -z ${BRANCH} ]] && exit_with_error "No kernel branch selected" + return 0 } function interactive_config_ask_release() { diff --git a/lib/library-functions.sh b/lib/library-functions.sh index 7dfcaeea7..840c91d3c 100644 --- a/lib/library-functions.sh +++ b/lib/library-functions.sh @@ -100,6 +100,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/artifacts/artifact-rootfs.sh source "${SRC}"/lib/functions/artifacts/artifact-rootfs.sh +# no errors tolerated. invoked before each sourced file to make sure. +#set -o pipefail # trace ERR through pipes - will be enabled "soon" +#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled +set -o errtrace # trace ERR through - enabled +set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled +### lib/functions/artifacts/artifact-uboot.sh +# shellcheck source=lib/functions/artifacts/artifact-uboot.sh +source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh + # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -127,15 +136,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/artifacts/artifacts-reversion.sh source "${SRC}"/lib/functions/artifacts/artifacts-reversion.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/artifacts/artifact-uboot.sh -# shellcheck source=lib/functions/artifacts/artifact-uboot.sh -source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -474,18 +474,18 @@ source "${SRC}"/lib/functions/compilation/packages/utils-dpkgdeb.sh #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled set -o errtrace # trace ERR through - enabled set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/compilation/patch/drivers-harness.sh -# shellcheck source=lib/functions/compilation/patch/drivers-harness.sh -source "${SRC}"/lib/functions/compilation/patch/drivers-harness.sh +### lib/functions/compilation/patch/drivers_network.sh +# shellcheck source=lib/functions/compilation/patch/drivers_network.sh +source "${SRC}"/lib/functions/compilation/patch/drivers_network.sh # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled set -o errtrace # trace ERR through - enabled set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/compilation/patch/drivers_network.sh -# shellcheck source=lib/functions/compilation/patch/drivers_network.sh -source "${SRC}"/lib/functions/compilation/patch/drivers_network.sh +### lib/functions/compilation/patch/drivers-harness.sh +# shellcheck source=lib/functions/compilation/patch/drivers-harness.sh +source "${SRC}"/lib/functions/compilation/patch/drivers-harness.sh # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" @@ -676,15 +676,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/general/extensions.sh source "${SRC}"/lib/functions/general/extensions.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/general/github-actions.sh -# shellcheck source=lib/functions/general/github-actions.sh -source "${SRC}"/lib/functions/general/github-actions.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -703,6 +694,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/general/git.sh source "${SRC}"/lib/functions/general/git.sh +# no errors tolerated. invoked before each sourced file to make sure. +#set -o pipefail # trace ERR through pipes - will be enabled "soon" +#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled +set -o errtrace # trace ERR through - enabled +set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled +### lib/functions/general/github-actions.sh +# shellcheck source=lib/functions/general/github-actions.sh +source "${SRC}"/lib/functions/general/github-actions.sh + # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled