#!/usr/bin/env bash # # make-package.sh - build an OTA update package for ButtonTask. # # Produces dist/buttontask-.tar.gz containing: # ButtonTask (the compiled binary) # webconfig/ (the web configurator + scripts) # manifest.json ({"version": ..., "created": ...}) # and prints the package's sha256 (paste it into the web UI for integrity). # # Usage: # make-package.sh [build-dir] [out-dir] # Example: # ./webconfig/scripts/make-package.sh 2.1 build dist set -euo pipefail VERSION="${1:?usage: make-package.sh [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" cat > "$STAGE/manifest.json" </dev/null 2>&1; then echo "sha256: $(sha256sum "$PKG" | awk '{print $1}')" fi