From bee37565e15b770a1a79e4855e715575765bf300 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Aug 2026 13:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(bash=5Fheader):=20PKG=5FINSTALL=20string=20?= =?UTF-8?q?=E2=86=92=20function=20+=20export=20DEBIAN=5FFRONTEND?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous definition assigned a multi-word string to PKG_INSTALL: PKG_INSTALL="DEBIAN_FRONTEND=noninteractive apt-get install -y" Downstream generators expand it as '$PKG_INSTALL pkg…', which bash parses as 'DEBIAN_FRONTEND=noninteractive apt-get install -y pkg…' — the leading assignment is treated as a command name, producing 'DEBIAN_FRONTEND=noninteractive: command not found' (e.g. docker.sh line 40). The DEBIAN_FRONTEND variable was also never set, so apt could fall into interactive mode for tzdata / debconf prompts. Fix: turn PKG_INSTALL into a shell function and export DEBIAN_FRONTEND separately. All ~50 call sites keep the existing $PKG_INSTALL pkg… syntax unchanged. Verified: bash -n OK; mock Ubuntu 22.04 run exits 0 with no 'command not found'; mock apt-get receives the correct args. All 44 generators still render successfully. --- generators/__init__.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/generators/__init__.py b/generators/__init__.py index a5a9480..39cc300 100644 --- a/generators/__init__.py +++ b/generators/__init__.py @@ -137,14 +137,27 @@ die() {{ echo "${{LOG_PREFIX}} ERROR: $*" >&2 ; exit 1 ; }} DISTRO_ID="${{ID:-unknown}}" DISTRO_LIKE="${{ID_LIKE:-}}" case "$DISTRO_ID" in - ubuntu|debian) PKG="apt-get"; PKG_INSTALL="DEBIAN_FRONTEND=noninteractive apt-get install -y" ;; - centos|rhel|rocky|almalinux|ol) PKG="yum"; PKG_INSTALL="yum install -y" ;; - fedora) PKG="dnf"; PKG_INSTALL="dnf install -y" ;; + ubuntu|debian) + PKG="apt-get" + export DEBIAN_FRONTEND=noninteractive + PKG_INSTALL() {{ DEBIAN_FRONTEND=noninteractive apt-get install -y "$@"; }} + ;; + centos|rhel|rocky|almalinux|ol) + PKG="yum" + PKG_INSTALL() {{ yum install -y "$@"; }} + ;; + fedora) + PKG="dnf" + PKG_INSTALL() {{ dnf install -y "$@"; }} + ;; *) if echo "$DISTRO_LIKE" | grep -qiE "rhel|centos|fedora"; then - PKG="yum"; PKG_INSTALL="yum install -y" + PKG="yum" + PKG_INSTALL() {{ yum install -y "$@"; }} elif echo "$DISTRO_LIKE" | grep -qi "debian"; then - PKG="apt-get"; PKG_INSTALL="DEBIAN_FRONTEND=noninteractive apt-get install -y" + PKG="apt-get" + export DEBIAN_FRONTEND=noninteractive + PKG_INSTALL() {{ DEBIAN_FRONTEND=noninteractive apt-get install -y "$@"; }} else die "Unsupported distribution: $DISTRO_ID" fi