62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# != 1 ]]; then
|
|
echo "usage: $0 SOURCE_ROOT" >&2
|
|
exit 2
|
|
fi
|
|
|
|
source_root=$(realpath -e -- "$1")
|
|
temporary=$(mktemp -d "${TMPDIR:-/tmp}/echoion-release-archive.XXXXXX")
|
|
trap 'rm -rf -- "$temporary"' EXIT
|
|
stage="$temporary/stage"
|
|
mkdir -p "$stage/bin" "$stage/lib"
|
|
install -m 0755 /bin/true "$stage/bin/echoiond"
|
|
install -m 0644 /bin/true "$stage/lib/Echoion.ts"
|
|
printf '%s\n' '{}' >"$stage/manifest.json"
|
|
cat >"$stage/install.sh" <<'INSTALL'
|
|
#!/bin/sh
|
|
set -eu
|
|
payload_root=$(CDPATH= cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
[ "$(stat -c '%a' -- "$payload_root/bin/echoiond")" = 755 ]
|
|
[ "$(stat -c '%a' -- "$payload_root/lib/Echoion.ts")" = 644 ]
|
|
[ "$1" = --record ]
|
|
record=$2
|
|
shift 2
|
|
printf '%s\n' "$@" >"$record"
|
|
INSTALL
|
|
printf '%s\n' '#!/bin/sh' 'exit 0' >"$stage/uninstall.sh"
|
|
chmod 0755 "$stage/install.sh" "$stage/uninstall.sh"
|
|
|
|
base=echoion-1.2.3-linux-x86_64
|
|
archive_one="$temporary/one.tar.zst"
|
|
installer_one="$temporary/one.run"
|
|
archive_two="$temporary/two.tar.zst"
|
|
installer_two="$temporary/two.run"
|
|
bash "$source_root/scripts/package-release-payload.sh" \
|
|
"$stage" "$base" 1700000000 "$archive_one" "$installer_one" "$temporary"
|
|
bash "$source_root/scripts/package-release-payload.sh" \
|
|
"$stage" "$base" 1700000000 "$archive_two" "$installer_two" "$temporary"
|
|
cmp "$archive_one" "$archive_two"
|
|
cmp "$installer_one" "$installer_two"
|
|
|
|
mapfile -t members < <(tar --zstd -tf "$archive_one")
|
|
((${#members[@]} > 0))
|
|
for member in "${members[@]}"; do
|
|
[[ $member == "$base" || $member == "$base/"* ]] || {
|
|
echo "archive member escaped top-level directory: $member" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
printf '%s\n' "${members[@]}" | grep -Fx "$base/bin/echoiond"
|
|
|
|
record="$temporary/installer-arguments"
|
|
(
|
|
umask 077
|
|
"$installer_one" --record "$record" alpha 'two words'
|
|
)
|
|
printf '%s\n' alpha 'two words' >"$temporary/expected-arguments"
|
|
cmp "$temporary/expected-arguments" "$record"
|
|
|
|
echo "release archive layout and .run regressions passed"
|