From 4b606a610e33ddca5d4c437f7e499152086fe315 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Thu, 17 Oct 2024 16:25:44 -0700 Subject: [PATCH] Switch EdgeDB 6 to PostgreSQL 17 (#117) --- .github/workflows/lint.yml | 6 +- edgedbpkg/edgedb/__init__.py | 18 +- edgedbpkg/postgresql/install.list | 1 + ...tgresql-edgedb__no_env_clobbering-17.patch | 87 ++ .../postgresql-edgedb__pkgconfig-17.patch | 1197 +++++++++++++++++ .../patches/postgresql-edgedb__popen-17.patch | 386 ++++++ ...resql-edgedb__predictable_install-17.patch | 81 ++ .../patches/postgresql-edgedb__wsl1-17.patch | 191 +++ 8 files changed, 1962 insertions(+), 5 deletions(-) create mode 100644 edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-17.patch create mode 100644 edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-17.patch create mode 100644 edgedbpkg/postgresql/patches/postgresql-edgedb__popen-17.patch create mode 100644 edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-17.patch create mode 100644 edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-17.patch diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f8801d14..550c8d92 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,10 +18,10 @@ jobs: os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.12" - uses: psf/black@stable - uses: python/mypy@master with: diff --git a/edgedbpkg/edgedb/__init__.py b/edgedbpkg/edgedb/__init__.py index a8284005..795d78c0 100644 --- a/edgedbpkg/edgedb/__init__.py +++ b/edgedbpkg/edgedb/__init__.py @@ -70,11 +70,16 @@ class EdgeDB(packages.BundledPythonPackage): "python-edgedb (~= 3.11.0)", "pgext-pgvector (~= 0.4.0)", ], - ">=5.0.dev1": [ + ">=5.0.dev1,<6.0.dev8898": [ "postgresql-edgedb (~= 16.0)", "python-edgedb (~= 3.12.0)", "pgext-pgvector (~= 0.6.0)", ], + ">=6.0.dev8898": [ + "postgresql-edgedb (~= 17.0)", + "python-edgedb (~= 3.12.0)", + "pgext-pgvector (~= 0.7.0)", + ], } artifact_build_requirements = { @@ -98,25 +103,34 @@ class EdgeDB(packages.BundledPythonPackage): "pyentrypoint (>=1.0.0)", "pypkg-setuptools (<70.2.0)", ], - ">=5.0.dev1": [ + ">=5.0.dev1,<6.0.dev8898": [ "postgresql-edgedb (~= 16.0)", "python-edgedb (~= 3.12.0)", "pgext-pgvector (~= 0.6.0)", "pyentrypoint (>=1.0.0)", "pypkg-setuptools (<70.2.0)", ], + ">=6.0.dev8898": [ + "postgresql-edgedb (~= 17.0)", + "python-edgedb (~= 3.12.0)", + "pgext-pgvector (~= 0.7.0)", + "pyentrypoint (>=1.0.0)", + "pypkg-setuptools (<70.2.0)", + ], } bundle_deps = [ postgresql.PostgreSQL(version="14.11"), postgresql.PostgreSQL(version="15.6"), postgresql.PostgreSQL(version="16.4"), + postgresql.PostgreSQL(version="17.0"), python_bundle.Python(version="3.10.11"), python_bundle.Python(version="3.11.8"), python_bundle.Python(version="3.12.2"), pyentrypoint.PyEntryPoint(version="1.0.0"), pgvector.PgVector("v0.4.2"), pgvector.PgVector("v0.6.0"), + pgvector.PgVector("v0.7.4"), ] @classmethod diff --git a/edgedbpkg/postgresql/install.list b/edgedbpkg/postgresql/install.list index 7da082fd..821ac552 100644 --- a/edgedbpkg/postgresql/install.list +++ b/edgedbpkg/postgresql/install.list @@ -1,5 +1,6 @@ {bindir}/initdb {bindir}/pg_basebackup +{bindir}/pg_combinebackup {bindir}/pg_ctl {bindir}/pg_config {bindir}/pg_dump diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-17.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-17.patch new file mode 100644 index 00000000..8310a6c8 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__no_env_clobbering-17.patch @@ -0,0 +1,87 @@ +From e77a269af07fdef6b24fa9d9efbe3493af847171 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Tue, 16 Aug 2022 22:00:31 -0700 +Subject: [PATCH 3/5] Add an envvar escape hatch to disable argv clobbering + +The `set_ps_display` business clobbers the environment block on Linux, +thus butchering all prior `getenv` calls, which includes +`getenv(LD_LIBRARY_PATH)` done by `ld-musl.so`. Musl is at fault too, +because it really ought to `strdup` the entry, but until that's fixed, +setting `PG_DISABLE_PS_DISPLAY=1` is the fix. +--- + src/backend/utils/misc/ps_status.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c +index 9da6377402..f82f04bf9f 100644 +--- a/src/backend/utils/misc/ps_status.c ++++ b/src/backend/utils/misc/ps_status.c +@@ -14,6 +14,7 @@ + + #include "postgres.h" + ++#include + #include + #if defined(__darwin__) + #include +@@ -27,6 +28,7 @@ extern char **environ; + + /* GUC variable */ + bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE; ++bool disable_ps_display = false; + + /* + * Alternative ways of updating ps display: +@@ -116,9 +118,16 @@ static char **save_argv; + char ** + save_ps_display_args(int argc, char **argv) + { ++ char *disable_env = getenv("PG_DISABLE_PS_DISPLAY"); ++ + save_argc = argc; + save_argv = argv; + ++ disable_ps_display = disable_env != NULL && *disable_env != '\0'; ++ ++ if (disable_ps_display) ++ return argv; ++ + #if defined(PS_USE_CLOBBER_ARGV) + + /* +@@ -266,6 +275,9 @@ save_ps_display_args(int argc, char **argv) + void + init_ps_display(const char *fixed_part) + { ++ if (disable_ps_display) ++ return; ++ + #ifndef PS_USE_NONE + bool save_update_process_title; + #endif +@@ -342,6 +354,9 @@ init_ps_display(const char *fixed_part) + static bool + update_ps_display_precheck(void) + { ++ if (disable_ps_display) ++ return false; ++ + /* update_process_title=off disables updates */ + if (!update_process_title) + return false; +@@ -529,6 +544,12 @@ flush_ps_display(void) + const char * + get_ps_display(int *displen) + { ++ if (disable_ps_display) ++ { ++ *displen = 0; ++ return ""; ++ } ++ + #ifdef PS_USE_CLOBBER_ARGV + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) +-- +2.45.2 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-17.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-17.patch new file mode 100644 index 00000000..565fd7ce --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__pkgconfig-17.patch @@ -0,0 +1,1197 @@ +From 69a790b296e80bf6e1c327c9bb322e22e3b8da0d Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Mon, 11 Feb 2019 20:28:00 -0500 +Subject: [PATCH 5/5] Use pkg-config for libuuid, openssl and zlib + +--- + configure | 665 ++++++++++++++++++++++++++++-- + configure.ac | 118 +++++- + contrib/pgcrypto/Makefile | 4 + + contrib/sslinfo/Makefile | 2 + + src/Makefile.global.in | 9 +- + src/backend/Makefile | 4 +- + src/backend/libpq/Makefile | 1 + + src/bin/pg_combinebackup/Makefile | 4 + + src/bin/pg_verifybackup/Makefile | 4 + + src/bin/pgbench/Makefile | 3 + + src/common/Makefile | 1 + + src/include/pg_config.h.in | 2 +- + src/interfaces/libpq/Makefile | 1 + + 13 files changed, 783 insertions(+), 35 deletions(-) + +diff --git a/configure b/configure +index 78db894968..12782bcd9b 100755 +--- a/configure ++++ b/configure +@@ -655,9 +655,14 @@ OPENSSL + ZSTD + LZ4 + UUID_LIBS ++UUID_CFLAGS + LDAP_LIBS_BE + LDAP_LIBS_FE + with_ssl ++OPENSSL_LIBS ++OPENSSL_CFLAGS ++ZLIB_LIBS ++ZLIB_CFLAGS + PTHREAD_CFLAGS + PTHREAD_LIBS + PTHREAD_CC +@@ -908,6 +913,12 @@ LDFLAGS_EX + LDFLAGS_SL + PERL + PYTHON ++ZLIB_CFLAGS ++ZLIB_LIBS ++OPENSSL_CFLAGS ++OPENSSL_LIBS ++UUID_CFLAGS ++UUID_LIBS + MSGFMT + TCLSH' + +@@ -1620,6 +1631,14 @@ Some influential environment variables: + LDFLAGS_SL extra linker flags for linking shared libraries only + PERL Perl program + PYTHON Python program ++ ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ++ ZLIB_LIBS linker flags for ZLIB, overriding pkg-config ++ OPENSSL_CFLAGS ++ C compiler flags for OPENSSL, overriding pkg-config ++ OPENSSL_LIBS ++ linker flags for OPENSSL, overriding pkg-config ++ UUID_CFLAGS C compiler flags for UUID, overriding pkg-config ++ UUID_LIBS linker flags for UUID, overriding pkg-config + MSGFMT msgfmt program for NLS + TCLSH Tcl interpreter program (tclsh) + +@@ -12133,7 +12152,74 @@ Use --without-readline to disable readline support." "$LINENO" 5 + fi + + if test "$with_zlib" = yes; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 ++ have_zlib=missing ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5 ++$as_echo_n "checking for zlib... " >&6; } ++ ++if test -n "$ZLIB_CFLAGS"; then ++ pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$ZLIB_LIBS"; then ++ pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "zlib") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib" 2>&1` ++ else ++ ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$ZLIB_PKG_ERRORS" >&5 ++ ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 + $as_echo_n "checking for inflate in -lz... " >&6; } + if ${ac_cv_lib_z_inflate+:} false; then : + $as_echo_n "(cached) " >&6 +@@ -12170,19 +12256,105 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5 + $as_echo "$ac_cv_lib_z_inflate" >&6; } + if test "x$ac_cv_lib_z_inflate" = xyes; then : +- cat >>confdefs.h <<_ACEOF +-#define HAVE_LIBZ 1 ++ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ++fi ++ ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 ++$as_echo_n "checking for inflate in -lz... " >&6; } ++if ${ac_cv_lib_z_inflate+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lz $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char inflate (); ++int ++main () ++{ ++return inflate (); ++ ; ++ return 0; ++} + _ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_z_inflate=yes ++else ++ ac_cv_lib_z_inflate=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflate" >&5 ++$as_echo "$ac_cv_lib_z_inflate" >&6; } ++if test "x$ac_cv_lib_z_inflate" = xyes; then : ++ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ++fi ++ ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++else ++ ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ++ ZLIB_LIBS=$pkg_cv_ZLIB_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++ have_zlib=yes ++ ++fi ++ ++ if test "x$have_zlib" = xyes; then : + +- LIBS="-lz $LIBS" ++ ++$as_echo "#define HAVE_LIBZ 1" >>confdefs.h ++ ++ LIBS="-lz $LIBS" ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" + + else +- as_fn_error $? "zlib library not found ++ ++ as_fn_error $? "zlib library not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. + Use --without-zlib to disable zlib support." "$LINENO" 5 +-fi + ++fi + fi + + if test "$enable_spinlocks" = yes; then +@@ -12330,10 +12502,108 @@ if test "$with_openssl" = yes ; then + fi + + if test "$with_ssl" = openssl ; then +- # Minimum required OpenSSL version is 1.0.2 ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl" >&5 ++$as_echo_n "checking for openssl... " >&6; } ++ ++if test -n "$OPENSSL_CFLAGS"; then ++ pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$OPENSSL_LIBS"; then ++ pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1` ++ else ++ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$OPENSSL_PKG_ERRORS" >&5 ++ ++ as_fn_error $? "Package requirements (openssl) were not met: ++ ++$OPENSSL_PKG_ERRORS ++ ++Consider adjusting the PKG_CONFIG_PATH environment variable if you ++installed software in a non-standard prefix. ++ ++Alternatively, you may set the environment variables OPENSSL_CFLAGS ++and OPENSSL_LIBS to avoid the need to call pkg-config. ++See the pkg-config man page for more details." "$LINENO" 5 ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it ++is in your PATH or set the PKG_CONFIG environment variable to the full ++path to pkg-config. ++ ++Alternatively, you may set the environment variables OPENSSL_CFLAGS ++and OPENSSL_LIBS to avoid the need to call pkg-config. ++See the pkg-config man page for more details. ++ ++To get pkg-config, see . ++See \`config.log' for more details" "$LINENO" 5; } ++else ++ OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS ++ OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++fi ++ # Minimum required OpenSSL version is 1.0.2 + + $as_echo "#define OPENSSL_API_COMPAT 0x10002000L" >>confdefs.h + ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $OPENSSL_CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $OPENSSL_LIBS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ + if test "$PORTNAME" != "win32"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5 + $as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; } +@@ -12606,6 +12876,10 @@ done + + $as_echo "#define USE_OPENSSL 1" >>confdefs.h + ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS + elif test "$with_ssl" != no ; then + as_fn_error $? "--with-ssl must specify openssl" "$LINENO" 5 + fi +@@ -13103,14 +13377,85 @@ else + fi + + elif test "$with_uuid" = e2fs ; then +- # On macOS, the UUID functions are in libc +- ac_fn_c_check_func "$LINENO" "uuid_generate" "ac_cv_func_uuid_generate" +-if test "x$ac_cv_func_uuid_generate" = xyes; then : +- UUID_LIBS="" ++ have_uuid=missing ++ ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid >= 2.20" >&5 ++$as_echo_n "checking for uuid >= 2.20... " >&6; } ++ ++if test -n "$UUID_CFLAGS"; then ++ pkg_cv_UUID_CFLAGS="$UUID_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_UUID_CFLAGS=`$PKG_CONFIG --cflags "uuid >= 2.20" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$UUID_LIBS"; then ++ pkg_cv_UUID_LIBS="$UUID_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_UUID_LIBS=`$PKG_CONFIG --libs "uuid >= 2.20" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes + else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 +-$as_echo_n "checking for uuid_generate in -luuid... " >&6; } +-if ${ac_cv_lib_uuid_uuid_generate+:} false; then : ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ UUID_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "uuid >= 2.20" 2>&1` ++ else ++ UUID_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "uuid >= 2.20" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$UUID_PKG_ERRORS" >&5 ++ ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -13124,34 +13469,279 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext + #ifdef __cplusplus + extern "C" + #endif +-char uuid_generate (); ++char uuid_generate_time (); + int + main () + { +-return uuid_generate (); ++return uuid_generate_time (); + ; + return 0; + } + _ACEOF + if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_uuid_uuid_generate=yes ++ ac_cv_lib_uuid_uuid_generate_time=yes + else +- ac_cv_lib_uuid_uuid_generate=no ++ ac_cv_lib_uuid_uuid_generate_time=no + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 +-$as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } +-if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : +- UUID_LIBS="-luuid" ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ ++else ++ ++ for ac_header in uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes ++else ++ ac_cv_lib_uuid_uuid_generate_time=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ ++fi ++ ++done ++ ++ ++fi ++ ++done ++ ++ ++ if test "x$have_uuid" = xyes; then : ++ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ ++fi ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes + else +- as_fn_error $? "library 'uuid' is required for E2FS UUID" "$LINENO" 5 ++ ac_cv_lib_uuid_uuid_generate_time=no + fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ + ++else ++ ++ for ac_header in uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_H 1 ++_ACEOF ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5 ++$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; } ++if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-luuid $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char uuid_generate_time (); ++int ++main () ++{ ++return uuid_generate_time (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_uuid_uuid_generate_time=yes ++else ++ ac_cv_lib_uuid_uuid_generate_time=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS + fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5 ++$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; } ++if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then : ++ have_uuid=yes ++fi ++ ++ ++fi ++ ++done + ++ ++fi ++ ++done ++ ++ ++ if test "x$have_uuid" = xyes; then : ++ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ ++fi ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ++ ++else ++ UUID_CFLAGS=$pkg_cv_UUID_CFLAGS ++ UUID_LIBS=$pkg_cv_UUID_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++ have_uuid=yes ++ ++fi ++ ++ # On macOS, the UUID functions are in libc ++ if test "x$have_uuid" = xmissing; then : ++ ++ for ac_header in uuid/uuid.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" ++if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_UUID_UUID_H 1 ++_ACEOF ++ ++ ac_fn_c_check_func "$LINENO" "uuid_generate_time" "ac_cv_func_uuid_generate_time" ++if test "x$ac_cv_func_uuid_generate_time" = xyes; then : ++ ++ have_uuid=yes ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-""} ++ ++fi ++ ++ ++fi ++ ++done ++ ++ ++fi ++ ++ if test "x$have_uuid" = xmissing; then : ++ ++ as_fn_error $? "library 'uuid' is required for E2FS UUID" "$LINENO" 5 ++ ++fi + elif test "$with_uuid" = ossp ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_export in -lossp-uuid" >&5 + $as_echo_n "checking for uuid_export in -lossp-uuid... " >&6; } +@@ -13507,6 +14097,8 @@ done + fi + + if test "$with_zlib" = yes; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" + if test "x$ac_cv_header_zlib_h" = xyes; then : + +@@ -13518,6 +14110,7 @@ Use --without-zlib to disable zlib support." "$LINENO" 5 + fi + + ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test -z "$LZ4"; then +@@ -13765,6 +14358,8 @@ pgac_openssl_version="$($OPENSSL version 2> /dev/null || echo openssl not found) + { $as_echo "$as_me:${as_lineno-$LINENO}: using openssl: $pgac_openssl_version" >&5 + $as_echo "$as_me: using openssl: $pgac_openssl_version" >&6;} + if test "$with_ssl" = openssl ; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS" + ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" + if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : + +@@ -13781,6 +14376,7 @@ else + fi + + ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test "$with_pam" = yes ; then +@@ -13934,6 +14530,9 @@ fi + + fi + ++pgac_save_CPPFLAGS=$CPPFLAGS ++CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ + # for contrib/uuid-ossp + if test "$with_uuid" = bsd ; then + for ac_header in uuid.h +@@ -14068,6 +14667,8 @@ done + + fi + ++CPPFLAGS=$pgac_save_CPPFLAGS ++ + if test "$PORTNAME" = "win32" ; then + for ac_header in crtdefs.h + do : +@@ -14790,6 +15391,24 @@ _ACEOF + fi + + ++if test "$with_zlib" = yes; then ++ # Check that defines z_streamp (versions before about 1.0.4 ++ # did not). While we could work around the lack of z_streamp, it ++ # seems unwise to encourage people to use such old zlib versions... ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" ++ ac_fn_c_check_type "$LINENO" "z_streamp" "ac_cv_type_z_streamp" "#include ++" ++if test "x$ac_cv_type_z_streamp" = xyes; then : ++ ++else ++ as_fn_error $? "zlib version is too old ++Use --without-zlib to disable zlib support." "$LINENO" 5 ++fi ++ ++ CPPFLAGS="$pgac_save_CPPFLAGS" ++fi ++ + case $host_cpu in + x86_64) + # On x86_64, check if we can compile a popcntq instruction +diff --git a/configure.ac b/configure.ac +index 791ec2579c..7bd8246b3c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1289,11 +1289,39 @@ Use --without-readline to disable readline support.]) + fi + + if test "$with_zlib" = yes; then +- AC_CHECK_LIB(z, inflate, [], +- [AC_MSG_ERROR([zlib library not found ++ have_zlib=missing ++ PKG_CHECK_MODULES( ++ [ZLIB], [zlib], [ ++ have_zlib=yes ++ ], [ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ AC_CHECK_LIB(z, inflate, [ ++ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ++ ZLIB_LIBS=${ZLIB_LIBS-"-lz"} ++ have_zlib=yes ++ ]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ] ++ ) ++ ++ AS_VAR_IF([have_zlib], [yes], [ ++ AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if you have zlib.]) ++ LIBS="-lz $LIBS" ++ LDFLAGS="$LDFLAGS $ZLIB_LIBS" ++ ], [ ++ AC_MSG_ERROR([zlib library not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. +-Use --without-zlib to disable zlib support.])]) ++Use --without-zlib to disable zlib support.]) ++ ]) + fi + + if test "$enable_spinlocks" = yes; then +@@ -1335,9 +1363,17 @@ fi + + if test "$with_ssl" = openssl ; then + dnl Order matters! ++ PKG_CHECK_MODULES(OPENSSL, openssl) + # Minimum required OpenSSL version is 1.0.2 + AC_DEFINE(OPENSSL_API_COMPAT, [0x10002000L], + [Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.]) ++ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $OPENSSL_CFLAGS $ZLIB_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $OPENSSL_LIBS $ZLIB_LIBS" ++ pgac_save_LIBS=$LIBS ++ + if test "$PORTNAME" != "win32"; then + AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) + AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) +@@ -1360,6 +1396,10 @@ if test "$with_ssl" = openssl ; then + # Function introduced in OpenSSL 1.1.1. + AC_CHECK_FUNCS([X509_get_signature_info SSL_CTX_set_num_tickets]) + AC_DEFINE([USE_OPENSSL], 1, [Define to 1 to build with OpenSSL support. (--with-ssl=openssl)]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS + elif test "$with_ssl" != no ; then + AC_MSG_ERROR([--with-ssl must specify openssl]) + fi +@@ -1436,12 +1476,51 @@ if test "$with_uuid" = bsd ; then + [UUID_LIBS=""], + [AC_MSG_ERROR([BSD UUID functions are not present])]) + elif test "$with_uuid" = e2fs ; then ++ have_uuid=missing ++ ++ PKG_CHECK_MODULES( ++ [UUID], [uuid >= 2.20], [ ++ have_uuid=yes ++ ], [ ++ pgac_save_CPPFLAGS=$CPPFLAGS ++ CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ pgac_save_LDFLAGS=$LDFLAGS ++ LDFLAGS="$LDFLAGS $UUID_LIBS" ++ pgac_save_LIBS=$LIBS ++ ++ AC_CHECK_HEADERS([uuid/uuid.h], [ ++ AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes]) ++ ], [ ++ AC_CHECK_HEADERS([uuid.h], [ ++ AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes]) ++ ]) ++ ]) ++ ++ AS_VAR_IF([have_uuid], [yes], [ ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-"-luuid"} ++ ]) ++ ++ CPPFLAGS=$pgac_save_CPPFLAGS ++ LDFLAGS=$pgac_save_LDFLAGS ++ LIBS=$pgac_save_LIBS ++ ] ++ ) ++ + # On macOS, the UUID functions are in libc +- AC_CHECK_FUNC(uuid_generate, +- [UUID_LIBS=""], +- [AC_CHECK_LIB(uuid, uuid_generate, +- [UUID_LIBS="-luuid"], +- [AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])]) ++ AS_VAR_IF([have_uuid], [missing], [ ++ AC_CHECK_HEADERS([uuid/uuid.h], [ ++ AC_CHECK_FUNC([uuid_generate_time], [ ++ have_uuid=yes ++ UUID_CFLAGS=${UUID_CFLAGS-""} ++ UUID_LIBS=${UUID_LIBS-""} ++ ]) ++ ]) ++ ]) ++ ++ AS_VAR_IF([have_uuid], [missing], [ ++ AC_MSG_ERROR([library 'uuid' is required for E2FS UUID]) ++ ]) + elif test "$with_uuid" = ossp ; then + AC_CHECK_LIB(ossp-uuid, uuid_export, + [UUID_LIBS="-lossp-uuid"], +@@ -1514,10 +1593,13 @@ Use --without-readline to disable libedit support.])])])]) + fi + + if test "$with_zlib" = yes; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found + If you have zlib already installed, see config.log for details on the + failure. It is possible the compiler isn't looking in the proper directory. + Use --without-zlib to disable zlib support.])]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + PGAC_PATH_PROGS(LZ4, lz4) +@@ -1541,8 +1623,11 @@ PGAC_PATH_PROGS(OPENSSL, openssl) + pgac_openssl_version="$($OPENSSL version 2> /dev/null || echo openssl not found)" + AC_MSG_NOTICE([using openssl: $pgac_openssl_version]) + if test "$with_ssl" = openssl ; then ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS" + AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file is required for OpenSSL])]) + AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file is required for OpenSSL])]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" + fi + + if test "$with_pam" = yes ; then +@@ -1591,6 +1676,9 @@ dnl If you want to use Apple's own Bonjour code on another platform, + dnl just add -ldns_sd to LIBS manually. + fi + ++pgac_save_CPPFLAGS=$CPPFLAGS ++CPPFLAGS="$CFLAGS $UUID_CFLAGS" ++ + # for contrib/uuid-ossp + if test "$with_uuid" = bsd ; then + AC_CHECK_HEADERS(uuid.h, +@@ -1615,6 +1703,8 @@ elif test "$with_uuid" = ossp ; then + [AC_MSG_ERROR([header file or is required for OSSP UUID])])]) + fi + ++CPPFLAGS=$pgac_save_CPPFLAGS ++ + if test "$PORTNAME" = "win32" ; then + AC_CHECK_HEADERS(crtdefs.h) + fi +@@ -1659,6 +1749,18 @@ AC_CHECK_TYPES([struct option], [], [], + #include + #endif]) + ++if test "$with_zlib" = yes; then ++ # Check that defines z_streamp (versions before about 1.0.4 ++ # did not). While we could work around the lack of z_streamp, it ++ # seems unwise to encourage people to use such old zlib versions... ++ pgac_save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" ++ AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old ++Use --without-zlib to disable zlib support.])], ++ [#include ]) ++ CPPFLAGS="$pgac_save_CPPFLAGS" ++fi ++ + case $host_cpu in + x86_64) + # On x86_64, check if we can compile a popcntq instruction +diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile +index 5efa10c334..26376d821a 100644 +--- a/contrib/pgcrypto/Makefile ++++ b/contrib/pgcrypto/Makefile +@@ -58,6 +58,10 @@ include $(top_builddir)/src/Makefile.global + include $(top_srcdir)/contrib/contrib-global.mk + endif + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif ++ + # Add libraries that pgcrypto depends (or might depend) on into the + # shared library link. (The order in which you list them here doesn't + # matter.) +diff --git a/contrib/sslinfo/Makefile b/contrib/sslinfo/Makefile +index dd1ff83b16..20a4615287 100644 +--- a/contrib/sslinfo/Makefile ++++ b/contrib/sslinfo/Makefile +@@ -20,4 +20,6 @@ include $(top_builddir)/src/Makefile.global + include $(top_srcdir)/contrib/contrib-global.mk + endif + ++LIBS += $(OPENSSL_LIBS) ++ + SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) +diff --git a/src/Makefile.global.in b/src/Makefile.global.in +index 8c1e3b9bb8..83a9234bfb 100644 +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -190,6 +190,13 @@ krb_srvtab = @krb_srvtab@ + ICU_CFLAGS = @ICU_CFLAGS@ + ICU_LIBS = @ICU_LIBS@ + ++OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ ++OPENSSL_LIBS = @OPENSSL_LIBS@ ++ ++UUID_CFLAGS = @UUID_CFLAGS@ ++ ++ZLIB_CFLAGS = @ZLIB_CFLAGS@ ++ + TCLSH = @TCLSH@ + TCL_LIBS = @TCL_LIBS@ + TCL_LIB_SPEC = @TCL_LIB_SPEC@ +@@ -214,7 +221,7 @@ CPP = @CPP@ + CPPFLAGS = @CPPFLAGS@ + PG_SYSROOT = @PG_SYSROOT@ + +-override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS) ++override CPPFLAGS := $(UUID_CFLAGS) $(OPENSSL_CFLAGS) $(ICU_CFLAGS) $(ZLIB_CFLAGS) $(CPPFLAGS) + + ifdef PGXS + override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS) +diff --git a/src/backend/Makefile b/src/backend/Makefile +index 84302cc6da..aa6a9fb6a7 100644 +--- a/src/backend/Makefile ++++ b/src/backend/Makefile +@@ -44,8 +44,8 @@ OBJS = \ + $(top_builddir)/src/port/libpgport_srv.a + + # We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add +-# libldap and ICU +-LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS) ++# libldap, ICU, and OpenSSL. ++LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS) $(OPENSSL_LIBS) + + # The backend doesn't need everything that's in LIBS, however + LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS)) +diff --git a/src/backend/libpq/Makefile b/src/backend/libpq/Makefile +index 6d385fd6a4..e385ab4c81 100644 +--- a/src/backend/libpq/Makefile ++++ b/src/backend/libpq/Makefile +@@ -31,6 +31,7 @@ OBJS = \ + + ifeq ($(with_ssl),openssl) + OBJS += be-secure-openssl.o ++LIBS += $(OPENSSL_LIBS) + endif + + ifeq ($(with_gssapi),yes) +diff --git a/src/bin/pg_combinebackup/Makefile b/src/bin/pg_combinebackup/Makefile +index c3729755ba..e5de9adce1 100644 +--- a/src/bin/pg_combinebackup/Makefile ++++ b/src/bin/pg_combinebackup/Makefile +@@ -28,6 +28,10 @@ OBJS = \ + reconstruct.o \ + write_manifest.o + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif ++ + all: pg_combinebackup + + pg_combinebackup: $(OBJS) | submake-libpgport submake-libpgfeutils +diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile +index 7c045f142e..e7f01780c1 100644 +--- a/src/bin/pg_verifybackup/Makefile ++++ b/src/bin/pg_verifybackup/Makefile +@@ -23,6 +23,10 @@ OBJS = \ + $(WIN32RES) \ + pg_verifybackup.o + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif ++ + all: pg_verifybackup + + pg_verifybackup: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils +diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile +index 987bf64df9..d828ee0254 100644 +--- a/src/bin/pgbench/Makefile ++++ b/src/bin/pgbench/Makefile +@@ -23,6 +23,9 @@ override CPPFLAGS += -DFD_SETSIZE=1024 + endif + LIBS += $(PTHREAD_LIBS) + ++ifeq ($(with_ssl),openssl) ++LIBS += $(OPENSSL_LIBS) ++endif + + all: pgbench + +diff --git a/src/common/Makefile b/src/common/Makefile +index 19c6f58f9f..9e9aadf626 100644 +--- a/src/common/Makefile ++++ b/src/common/Makefile +@@ -91,6 +91,7 @@ OBJS_COMMON += \ + cryptohash_openssl.o \ + hmac_openssl.o \ + protocol_openssl.o ++LIBS += $(OPENSSL_LIBS) + else + OBJS_COMMON += \ + cryptohash.o \ +diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in +index 66850edc9d..cef1c39a87 100644 +--- a/src/include/pg_config.h.in ++++ b/src/include/pg_config.h.in +@@ -276,7 +276,7 @@ + /* Define to 1 if you have the `xslt' library (-lxslt). */ + #undef HAVE_LIBXSLT + +-/* Define to 1 if you have the `z' library (-lz). */ ++/* Define to 1 if you have zlib. */ + #undef HAVE_LIBZ + + /* Define to 1 if you have the `zstd' library (-lzstd). */ +diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile +index b36a765764..cd9539a398 100644 +--- a/src/interfaces/libpq/Makefile ++++ b/src/interfaces/libpq/Makefile +@@ -53,6 +53,7 @@ endif + ifeq ($(with_ssl),openssl) + OBJS += \ + fe-secure-openssl.o ++LIBS += $(OPENSSL_LIBS) + endif + + ifeq ($(with_gssapi),yes) +-- +2.45.2 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-17.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-17.patch new file mode 100644 index 00000000..1a45d5e8 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__popen-17.patch @@ -0,0 +1,386 @@ +From 1c50d0d1d19c5a4f976d9ed080171b9688aa5858 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Sat, 30 May 2020 18:53:22 -0700 +Subject: [PATCH 2/5] Add a version of popen() that respects the SHELL + environment variable + +The main motivation here is to workaround SIP on macOS, where all +binaries in `/bin` will not inherit `DYLD_LIBRARY_PATH`, including +`/bin/sh`, which is spawned by `popen()`. This prevents running +Postgres from a temp installation dir. +--- + src/bin/initdb/initdb.c | 3 +- + src/bin/pg_ctl/pg_ctl.c | 3 +- + src/common/Makefile | 1 + + src/common/exec.c | 5 +- + src/common/popen.c | 224 +++++++++++++++++++++++++++++++++++++++ + src/include/port/popen.h | 42 ++++++++ + 6 files changed, 274 insertions(+), 4 deletions(-) + create mode 100644 src/common/popen.c + create mode 100644 src/include/port/popen.h + +diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c +index f00718a015..860ea95c2b 100644 +--- a/src/bin/initdb/initdb.c ++++ b/src/bin/initdb/initdb.c +@@ -81,6 +81,7 @@ + #include "getopt_long.h" + #include "mb/pg_wchar.h" + #include "miscadmin.h" ++#include "port/popen.h" + + + /* Ideally this would be in a .h file, but it hardly seems worth the trouble */ +@@ -690,7 +691,7 @@ popen_check(const char *command, const char *mode) + + fflush(NULL); + errno = 0; +- cmdfd = popen(command, mode); ++ cmdfd = pg_popen(command, mode); + if (cmdfd == NULL) + pg_log_error("could not execute command \"%s\": %m", command); + return cmdfd; +diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c +index 57ed8c8e29..59392eb6d4 100644 +--- a/src/bin/pg_ctl/pg_ctl.c ++++ b/src/bin/pg_ctl/pg_ctl.c +@@ -27,6 +27,7 @@ + #include "common/logging.h" + #include "common/string.h" + #include "getopt_long.h" ++#include "port/popen.h" + #include "utils/pidfile.h" + + #ifdef WIN32 /* on Unix, we don't need libpq */ +@@ -912,7 +913,7 @@ do_init(void) + exec_path, pgdata_opt, post_opts, DEVNULL); + + fflush(NULL); +- if (system(cmd) != 0) ++ if (pg_system(cmd) != 0) + { + write_stderr(_("%s: database system initialization failed\n"), progname); + exit(1); +diff --git a/src/common/Makefile b/src/common/Makefile +index 3d83299432..19c6f58f9f 100644 +--- a/src/common/Makefile ++++ b/src/common/Makefile +@@ -71,6 +71,7 @@ OBJS_COMMON = \ + pg_lzcompress.o \ + pg_prng.o \ + pgfnames.o \ ++ popen.o \ + psprintf.o \ + relpath.o \ + rmtree.o \ +diff --git a/src/common/exec.c b/src/common/exec.c +index 0bee19c1e5..1e318ac49c 100644 +--- a/src/common/exec.c ++++ b/src/common/exec.c +@@ -43,6 +43,7 @@ + #endif + + #include "common/string.h" ++#include "port/popen.h" + + /* Inhibit mingw CRT's auto-globbing of command line arguments */ + #if defined(WIN32) && !defined(_MSC_VER) +@@ -376,7 +377,7 @@ pipe_read_line(char *cmd) + fflush(NULL); + + errno = 0; +- if ((pipe_cmd = popen(cmd, "r")) == NULL) ++ if ((pipe_cmd = pg_popen(cmd, "r")) == NULL) + { + log_error(errcode(ERRCODE_SYSTEM_ERROR), + _("could not execute command \"%s\": %m"), cmd); +@@ -412,7 +413,7 @@ pclose_check(FILE *stream) + int exitstatus; + char *reason; + +- exitstatus = pclose(stream); ++ exitstatus = pg_pclose(stream); + + if (exitstatus == 0) + return 0; /* all is well */ +diff --git a/src/common/popen.c b/src/common/popen.c +new file mode 100644 +index 0000000000..6e5393d33d +--- /dev/null ++++ b/src/common/popen.c +@@ -0,0 +1,224 @@ ++/* $OpenBSD: popen.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */ ++/* ++ * Copyright (c) 1988, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * This code is derived from software written by Ken Arnold and ++ * published in UNIX Review, Vol. 6, No. 8. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#include "postgres.h" ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "port/popen.h" ++#include "libpq/pqsignal.h" ++ ++static struct pid { ++ struct pid *next; ++ FILE *fp; ++ pid_t pid; ++} *pidlist; ++ ++FILE * ++pg_popen(const char *program, const char *type) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return popen(program, type); ++ ++ struct pid * volatile cur; ++ FILE *iop; ++ int pdes[2]; ++ pid_t pid; ++ char *shell = getenv("SHELL"); ++ if (shell == NULL) ++ shell = _PATH_BSHELL; ++ char *argp[] = {shell, "-c", NULL, NULL}; ++ char *dyld_library_path = getenv("DYLD_LIBRARY_PATH"); ++ ++ if (dyld_library_path == NULL) ++ dyld_library_path = ""; ++ ++ if ((*type != 'r' && *type != 'w') || type[1] != '\0') { ++ errno = EINVAL; ++ return (NULL); ++ } ++ ++ if ((cur = malloc(sizeof(struct pid))) == NULL) ++ return (NULL); ++ ++ if (pipe(pdes) < 0) { ++ free(cur); ++ return (NULL); ++ } ++ ++ switch (pid = fork()) { ++ case -1: /* Error. */ ++ (void)close(pdes[0]); ++ (void)close(pdes[1]); ++ free(cur); ++ return (NULL); ++ /* NOTREACHED */ ++ case 0: /* Child. */ ++ { ++ struct pid *pcur; ++ /* ++ * We fork()'d, we got our own copy of the list, no ++ * contention. ++ */ ++ for (pcur = pidlist; pcur; pcur = pcur->next) ++ close(fileno(pcur->fp)); ++ ++ if (*type == 'r') { ++ (void) close(pdes[0]); ++ if (pdes[1] != STDOUT_FILENO) { ++ (void)dup2(pdes[1], STDOUT_FILENO); ++ (void)close(pdes[1]); ++ } ++ } else { ++ (void)close(pdes[1]); ++ if (pdes[0] != STDIN_FILENO) { ++ (void)dup2(pdes[0], STDIN_FILENO); ++ (void)close(pdes[0]); ++ } ++ } ++ argp[2] = (char *)program; ++ execv(shell, argp); ++ _exit(127); ++ /* NOTREACHED */ ++ } ++ } ++ ++ /* Parent; assume fdopen can't fail. */ ++ if (*type == 'r') { ++ iop = fdopen(pdes[0], type); ++ (void)close(pdes[1]); ++ } else { ++ iop = fdopen(pdes[1], type); ++ (void)close(pdes[0]); ++ } ++ ++ /* Link into list of file descriptors. */ ++ cur->fp = iop; ++ cur->pid = pid; ++ cur->next = pidlist; ++ pidlist = cur; ++ ++ return (iop); ++} ++ ++/* ++ * shell_pclose -- ++ * Pclose returns -1 if stream is not associated with a `popened' command, ++ * if already `pclosed', or waitpid returns an error. ++ */ ++int ++pg_pclose(FILE *iop) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return pclose(iop); ++ ++ struct pid *cur, *last; ++ int pstat; ++ pid_t pid; ++ ++ /* Find the appropriate file pointer. */ ++ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) ++ if (cur->fp == iop) ++ break; ++ ++ if (cur == NULL) ++ return (-1); ++ ++ (void)fclose(iop); ++ ++ do { ++ pid = waitpid(cur->pid, &pstat, 0); ++ } while (pid == -1 && errno == EINTR); ++ ++ /* Remove the entry from the linked list. */ ++ if (last == NULL) ++ pidlist = cur->next; ++ else ++ last->next = cur->next; ++ free(cur); ++ ++ return (pid == -1 ? -1 : pstat); ++} ++ ++ ++int ++pg_system(const char *command) ++{ ++ if (getenv("PGOVERRIDESTDSHELL") == NULL) ++ return system(command); ++ ++ char *shell = getenv("SHELL"); ++ if (shell == NULL) ++ shell = _PATH_BSHELL; ++ ++ pid_t pid; ++ sig_t intsave, quitsave; ++ sigset_t mask, omask; ++ int pstat; ++ char *argp[] = {shell, "-c", NULL, NULL}; ++ ++ if (!command) /* just checking... */ ++ return(1); ++ ++ argp[2] = (char *)command; ++ ++ sigemptyset(&mask); ++ sigaddset(&mask, SIGCHLD); ++ sigprocmask(SIG_BLOCK, &mask, &omask); ++ switch (pid = vfork()) { ++ case -1: /* error */ ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ return(-1); ++ case 0: /* child */ ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ execv(shell, argp); ++ _exit(127); ++ } ++ ++ intsave = (sig_t) pqsignal(SIGINT, SIG_IGN); ++ quitsave = (sig_t) pqsignal(SIGQUIT, SIG_IGN); ++ pid = waitpid(pid, (int *)&pstat, 0); ++ sigprocmask(SIG_SETMASK, &omask, NULL); ++ (void)pqsignal(SIGINT, intsave); ++ (void)pqsignal(SIGQUIT, quitsave); ++ return (pid == -1 ? -1 : pstat); ++} +diff --git a/src/include/port/popen.h b/src/include/port/popen.h +new file mode 100644 +index 0000000000..423aff536b +--- /dev/null ++++ b/src/include/port/popen.h +@@ -0,0 +1,42 @@ ++/* ++ * Copyright (c) 1988, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * This code is derived from software written by Ken Arnold and ++ * published in UNIX Review, Vol. 6, No. 8. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef PG_POPEN_H ++#define PG_POPEN_H ++ ++#include ++ ++extern FILE *pg_popen(const char *program, const char *type); ++extern int pg_pclose(FILE *iop); ++extern int pg_system(const char *command); ++ ++#endif +-- +2.45.2 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-17.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-17.patch new file mode 100644 index 00000000..08958168 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__predictable_install-17.patch @@ -0,0 +1,81 @@ +From 402364ac1c77f5005043cb85f8c0ad0eafa8cdbf Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Mon, 17 Oct 2022 16:32:14 -0700 +Subject: [PATCH 4/5] Make sure installation directories are predictable + +Remove attempts by Postgres to strip the trailing `postgresql` part of +the installation path if any of the prior path parts contain `postgres` +or `pgsql`. +--- + src/Makefile.global.in | 38 ++++++-------------------------------- + 1 file changed, 6 insertions(+), 32 deletions(-) + +diff --git a/src/Makefile.global.in b/src/Makefile.global.in +index a00c909681..8c1e3b9bb8 100644 +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -82,8 +82,7 @@ endif # not PGXS + # Installation directories + # + # These are set by the equivalent --xxxdir configure options. We +-# append "postgresql" to some of them, if the string does not already +-# contain "pgsql" or "postgres", in order to avoid directory clutter. ++# append "postgresql" to some of them. + # + # In a PGXS build, we cannot use the values inserted into Makefile.global + # by configure, since the installation tree may have been relocated. +@@ -100,46 +99,21 @@ datarootdir := @datarootdir@ + + bindir := @bindir@ + +-datadir := @datadir@ +-ifeq "$(findstring pgsql, $(datadir))" "" +-ifeq "$(findstring postgres, $(datadir))" "" +-override datadir := $(datadir)/postgresql +-endif +-endif ++datadir := @datadir@/postgresql + +-sysconfdir := @sysconfdir@ +-ifeq "$(findstring pgsql, $(sysconfdir))" "" +-ifeq "$(findstring postgres, $(sysconfdir))" "" +-override sysconfdir := $(sysconfdir)/postgresql +-endif +-endif ++sysconfdir := @sysconfdir@/postgresql + + libdir := @libdir@ + +-pkglibdir = $(libdir) +-ifeq "$(findstring pgsql, $(pkglibdir))" "" +-ifeq "$(findstring postgres, $(pkglibdir))" "" +-override pkglibdir := $(pkglibdir)/postgresql +-endif +-endif ++pkglibdir = $(libdir)/postgresql + + includedir := @includedir@ + +-pkgincludedir = $(includedir) +-ifeq "$(findstring pgsql, $(pkgincludedir))" "" +-ifeq "$(findstring postgres, $(pkgincludedir))" "" +-override pkgincludedir := $(pkgincludedir)/postgresql +-endif +-endif ++pkgincludedir = $(includedir)/postgresql + + mandir := @mandir@ + +-docdir := @docdir@ +-ifeq "$(findstring pgsql, $(docdir))" "" +-ifeq "$(findstring postgres, $(docdir))" "" +-override docdir := $(docdir)/postgresql +-endif +-endif ++docdir := @docdir@/postgresql + + htmldir := @htmldir@ + +-- +2.45.2 + diff --git a/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-17.patch b/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-17.patch new file mode 100644 index 00000000..b4f44a19 --- /dev/null +++ b/edgedbpkg/postgresql/patches/postgresql-edgedb__wsl1-17.patch @@ -0,0 +1,191 @@ +From 64541477f6cf5b2711b23018446c6e118ea8f8cc Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Fri, 15 Jul 2022 16:44:07 -0700 +Subject: [PATCH 1/5] Add a workaround for WSL1 signal mishandling + +WSL1 appears to mishandle `signal(..., SIG_IGN)` followed by +`sigprocmask`, which leads to `SetLatch` being completely broken because +`SIGURG` ends up being ignored instead of blocked and forwarded via +`signalfd`. + +See https://github.com/microsoft/WSL/issues/8619 +--- + configure | 2 +- + configure.ac | 1 + + src/backend/postmaster/postmaster.c | 34 +++++++++++++++++++++++++++++ + src/backend/storage/ipc/latch.c | 4 ++++ + src/backend/utils/init/globals.c | 5 +++++ + src/backend/utils/init/miscinit.c | 1 + + src/include/miscadmin.h | 1 + + src/include/pg_config.h.in | 3 +++ + src/include/postmaster/postmaster.h | 1 + + 9 files changed, 51 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 6db03e4a22..78db894968 100755 +--- a/configure ++++ b/configure +@@ -13338,7 +13338,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + fi + + +-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h termios.h ucred.h ++for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h sys/utsname.h termios.h ucred.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +diff --git a/configure.ac b/configure.ac +index 7531366b75..791ec2579c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1473,6 +1473,7 @@ AC_CHECK_HEADERS(m4_normalize([ + sys/procctl.h + sys/signalfd.h + sys/ucred.h ++ sys/utsname.h + termios.h + ucred.h + ])) +diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c +index bf0241aed0..1ccd46754b 100644 +--- a/src/backend/postmaster/postmaster.c ++++ b/src/backend/postmaster/postmaster.c +@@ -77,6 +77,10 @@ + #include + #include + ++#ifdef HAVE_SYS_UTSNAME_H ++#include ++#endif ++ + #ifdef USE_BONJOUR + #include + #endif +@@ -1080,6 +1084,11 @@ PostmasterMain(int argc, char *argv[]) + ereport(LOG, + (errmsg("starting %s", PG_VERSION_STR))); + ++ IsUnderWSL1 = DetectWSL1(); ++ if (IsUnderWSL1) ++ ereport(LOG, ++ (errmsg("detected WSL1, applying workarounds"))); ++ + /* + * Establish input sockets. + * +@@ -2068,6 +2077,31 @@ InitProcessGlobals(void) + } + + /* ++ * DetectWSL1 -- detect if we are running under WSL1 ++ */ ++bool ++DetectWSL1(void) ++{ ++#ifdef HAVE_SYS_UTSNAME_H ++ int rc; ++ struct utsname buf; ++ ++ memset(&buf, 0, sizeof buf); ++ rc = uname(&buf); ++ if (rc != 0) { ++ ereport(WARNING, ++ (errmsg("could not determine current kernel release version"))); ++ return false; ++ } else { ++ return pg_str_endswith(buf.release, "-Microsoft"); ++ } ++#else ++ return false; ++#endif ++} ++ ++/* ++ * reset_shared -- reset shared memory and semaphores + * Child processes use SIGUSR1 to notify us of 'pmsignals'. pg_ctl uses + * SIGUSR1 to ask postmaster to check for logrotate and promote files. + */ +diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c +index 608eb66abe..349bd2a5ad 100644 +--- a/src/backend/storage/ipc/latch.c ++++ b/src/backend/storage/ipc/latch.c +@@ -334,6 +334,10 @@ InitializeLatchSupport(void) + if (signal_fd < 0) + elog(FATAL, "signalfd() failed"); + ReserveExternalFD(); ++ ++ if (IsUnderWSL1) ++ /* Workaround https://github.com/microsoft/WSL/issues/8619 */ ++ pqsignal(SIGURG, SIG_DFL); + #endif + + #ifdef WAIT_USE_KQUEUE +diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c +index cc61937eef..f46d039f26 100644 +--- a/src/backend/utils/init/globals.c ++++ b/src/backend/utils/init/globals.c +@@ -117,6 +117,11 @@ bool IsPostmasterEnvironment = false; + bool IsUnderPostmaster = false; + bool IsBinaryUpgrade = false; + ++/* ++ * Whether we are running under WSL1, for various workarounds. ++ */ ++bool IsUnderWSL1 = false; ++ + bool ExitOnAnyError = false; + + int DateStyle = USE_ISO_DATES; +diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c +index 537d92c0cf..8052e393f5 100644 +--- a/src/backend/utils/init/miscinit.c ++++ b/src/backend/utils/init/miscinit.c +@@ -130,6 +130,7 @@ InitPostmasterChild(void) + /* In EXEC_BACKEND case we will not have inherited BlockSig etc values */ + #ifdef EXEC_BACKEND + pqinitmask(); ++ IsUnderWSL1 = DetectWSL1(); + #endif + + /* Initialize process-local latch support */ +diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h +index 90f9b21b25..071aa8d3db 100644 +--- a/src/include/miscadmin.h ++++ b/src/include/miscadmin.h +@@ -166,6 +166,7 @@ extern PGDLLIMPORT pid_t PostmasterPid; + extern PGDLLIMPORT bool IsPostmasterEnvironment; + extern PGDLLIMPORT bool IsUnderPostmaster; + extern PGDLLIMPORT bool IsBinaryUpgrade; ++extern PGDLLIMPORT bool IsUnderWSL1; + + extern PGDLLIMPORT bool ExitOnAnyError; + +diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in +index 6d9a0d001f..66850edc9d 100644 +--- a/src/include/pg_config.h.in ++++ b/src/include/pg_config.h.in +@@ -465,6 +465,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_UCRED_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_UTSNAME_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_TERMIOS_H + +diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h +index 89ad13b788..b8338af449 100644 +--- a/src/include/postmaster/postmaster.h ++++ b/src/include/postmaster/postmaster.h +@@ -57,6 +57,7 @@ extern PGDLLIMPORT bool LoadedSSL; + extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); + extern void ClosePostmasterPorts(bool am_syslogger); + extern void InitProcessGlobals(void); ++extern bool DetectWSL1(void); + + extern int MaxLivePostmasterChildren(void); + +-- +2.45.2 +