From de7b985b8805b88c4fa4f8c1cf71710b6d22d9a9 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 21 Oct 2025 14:55:37 +0200 Subject: [PATCH] Refine LXC template matching to exclude digits Updated awk and grep patterns in create_lxc_container to match non-digit characters after TEMPLATE_SEARCH, instead of only dashes or underscores. This improves accuracy when filtering available and local LXC templates. --- misc/build.func | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/build.func b/misc/build.func index 6e2ae201..ea92c0ee 100644 --- a/misc/build.func +++ b/misc/build.func @@ -3000,14 +3000,14 @@ create_lxc_container() { mapfile -t LOCAL_TEMPLATES < <( pveam list "$TEMPLATE_STORAGE" 2>/dev/null | - awk -v s="$TEMPLATE_SEARCH" -v p="$TEMPLATE_PATTERN" '$1 ~ "^"s"[-_]" && $1 ~ p {print $1}' | + awk -v s="$TEMPLATE_SEARCH" -v p="$TEMPLATE_PATTERN" '$1 ~ "^"s"[^0-9]" && $1 ~ p {print $1}' | sed 's|.*/||' | sort -t - -k 2 -V ) pveam update >/dev/null 2>&1 || msg_warn "Could not update template catalog (pveam update failed)." mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2>/dev/null | - grep -E "^${TEMPLATE_SEARCH}[-_].*${TEMPLATE_PATTERN}" | + grep -E "^${TEMPLATE_SEARCH}[^0-9].*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) ONLINE_TEMPLATE="" @@ -3063,12 +3063,12 @@ create_lxc_container() { TEMPLATE_SEARCH="${PCT_OSTYPE}-${PCT_OSVERSION:-}" mapfile -t LOCAL_TEMPLATES < <( pveam list "$TEMPLATE_STORAGE" 2>/dev/null | - awk -v s="$TEMPLATE_SEARCH" -v p="$TEMPLATE_PATTERN" '$1 ~ "^"s"[-_]" && $1 ~ p {print $1}' | + awk -v s="$TEMPLATE_SEARCH" -v p="$TEMPLATE_PATTERN" '$1 ~ "^"s"[^0-9]" && $1 ~ p {print $1}' | sed 's|.*/||' | sort -t - -k 2 -V ) mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2>/dev/null | - grep -E "^${TEMPLATE_SEARCH}[-_].*${TEMPLATE_PATTERN}" | + grep -E "^${TEMPLATE_SEARCH}[^0-9].*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) ONLINE_TEMPLATE=""