{ "name": "postgresql", "version": "18.6", "summary": "PostgreSQL 18: the server, psql and the other clients and the contrib extensions (libpq from the libpq recipe)", "category": "server", "license": "PostgreSQL", "homepage": "https://www.postgresql.org/", "source": { "url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f" }, "watch": {"kind": "index", "url": "https://ftp.postgresql.org/pub/source/", "regex": "href=\"v([0-9]+\\.[0-9]+)/\"", "checksum": "{source}.sha256", "pin": "18"}, "deps": [ "openssl", "zlib", "lz4", "zstd", "readline", "ncurses", "libpq" ], "env_packages": [], "static": false, "nss": true, "check": "v=$(bin/postgres --version) && t=$(mktemp -d) && chmod 755 \"$t\" && chown 65534:65534 \"$t\" && p=$(free_port) && pw=bvs-$RANDOM$RANDOM && m=v$RANDOM$RANDOM && printf '%s\\n' \"$pw\" > \"$t/pw\" && chown 65534:65534 \"$t/pw\" && chmod 600 \"$t/pw\" && { bin/initdb -D \"$t/root\" > \"$t/root.log\" 2>&1; has 'cannot be run as root' < \"$t/root.log\"; } && u() { setpriv --reuid=65534 --regid=65534 --clear-groups \"$@\"; } && u bin/initdb -D \"$t/data\" -U bvs --pwfile=\"$t/pw\" --auth=scram-sha-256 -E UTF8 --locale-provider=builtin --builtin-locale=C.UTF-8 --no-instructions > \"$t/initdb.log\" 2>&1 && up=1 && u bin/pg_ctl -D \"$t/data\" -l \"$t/pg.log\" -w -t 180 -o \"-p $p -k $t -c listen_addresses=127.0.0.1\" start > \"$t/start.log\" 2>&1 && grep -E '^Uid:[[:space:]]+65534[[:space:]]' \"/proc/$(head -n 1 \"$t/data/postmaster.pid\")/status\" > /dev/null && export PGPASSWORD=\"$pw\" PGUSER=bvs PGHOST=127.0.0.1 PGPORT=\"$p\" PGCONNECT_TIMEOUT=20 && q() { bin/psql -X -q -v ON_ERROR_STOP=1 -At \"$@\"; } && bin/createdb bvs && q -d bvs -c \"CREATE TABLE t (id int PRIMARY KEY, v text); INSERT INTO t VALUES (1, '$m')\" && [ \"$(q -d bvs -c 'SELECT v FROM t WHERE id = 1')\" = \"$m\" ] && [ \"$(q -d bvs -h \"$t\" -c 'SELECT count(*) FROM t')\" = 1 ] && CHECK_CPPFLAGS=\"-DPORT=\\\"$p\\\" -DPW=\\\"$pw\\\" -DVAL=\\\"$m\\\"\" check_lib libpq libpq-fe.h 'PGconn *c = PQsetdbLogin(\"127.0.0.1\", PORT, NULL, NULL, \"bvs\", \"bvs\", PW); PGresult *r; if (PQstatus(c) != CONNECTION_OK) { fprintf(stderr, \"libpq: %s\", PQerrorMessage(c)); return 1; } r = PQexec(c, \"SELECT v FROM t WHERE id = 1\"); if (PQresultStatus(r) != PGRES_TUPLES_OK || PQntuples(r) != 1 || strcmp(PQgetvalue(r, 0, 0), VAL)) return 2; PQclear(r); PQfinish(c)' && [ \"$(q -d bvs -c \"CREATE EXTENSION pgcrypto; SELECT encode(digest('bvs', 'sha256'), 'hex')\")\" = \"$(printf bvs | sha256sum | cut -c1-64)\" ] && [ \"$(q -d bvs -c \"CREATE TABLE z (v text COMPRESSION lz4); INSERT INTO z SELECT repeat('bvs', 20000); SELECT pg_column_compression(v) FROM z\")\" = lz4 ] && [ \"$(q -d bvs -c 'SET wal_compression = zstd; SHOW wal_compression')\" = zstd ] && [ \"$(q -d bvs -c \"SELECT upper(U&'\\\\017C\\\\00F3\\\\0142w') = U&'\\\\017B\\\\00D3\\\\0141W', datlocprovider, datlocale FROM pg_database WHERE datname = 'bvs'\")\" = 't|b|C.UTF-8' ] && { PGPASSWORD=x$pw bin/psql -X -At -d bvs -c 'SELECT 1' > \"$t/wrong.log\" 2>&1; has 'password authentication failed' < \"$t/wrong.log\"; } && u bin/pg_ctl -D \"$t/data\" -m fast -w -t 180 stop > \"$t/stop.log\" 2>&1 && up= && has 'database system is shut down' < \"$t/pg.log\" && { bin/psql -X -At -d bvs -c 'SELECT 1' > \"$t/stopped.log\" 2>&1; has 'Connection refused' < \"$t/stopped.log\"; }; r=$?; [ -n \"${up:-}\" ] && u bin/pg_ctl -D \"$t/data\" -m immediate -w stop > /dev/null 2>&1; [ $r = 0 ] || cat \"$t/initdb.log\" \"$t/start.log\" \"$t/pg.log\" \"$t/wrong.log\" \"$t/stopped.log\" >&2 2> /dev/null; rm -rf -- \"${t:?}\"; [ $r = 0 ] && echo \"$v: initdb and the server as uid 65534 (refused as root), a database, a table and a row over TCP with a SCRAM password (psql, and a program linked with libpq), a count over the unix socket, pgcrypto, lz4 and zstd, the builtin C.UTF-8 locale; a wrong password and a stopped server refused\"; exit $r" }