git clone https://garage44.eu/jeroen/pinnacle.git.. /tools/deploy/image.sh
#!/bin/bash
# The USB stick a PC (x86-64) installs Pinnacle from, as `midas deploy
# pinnacle-image` publishes it at https://pinnacle-os.eu/store/images/ for
# the website's Download page (docs/hardware.md, "Trying a real laptop").
# Writes dist/images/:
#
# pinnacle-pc.img.gz the stick whole (`cargo xtask installer pc`),
# gzipped: Etcher, Rufus and `dd` take it as is
# pinnacle-pc.img.gz.sha256 its digest, as `sha256sum -c` reads it
# pc.json what the page shows: version, commit, bytes
# (packed and written), digest, when it was built
#
# The version is the number of commits on main, as the Store's apps have it.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
version="$(git rev-list --count HEAD)"
commit="$(git rev-parse --short=8 HEAD)"
cargo xtask installer pc
out=dist/images
rm -rf "$out"
mkdir -p "$out"
gzip -9 -c target/install-pc.img > "$out/pinnacle-pc.img.gz"
digest() { if command -v sha256sum >/dev/null; then sha256sum "$1"; else shasum -a 256 "$1"; fi; }
(cd "$out" && digest pinnacle-pc.img.gz > pinnacle-pc.img.gz.sha256)
sha="$(cut -d' ' -f1 "$out/pinnacle-pc.img.gz.sha256")"
packed="$(wc -c < "$out/pinnacle-pc.img.gz" | tr -d ' ')"
written="$(wc -c < target/install-pc.img | tr -d ' ')"
built="$(date -u +%Y-%m-%dT%H:%MZ)"
cat > "$out/pc.json" <<EOF
{"version":"$version","commit":"$commit","file":"pinnacle-pc.img.gz","bytes":$packed,"written":$written,"sha256":"$sha","built":"$built"}
EOF
test -s "$out/pinnacle-pc.img.gz" && test -s "$out/pc.json"
cat "$out/pc.json"