From ef844445754c0c3f74bfd954c3bb84f1576e8557 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Tue, 7 Jan 2025 14:38:48 -0800 Subject: [PATCH] Update PostGIS to 3.5.1 Remove hardcoded Postgres extension version while at it and add an EdgeQL-only version of the package. --- edgedbpkg/edgedb_ext/__init__.py | 4 +- edgedbpkg/edgedb_ext/base.py | 89 +++++++++++------- edgedbpkg/edgedb_ext/postgis/__init__.py | 15 ++- ... pgext-postgis__fix-out-of-tree-304.patch} | 0 .../patches/pgext-postgis__gettext-305.patch | 94 +++++++++++++++++++ .../pgext-postgis__macos-fix-305.patch | 62 ++++++++++++ ...ext-postgis__mkdir-p-config-fix-304.patch} | 0 ...pgext-postgis__protocc-pkgconfig-305.patch | 77 +++++++++++++++ ...__remove-explicit-libstdcpp-link-305.patch | 57 +++++++++++ 9 files changed, 359 insertions(+), 39 deletions(-) rename edgedbpkg/pgext/postgis/patches/{pgext-postgis__fix-out-of-tree.patch => pgext-postgis__fix-out-of-tree-304.patch} (100%) create mode 100644 edgedbpkg/pgext/postgis/patches/pgext-postgis__gettext-305.patch create mode 100644 edgedbpkg/pgext/postgis/patches/pgext-postgis__macos-fix-305.patch rename edgedbpkg/pgext/postgis/patches/{pgext-postgis__mkdir-p-config-fix.patch => pgext-postgis__mkdir-p-config-fix-304.patch} (100%) create mode 100644 edgedbpkg/pgext/postgis/patches/pgext-postgis__protocc-pkgconfig-305.patch create mode 100644 edgedbpkg/pgext/postgis/patches/pgext-postgis__remove-explicit-libstdcpp-link-305.patch diff --git a/edgedbpkg/edgedb_ext/__init__.py b/edgedbpkg/edgedb_ext/__init__.py index c027257..010faec 100644 --- a/edgedbpkg/edgedb_ext/__init__.py +++ b/edgedbpkg/edgedb_ext/__init__.py @@ -1,3 +1,3 @@ -from .base import EdgeDBExtension +from .base import EdgeDBExtension, PGEXT_VERSION_AUTO -__all__ = ("EdgeDBExtension",) +__all__ = ("EdgeDBExtension", "PGEXT_VERSION_AUTO") diff --git a/edgedbpkg/edgedb_ext/base.py b/edgedbpkg/edgedb_ext/base.py index e0ca63d..4367f68 100644 --- a/edgedbpkg/edgedb_ext/base.py +++ b/edgedbpkg/edgedb_ext/base.py @@ -24,11 +24,13 @@ + "/tests/extension-testing/exts.mk" ) +PGEXT_VERSION_AUTO = "auto" + class EdgeDBExtension(packages.BuildSystemMakePackage): # Populated in resolve() when this is built as top-level package. bundle_deps: list[packages.BundledPackage] = [] - _edb: edgedb.EdgeDB + _edb: edgedb.EdgeDB | None _pgext: poetry_dep.Dependency @classmethod @@ -48,34 +50,62 @@ def resolve( server_slot, _, version = version.rpartition("!") if not server_slot: - raise RuntimeError( - "must specify EdgeDB version as epoch, eg 5!1.0" - ) + if cls.is_universal(): + edb = None + else: + raise RuntimeError( + "must specify EdgeDB version as epoch, eg 5!1.0" + ) + else: + edb_ver = poetry_version.Version.parse(server_slot) + if edb_ver.minor is None: + edb_ver = edb_ver.replace( + release=dataclasses.replace(edb_ver.release, minor=0), + ) - edb_ver = poetry_version.Version.parse(server_slot) - if edb_ver.minor is None: - edb_ver = edb_ver.replace( - release=dataclasses.replace(edb_ver.release, minor=0), + edb = edgedb.EdgeDB.resolve( + io, + version=f"v{edb_ver}", + is_release=edb_ver.dev is None, + target=target, ) - edb = edgedb.EdgeDB.resolve( - io, - version=f"v{edb_ver}", - is_release=edb_ver.dev is None, - target=target, - ) - if requires is None: requires = [] else: requires = list(requires) + if name is None: + pkgname = cls.ident.removeprefix("edbext-") + else: + pkgname = str(name) + + if edb is not None: + name = packages.canonicalize_name(f"{edb.name_slot}-{pkgname}") + else: + name = packages.canonicalize_name(pkgname) + + ext = super().resolve( + io, + name=name, + version=version, + revision=revision, + is_release=is_release, + target=target, + requires=requires, + ) + ext._edb = edb + pgext_ver = cls.get_pgext_ver() + if pgext_ver is PGEXT_VERSION_AUTO: + self_ver = ext.version.without_local().without_postrelease() + pgext_ver = self_ver.to_string() pg_ext: pgext.PostgresCExtension | None if pgext_ver: # Find the postgres version - for dep in edb.get_requirements(): + reqs = edb.get_requirements() if edb is not None else [] + for dep in reqs: if dep.name == "postgresql-edgedb": pg = packages.get_bundled_pkg(dep) break @@ -102,25 +132,8 @@ def resolve( else: pg_ext = None - if name is None: - pkgname = cls.ident.removeprefix("edbext-") - else: - pkgname = str(name) - - name = packages.canonicalize_name(f"{edb.name_slot}-{pkgname}") - - ext = super().resolve( - io, - name=name, - version=version, - revision=revision, - is_release=is_release, - target=target, - requires=requires, - ) - ext._edb = edb - if pg_ext is not None: + ext.add_dependency(pg_ext.to_dependency()) ext.bundle_deps.append(pg_ext) return ext @@ -137,6 +150,10 @@ def _get_sources(cls, version: str | None) -> list[packages.BaseSource]: def get_pgext_ver(cls) -> str | None: return None + @classmethod + def is_universal(cls) -> bool: + return False + @property def supports_out_of_tree_builds(self) -> bool: return False @@ -171,7 +188,7 @@ def get_make_install_args(self, build: targets.Build) -> packages.Args: } def get_root_install_subdir(self, build: targets.Build) -> pathlib.Path: - if build.target.is_portable(): + if build.target.is_portable() or self._edb is None: return pathlib.Path(self.name_slot) else: return pathlib.Path(self._edb.name_slot) @@ -180,7 +197,7 @@ def get_make_install_destdir_subdir( self, build: targets.Build, ) -> pathlib.Path: - if build.target.is_portable(): + if build.target.is_portable() or self._edb is None: return pathlib.Path("") else: return ( diff --git a/edgedbpkg/edgedb_ext/postgis/__init__.py b/edgedbpkg/edgedb_ext/postgis/__init__.py index 4ccf7c0..030c9f4 100644 --- a/edgedbpkg/edgedb_ext/postgis/__init__.py +++ b/edgedbpkg/edgedb_ext/postgis/__init__.py @@ -25,7 +25,7 @@ class PostGIS(edgedb_ext.EdgeDBExtension): @classmethod def get_pgext_ver(cls) -> str | None: - return "3.4.3" + return edgedb_ext.PGEXT_VERSION_AUTO def get_make_install_destdir_subdir( self, @@ -35,3 +35,16 @@ def get_make_install_destdir_subdir( return build.get_rel_install_prefix(self) else: return super().get_make_install_destdir_subdir(build) + + +# EdgeQL-only version of the above +class PostGISEdgeQL(PostGIS): + ident = "edbext-postgis-edgeql" + + @classmethod + def get_pgext_ver(cls) -> str | None: + return None + + @classmethod + def is_universal(cls) -> bool: + return True diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__fix-out-of-tree.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__fix-out-of-tree-304.patch similarity index 100% rename from edgedbpkg/pgext/postgis/patches/pgext-postgis__fix-out-of-tree.patch rename to edgedbpkg/pgext/postgis/patches/pgext-postgis__fix-out-of-tree-304.patch diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__gettext-305.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__gettext-305.patch new file mode 100644 index 0000000..c8cdc7f --- /dev/null +++ b/edgedbpkg/pgext/postgis/patches/pgext-postgis__gettext-305.patch @@ -0,0 +1,94 @@ +From 24e4e6d4d94a4203e4a50000e25c983467a1c51e Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Thu, 3 Oct 2024 23:12:22 -0700 +Subject: [PATCH 4/4] Fix `make install` with gettext disabled + +--- + configure | 44 +++++++++++++++++++++++++++++++++++++++++++- + configure.ac | 1 + + 2 files changed, 44 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 7283cb55e..3b9467974 100755 +--- a/configure ++++ b/configure +@@ -718,7 +718,6 @@ GMSGFMT + MSGFMT + GETTEXT_MACRO_VERSION + USE_NLS +-MKDIR_P + SET_MAKE + HAVE_SFCGAL + SFCGAL +@@ -840,6 +839,7 @@ build_vendor + build_cpu + build + LIBTOOL ++MKDIR_P + INSTALL_DATA + INSTALL_SCRIPT + INSTALL_PROGRAM +@@ -2741,6 +2741,48 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 ++$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } ++if test -z "$MKDIR_P"; then ++ if ${ac_cv_path_mkdir+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in mkdir gmkdir; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue ++ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( ++ 'mkdir (GNU coreutils) '* | \ ++ 'mkdir (coreutils) '* | \ ++ 'mkdir (fileutils) '4.1*) ++ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext ++ break 3;; ++ esac ++ done ++ done ++ done ++IFS=$as_save_IFS ++ ++fi ++ ++ test -d ./--version && rmdir ./--version ++ if test "${ac_cv_path_mkdir+set}" = set; then ++ MKDIR_P="$ac_cv_path_mkdir -p" ++ else ++ # As a last resort, use the slow shell script. Don't cache a ++ # value for MKDIR_P within a source directory, because that will ++ # break other packages using the cache if that directory is ++ # removed, or if the value is a relative name. ++ MKDIR_P="$ac_install_sh -d" ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 ++$as_echo "$MKDIR_P" >&6; } ++ + + # _LT_PROG_AR + +diff --git a/configure.ac b/configure.ac +index 1ae526f47..1a319e4d6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -27,6 +27,7 @@ AH_TEMPLATE([HAVE_ASPRINTF]) + AC_CONFIG_MACRO_DIR([macros]) + AC_CONFIG_AUX_DIR([build-aux]) + AC_PROG_INSTALL ++AC_PROG_MKDIR_P + + dnl Overwrite _LT_PROG_AR + m4_pushdef([_LT_PROG_AR], +-- +2.45.2 + diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__macos-fix-305.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__macos-fix-305.patch new file mode 100644 index 0000000..61e1d32 --- /dev/null +++ b/edgedbpkg/pgext/postgis/patches/pgext-postgis__macos-fix-305.patch @@ -0,0 +1,62 @@ +From 06ea94850d9e74510b5f580fc26cfcd1b5f7103f Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Thu, 3 Oct 2024 17:37:17 -0700 +Subject: [PATCH 3/4] Fix building on macOS + +topology/Makefile clobbers bindir, which, in turn breaks the +`-bundle_loader` flag set by pgxs.mk. +--- + topology/Makefile.in | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/topology/Makefile.in b/topology/Makefile.in +index ef8de4bb9..a322f394b 100644 +--- a/topology/Makefile.in ++++ b/topology/Makefile.in +@@ -83,7 +83,7 @@ include $(PGXS) + # Set prefix variables _after_ the include of PGXS + prefix = @prefix@ + exec_prefix = @exec_prefix@ +-bindir = @bindir@ ++my_bindir = @bindir@ + + # Set PERL _after_ the include of PGXS + PERL=@PERL@ +@@ -99,7 +99,7 @@ $(OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postgis_ + # so that no prefix is included. This allows us to relocate to a temporary + # directory for regression testing. + ifeq ($(REGRESS),1) +- bindir=/bin ++ my_bindir=/bin + pkglibdir=/lib + datadir=/share + datamoduledir=contrib/postgis +@@ -177,20 +177,20 @@ distclean: clean + rm -f Makefile test/Makefile + + installdir: +- mkdir -p $(DESTDIR)$(bindir) ++ mkdir -p $(DESTDIR)$(my_bindir) + + install: install-importer install-exporter + + install-importer: loader/pgtopo_import | installdir +- $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(bindir)/pgtopo_import" ++ $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(my_bindir)/pgtopo_import" + + install-exporter: loader/pgtopo_export | installdir +- $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(bindir)/pgtopo_export" ++ $(LIBTOOL) --mode=install $(INSTALL) $^ "$(DESTDIR)$(my_bindir)/pgtopo_export" + + uninstall: uninstall-importer uninstall-exporter + + uninstall-importer: +- rm -f '$(DESTDIR)$(bindir)/pgtopo_import' ++ rm -f '$(DESTDIR)$(my_bindir)/pgtopo_import' + + uninstall-exporter: +- rm -f '$(DESTDIR)$(bindir)/pgtopo_export' ++ rm -f '$(DESTDIR)$(my_bindir)/pgtopo_export' +-- +2.45.2 + diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__mkdir-p-config-fix.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__mkdir-p-config-fix-304.patch similarity index 100% rename from edgedbpkg/pgext/postgis/patches/pgext-postgis__mkdir-p-config-fix.patch rename to edgedbpkg/pgext/postgis/patches/pgext-postgis__mkdir-p-config-fix-304.patch diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__protocc-pkgconfig-305.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__protocc-pkgconfig-305.patch new file mode 100644 index 0000000..53aeff1 --- /dev/null +++ b/edgedbpkg/pgext/postgis/patches/pgext-postgis__protocc-pkgconfig-305.patch @@ -0,0 +1,77 @@ +From 45ed5a5cb57ff2cb8c8365ceae11b02906066593 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Mon, 23 Sep 2024 11:37:32 -0700 +Subject: [PATCH 1/4] Look for protoc-c in directories provided by `pkg-config` + +--- + configure | 41 +++++++++++++++++++++++++++++++++++++++++ + configure.ac | 1 + + 2 files changed, 42 insertions(+) + +diff --git a/configure b/configure +index a14fa80ce..469d28b52 100755 +--- a/configure ++++ b/configure +@@ -19494,6 +19494,47 @@ $as_echo "yes" >&6; } + PROTOBUF_CPPFLAGS="$PROTOBUFC_CFLAGS"; + PROTOBUF_LDFLAGS="$PROTOBUFC_LIBS"; + PROTOC_VERSION=`$PKG_CONFIG libprotobuf-c --modversion | sed 's/\([0-9]\).*\([0-9]\).*\([0-9]\)/\100\200\3/'` ++ # Extract the first word of "protoc-c", so it can be a program name with args. ++set dummy protoc-c; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_path_PROTOCC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $PROTOCC in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_PROTOCC="$PROTOCC" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++as_dummy="`$PKG_CONFIG --variable=exec_prefix libprotobuf-c`/bin:$PATH" ++for as_dir in $as_dummy ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_path_PROTOCC="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++fi ++PROTOCC=$ac_cv_path_PROTOCC ++if test -n "$PROTOCC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROTOCC" >&5 ++$as_echo "$PROTOCC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ + + fi + fi +diff --git a/configure.ac b/configure.ac +index ed5d17255..8b60a672e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1173,6 +1173,7 @@ if test "$CHECK_PROTOBUF" != "no"; then + PROTOBUF_CPPFLAGS="$PROTOBUFC_CFLAGS"; + PROTOBUF_LDFLAGS="$PROTOBUFC_LIBS"; + PROTOC_VERSION=`$PKG_CONFIG libprotobuf-c --modversion | sed 's/\([[0-9]]\).*\([[0-9]]\).*\([[0-9]]\)/\100\200\3/'` ++ AC_PATH_PROG(PROTOCC, protoc-c, [], [`$PKG_CONFIG --variable=exec_prefix libprotobuf-c`/bin:$PATH]) + ], [ + AC_MSG_RESULT([libprotobuf-c not found in pkg-config]) + ]) +-- +2.45.2 + diff --git a/edgedbpkg/pgext/postgis/patches/pgext-postgis__remove-explicit-libstdcpp-link-305.patch b/edgedbpkg/pgext/postgis/patches/pgext-postgis__remove-explicit-libstdcpp-link-305.patch new file mode 100644 index 0000000..9dc0476 --- /dev/null +++ b/edgedbpkg/pgext/postgis/patches/pgext-postgis__remove-explicit-libstdcpp-link-305.patch @@ -0,0 +1,57 @@ +From 63b357d4cc3b6469aa32b71b48234327bab1dd87 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus +Date: Tue, 24 Sep 2024 22:01:15 -0700 +Subject: [PATCH 2/4] Avoid linking with libstdc++ explicitly + +--- + configure | 4 ++-- + configure.ac | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/configure b/configure +index 469d28b52..7283cb55e 100755 +--- a/configure ++++ b/configure +@@ -25126,7 +25126,7 @@ fi + if test "x$HAVE_CPP" = "xyes"; then + WAGYU_LDFLAGS="-lc++" + elif test "x$HAVE_STDCPP" = "xyes"; then +- WAGYU_LDFLAGS="-lstdc++" ++ WAGYU_LDFLAGS="" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Could not find a C++ standard library\"" >&5 + $as_echo "$as_me: WARNING: \"Could not find a C++ standard library\"" >&2;} +@@ -25873,7 +25873,7 @@ fi + if test "x$HAVE_CPP" = "xyes"; then + FLATGEOBUF_LDFLAGS="-lc++" + elif test "x$HAVE_STDCPP" = "xyes"; then +- FLATGEOBUF_LDFLAGS="-lstdc++" ++ FLATGEOBUF_LDFLAGS="" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Could not find a C++ standard library\"" >&5 + $as_echo "$as_me: WARNING: \"Could not find a C++ standard library\"" >&2;} +diff --git a/configure.ac b/configure.ac +index 8b60a672e..1ae526f47 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1766,7 +1766,7 @@ if test "x$HAVE_PROTOBUF" = "xyes"; then + if test "x$HAVE_CPP" = "xyes"; then + WAGYU_LDFLAGS="-lc++" + elif test "x$HAVE_STDCPP" = "xyes"; then +- WAGYU_LDFLAGS="-lstdc++" ++ WAGYU_LDFLAGS="" + else + AC_MSG_WARN("Could not find a C++ standard library") + WAGYU_LDFLAGS="" +@@ -1839,7 +1839,7 @@ AC_CHECK_LIB(stdc++, main, [HAVE_STDCPP=yes], [HAVE_STDCPP=no]) + if test "x$HAVE_CPP" = "xyes"; then + FLATGEOBUF_LDFLAGS="-lc++" + elif test "x$HAVE_STDCPP" = "xyes"; then +- FLATGEOBUF_LDFLAGS="-lstdc++" ++ FLATGEOBUF_LDFLAGS="" + else + AC_MSG_WARN("Could not find a C++ standard library") + FLATGEOBUF_LDFLAGS="" +-- +2.45.2 +