Skip to content

Proposed Change - Add Kernel Version Parsing and Custom Description #8152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/sources/families/k3.conf
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ case "${BRANCH}" in
declare -g CORESDK_TAG="tag:11.00.09"
declare -g KERNEL_MAJOR_MINOR="6.12"
declare -g KERNELBRANCH="${CORESDK_TAG}"
declare -g KERNEL_DESCRIPTION="Texas Instruments currently supported SDK (vendor) kernel"
declare -g ATFBRANCH="commit:b11beb2b6bd30b75c4bfb0e9925c0e72f16ca53f"
declare -g OPTEE_BRANCH="tag:4.6.0"
declare -g TI_LINUX_FIRMWARE_BRANCH="${CORESDK_TAG}"
@@ -43,6 +44,7 @@ case "${BRANCH}" in
declare -g TI_LINUX_FIRMWARE_BRANCH="${CORESDK_TAG}"
declare -g BOOTBRANCH="${CORESDK_TAG}"
EXTRAWIFI="no"
declare -g KERNEL_DESCRIPTION="Edge branch of TI Linux SDK"
;;

esac
2 changes: 1 addition & 1 deletion lib/functions/configuration/change-tracking.sh
Original file line number Diff line number Diff line change
@@ -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
116 changes: 83 additions & 33 deletions lib/functions/configuration/interactive.sh
Original file line number Diff line number Diff line change
@@ -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() {