2026-10-11 14:45:57
This commit is contained in:
1 parent
ce49d78f31
commit
fbf826bf0c
12 files changed
+512
-57
No files matched your search
@@ -9,12 +9,18 @@ source "$SCRIPT_DIR/install_common.sh"
|
||||
readonly STAGING_DIR="${STAGING_DIR:-$SCRIPT_DIR/tmp}"
|
||||
readonly POSTGRES_ROOT="${POSTGRES_ROOT:-/app/postgres/rdbms}"
|
||||
|
||||
[[ $# -eq 1 ]] || die "Usage: $0 <postgresql-version>"
|
||||
readonly POSTGRES_VERSION="$1"
|
||||
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
||||
show_help "$0" "Build and install PostgreSQL from source."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
POSTGRES_VERSION="$(parse_postgresql_version "$@")"
|
||||
readonly POSTGRES_VERSION
|
||||
validate_postgresql_version "$POSTGRES_VERSION"
|
||||
require_tools curl tar make gcc
|
||||
|
||||
readonly PREFIX="$POSTGRES_ROOT/$POSTGRES_VERSION"
|
||||
readonly PREFIX="${PREFIX:-$POSTGRES_ROOT/$POSTGRES_VERSION}"
|
||||
readonly POSTGRES_CONFIGURE_OPTIONS="${POSTGRES_CONFIGURE_OPTIONS:---with-ssl=openssl,--with-lz4}"
|
||||
readonly PG_BIN="$PREFIX/bin"
|
||||
readonly PG_CONFIG="$PG_BIN/pg_config"
|
||||
[[ "$PREFIX" != "/" ]] || die "PREFIX must not be the filesystem root"
|
||||
@@ -31,13 +37,33 @@ curl -fL --retry 3 --retry-delay 2 \
|
||||
tar -xzf "$POSTGRES_ARCHIVE" -C "$STAGING_DIR"
|
||||
|
||||
cd "$POSTGRES_SOURCE"
|
||||
[[ "$POSTGRES_CONFIGURE_OPTIONS" != ,* &&
|
||||
"$POSTGRES_CONFIGURE_OPTIONS" != *, &&
|
||||
"$POSTGRES_CONFIGURE_OPTIONS" != *,,* ]] || die "configure options must be a non-empty comma-separated list"
|
||||
IFS=',' read -r -a CONFIGURE_OPTIONS <<< "${POSTGRES_CONFIGURE_OPTIONS:-}"
|
||||
./configure \
|
||||
--prefix="$PREFIX" \
|
||||
--with-ssl=openssl \
|
||||
--with-lz4
|
||||
"${CONFIGURE_OPTIONS[@]}"
|
||||
make -j"${JOBS:-$(nproc)}"
|
||||
make install
|
||||
|
||||
printf '\nVerification:\n'
|
||||
"$PG_BIN/postgres" --version
|
||||
"$PG_CONFIG" --version
|
||||
|
||||
readonly SAVED_SOURCE_DIR="$(copy_install_source "$POSTGRES_SOURCE" "$PREFIX" "postgresql-$POSTGRES_VERSION")"
|
||||
write_install_recipe "$SAVED_SOURCE_DIR" "$POSTGRES_VERSION" "$PREFIX" "$POSTGRES_CONFIGURE_OPTIONS" <<'RECIPE'
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# Configure
|
||||
IFS=',' read -r -a CONFIGURE_OPTIONS <<< "$POSTGRES_CONFIGURE_OPTIONS"
|
||||
./configure \
|
||||
--prefix="$PREFIX" \
|
||||
"${CONFIGURE_OPTIONS[@]}"
|
||||
|
||||
# Make
|
||||
make -j"$JOBS"
|
||||
|
||||
# Make install
|
||||
make install
|
||||
RECIPE
|
||||
Reference in new issue
Block a user