# shellcheck shell=bash # Shared by scripts/install.sh (Linux) and scripts/macos_install.sh. Sourced, # not run. # sha256 of a file, hex only (sha256sum on Linux, shasum on macOS). sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum < "$1" | cut -d' ' -f1 else shasum -a 256 < "$1" | cut -d' ' -f1 fi } # Shell completions, generated from the CLI's command table. # $1: installed strawberry binary. install_completions() { local bin="$1" entry shell target for entry in "bash:/usr/local/share/bash-completion/completions/strawberry" \ "zsh:/usr/local/share/zsh/site-functions/_strawberry" \ "fish:/usr/local/share/fish/vendor_completions.d/strawberry.fish"; do shell="${entry%%:*}" target="${entry#*:}" install -d -m 0755 "$(dirname "$target")" if "$bin" completion "$shell" > "$target.tmp"; then chmod 0644 "$target.tmp" && mv -f "$target.tmp" "$target" else echo "Warning: could not generate $shell completions" rm -f "$target.tmp" fi done } # Write the installed-files manifest atomically: root-owned, 0644, in # sha256sum format. The daemon records writes to these persistence paths as # evidence instead of raising findings while the content still matches. # $1: manifest path, $2: owner group (root/wheel), then pairs of # . write_installed_manifest() { local manifest="$1" group="$2" shift 2 : > "$manifest.tmp" while [ $# -ge 2 ]; do if [ -f "$1" ]; then printf '%s %s\n' "$(sha256_of "$1")" "$2" >> "$manifest.tmp" fi shift 2 done install -m 0644 -o root -g "$group" "$manifest.tmp" "$manifest" rm -f "$manifest.tmp" } # Attack traces for replay and training (read-only data): # standard.trace evaluates (strawberry replay --inject, the promotion gate), # training.trace trains (strawberry model train --inject-train). # $1: install prefix (/usr/local). install_traces() { local dir="$1/share/strawberry/traces" trace install -d -m 0755 "$dir" for trace in config/traces/*.trace; do install -m 0644 "$trace" "$dir/$(basename "$trace")" done }