#!/usr/bin/env bash # Stage exactly the .deb versions named in .env into ./debs, so the image build # is reproducible from a version number rather than from whatever was left in # the directory last time. Run before `docker compose build`. # # packaging/devstack/fetch-debs.sh # # Reads DEB_DIR, DB_VERSION, DB_CLIENT_VERSION and VAPI_VERSION from .env (or # the environment). Every name is version-matched and then the staged file's own # Version field is read back - a filename glob on the package name is not a # match, and staging the wrong version is a mistake this repo has made before. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" [[ -f "$HERE/.env" ]] && set -a && . "$HERE/.env" && set +a : "${DEB_DIR:?set DEB_DIR in .env}" : "${DB_VERSION:?set DB_VERSION in .env}" : "${DB_CLIENT_VERSION:?set DB_CLIENT_VERSION in .env}" : "${VAPI_VERSION:?set VAPI_VERSION in .env}" cd "$HERE" DEB_DIR="$(cd "$DEB_DIR" && pwd)" rm -rf debs && mkdir -p debs # name:version pairs. The webui is _all, the rest _amd64; the CLI rides the # client's version because it links the same shared library. stage() { local pkg="$1" ver="$2" arch="$3" src="$DEB_DIR/${1}_${2}_${3}.deb" [[ -f "$src" ]] || { echo "not found: $src" >&2; return 1; } cp "$src" debs/ # Read the version back OUT of the file rather than trusting the name. local got; got="$(dpkg-deb -f "debs/${pkg}_${ver}_${arch}.deb" Version)" [[ "$got" == "$ver" ]] || { echo "$pkg: file says $got, expected $ver" >&2; return 1; } printf ' %-32s %s\n' "$pkg" "$got" } echo "staging from $DEB_DIR" stage smartbotic-database "$DB_VERSION" amd64 stage libsmartbotic-db-client "$DB_CLIENT_VERSION" amd64 stage smartbotic-db-cli "$DB_CLIENT_VERSION" amd64 stage smartbotic-vectorapi "$VAPI_VERSION" amd64 stage smartbotic-vectorapi-runner "$VAPI_VERSION" amd64 stage smartbotic-vectorapi-webui "$VAPI_VERSION" all echo "staged $(ls debs | wc -l) debs into $HERE/debs"