cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

fix/portal-dist-prebuild
goq / scripts / tests / bazzite-host-executable-layout.sh
bazzite-host-executable-layout.sh 2.5K executable
1#!/usr/bin/env bash23set -euo pipefail45script_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"6repo_dir="$(CDPATH='' cd -- "$script_dir/../.." && pwd -P)"7rollback="$repo_dir/scripts/rollback-bazzite-release.sh"8temp_parent="${TMPDIR:-/tmp}"9temp_parent="${temp_parent%/}"10temp_root="$(mktemp -d "$temp_parent/sigil-host-layout.XXXXXX")"11helper_script="$temp_root/release-host-executable.sh"1213cleanup() {14 local status=$?15 trap - EXIT INT TERM HUP16 case "$temp_root" in17 "$temp_parent"/sigil-host-layout.??????) rm -rf -- "$temp_root" ;;18 esac19 exit "$status"20}21trap cleanup EXIT INT TERM HUP2223sed -n \24 '/^# BEGIN release host executable compatibility helper$/,/^# END release host executable compatibility helper$/p' \25 "$rollback" | sed '1d;$d' >"$helper_script"26grep -Fq 'release_host_executable()' "$helper_script"2728# shellcheck source=/dev/null29source "$helper_script"3031make_executable() {32 local path="$1"33 local marker="$2"34 printf '#!/usr/bin/env bash\n# %s\nexit 0\n' "$marker" >"$path"35 chmod 0755 "$path"36}3738legacy="$temp_root/legacy"39install -d -m 0700 "$legacy"40make_executable "$legacy/sigil-host" legacy41[[ "$(release_host_executable "$legacy")" == "$legacy/sigil-host" ]]4243current="$temp_root/current"44install -d -m 0700 "$current"45make_executable "$current/sigil" current46cp "$current/sigil" "$current/sigil-host"47chmod 0755 "$current/sigil-host"48[[ "$(release_host_executable "$current")" == "$current/sigil" ]]4950missing_alias="$temp_root/missing-alias"51install -d -m 0700 "$missing_alias"52make_executable "$missing_alias/sigil" current53if release_host_executable "$missing_alias" >/dev/null; then54 printf 'FAIL: new release without sigil-host compatibility copy was accepted\n' >&255 exit 156fi5758mismatched_alias="$temp_root/mismatched-alias"59install -d -m 0700 "$mismatched_alias"60make_executable "$mismatched_alias/sigil" current61make_executable "$mismatched_alias/sigil-host" different62if release_host_executable "$mismatched_alias" >/dev/null; then63 printf 'FAIL: mismatched sigil-host compatibility copy was accepted\n' >&264 exit 165fi6667unsafe_primary="$temp_root/unsafe-primary"68install -d -m 0700 "$unsafe_primary"69make_executable "$unsafe_primary/elsewhere" current70ln -s elsewhere "$unsafe_primary/sigil"71cp "$unsafe_primary/elsewhere" "$unsafe_primary/sigil-host"72chmod 0755 "$unsafe_primary/sigil-host"73if release_host_executable "$unsafe_primary" >/dev/null; then74 printf 'FAIL: symlink primary executable was accepted as a legacy layout\n' >&275 exit 176fi7778printf 'bazzite_host_executable_layout_tests=ok\n'