diff --git a/PostgreSQL/build_rdbms_01/Readme.md b/PostgreSQL/build_rdbms_01/Readme.md index 7564a27..c98a37c 100644 --- a/PostgreSQL/build_rdbms_01/Readme.md +++ b/PostgreSQL/build_rdbms_01/Readme.md @@ -41,9 +41,10 @@ The orchestrator runs the installers in this order: 4. pgAudit 5. set_user 6. pg_stat_statements -7. pg_repack -8. pg_stat_monitor -9. pgvector +7. passwordcheck +8. pg_repack +9. pg_stat_monitor +10. pgvector After a successful run, the orchestrator: @@ -65,6 +66,7 @@ Each component can also be installed independently. The PostgreSQL installation ./install_pgaudit.sh --version 18.6 ./install_set_user.sh --version 18.6 ./install_pg_stat_statements.sh --version 18.6 +./install_passwordcheck.sh --version 18.6 ./install_pg_repack.sh --version 18.6 ./install_pg_stat_monitor.sh --version 18.6 ./install_pgvector.sh --version 18.6 @@ -119,6 +121,10 @@ Builds and installs the `set_user` extension using the selected PostgreSQL `pg_c Downloads the matching PostgreSQL source tree and builds `pg_stat_statements` from `contrib` using PGXS. +### `install_passwordcheck.sh` + +Downloads the matching PostgreSQL source tree and builds the `passwordcheck` contrib module using PGXS. The module is loaded at server startup through `shared_preload_libraries`; it does not have a `CREATE EXTENSION` control file. + ### `install_pg_repack.sh` Builds and installs the `pg_repack` extension and its `pg_repack` command-line utility. @@ -185,13 +191,13 @@ SET_USER_TAG=REL4_2_0 \ ./install_postgresql_extensions.sh 17.11 ``` -When `CONFIG_FILE` is supplied, the orchestrator adds the extensions that require server startup loading: +When `CONFIG_FILE` is supplied, the orchestrator adds the modules and extensions that require server startup loading: ```conf -shared_preload_libraries = 'pg_cron,timescaledb,pgaudit,pg_stat_statements,pg_stat_monitor' +shared_preload_libraries = 'pg_cron,timescaledb,pgaudit,pg_stat_statements,pg_stat_monitor,passwordcheck' ``` -`pg_repack` and `set_user` do not require `shared_preload_libraries`. `pg_stat_activity` is a PostgreSQL system view and is not installed as an extension. +`pg_repack`, pgvector, and `set_user` do not require `shared_preload_libraries`. `passwordcheck` is a PostgreSQL contrib module (not a SQL extension), and `pg_stat_activity` is a built-in PostgreSQL system view. ## Prerequisites diff --git a/PostgreSQL/build_rdbms_01/install_passwordcheck.sh b/PostgreSQL/build_rdbms_01/install_passwordcheck.sh new file mode 100644 index 0000000..94c69bd --- /dev/null +++ b/PostgreSQL/build_rdbms_01/install_passwordcheck.sh @@ -0,0 +1,52 @@ +#!/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}" + +if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then + show_help "$0" "Build and install PostgreSQL's passwordcheck module." + exit 0 +fi + +POSTGRES_VERSION="$(parse_postgresql_version "$@")" +readonly POSTGRES_VERSION +require_tools curl tar make +readonly PREFIX="${PREFIX:-$POSTGRES_ROOT/$POSTGRES_VERSION}" +readonly PG_CONFIG="$PREFIX/bin/pg_config" +require_postgresql_installation "$PREFIX" +reset_staging_dir "$STAGING_DIR" + +printf 'Building passwordcheck from 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" + +readonly PASSWORDCHECK_SOURCE="$POSTGRES_SOURCE/contrib/passwordcheck" +make -C "$PASSWORDCHECK_SOURCE" \ + -j"${JOBS:-$(nproc)}" USE_PGXS=1 PG_CONFIG="$PG_CONFIG" +make -C "$PASSWORDCHECK_SOURCE" \ + install USE_PGXS=1 PG_CONFIG="$PG_CONFIG" +test -f "$PREFIX/lib/passwordcheck.so" + +readonly SAVED_SOURCE_DIR="$(copy_install_source "$PASSWORDCHECK_SOURCE" "$PREFIX" "passwordcheck-$POSTGRES_VERSION")" +write_install_recipe "$SAVED_SOURCE_DIR" "$POSTGRES_VERSION" "$PREFIX" <<'RECIPE' +cd "$SCRIPT_DIR" + +# Configure +# passwordcheck uses PGXS directly and does not require a separate configure step. + +# Make +make -j"$JOBS" USE_PGXS=1 PG_CONFIG="$PG_CONFIG" + +# Make install +make install USE_PGXS=1 PG_CONFIG="$PG_CONFIG" +RECIPE diff --git a/PostgreSQL/build_rdbms_01/install_postgresql_extensions.sh b/PostgreSQL/build_rdbms_01/install_postgresql_extensions.sh index 379d746..4411668 100644 --- a/PostgreSQL/build_rdbms_01/install_postgresql_extensions.sh +++ b/PostgreSQL/build_rdbms_01/install_postgresql_extensions.sh @@ -152,12 +152,13 @@ mkdir -p "$SOURCES_DIR" "$SCRIPT_DIR/install_pgaudit.sh" --version "$POSTGRES_VERSION" "$SCRIPT_DIR/install_set_user.sh" --version "$POSTGRES_VERSION" "$SCRIPT_DIR/install_pg_stat_statements.sh" --version "$POSTGRES_VERSION" +"$SCRIPT_DIR/install_passwordcheck.sh" --version "$POSTGRES_VERSION" "$SCRIPT_DIR/install_pg_repack.sh" --version "$POSTGRES_VERSION" "$SCRIPT_DIR/install_pg_stat_monitor.sh" --version "$POSTGRES_VERSION" "$SCRIPT_DIR/install_pgvector.sh" --version "$POSTGRES_VERSION" readonly CONFIG_FILE="${CONFIG_FILE:-}" -readonly SHARED_PRELOAD_LIBRARIES="pg_cron,timescaledb,pgaudit,pg_stat_statements,pg_stat_monitor" +readonly SHARED_PRELOAD_LIBRARIES="pg_cron,timescaledb,pgaudit,pg_stat_statements,pg_stat_monitor,passwordcheck" if [[ -n "$CONFIG_FILE" ]]; then [[ -f "$CONFIG_FILE" ]] || { @@ -173,7 +174,7 @@ path = pathlib.Path(sys.argv[1]) text = path.read_text() pattern = r"(?m)^[ \t]*(#?)[ \t]*shared_preload_libraries[ \t]*=[ \t]*'([^']*)'[^\n]*$" match = re.search(pattern, text) -required = ("pg_cron", "timescaledb", "pgaudit", "pg_stat_statements", "pg_stat_monitor") +required = ("pg_cron", "timescaledb", "pgaudit", "pg_stat_statements", "pg_stat_monitor", "passwordcheck") if match: libraries = [item.strip() for item in match.group(2).split(",") if item.strip()] for library in required: @@ -206,6 +207,7 @@ printf ' TimescaleDB: %s\n' "$(extension_version timescaledb)" printf ' pgaudit: %s\n' "$(extension_version pgaudit)" printf ' set_user: %s\n' "$(extension_version set_user)" printf ' pg_stat_statements: %s\n' "$(extension_version pg_stat_statements)" +printf ' passwordcheck: PostgreSQL %s contrib module\n' "$POSTGRES_VERSION" printf ' pg_repack: %s\n' "$(extension_version pg_repack)" printf ' pg_stat_monitor: %s\n' "$(extension_version pg_stat_monitor)" printf ' pgvector: %s\n' "$(extension_version vector)"