From 4e856c86a29482ee136c4b0c3de706a229fcdda8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:24:33 +0200 Subject: [PATCH] Update build.func --- misc/build.func | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/misc/build.func b/misc/build.func index 613adeaf..b2e4ce41 100644 --- a/misc/build.func +++ b/misc/build.func @@ -3010,7 +3010,8 @@ create_lxc_container() { 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 | - awk '/\.tar\.(zst|xz|gz)/ {print $1}' | + grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | + awk '{print $1}' | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) @@ -3019,6 +3020,12 @@ create_lxc_container() { msg_debug "SEARCH_PATTERN='${SEARCH_PATTERN}' TEMPLATE_PATTERN='${TEMPLATE_PATTERN}'" msg_debug "Found ${#LOCAL_TEMPLATES[@]} local templates, ${#ONLINE_TEMPLATES[@]} online templates" + if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then + msg_debug "First 3 online templates:" + for i in {0..2}; do + [[ -n "${ONLINE_TEMPLATES[$i]}" ]] && msg_debug " [$i]: ${ONLINE_TEMPLATES[$i]}" + done + fi msg_debug "ONLINE_TEMPLATE='$ONLINE_TEMPLATE'" if [[ ${#LOCAL_TEMPLATES[@]} -gt 0 ]]; then @@ -3080,7 +3087,8 @@ create_lxc_container() { ) mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2>/dev/null | - awk '/\.tar\.(zst|xz|gz)/ {print $1}' | + grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | + awk '{print $1}' | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) @@ -3121,6 +3129,15 @@ create_lxc_container() { fi } + # Validate that we found a template + if [[ -z "$TEMPLATE" ]]; then + msg_error "No template found for ${PCT_OSTYPE} ${PCT_OSVERSION}" + msg_info "Please check:" + msg_info " - Is pveam catalog available? (run: pveam available -section system)" + msg_info " - Does the template exist for your OS version?" + exit 225 + fi + msg_ok "Template ${BL}$TEMPLATE${CL} [$TEMPLATE_SOURCE]" msg_debug "Resolved TEMPLATE_PATH=$TEMPLATE_PATH"