add injected code for openeuler
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -7,8 +7,10 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
|||||||
# Source: https://www.openeuler.org/
|
# Source: https://www.openeuler.org/
|
||||||
|
|
||||||
# NOTE: openEuler has a PVE compatibility issue
|
# NOTE: openEuler has a PVE compatibility issue
|
||||||
# PVE's post_create_hook expects /etc/redhat-release which openEuler doesn't have by default
|
# PVE detects openEuler templates as ostype 'centos', but the templates ship
|
||||||
# We handle this in build.func by creating the file after container creation
|
# without /etc/redhat-release, so PVE's post_create_hook aborts pct create.
|
||||||
|
# build.func patches the cached template once (injects /etc/redhat-release)
|
||||||
|
# right before pct create, see template_patch step in build_container().
|
||||||
|
|
||||||
APP="openEuler"
|
APP="openEuler"
|
||||||
var_tags="${var_tags:-os}"
|
var_tags="${var_tags:-os}"
|
||||||
|
|||||||
@@ -6067,6 +6067,32 @@ create_lxc_container() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# openEuler templates are detected by PVE as ostype 'centos' but ship without
|
||||||
|
# /etc/redhat-release, which makes PVE::LXC::Setup::post_create_hook abort with
|
||||||
|
# "can't open '/etc/redhat-release' - No such file or directory".
|
||||||
|
# Patch the cached template once to inject a CentOS-compatible release file.
|
||||||
|
if [[ "${var_os:-}" == "openeuler" ]]; then
|
||||||
|
if ! tar -tf "$TEMPLATE_PATH" 2>/dev/null | grep -qE '^\.?/?etc/redhat-release$'; then
|
||||||
|
msg_info "Patching openEuler template (adding /etc/redhat-release)"
|
||||||
|
local _oe_tmp
|
||||||
|
_oe_tmp=$(mktemp -d) || _oe_tmp=""
|
||||||
|
if [[ -n "$_oe_tmp" ]] && mkdir -p "$_oe_tmp/etc"; then
|
||||||
|
# Content is parsed by PVE's CentOS setup plugin (expects "<name> release <ver>")
|
||||||
|
local _oe_ver="${var_version:-25.03}"
|
||||||
|
echo "CentOS Linux release ${_oe_ver} (openEuler)" >"$_oe_tmp/etc/redhat-release"
|
||||||
|
if xz -dc "$TEMPLATE_PATH" >"$_oe_tmp/template.tar" 2>/dev/null &&
|
||||||
|
tar -C "$_oe_tmp" --append -f "$_oe_tmp/template.tar" etc/redhat-release 2>/dev/null &&
|
||||||
|
xz -f "$_oe_tmp/template.tar" 2>/dev/null &&
|
||||||
|
mv -f "$_oe_tmp/template.tar.xz" "$TEMPLATE_PATH"; then
|
||||||
|
msg_ok "Patched openEuler template"
|
||||||
|
else
|
||||||
|
msg_warn "Failed to patch openEuler template – pct create may fail in post_create_hook"
|
||||||
|
fi
|
||||||
|
rm -rf "$_oe_tmp"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Release lock after template validation - pct create has its own internal locking
|
# Release lock after template validation - pct create has its own internal locking
|
||||||
exec 9>&-
|
exec 9>&-
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user