Files
programming/PostgreSQL/build_rdbms_01/install_pgvector.sh
T

34 lines
1.3 KiB
Bash
Raw Normal View History

2026-10-11 09:00:59 +02:00
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=install_common.sh
source "$SCRIPT_DIR/install_common.sh"
readonly STAGING_DIR="${STAGING_DIR:-$SCRIPT_DIR/tmp}"
readonly POSTGRES_ROOT="${POSTGRES_ROOT:-/app/postgres/rdbms}"
readonly PGVECTOR_REPOSITORY="${PGVECTOR_REPOSITORY:-pgvector/pgvector}"
[[ $# -eq 1 ]] || die "Usage: $0 <postgresql-version>"
readonly POSTGRES_VERSION="$1"
validate_postgresql_version "$POSTGRES_VERSION"
require_tools curl tar make
readonly PREFIX="$POSTGRES_ROOT/$POSTGRES_VERSION"
readonly PG_CONFIG="$PREFIX/bin/pg_config"
require_postgresql_installation "$PREFIX"
reset_staging_dir "$STAGING_DIR"
readonly PGVECTOR_TAG="${PGVECTOR_TAG:-$(latest_tag "$PGVECTOR_REPOSITORY")}"
[[ -n "$PGVECTOR_TAG" ]] || die "could not determine the latest pgvector release"
readonly PGVECTOR_VERSION="${PGVECTOR_TAG#v}"
readonly PGVECTOR_DIR="$STAGING_DIR/pgvector-$PGVECTOR_VERSION"
printf 'Building pgvector %s\n' "$PGVECTOR_TAG"
download_source "$STAGING_DIR" "$PGVECTOR_REPOSITORY" "$PGVECTOR_TAG" \
"pgvector-$PGVECTOR_VERSION.tar.gz" "$PGVECTOR_DIR"
cd "$PGVECTOR_DIR"
make -j"${JOBS:-$(nproc)}" PG_CONFIG="$PG_CONFIG"
make install PG_CONFIG="$PG_CONFIG"
test -f "$PREFIX/lib/vector.so"
test -f "$PREFIX/share/extension/vector.control"