Files
Precious Okwu dbaa28c4ed Linux packages bundle the pinned kiri-forge; Kiri Forge 0.1.1; 0.3.0 notes (#1048)
The Linux package build now fetches the pinned kiri-forge for each architecture, checks it against the SHA-256 in cli_pins.rs and bundles it, as the Mac and Windows builds do; before, /usr/bin/kiri-forge in the packages was a link to kiri. A release build stops if the binary is missing.

The bundled Kiri Forge is 0.1.1. docs/releases/0.3.0.md holds the notes for 0.3.0 and docs/releases/0.3.0.announce.json its announcement.
2026-11-30 00:55:37 +01:00

40 lines
1.9 KiB
Bash

#!/bin/bash
# The standalone kiri-forge both Linux packages bundle as /usr/bin/kiri-forge,
# at the version and SHA-256s pinned in crates/kiri/src/cli_pins.rs
# (FORGE_VERSION, FORGE_LINUX_X86_64, FORGE_LINUX_AARCH64), as Kiri.app and
# Kiri for Windows bundle it (cargo xtask release, cargo xtask msi):
# packaging/linux/fetch-forge.sh <bindir> [cache-dir] [x86_64|aarch64]
# Leaves <bindir>/kiri-forge, verified, for packaging/linux/build.sh.
set -euo pipefail
dir=$1 cache=${2:-${XDG_CACHE_HOME:-$HOME/.cache}/kiri-linux-cli} arch=${3:-x86_64}
case $arch in
x86_64) p=FORGE_LINUX_X86_64 ;;
aarch64) p=FORGE_LINUX_AARCH64 ;;
*) echo "arch must be x86_64 or aarch64" >&2; exit 1 ;;
esac
root=$(cd "$(dirname "$0")/../.." && pwd)
pins=$root/crates/kiri/src/cli_pins.rs
v=$(sed -n 's/^pub const FORGE_VERSION: &str = "\([^"]*\)";.*/\1/p' "$pins" | tr -d '\r')
sum=$(sed -n "s/^pub const $p: (&str, &str) = (FORGE_VERSION, \"\([0-9a-f]*\)\");.*/\1/p" "$pins" | tr -d '\r')
[ -n "$v" ] && [ -n "$sum" ] || { echo "no FORGE_VERSION or $p pin in $pins" >&2; exit 1; }
mkdir -p "$dir" "$cache"
dir=$(cd "$dir" && pwd)
name=kiri-forge-$v-linux-$arch.tar.gz
f=$cache/$name
if [ ! -f "$f" ]; then
# HTTPS only, redirects included; a failed download leaves no .part behind.
# The .part is this process's own, as CI jobs on one machine share the cache.
if ! curl -fsSL --proto '=https' --proto-redir '=https' --retry 3 -o "$f.$$.part" "https://download.runkiri.com/forge/$v/$name"; then
rm -f "$f.$$.part"
echo "could not download https://download.runkiri.com/forge/$v/$name" >&2
exit 1
fi
mv "$f.$$.part" "$f"
fi
echo "$sum $f" | sha256sum -c --quiet - || { echo "$name does not match the pinned SHA-256; delete $f and retry" >&2; exit 1; }
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
tar xzf "$f" -C "$work" kiri-forge || { echo "$name has no kiri-forge" >&2; exit 1; }
install -m 755 "$work/kiri-forge" "$dir/kiri-forge"
echo "$dir: kiri-forge $v ($arch)"