2026-09-23 17:19:50 +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"
|
|
|
|
|
|
2026-10-11 09:00:59 +02:00
|
|
|
readonly STAGING_DIR="${STAGING_DIR:-$SCRIPT_DIR/tmp}"
|
2026-09-23 17:19:50 +02:00
|
|
|
readonly POSTGRES_ROOT="${POSTGRES_ROOT:-/app/postgres/rdbms}"
|
|
|
|
|
readonly PG_REPACK_REPOSITORY="${PG_REPACK_REPOSITORY:-reorg/pg_repack}"
|
|
|
|
|
|
2026-10-11 16:45:57 +02:00
|
|
|
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
|
|
|
|
show_help "$0" "Build and install pg_repack for an existing PostgreSQL installation."
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
POSTGRES_VERSION="$(parse_postgresql_version "$@")"
|
|
|
|
|
readonly POSTGRES_VERSION
|
2026-09-23 17:19:50 +02:00
|
|
|
validate_postgresql_version "$POSTGRES_VERSION"
|
|
|
|
|
require_tools curl tar make
|
2026-10-11 16:45:57 +02:00
|
|
|
readonly PREFIX="${PREFIX:-$POSTGRES_ROOT/$POSTGRES_VERSION}"
|
2026-09-23 17:19:50 +02:00
|
|
|
readonly PG_CONFIG="$PREFIX/bin/pg_config"
|
|
|
|
|
require_postgresql_installation "$PREFIX"
|
|
|
|
|
reset_staging_dir "$STAGING_DIR"
|
|
|
|
|
|
|
|
|
|
readonly PG_REPACK_TAG="${PG_REPACK_TAG:-$(latest_tag "$PG_REPACK_REPOSITORY")}"
|
|
|
|
|
[[ -n "$PG_REPACK_TAG" ]] || die "could not determine the latest pg_repack release"
|
|
|
|
|
readonly PG_REPACK_DIR="$STAGING_DIR/pg_repack-${PG_REPACK_TAG}"
|
|
|
|
|
|
|
|
|
|
printf 'Building pg_repack %s\n' "$PG_REPACK_TAG"
|
|
|
|
|
download_source "$STAGING_DIR" "$PG_REPACK_REPOSITORY" "$PG_REPACK_TAG" \
|
|
|
|
|
"pg_repack-${PG_REPACK_TAG}.tar.gz" "$PG_REPACK_DIR"
|
2026-10-25 22:20:39 +01:00
|
|
|
record_source_download "pg_repack" "$(github_source_url "$PG_REPACK_REPOSITORY" "$PG_REPACK_TAG")" "$PG_REPACK_TAG"
|
2026-09-23 17:19:50 +02:00
|
|
|
cd "$PG_REPACK_DIR"
|
|
|
|
|
make -j"${JOBS:-$(nproc)}" PG_CONFIG="$PG_CONFIG"
|
|
|
|
|
make install PG_CONFIG="$PG_CONFIG"
|
|
|
|
|
test -x "$PREFIX/bin/pg_repack"
|
|
|
|
|
test -f "$PREFIX/share/extension/pg_repack.control"
|
2026-10-11 16:45:57 +02:00
|
|
|
|
|
|
|
|
readonly SAVED_SOURCE_DIR="$(copy_install_source "$PG_REPACK_DIR" "$PREFIX" "pg_repack-$PG_REPACK_TAG")"
|
|
|
|
|
write_install_recipe "$SAVED_SOURCE_DIR" "$POSTGRES_VERSION" "$PREFIX" <<'RECIPE'
|
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
|
|
|
|
|
|
# Configure
|
|
|
|
|
# pg_repack uses PG_CONFIG directly and does not require a separate configure step.
|
|
|
|
|
|
|
|
|
|
# Make
|
|
|
|
|
make -j"$JOBS" PG_CONFIG="$PG_CONFIG"
|
|
|
|
|
|
|
|
|
|
# Make install
|
|
|
|
|
make install PG_CONFIG="$PG_CONFIG"
|
|
|
|
|
RECIPE
|