Files
Button/webconfig/scripts/make-package.sh
T
GrigoandClaude Opus 5.5 56d635f051 docs: what OTA changes in the system (docs/ota.md)
bt-update runs as root and installs helpers, sudoers, systemd units and
config; none of it is rolled back. Documents the order of stage steps, the
'old bt-update runs the OTA' pitfall and how to add a system change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:58:05 +00:00

61 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# make-package.sh - build an OTA update package for ButtonTask.
#
# Produces dist/buttontask-<version>.tar.gz containing:
# ButtonTask (the compiled binary)
# webconfig/ (the web configurator + scripts)
# collector/ (BLE GATT collector, if present in the repo)
# manifest.json ({"version": ..., "created": ...})
# and prints the package's sha256 (paste it into the web UI for integrity).
# System files (helpers, sudoers, systemd units/config) are installed by
# bt-update from webconfig/ — see docs/ota.md. apt packages still need a full
# deploy .tgz.
#
# Usage:
# make-package.sh <version> [build-dir] [out-dir]
# Example:
# ./webconfig/scripts/make-package.sh 2.1 build dist
set -euo pipefail
VERSION="${1:?usage: make-package.sh <version> [build-dir] [out-dir]}"
BUILD_DIR="${2:-build}"
OUT_DIR="${3:-dist}"
# Resolve repo root (two levels up from this script).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BIN="$REPO_ROOT/$BUILD_DIR/ButtonTask"
[ -x "$BIN" ] || { echo "binary not found: $BIN (build first)"; exit 1; }
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
cp "$BIN" "$STAGE/ButtonTask"
cp -r "$REPO_ROOT/webconfig" "$STAGE/webconfig"
# Drop dev artefacts from the packaged webconfig.
rm -rf "$STAGE/webconfig/__pycache__" "$STAGE/webconfig/.webconfig.secret"
if [ -d "$REPO_ROOT/collector" ]; then
cp -r "$REPO_ROOT/collector" "$STAGE/collector"
rm -rf "$STAGE/collector/__pycache__" "$STAGE/collector/tests/__pycache__"
find "$STAGE/collector" -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
fi
cat > "$STAGE/manifest.json" <<EOF
{
"version": "$VERSION",
"created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
mkdir -p "$REPO_ROOT/$OUT_DIR"
PKG="$REPO_ROOT/$OUT_DIR/buttontask-$VERSION.tar.gz"
tar -czf "$PKG" -C "$STAGE" .
echo "package: $PKG"
if command -v sha256sum >/dev/null 2>&1; then
echo "sha256: $(sha256sum "$PKG" | awk '{print $1}')"
fi