fix(generators): call PKG_INSTALL without '$' under 'set -u'

In bash with 'set -u', an undefined variable triggers an unbound-variable
error. Functions don't satisfy '$FUNCNAME' expansion under set -u, so
the previous fix that kept '$PKG_INSTALL pkg...' as the call syntax
broke every call site:

    docker.sh: line 53: PKG_INSTALL: unbound variable

Fix: drop the leading '$' in all 47 call sites across 6 generator
files. 'PKG_INSTALL pkg...' is a normal command/function lookup and
behaves identically under set -u or not.

Verified: web UI served docker.sh now has 'PKG_INSTALL' (no $);
'bash -n' passes; smoke run with stubbed PATH hits real line-53 call
site, mock apt-get receives correct args, exit 0, no unbound variable.
Sampled 6 other generators also syntax-OK with $PKG_INSTALL count 0.
This commit is contained in:
Your Name
2026-08-07 13:20:18 +08:00
parent bee37565e1
commit 66aefd6161
6 changed files with 47 additions and 47 deletions
+4 -4
View File
@@ -27,7 +27,7 @@ class Memcached(Generator):
listen = p.get("listen", "0.0.0.0")
out = [bash_header(self.title)]
out.append('log "Installing memcached..."')
out.append('$PKG_INSTALL memcached')
out.append('PKG_INSTALL memcached')
out.append('cp /etc/memcached.conf /etc/memcached.conf.bak.$(date +%s) || true')
out.append('sed -i "s/^-m .*/-m ' + mem + '/" /etc/memcached.conf')
out.append('sed -i "s/^-p .*/-p ' + port + '/" /etc/memcached.conf')
@@ -54,9 +54,9 @@ class SqliteTools(Generator):
pyb = bool_str(p.get("install_python_bindings", True))
out = [bash_header(self.title)]
out.append('log "Installing sqlite3..."')
out.append('$PKG_INSTALL sqlite3 libsqlite3-dev || $PKG_INSTALL sqlite sqlite-devel')
out.append('PKG_INSTALL sqlite3 libsqlite3-dev || PKG_INSTALL sqlite sqlite-devel')
if pyb:
out.append('command -v pip3 >/dev/null || $PKG_INSTALL python3-pip')
out.append('command -v pip3 >/dev/null || PKG_INSTALL python3-pip')
out.append('pip3 install --break-system-packages sqlite-utils || pip3 install sqlite-utils')
out.append('sqlite3 --version')
return "\n".join(out) + "\n"
@@ -143,7 +143,7 @@ class ClickHouse(Generator):
dp = p.get("data_path", "/var/lib/clickhouse")
out = [bash_header(self.title)]
out.append('log "Installing ClickHouse..."')
out.append('$PKG_INSTALL apt-transport-https ca-certificates curl || $PKG_INSTALL ca-certificates curl')
out.append('PKG_INSTALL apt-transport-https ca-certificates curl || PKG_INSTALL ca-certificates curl')
out.append('mkdir -p /etc/apt/keyrings')
out.append('curl -fsSL https://clickhouse.com/keys/clickhouse.asc | gpg --dearmor -o /etc/apt/keyrings/clickhouse.gpg')
out.append('echo "deb [signed-by=/etc/apt/keyrings/clickhouse.gpg] https://packages.clickhouse.com/deb stable main" > /etc/apt/sources.list.d/clickhouse.list')