Files
vmmngr/tools/build-package.sh
T

57 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# build-package.sh - create the distributable extension tarball.
#
# Usage: tools/build-package.sh [--version <ver>]
# Output: dist/vmmngr-<version>.tar.gz (+ .sha256)
set -eu
ROOT=$(cd "$(dirname "$0")/.." && pwd -P)
cd "${ROOT}"
VERSION=$(cat version.txt 2>/dev/null | tr -d '\n')
if [ "${1:-}" = "--version" ]; then
VERSION="$2"
fi
[ -n "${VERSION}" ] || { echo "version.txt missing or empty" >&2; exit 1; }
NAME="vmmngr-${VERSION}"
STAGE="dist/${NAME}"
rm -rf "${STAGE}"
mkdir -p "${STAGE}" dist
# code and metadata (state/log/backup are runtime data and never shipped)
cp -R bin gui templates "${STAGE}/"
cp vmm-init version.txt README.md CHANGELOG.md "${STAGE}/" 2>/dev/null || true
[ -f LICENSE ] && cp LICENSE "${STAGE}/"
# bundled binaries (only when present)
if [ -d vendor ]; then
mkdir -p "${STAGE}/vendor"
for d in vendor/*/; do
[ -d "$d" ] || continue
cp -R "$d" "${STAGE}/vendor/"
done
find "${STAGE}/vendor" -name '.gitkeep' -delete
fi
find "${STAGE}" -name '.gitignore' -delete
find "${STAGE}" -name '.DS_Store' -delete
chmod 0755 "${STAGE}" 2>/dev/null || true
chmod 0555 "${STAGE}/vmm-init" 2>/dev/null || true
find "${STAGE}/bin" -type f -exec chmod 0555 {} \; 2>/dev/null || true
tar -czf "dist/${NAME}.tar.gz" -C dist "${NAME}"
rm -rf "${STAGE}"
if command -v sha256sum >/dev/null 2>&1; then
(cd dist && sha256sum "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256")
elif command -v shasum >/dev/null 2>&1; then
(cd dist && shasum -a 256 "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256")
fi
echo "built dist/${NAME}.tar.gz"
ls -l "dist/${NAME}.tar.gz"