File postgresql-plsh.spec of Package postgresql-plsh

#
# spec file for package plsh
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%define pgname @BUILD_FLAVOR@
%if "%{pgname}" == ""
%define         pgname postgresql
ExclusiveArch:  do_not_build
%endif
%define         sname plsh
%define         pg_bindir %(pg_config --bindir)
%define         pg_libdir %(pg_config --pkglibdir)
%define         pg_share %(pg_config --sharedir)
# double \ as they are escaped in %%() call
%define         pg_version %(pg_config --version | sed -e 's/.*[[:space:]]//' -e 's/\\.[0-9]*$//' -e 's/\\.//')

Name:           %{pgname}-%{sname}
Version:        1.20171014
Release:        0
Summary:        PostgreSQL PL/sh - procedural language handler for PostgreSQL
License:        MIT
Group:          Productivity/Databases/Tools
Url:            https://github.com/petere/plsh/
Source0:        https://github.com/petere/plsh/archive/%{version}.tar.gz#/%{sname}-%{version}.tar.gz
# BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  gdal-devel
BuildRequires:  pkgconfig
BuildRequires:  %{pgname}-devel
BuildRequires:  %{pgname}-server

%description
PL/sh is a procedural language handler for PostgreSQL that allows you to write stored procedures in a shell of your choice. 

%prep
%setup -q -n %{sname}-%{version}

%build
make %{?_smp_mflags}

%install
mkdir -p %{buildroot}/`pg_config --bindir`
%make_install

# One word about alternatives
# the actual way postgresql is doing its magics under openSUSE is that it pick also our binaries
# in its group. so we can't make it more proper than it is.
# We are missing man, desktop, icons.
# install-alternatives is only available in TW or post 42.3
%if 0%{?suse_version} >= 1500
%postun
%{_datadir}/postgresql/install-alternatives %pg_version
%endif

%if 0%{?suse_version} >= 1500
%post
%{_datadir}/postgresql/install-alternatives %pg_version
%endif

%files
%defattr(-, root, root)
%{pg_libdir}/plsh.so
%dir %{pg_share}/extension/
%{pg_share}/extension/plsh.control
%{pg_share}/extension/plsh*.sql

%changelog
openSUSE Build Service is sponsored by