Files
steamify-cachyos/.github/tools/bundle.sh
T
theupriser 443dbcdfb8 feat: Power-off fix for the Steam Machine; the kernel pin is optional
Kernels >= 7.2 keep the firmware's S4/S5 wake bit on GPIO pin 18, so the
Steam Machine starts again right after powering off. Steam Machine
support now builds a DKMS module (patches/steamify-fremont-poweroff.c)
that clears it before power-off, for every kernel. The kernel pin is no
longer ticked by default. Module sources and patches move to patches/,
embedded by the single-file build.
2026-09-27 12:13:23 +02:00

67 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Build a single-file version of the wizard for `curl | bash` use:
# .github/tools/bundle.sh [output] (default: dist/steamify.sh)
#
# Inlines lib/*.sh in the order steamify.sh sources them and
# wraps the entry point's body in main(), so bash has read the whole file
# before anything runs. That lets the bundle reattach stdin to the terminal
# when it was piped in by curl, so the interactive menu still works.
set -euo pipefail
cd "$(dirname "$0")/../.."
out="${1:-dist/steamify.sh}"
entry=steamify.sh
mkdir -p "$(dirname "$out")"
# Library order, taken from the entry point's source loop.
libs=$(grep -oP '^for lib in \K.*(?=; do$)' "$entry")
[[ -n "$libs" ]] || { echo "bundle: can't find the lib source loop in $entry" >&2; exit 1; }
version="v$(grep -oP '^VERSION=\K.*' "$entry"), $(git describe --always --dirty 2>/dev/null || echo unknown)"
{
# Header comment and `set` line of the entry point, up to the source loop.
sed -n '1,/^SCRIPT_DIR=/p' "$entry" | sed '$d'
echo "# Single-file build ($version), generated by .github/tools/bundle.sh - edit the"
echo "# sources in the repository instead: https://github.com/theupriser/steamify-cachyos"
echo
for lib in $libs; do
echo "# ----- lib/$lib.sh -----"
# Drop each module's shebang and its "Sourced by ..." boilerplate.
sed -e '1{/^#!/d}' -e '/^# Sourced by steamify.sh/d' "lib/$lib.sh"
echo
done
# patches/ embedded: replaces lib/common.sh's patch_file, which reads
# them from the checkout.
echo "# ----- patches/ -----"
echo "patch_file() {"
echo ' case "$1" in'
for f in patches/*; do
[[ "$f" == patches/README.md ]] && continue
grep -q '^STEAMIFY_PATCH_EOF$' "$f" && { echo "bundle: $f contains the heredoc delimiter" >&2; exit 1; }
echo " $(basename "$f")) cat << 'STEAMIFY_PATCH_EOF'"
cat "$f"
echo "STEAMIFY_PATCH_EOF"
echo " ;;"
done
echo ' *) return 1 ;;'
echo ' esac'
echo "}"
echo
echo "# ----- steamify.sh -----"
echo "main() {"
# Everything after the source loop is the entry point's body.
sed -n '/^for lib in /,$p' "$entry" | sed '1,/^done$/d' | sed 's/^/ /; s/^ $//'
echo "}"
echo
echo "# Piped in via curl, bash reads this very file from stdin. Give the menu"
echo "# the terminal instead - on the same line as main and exit: bash has read"
echo "# this line in full, so it never reads further script from the terminal."
echo 'reattach_tty() { if [[ ! -t 0 && -z "${WIZARD_KEEP_STDIN:-}" ]]; then { exec </dev/tty; } 2>/dev/null || true; fi; }'
echo 'reattach_tty; main "$@"; exit $?'
} > "$out"
chmod +x "$out"
bash -n "$out"
echo "Wrote $out ($version)"