From d56a879057da6c77d15ccd04b6c2dc6a5dee9210 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 10 Oct 2017 09:12:42 +0200 Subject: [PATCH] upgrade: build compat so-version twice Usually (when only postgis is updated, and not postgresql itself) it is enough to maintain only the latest version of postgis-%majorversion.so file. The upgrade scenario is then hit (a) 'dnf upgrade -y', which brings 'postgis-X.Y+1.so', and (b) run (manually) 'ALTER EXTENSION potgis' for all the databases. For this scenario the compatibility library is not needed at all. The situation is complicated in situations where also PostgreSQL has major version upgrade (when upgrading from Fedora N to Fedora N+1, usually). Then, you need to *also* have (a) 'postgis-%prevversion.so' built against old server (against postgresql-upgrade-devel), and (b) 'postgis-%prevversion.so' built against the actual postgresql version (postgresql-devel). The first library is needed to allow the old-stack dump properly, and the second is needed to satisfy pg_upgrade's pre-upgrade checks (pg_upgrade is checking that the same library exists for both stacks, in the same version). Note that it seems like *it could be* enough to have just symlink from %majorversion to %prevmajorversion posgis.so to "silence" the pg_upgrade's checker, but I'm not brave enough to go this way at this point. There's one more (maybe theoretical) possibility that the PostgreSQL version is updated, but PostGIS version is not. In this case, the prevmajorversion should be eqal to majorversion (for the build against older stack), and the compat build shouldn't be needed. If this ever happens, we can twak the buildsystem/macros more. Version: 2.4.0-1 --- postgis-1.5.1-pgsql9.patch | 15 - postgis-2.4.0-upgrade-2.3.3.patch | 2475 +++++++++++++++++++++++++++++ postgis.spec | 70 +- 3 files changed, 2527 insertions(+), 33 deletions(-) delete mode 100644 postgis-1.5.1-pgsql9.patch create mode 100644 postgis-2.4.0-upgrade-2.3.3.patch diff --git a/postgis-1.5.1-pgsql9.patch b/postgis-1.5.1-pgsql9.patch deleted file mode 100644 index 5882e57..0000000 --- a/postgis-1.5.1-pgsql9.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff -up postgis-1.5.1/postgis/Makefile.pgxs.pgsql9 postgis-1.5.1/postgis/Makefile.pgxs ---- postgis-1.5.1/postgis/Makefile.pgxs.pgsql9 2010-01-12 11:33:49.000000000 +0100 -+++ postgis-1.5.1/postgis/Makefile.pgxs 2011-04-03 13:45:33.972315988 +0200 -@@ -12,6 +12,11 @@ datamoduledir = contrib - docmoduledir = contrib - endif - -+# cope with PostgreSQL 9.0 build environment -+ifndef mkinstalldirs -+mkinstalldirs = $(MKDIR_P) -+endif -+ - install: all installdirs - ifneq (,$(DATA)$(DATA_built)) - @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ diff --git a/postgis-2.4.0-upgrade-2.3.3.patch b/postgis-2.4.0-upgrade-2.3.3.patch new file mode 100644 index 0000000..e890906 --- /dev/null +++ b/postgis-2.4.0-upgrade-2.3.3.patch @@ -0,0 +1,2475 @@ +From 19b8b9cd659363fcf32a5967546d5d7aa57fc57f Mon Sep 17 00:00:00 2001 +From: Paul Ramsey +Date: Tue, 5 Sep 2017 20:37:59 +0000 +Subject: [PATCH 1/2] Support PgSQL 10 on PostGIS 2.3 + +git-svn-id: http://svn.osgeo.org/postgis/branches/2.3@15630 b70326c6-7e19-0410-871a-916f4a2858ee +--- + configure.ac | 9 + + libpgcommon/gserialized_gist.c | 4 + + postgis/gserialized_estimate.c | 65 +- + postgis/gserialized_gist_nd.c | 3 + + raster/rt_pg/rtpostgis.sql.in | 2 +- + raster/test/regress/rt_union.sql | 8 +- + raster/test/regress/rt_union_expected | 3 - + regress/regress_selectivity.sql | 2147 ++++++++++++++++++++++++++- + topology/sql/topogeometry/totopogeom.sql.in | 31 +- + topology/test/regress/copytopology.sql | 14 +- + topology/test/regress/copytopology_expected | 14 +- + 11 files changed, 2239 insertions(+), 61 deletions(-) + +diff --git a/configure.ac b/configure.ac +index df6dd88ad..ebf8eb402 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -433,6 +433,15 @@ if test "x$LIBLWGEOM_ONLY" = "xno"; then + PGSQL_MAJOR_VERSION=`echo $PGSQL_FULL_VERSION | sed 's/[[^0-9]]*\([[0-9]]*\).*/\1/'` + PGSQL_MINOR_VERSION=`echo $PGSQL_FULL_VERSION | sed 's/[[^\.]]*\.\([[0-9]]*\).*/\1/'` + PGSQL_MINOR_VERSION=`echo $PGSQL_MINOR_VERSION | sed 's/.*devel.*/0/'` ++ ++ if test $PGSQL_MAJOR_VERSION -gt 9; then ++ dnl ================================================================== ++ dnl Starting with PostgreSQL 10, major is the new minor ++ dnl This is to prevent things like 10.31 ranking higher than 11.0 ++ dnl=================================================================== ++ PGSQL_MINOR_VERSION=0 ++ fi ++ + POSTGIS_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION" + + PGSQL_PKGLIBDIR=`$PG_CONFIG --pkglibdir` +diff --git a/libpgcommon/gserialized_gist.c b/libpgcommon/gserialized_gist.c +index d379fb26a..ec2585d6a 100644 +--- a/libpgcommon/gserialized_gist.c ++++ b/libpgcommon/gserialized_gist.c +@@ -22,6 +22,10 @@ + #include "lwgeom_pg.h" /* For debugging macros. */ + #include "gserialized_gist.h" + ++#if POSTGIS_PGSQL_VERSION >= 100 ++#include ++#endif ++ + #define FLAGS_NDIMS_GIDX(f) ( FLAGS_GET_GEODETIC(f) ? 3 : \ + FLAGS_GET_M(f) ? 4 : \ + FLAGS_GET_Z(f) ? 3 : 2 ) +diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c +index 5f967059b..ea343495b 100644 +--- a/postgis/gserialized_estimate.c ++++ b/postgis/gserialized_estimate.c +@@ -827,31 +827,52 @@ nd_increment(ND_IBOX *ibox, int ndims, int *counter) + static ND_STATS* + pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode) + { +- int stats_kind = STATISTIC_KIND_ND; +- int rv, nvalues; ++ int stats_kind = STATISTIC_KIND_ND; ++ int rv; ++ ND_STATS *nd_stats; ++ ++ /* If we're in 2D mode, set the kind appropriately */ ++ if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D; ++ ++ /* Then read the geom status histogram from that */ ++ ++#if POSTGIS_PGSQL_VERSION < 100 + float4 *floatptr; +- ND_STATS *nd_stats; +- +- /* If we're in 2D mode, set the kind appropriately */ +- if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D; +- +- /* Then read the geom status histogram from that */ +- rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid, +- NULL, NULL, NULL, &floatptr, &nvalues); +- if ( ! rv ) { +- POSTGIS_DEBUGF(2, +- "no slot of kind %d in stats tuple", stats_kind); +- return NULL; +- } ++ int nvalues; + +- /* Clone the stats here so we can release the attstatsslot immediately */ +- nd_stats = palloc(sizeof(float) * nvalues); +- memcpy(nd_stats, floatptr, sizeof(float) * nvalues); +- +- /* Clean up */ +- free_attstatsslot(0, NULL, 0, floatptr, nvalues); ++ rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid, ++ NULL, NULL, NULL, &floatptr, &nvalues); ++ ++ if ( ! rv ) { ++ POSTGIS_DEBUGF(2, ++ "no slot of kind %d in stats tuple", stats_kind); ++ return NULL; ++ } ++ ++ /* Clone the stats here so we can release the attstatsslot immediately */ ++ nd_stats = palloc(sizeof(float) * nvalues); ++ memcpy(nd_stats, floatptr, sizeof(float) * nvalues); ++ ++ /* Clean up */ ++ free_attstatsslot(0, NULL, 0, floatptr, nvalues); ++#else /* PostgreSQL 10 or higher */ ++ AttStatsSlot sslot; ++ rv = get_attstatsslot(&sslot, stats_tuple, stats_kind, InvalidOid, ++ ATTSTATSSLOT_NUMBERS); ++ if ( ! rv ) { ++ POSTGIS_DEBUGF(2, ++ "no slot of kind %d in stats tuple", stats_kind); ++ return NULL; ++ } ++ ++ /* Clone the stats here so we can release the attstatsslot immediately */ ++ nd_stats = palloc(sizeof(float4) * sslot.nnumbers); ++ memcpy(nd_stats, sslot.numbers, sizeof(float4) * sslot.nnumbers); ++ ++ free_attstatsslot(&sslot); ++#endif + +- return nd_stats; ++ return nd_stats; + } + + /** +diff --git a/postgis/gserialized_gist_nd.c b/postgis/gserialized_gist_nd.c +index 4fc5fa476..e8c16c5ad 100644 +--- a/postgis/gserialized_gist_nd.c ++++ b/postgis/gserialized_gist_nd.c +@@ -52,6 +52,9 @@ + + #include + ++#if POSTGIS_PGSQL_VERSION >= 100 ++#include ++#endif + + /* Fall back to older finite() if necessary */ + #ifndef HAVE_ISFINITE +diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in +index 295892d22..9175705d2 100644 +--- a/raster/rt_pg/rtpostgis.sql.in ++++ b/raster/rt_pg/rtpostgis.sql.in +@@ -7037,7 +7037,7 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_blocksize(rastschema name, ra + SELECT + CASE + WHEN strpos(s.consrc, 'ANY (ARRAY[') > 0 THEN +- split_part((regexp_matches(s.consrc, E'ARRAY\\[(.*?){1}\\]'))[1], ',', 1)::integer ++ split_part((substring(s.consrc FROM E'ARRAY\\[(.*?){1}\\]')), ',', 1)::integer + ELSE + regexp_replace( + split_part(s.consrc, '= ', 2), +diff --git a/raster/test/regress/rt_union.sql b/raster/test/regress/rt_union.sql +index 8b47e877f..a64b23a1c 100644 +--- a/raster/test/regress/rt_union.sql ++++ b/raster/test/regress/rt_union.sql +@@ -143,13 +143,13 @@ INSERT INTO raster_union_out + + SELECT + uniontype, +- x, +- y, +- val ++ (pp).x, ++ (pp).y, ++ (pp).val + FROM ( + SELECT + uniontype, +- (ST_PixelAsPoints(rast)).* ++ (ST_PixelAsPoints(rast)) AS pp + FROM raster_union_out + ) foo + ORDER BY uniontype, y, x; +diff --git a/raster/test/regress/rt_union_expected b/raster/test/regress/rt_union_expected +index ac32ef69d..51cc3e3d2 100644 +--- a/raster/test/regress/rt_union_expected ++++ b/raster/test/regress/rt_union_expected +@@ -53,9 +53,6 @@ SUM|3|2|2 + SUM|2|3|2 + SUM|3|3|2 + NOTICE: No pixels found for band 1 +-NOTICE: No pixels found for band 1 +-NOTICE: No pixels found for band 1 +-NOTICE: No pixels found for band 1 + COUNT|1|1|1 + COUNT|2|1|1 + COUNT|3|1|1 +diff --git a/regress/regress_selectivity.sql b/regress/regress_selectivity.sql +index 82c5e70d8..ca7f2722d 100644 +--- a/regress/regress_selectivity.sql ++++ b/regress/regress_selectivity.sql +@@ -1,3 +1,2140 @@ ++-- Make example data ++ ++CREATE TABLE regular_overdots_ab ( ++ a integer, ++ b integer ++); ++ ++COPY regular_overdots_ab (a, b) FROM stdin; ++1 1 ++1 1 ++1 2 ++1 1 ++1 2 ++1 3 ++1 1 ++1 2 ++1 3 ++1 4 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 6 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 6 ++1 7 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 6 ++1 7 ++1 8 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 6 ++1 7 ++1 8 ++1 9 ++1 1 ++1 2 ++1 3 ++1 4 ++1 5 ++1 6 ++1 7 ++1 8 ++1 9 ++1 10 ++1 1 ++2 1 ++1 1 ++2 2 ++1 1 ++2 2 ++1 3 ++2 1 ++1 2 ++2 3 ++1 1 ++2 2 ++1 3 ++2 4 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 1 ++1 2 ++2 3 ++1 4 ++2 5 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 6 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 6 ++1 7 ++2 1 ++1 2 ++2 3 ++1 4 ++2 5 ++1 6 ++2 7 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 6 ++1 7 ++2 8 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 6 ++1 7 ++2 8 ++1 9 ++2 1 ++1 2 ++2 3 ++1 4 ++2 5 ++1 6 ++2 7 ++1 8 ++2 9 ++1 1 ++2 2 ++1 3 ++2 4 ++1 5 ++2 6 ++1 7 ++2 8 ++1 9 ++2 10 ++1 1 ++2 1 ++3 1 ++1 1 ++2 2 ++3 1 ++1 2 ++2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 ++4 2 ++5 3 ++6 4 ++7 5 ++8 6 ++9 7 ++10 8 ++1 1 ++2 2 ++3 3 ++4 4 ++5 5 ++6 6 ++7 7 ++8 8 ++9 9 ++10 1 ++1 2 ++2 3 ++3 4 ++4 5 ++5 6 ++6 7 ++7 8 ++8 9 ++9 1 ++10 2 ++1 3 ++2 4 ++3 5 ++4 6 ++5 7 ++6 8 ++7 9 ++8 1 ++9 2 ++10 3 ++1 4 ++2 5 ++3 6 ++4 7 ++5 8 ++6 9 ++7 1 ++8 2 ++9 3 ++10 4 ++1 5 ++2 6 ++3 7 ++4 8 ++5 9 ++6 1 ++7 2 ++8 3 ++9 4 ++10 5 ++1 6 ++2 7 ++3 8 ++4 9 ++5 1 ++6 2 ++7 3 ++8 4 ++9 5 ++10 6 ++1 7 ++2 8 ++3 9 ++4 1 ++5 2 ++6 3 ++7 4 ++8 5 ++9 6 ++10 7 ++1 8 ++2 9 ++3 1 ++4 2 ++5 3 ++6 4 ++7 5 ++8 6 ++9 7 ++10 8 ++1 9 ++2 1 ++3 2 ++4 3 ++5 4 ++6 5 ++7 6 ++8 7 ++9 8 ++10 9 ++1 1 ++2 2 ++3 3 ++4 4 ++5 5 ++6 6 ++7 7 ++8 8 ++9 9 ++10 10 ++\. ++ + + -- Check for error messages + create table no_stats ( g geometry, id integer ); +@@ -8,15 +2145,12 @@ select _postgis_join_selectivity('no_stats', 'g', 'no_stats_join', 'g'); + insert into no_stats (g, id) values ('POINT(0 0)', 0); + analyze no_stats; + select _postgis_join_selectivity('no_stats', 'g', 'no_stats_join', 'g'); +-drop table no_stats; +-drop table no_stats_join; ++drop table if exists no_stats; ++drop table if exists no_stats_join; + + -- Table with uniformly variable density, highest at 1,1, lowest at 10,10 + create table regular_overdots as +-with +-ij as ( select i, j from generate_series(1, 10) i, generate_series(1, 10) j), +-iijj as (select generate_series(1, i) as a, generate_series(1, j) b from ij) +-select st_makepoint(a, b) as g from iijj; ++ select st_makepoint(a, b) as g from regular_overdots_ab; + + -- Generate the stats + analyze regular_overdots; +@@ -49,4 +2183,5 @@ select 'selectivity_09', 'estimated', _postgis_selectivity('regular_overdots','g + + -- Clean + drop table if exists regular_overdots; ++drop table if exists regular_overdots_ab; + +diff --git a/topology/sql/topogeometry/totopogeom.sql.in b/topology/sql/topogeometry/totopogeom.sql.in +index 79520c64e..6d3192de0 100644 +--- a/topology/sql/topogeometry/totopogeom.sql.in ++++ b/topology/sql/topogeometry/totopogeom.sql.in +@@ -139,6 +139,7 @@ DECLARE + tolerance FLOAT8; + alayer INT; + atopology TEXT; ++ var_dims integer; + BEGIN + + #ifdef POSTGIS_TOPOLOGY_DEBUG +@@ -230,23 +231,31 @@ BEGIN + 'Unexpected feature dimension %', ST_Dimension(ageom); + END IF; + ++ + -- Now that we have an empty topogeometry, we loop over distinct components + -- and add them to the definition of it. We add them as soon + -- as possible so that each element can further edit the + -- definition by splitting + FOR rec IN SELECT id(tg), alayer as lyr, +- geom, ST_Dimension(geom) as dims +- FROM (SELECT (ST_Dump(ageom)).geom) as f +- WHERE NOT ST_IsEmpty(geom) ++ geom, ST_Dimension(gd.geom) as dims ++ FROM ST_Dump(ageom) AS gd ++ WHERE NOT ST_IsEmpty(gd.geom) + LOOP +- FOR rec2 IN SELECT CASE +- WHEN rec.dims = 0 THEN +- topology.topogeo_addPoint(atopology, rec.geom, tolerance) +- WHEN rec.dims = 1 THEN +- topology.topogeo_addLineString(atopology, rec.geom, tolerance) +- WHEN rec.dims = 2 THEN +- topology.topogeo_addPolygon(atopology, rec.geom, tolerance) +- END as primitive ++ -- NOTE: Switched from using case to this because of PG 10 behavior change ++ -- Using a UNION ALL only one will be processed because of the WHERE ++ -- Since the WHERE clause will be processed first ++ FOR rec2 IN SELECT primitive ++ FROM ++ ( ++ SELECT topology.topogeo_addPoint(atopology, rec.geom, tolerance) ++ WHERE rec.dims = 0 ++ UNION ALL ++ SELECT topology.topogeo_addLineString(atopology, rec.geom, tolerance) ++ WHERE rec.dims = 1 ++ UNION ALL ++ SELECT topology.topogeo_addPolygon(atopology, rec.geom, tolerance) ++ WHERE rec.dims = 2 ++ ) AS f(primitive) + LOOP + elem := ARRAY[rec.dims+1, rec2.primitive]::text; + IF elems @> ARRAY[elem] THEN +diff --git a/topology/test/regress/copytopology.sql b/topology/test/regress/copytopology.sql +index 414e01993..182ff493c 100644 +--- a/topology/test/regress/copytopology.sql ++++ b/topology/test/regress/copytopology.sql +@@ -39,13 +39,13 @@ WHERE l.topology_id = t.id and t.name = 'CITY_data_UP_down' + ORDER BY l.layer_id; + + -- Check sequences +-SELECT * from "CITY_data_UP_down".node_node_id_seq; +-SELECT * from "CITY_data_UP_down".edge_data_edge_id_seq; +-SELECT * from "CITY_data_UP_down".face_face_id_seq; +-SELECT sequence_name, last_value, start_value, increment_by, max_value, min_value, cache_value, is_cycled, is_called from "CITY_data_UP_down".layer_id_seq; +-SELECT * from "CITY_data_UP_down".topogeo_s_1; +-SELECT * from "CITY_data_UP_down".topogeo_s_2; +-SELECT * from "CITY_data_UP_down".topogeo_s_3; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".node_node_id_seq; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".edge_data_edge_id_seq; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".face_face_id_seq; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".layer_id_seq; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".topogeo_s_1; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".topogeo_s_2; ++SELECT tableoid::regclass AS sequence_name, last_value, is_called from "CITY_data_UP_down".topogeo_s_3; + + SELECT topology.DropTopology('CITY_data_UP_down'); + SELECT topology.DropTopology('city_data'); +diff --git a/topology/test/regress/copytopology_expected b/topology/test/regress/copytopology_expected +index 95083dbbf..ffdb1316b 100644 +--- a/topology/test/regress/copytopology_expected ++++ b/topology/test/regress/copytopology_expected +@@ -19,13 +19,13 @@ layers|3 + 1|CITY_data_UP_down|LAYER1| + 2|CITY_data_UP_down|LAYER2| + 3|CITY_data_UP_down|LAYER3| +-node_node_id_seq|22|1|1|9223372036854775807|1|1|0|f|t +-edge_data_edge_id_seq|26|1|1|9223372036854775807|1|1|0|f|t +-face_face_id_seq|9|1|1|9223372036854775807|1|1|0|f|t +-layer_id_seq|1|1|1|9223372036854775807|1|1|f|f +-topogeo_s_1|9|1|1|9223372036854775807|1|1|0|f|t +-topogeo_s_2|8|1|1|9223372036854775807|1|1|0|f|t +-topogeo_s_3|8|1|1|9223372036854775807|1|1|0|f|t ++"CITY_data_UP_down".node_node_id_seq|22|t ++"CITY_data_UP_down".edge_data_edge_id_seq|26|t ++"CITY_data_UP_down".face_face_id_seq|9|t ++"CITY_data_UP_down".layer_id_seq|1|f ++"CITY_data_UP_down".topogeo_s_1|9|t ++"CITY_data_UP_down".topogeo_s_2|8|t ++"CITY_data_UP_down".topogeo_s_3|8|t + Topology 'CITY_data_UP_down' dropped + Topology 'city_data' dropped + #2184.1|t +-- +2.13.6 + diff --git a/postgis.spec b/postgis.spec index fd7cbe2..a42041b 100644 --- a/postgis.spec +++ b/postgis.spec @@ -6,6 +6,7 @@ %global majorversion 2.4 %global prevmajorversion 2.3 %global prevversion %{prevmajorversion}.3 +%global so_files rtpostgis postgis_topology postgis address_standardizer %global pg_version_minimum 9.2 @@ -17,10 +18,12 @@ License: GPLv2+ Group: Applications/Databases Source0: http://download.osgeo.org/%{name}/source/%{name}-%{version}.tar.gz Source2: http://download.osgeo.org/%{name}/docs/%{name}-%{version}.pdf +%if %upgrade Source3: http://download.osgeo.org/%{name}/source/%{name}-%{prevversion}.tar.gz +%endif Source4: filter-requires-perl-Pg.sh -# CFLAGS are reset before AC_CHECK_LIBRARY, but -fPIC is necessary to link against gdal Patch1: postgis-configureac21.patch +Patch2: postgis-2.4.0-upgrade-2.3.3.patch URL: http://www.postgis.net BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -29,6 +32,9 @@ BuildRequires: postgresql-devel >= %{pg_version_minimum}, proj-devel, geos-devel BuildRequires: gtk2-devel, libxml2-devel, gdal-devel >= 1.10.0 BuildRequires: pcre-devel BuildRequires: autoconf, automake, libtool +%if %upgrade +BuildRequires: postgresql-upgrade-devel +%endif Requires: postgresql-server(:MODULE_COMPAT_%{postgresql_major}) Requires: geos >= 3.4.2, proj, gdal >= 1.10.0, json-c @@ -89,7 +95,6 @@ The postgis-utils package provides the utilities for PostGIS. Summary: Support for upgrading from the previous major release of Postgis Group: Applications/Databases Requires: %{name}%{?_isa} = %{version}-%{release} -BuildRequires: postgresql-upgrade-devel %description upgrade The postgis-upgrade package contains the previous version of postgis @@ -99,16 +104,20 @@ necessary for correct dump of schema from previous version of PostgreSQL. %define __perl_requires %{SOURCE4} %prep -%setup -q -n %{name}-%{version} +%setup -q -n %{name}-%{version} -a 3 +( +cd %{name}-%{prevversion} +# Remove once we move to prevversion==2.4 (2.4 build works fine). %patch1 -p0 -b .configureac21 -# Copy .pdf file to top directory before installing. +./autogen.sh +%patch2 -p1 +) cp -p %{SOURCE2} . + %build -./autogen.sh %configure --with-gui --enable-raster -# FIXME {_smp_mflags} macro doesn't work -make LPATH=`pg_config --pkglibdir` shlib="%{name}.so" +make %{?_smp_mflags} %if %javabuild export BUILDXML_DIR=%{_builddir}/%{name}-%{version}/java/jdbc @@ -121,16 +130,26 @@ popd %endif %if %utils - make %{?_smp_mflags} -C utils +make %{?_smp_mflags} -C utils %endif -# PostGIS 2.1 breaks compatibility with 2.0, and we need to ship -# postgis-2.0.so file along with 2.1 package, so that we can upgrade: -tar zxf %{SOURCE3} +( +# TODO: report that out-of-tree (VPATH) build is broken cd %{name}-%{prevversion} -%configure --without-raster --disable-rpath --without-json -make %{?_smp_mflags} LPATH=`%[_bindir}/pg_config --pkglibdir` shlib="%{name}-%{prevmajorversion}.so" +# first perform compat-build (against the actual PostgreSQL version). We need +# only the so names. +%configure --enable-raster +make %{?_smp_mflags} +mkdir ../compat-build +for so in %so_files; do + find -name $so-%prevmajorversion.so -exec cp -t ../compat-build/ {} + +done + +# second, build feature-full build against previous PostgreSQL version +%configure --enable-raster --with-pgconfig=/usr/lib64/pgsql/postgresql-9.6/bin/pg_config +make %{?_smp_mflags} +) %install rm -rf %{buildroot} @@ -140,10 +159,14 @@ make %{?_smp_mflags} -C extensions install DESTDIR=%{buildroot} rm -f %{buildroot}%{_libdir}/liblwgeom.{a,la} -# (moved into install section: -# Install postgis-2.0.so file manually: -%{__mkdir} -p %{buildroot}/%{_libdir}/pgsql -%{__install} -m 644 %{name}-%{prevversion}/postgis/postgis-%{prevmajorversion}.so %{buildroot}/%{_libdir}/pgsql/postgis-%{prevmajorversion}.so +cd %{name}-%{prevversion} +make install DESTDIR=%{buildroot} +cd .. + +# Manually install compat-build binary. +for so in %so_files; do +%{__install} -m 644 compat-build/$so-%{prevmajorversion}.so %{buildroot}/%{_libdir}/pgsql +done rm -f %{buildroot}%{_datadir}/*.sql @@ -175,7 +198,6 @@ rm -rf %{buildroot} %defattr(-,root,root) %doc COPYING CREDITS NEWS TODO README.%{name} doc/html loader/README.* doc/%{name}.xml doc/ZMSgeoms.txt %attr(755,root,root) %{_bindir}/* -%attr(755,root,root) %{_libdir}/pgsql/%{name}-%{prevmajorversion}.so %attr(755,root,root) %{_libdir}/pgsql/%{name}-%{majorversion}.so %{_datadir}/pgsql/contrib/postgis-%{majorversion}/*.sql #if {_lib} == lib64 @@ -206,6 +228,7 @@ rm -rf %{buildroot} %{_includedir}/liblwgeom.h %{_includedir}/liblwgeom_topo.h + %if %javabuild %files jdbc %defattr(-,root,root) @@ -218,6 +241,14 @@ rm -rf %{buildroot} %endif %endif + +%if %upgrade +%files upgrade +%_libdir/pgsql/postgresql-9.6/* +%_libdir/pgsql/*-%{prevmajorversion}.so +%endif + + %if %utils %files utils %defattr(755,root,root) @@ -241,6 +272,9 @@ rm -rf %{buildroot} %doc postgis*.pdf %changelog +* Tue Oct 10 2017 Pavel Raiskup - 2.4.0-1 +- provide postgis-upgrade package (rhbz#1475177) + * Mon Oct 09 2017 Pavel Raiskup - 2.4.0-1 - update to 2.4.0, per upstream release notes https://postgis.net/2017/09/30/postgis-2.4.0/