From 12f212afb7190ba75413e3efe740efffb9d906cc Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Wed, 15 Apr 2026 10:42:37 -0700 Subject: [PATCH] native: bash + SHELL + jq + file for onboard Claude CLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On the G7 user reports Claude Code CLI complains "SHELL env var isn't set" and some Bash-tool commands don't run. Init has HOME+PATH but no SHELL; busybox's sh applet lacks bashisms (arrays, process subs, \$'…' escapes) that CLI internals and user commands rely on. init: export SHELL=/bin/sh, TERM=xterm-256color, COLORTERM=truecolor, EDITOR=/bin/vi so tty-based tools like Claude's repl get reasonable color + editor behavior. docker-build.sh: - Bundle real GNU bash (from the builder image) + its shared-lib deps at /bin/bash. Claude's Bash tool `bash -c "…"` now hits actual bash, not busybox-pretending-to-be-sh. - Additional busybox applets: pwd tty logger clear reset man less more tac nl fold cmp hexdump md5sum sha256sum sha512sum base64 nslookup ping traceroute pgrep pkill timeout stty sysctl free uptime uname usleep unzip zcat — common CLI ergonomics. - Bundle jq, file, strace if present — common debug tools. jq is critical for any JSON poking from the shell. Dockerfile.builder: explicit bash + file installs so the above always have a source in the builder image (they would mostly be there anyway but the list is now self-documenting). Audio: still investigating. G7 now reports 3 sdmode toggles (was 10,686) confirming the 10ms/40ms SOF buffer fix works. hw:0,0 correctly opens "Speakers" per /proc/asound. Remaining gap is apparently in the DSP → I2S → amp path at the signal level, not the ALSA/kernel/GPIO layers — testable via the speaker.mjs piece now that ac-native boots cleanly. Co-Authored-By: Claude Opus 4.6 (1M context) --- fedac/native/Dockerfile.builder | 3 ++- fedac/native/docker-build.sh | 34 ++++++++++++++++++++++++++++++++- fedac/native/initramfs/init | 8 ++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/fedac/native/Dockerfile.builder b/fedac/native/Dockerfile.builder index a3241e2263..15a9de882a 100644 --- a/fedac/native/Dockerfile.builder +++ b/fedac/native/Dockerfile.builder @@ -14,7 +14,8 @@ RUN dnf install -y --setopt=install_weak_deps=False \ gcc ccache make cpio lz4 bc perl flex bison diffutils \ elfutils-libelf-devel openssl-devel \ gnu-efi-devel \ - curl jq git tar xz findutils pkgconf-pkg-config zstd xorriso \ + curl jq file git tar xz findutils pkgconf-pkg-config zstd xorriso \ + bash \ ca-certificates \ alsa-lib-devel libdrm-devel flite-devel SDL3-devel \ ffmpeg-free-devel \ diff --git a/fedac/native/docker-build.sh b/fedac/native/docker-build.sh index 304f06355c..43621cdb08 100644 --- a/fedac/native/docker-build.sh +++ b/fedac/native/docker-build.sh @@ -144,9 +144,41 @@ for cmd in sh sleep mkdir mount umount cat echo ls cp mv rm ln chmod chown \ mktemp printf seq stat basename dirname env expr true false readlink \ realpath rmdir uniq yes tar gzip gunzip hostname id ip modprobe \ mkswap swapon vi df du diff xargs nohup pgrep killall cut whoami awk \ - sync poweroff reboot halt mknod udhcpc; do + sync poweroff reboot halt mknod udhcpc \ + pwd tty logger clear reset man less more tac nl fold cmp hexdump md5sum \ + sha256sum sha512sum base64 nslookup ping traceroute pgrep pkill timeout \ + stty sysctl free uptime uname usleep unzip zcat; do ln -s busybox "$IROOT/bin/$cmd" done +# Real GNU bash — busybox's sh applet lacks bashisms (arrays, process +# substitution, [[ ]], $'…' escapes, etc.) that Claude Code CLI's Bash tool +# leans on, plus a lot of user-supplied commands. Ship the full binary from +# the builder image + its shared lib dependencies so `bash -c "..."` works +# without surprises. +BASH_BIN=$(command -v bash) +if [ -n "$BASH_BIN" ] && [ -f "$BASH_BIN" ]; then + cp -L "$BASH_BIN" "$IROOT/bin/bash" + chmod +x "$IROOT/bin/bash" + for dep in $(ldd "$BASH_BIN" 2>/dev/null | grep -oP '/\S+'); do + base=$(basename "$dep") + [ ! -f "$IROOT/lib64/$base" ] && cp -L "$(readlink -f "$dep")" "$IROOT/lib64/$base" 2>/dev/null || true + done + log " Bundled GNU bash for Claude Code CLI" +else + log " bash not found on builder — Claude CLI Bash tool may fail" +fi + +# Additional tools Claude's Bash tool commonly wants: jq for JSON, file +# for type detection, strace for debugging. Best-effort — skip if absent. +for bin in jq file strace; do + SRC_BIN=$(command -v "$bin" 2>/dev/null || true) + [ -z "$SRC_BIN" ] && continue + cp -L "$SRC_BIN" "$IROOT/bin/$bin" + for dep in $(ldd "$SRC_BIN" 2>/dev/null | grep -oP '/\S+'); do + base=$(basename "$dep") + [ ! -f "$IROOT/lib64/$base" ] && cp -L "$(readlink -f "$dep")" "$IROOT/lib64/$base" 2>/dev/null || true + done +done # udhcpc also expected at /sbin/ by wifi.c ln -sf ../bin/busybox "$IROOT/sbin/udhcpc" 2>/dev/null || true diff --git a/fedac/native/initramfs/init b/fedac/native/initramfs/init index 0b5fdae352..f46cba855a 100755 --- a/fedac/native/initramfs/init +++ b/fedac/native/initramfs/init @@ -62,6 +62,14 @@ export SSL_CERT_FILE="/etc/pki/tls/certs/ca-bundle.crt" export CURL_CA_BUNDLE="/etc/pki/tls/certs/ca-bundle.crt" export SSL_CERT_DIR="/etc/ssl/certs" export HOME="/tmp" +# Claude Code CLI (/bin/claude) reads SHELL to know which interpreter to +# spawn for its Bash tool. Without this it errors with "SHELL env var +# isn't set". /bin/sh is busybox — good enough to run short commands. +# TERM gives rich output; COLORTERM hints truecolor so the CLI uses colors. +export SHELL="/bin/sh" +export TERM="${TERM:-xterm-256color}" +export COLORTERM="truecolor" +export EDITOR="/bin/vi" # ── Mount USB config/log partition (for config.json, wifi creds, logs) ── # Prefer the writable config partition over the boot partitions. -- 2.51.2