feat: add script for creating self-extracting archives

- Introduces a script to build self-extracting archives with validation
- Includes payload compression, placeholder replacement, and output creation
- Adds a header script to extract and execute the embedded entrypoint
This commit is contained in:
2025-06-15 16:30:03 +02:00
commit 65f26e495a
2 changed files with 97 additions and 0 deletions

19
sfx_header.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/sfx.XXXXXX")"
ARCHIVE_LINE=__ARCHIVE_LINE__
cleanup() {
rm -rf "$TMPDIR"
}
trap cleanup EXIT
tail -n +$ARCHIVE_LINE "$0" | unzstd | tar -xf - -C "$TMPDIR"
ENTRYPOINT="$TMPDIR/__ENTRYPOINT__"
chmod +x "$ENTRYPOINT"
"$ENTRYPOINT" "$@"
exit_code=$?
exit $exit_code
__ARCHIVE_BEGIN__