2026-09-23 15:19:50
This commit is contained in:
1 parent
e808725578
commit
5ea2bdbed7
12 files changed
+642
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#!/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:-/app/staging_area/copilot/tmp}"
|
||||
readonly POSTGRES_ROOT="${POSTGRES_ROOT:-/app/postgres/rdbms}"
|
||||
|
||||
[[ $# -eq 1 ]] || die "Usage: $0 <postgresql-version>"
|
||||
readonly POSTGRES_VERSION="$1"
|
||||
validate_postgresql_version "$POSTGRES_VERSION"
|
||||
require_tools curl tar make gcc
|
||||
|
||||
readonly PREFIX="$POSTGRES_ROOT/$POSTGRES_VERSION"
|
||||
readonly PG_BIN="$PREFIX/bin"
|
||||
readonly PG_CONFIG="$PG_BIN/pg_config"
|
||||
[[ "$PREFIX" != "/" ]] || die "PREFIX must not be the filesystem root"
|
||||
reset_staging_dir "$STAGING_DIR"
|
||||
rm -rf -- "$PREFIX"
|
||||
mkdir -p "$STAGING_DIR" "$PREFIX"
|
||||
|
||||
printf 'Building PostgreSQL %s\n' "$POSTGRES_VERSION"
|
||||
readonly POSTGRES_ARCHIVE="$STAGING_DIR/postgresql-$POSTGRES_VERSION.tar.gz"
|
||||
readonly POSTGRES_SOURCE="$STAGING_DIR/postgresql-$POSTGRES_VERSION"
|
||||
curl -fL --retry 3 --retry-delay 2 \
|
||||
-o "$POSTGRES_ARCHIVE" \
|
||||
"https://ftp.postgresql.org/pub/source/v$POSTGRES_VERSION/postgresql-$POSTGRES_VERSION.tar.gz"
|
||||
tar -xzf "$POSTGRES_ARCHIVE" -C "$STAGING_DIR"
|
||||
|
||||
cd "$POSTGRES_SOURCE"
|
||||
./configure \
|
||||
--prefix="$PREFIX" \
|
||||
--with-ssl=openssl \
|
||||
--with-lz4
|
||||
make -j"${JOBS:-$(nproc)}"
|
||||
make install
|
||||
|
||||
printf '\nVerification:\n'
|
||||
"$PG_BIN/postgres" --version
|
||||
"$PG_CONFIG" --version
|
||||
Reference in new issue
Block a user