Skip to content

Commit 6278aaa

Browse files
committed
bug: fix kernel hwe detection to installed status (#878)
1 parent 63a6c55 commit 6278aaa

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

print_summary_table.sh

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ main() {
4141
print_footer
4242
}
4343

44+
# Extract installed HWE version and apt status tag (returns two lines: version, tag)
45+
get_installed_hwe_info() {
46+
local output="$1"
47+
local installed_line version tag
48+
installed_line=$(echo "$output" | grep -E "\[installed" | head -n1 || true)
49+
if [ -n "$installed_line" ]; then
50+
version=$(echo "$installed_line" | awk '{print $2}' || true)
51+
tag=$(echo "$installed_line" | grep -o "\[installed[^]]*\]" || true)
52+
else
53+
version=$(echo "$output" | grep -E "linux-image-generic-hwe-" | head -n1 | awk '{print $2}' || true)
54+
tag=""
55+
fi
56+
printf "%s\n%s\n" "$version" "$tag"
57+
}
58+
4459
# Print summary header
4560
print_header() {
4661
printf "\n==================== System Installation Summary ====================\n"
@@ -55,14 +70,17 @@ detect_system_info() {
5570
kernel_version=$(timeout_cmd 3 uname -r)
5671

5772
# HWE stack detection using apt list with timeout
58-
local hwe_kernel_output hwe_version
73+
local hwe_kernel_output hwe_version hwe_tag
5974
hwe_kernel_output=$(timeout_cmd 5 apt list -a --installed linux-image-generic-hwe-* 2>/dev/null || true)
6075

6176
if [ -n "$hwe_kernel_output" ]; then
62-
# Extract version from apt list output
63-
hwe_version=$(echo "$hwe_kernel_output" | grep -E "linux-image-generic-hwe-" | head -n1 | awk '{print $2}' || true)
77+
read -r hwe_version hwe_tag < <(get_installed_hwe_info "$hwe_kernel_output")
6478
if [ -n "$hwe_version" ]; then
65-
hwe_stack="Installed ($hwe_version)"
79+
if [ -n "$hwe_tag" ]; then
80+
hwe_stack="Installed ($hwe_version) $hwe_tag"
81+
else
82+
hwe_stack="Installed ($hwe_version)"
83+
fi
6684
else
6785
hwe_stack="Installed"
6886
fi
@@ -331,19 +349,22 @@ validate_configuration() {
331349
fi
332350

333351
# HARD CHECK 3: HWE kernel requirement with 6.14 version check
334-
local hwe_stack hwe_kernel_output hwe_version hwe_kernel_major hwe_kernel_minor
352+
local hwe_stack hwe_kernel_output hwe_version hwe_kernel_major hwe_kernel_minor hwe_tag
335353
hwe_kernel_output=$(timeout_cmd 5 apt list -a --installed linux-image-generic-hwe-* 2>/dev/null || true)
336354

337355
if [ -n "$hwe_kernel_output" ]; then
338-
# Extract version from apt list output
339-
hwe_version=$(echo "$hwe_kernel_output" | grep -E "linux-image-generic-hwe-" | head -n1 | awk '{print $2}' || true)
356+
read -r hwe_version hwe_tag < <(get_installed_hwe_info "$hwe_kernel_output")
340357
if [ -n "$hwe_version" ]; then
341358
# Extract major.minor version from HWE kernel (e.g., "6.14" from "6.14.0-33.33~24.04.1")
342359
hwe_kernel_major=$(echo "$hwe_version" | cut -d. -f1)
343360
hwe_kernel_minor=$(echo "$hwe_version" | cut -d. -f2)
344361

345362
if [ "$hwe_kernel_major" = "6" ] && [ "$hwe_kernel_minor" = "14" ]; then
346-
hwe_stack="Installed (6.14 HWE)"
363+
if [ -n "$hwe_tag" ]; then
364+
hwe_stack="Installed (6.14 HWE) $hwe_tag"
365+
else
366+
hwe_stack="Installed (6.14 HWE)"
367+
fi
347368

348369
# Check if current running kernel matches HWE kernel version
349370
if [[ ! "$kernel_version" =~ ^6\.14 ]]; then
@@ -401,7 +422,20 @@ validate_configuration() {
401422
else
402423
printf "%-25s | %-40s\n" "Platform Status" "$S_ERROR Incorrect platform configuration"
403424
if [ ${#missing_items[@]} -gt 0 ]; then
404-
printf "%-25s | %-40s\n" "Missing/Invalid Items" "$(IFS=', '; echo "${missing_items[*]}")"
425+
# Dedupe missing_items to avoid repeated entries
426+
declare -A _seen
427+
declare -a _unique
428+
for _item in "${missing_items[@]}"; do
429+
if [ -n "$_item" ] && [ -z "${_seen[$_item]}" ]; then
430+
_seen[$_item]=1
431+
_unique+=("$_item")
432+
fi
433+
done
434+
# Print header once, then each missing item on its own line
435+
printf "%-25s | %-40s\n" "Missing/Invalid Items" "${_unique[0]}"
436+
for ((i=1; i<${#_unique[@]}; i++)); do
437+
printf "%-25s | %-40s\n" "" "${_unique[$i]}"
438+
done
405439
fi
406440
fi
407441

0 commit comments

Comments
 (0)