Skip to content

Commit 597c825

Browse files
committed
json: add kernel_version field to images output
Extract kernel version from image filename and include it as a separate field in the generated JSON. This allows users to filter and identify images by their kernel version. Handles both standard and community image filename patterns: - Standard: Armbian_24.11.1_Board_Distro_Branch_6.6.62_... → kernel at array index 5 - Community: Armbian_community_26.2.0-trunk.357_Board_Distro_Branch_6.1.115_... → kernel at array index 6 The extraction properly strips: - Variant suffixes (e.g., "6.6.62-gnome" → "6.6.62") - File extensions (e.g., "6.6.62.img.xz" → "6.6.62") - RC suffixes (e.g., "6.19.0-rc7" → "6.19.0") While preserving version number dots (e.g., "6.6.62", "6.12.58"). Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent a651181 commit 597c825

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

scripts/generate-armbian-images-json.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
539539
# JSON generation
540540
# -----------------------------------------------------------------------------
541541
{
542-
echo '"board_slug"|"board_name"|"board_vendor"|"board_support"|"company_name"|"company_website"|"company_logo"|"armbian_version"|"file_url"|"file_url_asc"|"file_url_sha"|"file_url_torrent"|"redi_url"|"redi_url_asc"|"redi_url_sha"|"redi_url_torrent"|"file_size"|"file_date"|"distro"|"branch"|"variant"|"file_application"|"promoted"|"download_repository"|"file_extension"|"platinum"|"platinum_expired"|"platinum_until"'
542+
echo '"board_slug"|"board_name"|"board_vendor"|"board_support"|"company_name"|"company_website"|"company_logo"|"armbian_version"|"file_url"|"file_url_asc"|"file_url_sha"|"file_url_torrent"|"redi_url"|"redi_url_asc"|"redi_url_sha"|"redi_url_torrent"|"file_size"|"file_date"|"distro"|"branch"|"variant"|"file_application"|"promoted"|"download_repository"|"file_extension"|"kernel_version"|"platinum"|"platinum_expired"|"platinum_until"'
543543

544544
while IFS="|" read -r SIZE URL DATE; do
545545
IMAGE_SIZE="${SIZE//[.,]/}"
@@ -549,6 +549,24 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
549549
VER="${p[0]:-}"; BOARD="${p[1]:-}"; DISTRO="${p[2]:-}"; BRANCH="${p[3]:-}"
550550
VARIANT="${p[4]:-server}"; APP="${p[5]:-}"; STORAGE="${p[6]:-}"
551551

552+
# Extract kernel version by splitting filename and getting the appropriate field
553+
# Standard: Armbian_24.11.1_Board_Distro_Branch_Kernel_... (kernel at index 5)
554+
# Community: Armbian_community_Version_Board_Distro_Branch_Kernel_... (kernel at index 6)
555+
KERNEL_VERSION=""
556+
IFS='_' read -r -a f <<< "$IMAGE_NAME"
557+
if [[ "${f[1]:-}" =~ ^[0-9]+\.[0-9] ]]; then
558+
# Version token at position 1 (standard images)
559+
KERNEL_VERSION="${f[5]:-}"
560+
else
561+
# Version token at position 2 (community images with prefix)
562+
KERNEL_VERSION="${f[6]:-}"
563+
fi
564+
# Strip any suffixes: variants (e.g., "6.6.62-gnome" -> "6.6.62")
565+
# and file extensions (e.g., "6.6.62.img.xz" -> "6.6.62")
566+
KERNEL_VERSION="${KERNEL_VERSION%%-*}"
567+
# Strip .img* suffix only if present (doesn't affect version numbers with dots)
568+
KERNEL_VERSION="${KERNEL_VERSION%.img*}"
569+
552570
[[ -z "$BOARD" ]] && continue
553571
BOARD_SLUG="${BOARD,,}"
554572

@@ -649,7 +667,7 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
649667
PLAT_EXPIRED="false"
650668
fi
651669
fi
652-
echo "${BOARD_SLUG}|${BOARD_NAME_MAP[$BOARD_SLUG]:-}|${BOARD_VENDOR}|${BOARD_SUPPORT}|${C_NAME}|${C_WEB}|${C_LOGO}|${VER}|${FILE_URL}|${ASC}|${SHA}|${TOR}|${REDI_URL}|${REDI_URL}.asc|${REDI_URL}.sha|${REDI_URL}.torrent|${IMAGE_SIZE}|${DATE}|${DISTRO}|${BRANCH}|${VARIANT}|${APP}|${PROMOTED}|${REPO}|${FILE_EXTENSION}|${PLAT}|${PLAT_EXPIRED}|${PLAT_UNTIL}"
670+
echo "${BOARD_SLUG}|${BOARD_NAME_MAP[$BOARD_SLUG]:-}|${BOARD_VENDOR}|${BOARD_SUPPORT}|${C_NAME}|${C_WEB}|${C_LOGO}|${VER}|${FILE_URL}|${ASC}|${SHA}|${TOR}|${REDI_URL}|${REDI_URL}.asc|${REDI_URL}.sha|${REDI_URL}.torrent|${IMAGE_SIZE}|${DATE}|${DISTRO}|${BRANCH}|${VARIANT}|${APP}|${PROMOTED}|${REPO}|${FILE_EXTENSION}|${KERNEL_VERSION}|${PLAT}|${PLAT_EXPIRED}|${PLAT_UNTIL}"
653671

654672
# Check if this board is used by any reusable boards
655673
for reusable_slug in "${!REUSABLE_BOARD_USES[@]}"; do
@@ -728,7 +746,7 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
728746
fi
729747

730748
# Output for reusable board
731-
echo "${reusable_slug}|${reusable_name}|${reusable_vendor}|${reusable_support}|${reusable_c_name}|${reusable_c_web}|${reusable_c_logo}|${VER}|${FILE_URL}|${reusable_asc}|${reusable_sha}|${reusable_tor}|${reusable_redi_url}|${reusable_redi_url}.asc|${reusable_redi_url}.sha|${reusable_redi_url}.torrent|${IMAGE_SIZE}|${DATE}|${DISTRO}|${BRANCH}|${VARIANT}|${APP}|${reusable_promoted}|${REPO}|${FILE_EXTENSION}|${reusable_plat}|${reusable_plat_expired}|${reusable_plat_until}"
749+
echo "${reusable_slug}|${reusable_name}|${reusable_vendor}|${reusable_support}|${reusable_c_name}|${reusable_c_web}|${reusable_c_logo}|${VER}|${FILE_URL}|${reusable_asc}|${reusable_sha}|${reusable_tor}|${reusable_redi_url}|${reusable_redi_url}.asc|${reusable_redi_url}.sha|${reusable_redi_url}.torrent|${IMAGE_SIZE}|${DATE}|${DISTRO}|${BRANCH}|${VARIANT}|${APP}|${reusable_promoted}|${REPO}|${FILE_EXTENSION}|${KERNEL_VERSION}|${reusable_plat}|${reusable_plat_expired}|${reusable_plat_until}"
732750
fi
733751
done
734752
done <"$feed"

0 commit comments

Comments
 (0)