Skip to content

Commit 61e0a7f

Browse files
committed
Add Kernel Version Parsing and Custom Description
Adds ability to set custom descriptions for kernel inside family config and parses for kernel version.
1 parent ec34878 commit 61e0a7f

File tree

3 files changed

+108
-58
lines changed

3 files changed

+108
-58
lines changed

lib/functions/configuration/change-tracking.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function track_config_variables() {
4141
}
4242

4343
function track_general_config_variables() {
44-
track_config_variables "${1}" BOARDFAMILY KERNELSOURCE KERNEL_MAJOR_MINOR KERNELBRANCH LINUXFAMILY LINUXCONFIG KERNELPATCHDIR KERNEL_PATCH_ARCHIVE_BASE
44+
track_config_variables "${1}" BOARDFAMILY KERNELSOURCE KERNEL_MAJOR_MINOR KERNELBRANCH KERNEL_DESCRIPTION LINUXFAMILY LINUXCONFIG KERNELPATCHDIR KERNEL_PATCH_ARCHIVE_BASE
4545
array_values="yes" track_config_variables "${1}" KERNEL_DRIVERS_SKIP
4646
track_config_variables "${1}" BOOTSOURCE BOOTSOURCEDIR BOOTBRANCH BOOTPATCHDIR BOOTDIR BOOTCONFIG BOOTBRANCH_BOARD BOOTPATCHDIR_BOARD
4747
track_config_variables "${1}" ATFSOURCEDIR ATFDIR ATFBRANCH CRUSTSOURCEDIR CRUSTDIR CRUSTBRANCH LINUXSOURCEDIR

lib/functions/configuration/interactive.sh

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -176,43 +176,93 @@ function interactive_config_ask_board_list() {
176176
done
177177
}
178178

179+
function get_kernel_info_for_branch() {
180+
local search_branch="$1"
181+
local conf_file="${SRC}/config/sources/families/${BOARDFAMILY}.conf"
182+
183+
awk -v branch="$search_branch" '
184+
BEGIN { found=0; major_minor=""; desc="" }
185+
/^[[:space:]]*[a-zA-Z0-9_-]+\)/ {
186+
if ($0 ~ "^[[:space:]]*" branch "\\)") {
187+
found=1
188+
next
189+
} else if (found) {
190+
exit
191+
}
192+
}
193+
found && /declare[[:space:]]+-g[[:space:]]+KERNEL_MAJOR_MINOR=/ {
194+
if (match($0, /"([^"]+)"/, arr)) {
195+
major_minor=arr[1]
196+
}
197+
}
198+
found && /declare[[:space:]]+-g[[:space:]]+KERNEL_DESCRIPTION=/ {
199+
if (match($0, /"([^"]+)"/, arr)) {
200+
desc=arr[1]
201+
}
202+
}
203+
END {
204+
print major_minor "|" desc
205+
}
206+
' "$conf_file"
207+
}
208+
179209
function interactive_config_ask_branch() {
180-
# if BRANCH not set, display selection menu
181-
if [[ -n $BRANCH ]]; then
182-
display_alert "Already set BRANCH, skipping interactive" "${BRANCH}" "debug"
183-
return 0
184-
fi
185-
declare -a options=()
186-
# Loop over the kernel targets and add them to the options array. They're comma separated.
187-
declare one_kernel_target
188-
for one_kernel_target in $(echo "${KERNEL_TARGET}" | tr "," "\n"); do
189-
case $one_kernel_target in
190-
"current")
191-
options+=("current" "Recommended. Usually an LTS kernel")
192-
;;
193-
"legacy")
194-
options+=("legacy" "Old stable / Legacy / Vendor kernel")
195-
;;
196-
"edge")
197-
options+=("edge" "Bleeding edge / latest possible")
198-
;;
199-
"cloud")
200-
options+=("cloud" "Cloud optimised minimal LTS kernel")
201-
;;
202-
*)
203-
options+=("${one_kernel_target}" "Experimental ${one_kernel_target} kernel / for Developers")
204-
;;
205-
esac
206-
done
210+
if [[ -n $BRANCH ]]; then
211+
display_alert "Already set BRANCH, skipping interactive" "${BRANCH}" "debug"
212+
return 0
213+
fi
207214

208-
dialog_if_terminal_set_vars --title "Choose a kernel" --backtitle "$backtitle" --colors \
209-
--menu "Select the target kernel branch.\nSelected BOARD='${BOARD}'\nExact kernel versions depend on selected board and its family." \
210-
$TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
215+
declare -a options=()
216+
declare one_kernel_target
211217

212-
set_interactive_config_value BRANCH "${DIALOG_RESULT}"
218+
for one_kernel_target in $(echo "${KERNEL_TARGET}" | tr "," "\n"); do
213219

214-
[[ -z ${BRANCH} ]] && exit_with_error "No kernel branch selected"
215-
return 0
220+
221+
local version=""
222+
local description=""
223+
224+
local info
225+
info="$(get_kernel_info_for_branch "$one_kernel_target")"
226+
version="${info%%|*}"
227+
description="${info#*|}"
228+
229+
# Fallback if description is empty
230+
if [[ -z "$description" ]]; then
231+
case "$one_kernel_target" in
232+
current)
233+
description="Recommended. Usually an LTS kernel"
234+
;;
235+
legacy)
236+
description="Old stable / Legacy / Vendor kernel"
237+
;;
238+
edge)
239+
description="Bleeding edge / latest possible"
240+
;;
241+
cloud)
242+
description="Cloud optimised minimal LTS kernel"
243+
;;
244+
*)
245+
description="Experimental ${one_kernel_target} kernel / for Developers"
246+
;;
247+
esac
248+
fi
249+
250+
# Append version if found
251+
if [[ -n "$version" ]]; then
252+
description="${description} (${version})"
253+
fi
254+
255+
options+=("${one_kernel_target}" "${description}")
256+
done
257+
258+
dialog_if_terminal_set_vars --title "Choose a kernel" --backtitle "$backtitle" --colors \
259+
--menu "Select the target kernel branch.\nSelected BOARD='${BOARD}'\nExact kernel versions depend on selected board and its family." \
260+
$TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}"
261+
262+
set_interactive_config_value BRANCH "${DIALOG_RESULT}"
263+
264+
[[ -z ${BRANCH} ]] && exit_with_error "No kernel branch selected"
265+
return 0
216266
}
217267

218268
function interactive_config_ask_release() {

lib/library-functions.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
100100
# shellcheck source=lib/functions/artifacts/artifact-rootfs.sh
101101
source "${SRC}"/lib/functions/artifacts/artifact-rootfs.sh
102102

103+
# no errors tolerated. invoked before each sourced file to make sure.
104+
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
105+
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
106+
set -o errtrace # trace ERR through - enabled
107+
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
108+
### lib/functions/artifacts/artifact-uboot.sh
109+
# shellcheck source=lib/functions/artifacts/artifact-uboot.sh
110+
source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh
111+
103112
# no errors tolerated. invoked before each sourced file to make sure.
104113
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
105114
#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
127136
# shellcheck source=lib/functions/artifacts/artifacts-reversion.sh
128137
source "${SRC}"/lib/functions/artifacts/artifacts-reversion.sh
129138

130-
# no errors tolerated. invoked before each sourced file to make sure.
131-
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
132-
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
133-
set -o errtrace # trace ERR through - enabled
134-
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
135-
### lib/functions/artifacts/artifact-uboot.sh
136-
# shellcheck source=lib/functions/artifacts/artifact-uboot.sh
137-
source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh
138-
139139
# no errors tolerated. invoked before each sourced file to make sure.
140140
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
141141
#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
474474
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
475475
set -o errtrace # trace ERR through - enabled
476476
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
477-
### lib/functions/compilation/patch/drivers-harness.sh
478-
# shellcheck source=lib/functions/compilation/patch/drivers-harness.sh
479-
source "${SRC}"/lib/functions/compilation/patch/drivers-harness.sh
477+
### lib/functions/compilation/patch/drivers_network.sh
478+
# shellcheck source=lib/functions/compilation/patch/drivers_network.sh
479+
source "${SRC}"/lib/functions/compilation/patch/drivers_network.sh
480480

481481
# no errors tolerated. invoked before each sourced file to make sure.
482482
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
483483
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
484484
set -o errtrace # trace ERR through - enabled
485485
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
486-
### lib/functions/compilation/patch/drivers_network.sh
487-
# shellcheck source=lib/functions/compilation/patch/drivers_network.sh
488-
source "${SRC}"/lib/functions/compilation/patch/drivers_network.sh
486+
### lib/functions/compilation/patch/drivers-harness.sh
487+
# shellcheck source=lib/functions/compilation/patch/drivers-harness.sh
488+
source "${SRC}"/lib/functions/compilation/patch/drivers-harness.sh
489489

490490
# no errors tolerated. invoked before each sourced file to make sure.
491491
#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
676676
# shellcheck source=lib/functions/general/extensions.sh
677677
source "${SRC}"/lib/functions/general/extensions.sh
678678

679-
# no errors tolerated. invoked before each sourced file to make sure.
680-
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
681-
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
682-
set -o errtrace # trace ERR through - enabled
683-
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
684-
### lib/functions/general/github-actions.sh
685-
# shellcheck source=lib/functions/general/github-actions.sh
686-
source "${SRC}"/lib/functions/general/github-actions.sh
687-
688679
# no errors tolerated. invoked before each sourced file to make sure.
689680
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
690681
#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
703694
# shellcheck source=lib/functions/general/git.sh
704695
source "${SRC}"/lib/functions/general/git.sh
705696

697+
# no errors tolerated. invoked before each sourced file to make sure.
698+
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
699+
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
700+
set -o errtrace # trace ERR through - enabled
701+
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
702+
### lib/functions/general/github-actions.sh
703+
# shellcheck source=lib/functions/general/github-actions.sh
704+
source "${SRC}"/lib/functions/general/github-actions.sh
705+
706706
# no errors tolerated. invoked before each sourced file to make sure.
707707
#set -o pipefail # trace ERR through pipes - will be enabled "soon"
708708
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled

0 commit comments

Comments
 (0)