fetch-debs.sh 2.0 KB

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