File postgis.spec of Package postgis

# spec file for package postgis
# Copyright (c) 2021 SUSE LLC
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define pgname @BUILD_FLAVOR@
%define         sname postgis
%define         pg_bindir %(pg_config --bindir)
%define         pg_libdir %(pg_config --pkglibdir)
%define         pg_share %(pg_config --sharedir)
%if 0%{?is_opensuse} && 0%{?suse_version} >= 1500 && ("%{pgname}" == "postgresql11" || "%{pgname}" == "postgresql12" || "%{pgname}" == "postgresql13")
%bcond_without  llvm
%bcond_with     llvm
# double \ as they are escaped in %%() call
%define         pg_version %(pg_config --version | sed -e 's/.*[[:space:]]//' -e 's/\\.[0-9]*$//' -e 's/\\.//')
%define         main_version 3.1
%if "%{pgname}" == ""
Name:           %{sname}
ExclusiveArch:  do_not_build
Name:           %{pgname}-%{sname}
# Build for Leap 15.2 but not for missing postgresql13
%if (0%{?is_opensuse} && 0%{?sle_version} == 150200) && ("%{pgname}" == "postgresql13")
ExclusiveArch:  do_not_build
Version:        3.1.4
Release:        0
Summary:        Geographic Information Systems Extensions to PostgreSQL
License:        GPL-2.0-or-later
Group:          Productivity/Databases/Servers
Patch0:         patch-tests-results.patch
BuildRequires:  %{pgname}-devel >= 10
%if "%{pgname}" == "postgresql11" || "%{pgname}" == "postgresql12" || "%{pgname}" == "postgresql13"
BuildRequires:  %{pgname}-server-devel >= 11
BuildRequires:  %{pgname}-server >= 10
%if %{with llvm}
BuildRequires:  clang-devel
BuildRequires:  llvm-devel
BuildRequires:  %{pgname}-llvmjit
BuildRequires:  cgal-devel
BuildRequires:  cunit-devel
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gcc-c++
%if 0%{?sle_version} >= 150000 && 0%{?sle_version} <= 150100 && 0%{?is_opensuse}
BuildRequires:  gdal-devel
BuildRequires:  gdal-devel >= 3.0
BuildRequires:  gtk2-devel
BuildRequires:  libprotobuf-c-devel
BuildRequires:  libgeos-devel >= 3.7.0
BuildRequires:  libjson-c-devel
BuildRequires:  libproj-devel >= 6.0.0
# proj.db is required for ST_ functions and tests boo#1188129
BuildRequires:  proj
BuildRequires:  libxml2-devel
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  libxml2-tools
# building doc but would add 350 texlive packages
# BuildRequires:  dblatex
# BuildRequires:  ImageMagick
BuildRequires:  protobuf-c >= 1.1.0
BuildRequires:  sfcgal-devel > 1.3.1
BuildRequires:  update-alternatives
%requires_eq    %{pgname}-server
# proj.db is required for ST_ functions and tests boo#1188129
Requires:       proj
Requires(post): update-alternatives
Requires(postun): update-alternatives
Conflicts:      postgis2
Provides:       postgis

PostGIS is a spatial database extender for PostgreSQL object-relational
database. It adds support for geographic objects allowing location queries
to be run in SQL.

%package utils
Summary:        The utils for PostGIS
Group:          Productivity/Databases/Tools
Requires:       %{name} = %{version}
Requires:       perl-DBD-Pg
Provides:       postgis-utils

%description utils
The postgis-utils package provides utilities for PostGIS.

%if %{with llvm}
%package llvmjit
Summary:        Just-in-time compilation support for PostgreSQL %{sname} extension
Group:          Productivity/Databases/Servers
Requires:       %{pgname}-%{sname} = %{version}-%{release}
Requires:       %{pgname}-llvmjit
Supplements:    packageand(%{pgname}-llvmjit:%{name})

%description llvmjit
This package contains support for just-in-time compiling parts of
PostgreSQL queries. Using LLVM it compiles e.g. expressions and tuple
deforming into native code, with the goal of accelerating analytics

%setup -q -n %{sname}-%{version}
echo "pg_version is %{pg_version}"
%patch0 -p1

%configure \
    --with-protobuf \
    --with-raster \
    --with-topology \
    --with-gui \
    --with-json \
    --with-sfcgal=%{_bindir}/sfcgal-config \
    --disable-rpath \
    --with-wagyu \
    --disable-gtktest \
    --with-interrupt-tests \

%make_build soname="%{sname}-%{main_version}.so"

install -d -m 755 %{buildroot}%{pg_bindir}

# install manpages format them as our pg packages
install -d -m 755 %{buildroot}%{_mandir}/man1
install -m 644 doc/man/pgsql2shp.1 %{buildroot}%{_mandir}/man1/pgsql2shp.1pg%{pg_version}
install -m 644 doc/man/shp2pgsql.1 %{buildroot}%{_mandir}/man1/shp2pgsql.1pg%{pg_version}
# fix shebang and install utils
sed -i 's,^#!/usr/bin/env perl,#!/usr/bin/perl,g' utils/*.pl regress/*.pl
install -m 755 utils/*.pl %{buildroot}%{pg_bindir}
# Wrong location (this is new on 2.2.x) automatically installed we already place it to pgbindir
rm %{buildroot}%{pg_share}/contrib/%{sname}-%{main_version}/
# remove .a and .la files
rm -f %{buildroot}/%{_libdir}/*.la
rm -f %{buildroot}/%{_libdir}/*.a

# Temporary fix we re-add the readme with doc macro
rm -fr %{buildroot}%{_docdir}/%{pgname}

%fdupes %{buildroot}/%{pg_share}

# To avoid shm trouble we just skip tests for 9.6
%if "%{pgname}" != "postgresql96"
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export PGDATA=/home/abuild/postgis_tests/data
export PGHOST=/tmp
export PGPORT=5454
mkdir -p "${PGDATA}"
initdb --pgdata=${PGDATA} --auth=peer --auth-host=scram-sha-256 --auth-local=peer --encoding=UTF-8 --locale=en_US.UTF-8 --lc-message=en_US.UTF-8
pg_ctl -D "${PGDATA}" -l logfile -o "-p ${PGPORT} -k ${PGHOST} -B 1024" start
psql -d postgres -c "\dx"
# Don't fail test yet, we have a different result for mvt between Leap and TW
make check || :
pg_ctl -D "${PGDATA}" --mode="fast" stop

%{_datadir}/postgresql/install-alternatives %pg_version

%{_datadir}/postgresql/install-alternatives %pg_version

%postun utils
%{_datadir}/postgresql/install-alternatives %pg_version

%post utils
%{_datadir}/postgresql/install-alternatives %pg_version

%license COPYING
%doc ChangeLog README.postgis MIGRATION NEWS extensions/address_standardizer/README.address_standardizer
%exclude %{pg_libdir}/bitcode/*
%dir %{pg_share}/applications
%dir %{pg_share}/icons
%dir %{pg_share}/contrib

%if %{with llvm}
%files llvmjit

%files utils

openSUSE Build Service is sponsored by