67 lines
2.6 KiB
Bash
Executable File
67 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build a release: everything needed to install Guix on the Raspberry Pi 4
|
|
# and the GL-MT6000, in release/guix-router-DATE-REV/:
|
|
#
|
|
# guix-router-rpi4.img.zst Pi SD-card / USB image
|
|
# guix-router-mt6000-root.ext4.zst MT6000 root file system (p7)
|
|
# guix-router-mt6000-boot.itb MT6000 boot image, FIT (p6)
|
|
# install-mt6000.sh, flash-rpi.sh installers
|
|
# INSTALL.md how to install, log in, recover
|
|
# SHA256SUMS, SHA256SUMS.uncompressed, SIZES.uncompressed, BUILD-INFO
|
|
#
|
|
# ./build-release.sh [all|rpi|mt6000]
|
|
#
|
|
# Builds from the working tree (BUILD-INFO records the commit and whether it
|
|
# was dirty). The images carry this tree's files/workstation.pub (SSH) and
|
|
# files/workstation-guix.pub (deploys) -- put your own keys there first.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
export PATH=$HOME/.local/bin:$PATH
|
|
export GUIX_PACKAGE_PATH="$PWD/packages:$HOME/channels/nonguix"
|
|
|
|
what=${1:-all}
|
|
case "$what" in all|rpi|mt6000) ;; *) sed -n '2,15p' "$0"; exit 1 ;; esac
|
|
|
|
rev=$(git describe --always --dirty)
|
|
out=release/guix-router-$(date +%Y%m%d)-$rev
|
|
mkdir -p "$out"
|
|
zstd=$(guix build zstd | grep -E -- '-zstd-[0-9][^-]*$')/bin/zstd
|
|
# (zstd copies the source's mode and time: store files are read-only, 1970.)
|
|
pack() { "$zstd" -T0 -12 --long=27 -q -f -o "$2" "$1"; chmod 644 "$2"; touch "$2"; }
|
|
|
|
uncompressed() { # record checksum and size of an image before compression
|
|
local name=$1 file=$2
|
|
echo "$(sha256sum < "$file" | cut -c1-64) $name" >> "$out/SHA256SUMS.uncompressed"
|
|
echo "$(stat -L -c %s "$file") $name" >> "$out/SIZES.uncompressed"
|
|
}
|
|
rm -f "$out/SHA256SUMS.uncompressed" "$out/SIZES.uncompressed"
|
|
|
|
if [ "$what" != mt6000 ]; then
|
|
echo "== Raspberry Pi 4 image"
|
|
./build-rpi-image.sh
|
|
uncompressed guix-router-rpi4.img guix-rpi4-claude.img
|
|
pack guix-rpi4-claude.img "$out/guix-router-rpi4.img.zst"
|
|
cp flash-rpi.sh "$out/"
|
|
fi
|
|
|
|
if [ "$what" != rpi ]; then
|
|
echo "== GL-MT6000 root file system and boot image"
|
|
./build-mt6000-root.sh
|
|
uncompressed guix-router-mt6000-root.ext4 mt6000-root.ext4
|
|
pack mt6000-root.ext4 "$out/guix-router-mt6000-root.ext4.zst"
|
|
cp mt6000-boot.itb "$out/guix-router-mt6000-boot.itb"
|
|
cp install-mt6000.sh "$out/"
|
|
fi
|
|
|
|
cp docs/INSTALL.md "$out/"
|
|
{
|
|
echo "guix-router release $(basename "$out")"
|
|
echo "commit: $(git rev-parse HEAD)$(git diff --quiet HEAD || echo ' (working tree had changes)')"
|
|
echo "built: $(date -u +%FT%TZ) on $(hostname)"
|
|
guix --version | head -1
|
|
} > "$out/BUILD-INFO"
|
|
(cd "$out" && sha256sum -- *.zst *.itb *.sh INSTALL.md 2>/dev/null > SHA256SUMS)
|
|
echo
|
|
echo "release: $PWD/$out"
|
|
ls -lh "$out"
|