File libkiwix.spec of Package libkiwix

#
# spec file for package libkiwix
#
# Copyright (c) 2021 Samu Voutilainen <kiwix@smar.fi>
#
# 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.

%define sover 14

Name:           libkiwix
Version:        14.2.0
Release:        0
Summary:        Common library for all Kiwix projects
License:        GPL-3.0
Group:          Productivity/Other
Url:            https://github.com/kiwix/libkiwix
Source0:        %{name}-%{version}.tar.xz
Source1:        mustache.hpp
BuildRequires:  c++_compiler
BuildRequires:  libcurl-devel
BuildRequires:  libicu-devel
BuildRequires:  libmicrohttpd-devel
BuildRequires:  libzim-devel
BuildRequires:  meson
BuildRequires:  ninja
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(icu-i18n)
BuildRequires:  pugixml-devel
BuildRequires:  zlib-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The Kiwix library provides the Kiwix software suite core. It contains the code
shared by all Kiwix ports (Windows, GNU/Linux, macOS, Android, iOS, ...).

%package -n kiwix-compile-i18n
Summary:        Helper script to compile and generate some Kiwix resources
Group:          Development/Tools/Doc Generators

%description -n kiwix-compile-i18n
The Kiwix library provides the Kiwix software suite core. It contains the code
shared by all Kiwix ports (Windows, GNU/Linux, macOS, Android, iOS, ...).

This package contains Python script that can be used to compile and generate
some Kiwix resources.

%package -n kiwix-compile-resources
Summary:        Helper script to compile and generate some Kiwix resources
Group:          Development/Tools/Doc Generators

%description -n kiwix-compile-resources
The Kiwix library provides the Kiwix software suite core. It contains the code
shared by all Kiwix ports (Windows, GNU/Linux, macOS, Android, iOS, ...).

This package contains Python script that can be used to compile and generate
some Kiwix resources.

%package -n libkiwix%{sover}
Summary:        Shared library for Kiwix
Group:          System/Libraries

%description -n libkiwix%{sover}
The Kiwix library provides the Kiwix software suite core. It contains the code
shared by all Kiwix ports (Windows, GNU/Linux, macOS, Android, iOS, ...).

This package contains shared library.

%package devel
Summary:        Development libraries and header files for %{name}
Group:          Development/Languages/C and C++
Requires:       libkiwix%{sover}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}

%description devel
The Kiwix library provides the Kiwix software suite core. It contains the code
shared by all Kiwix ports (Windows, GNU/Linux, macOS, Android, iOS, ...).

This package contains development files.

%prep
%setup -q

cd %{_builddir}
mkdir mustache
cp %{S:1} mustache/

%build
# Using bundled mustache since there is no package and upstream is suggesting just to copy.
export CPPFLAGS="$CPPFLAGS -I%{_builddir}/mustache"
%meson
%meson_build

%install
%meson_install

sed -i 's|/usr/bin/env python3|/usr/bin/python3|' %{buildroot}%{_bindir}/kiwix-compile-i18n
sed -i 's|/usr/bin/env python3|/usr/bin/python3|' %{buildroot}%{_bindir}/kiwix-compile-resources

%check
%meson_test

%post -n libkiwix%{sover} -p /sbin/ldconfig
%postun -n libkiwix%{sover} -p /sbin/ldconfig

%files -n kiwix-compile-resources
%defattr(-,root,root,-)

%{_bindir}/kiwix-compile-resources

%{_mandir}/man1/kiwix-compile-resources.1%{ext_man}

%files -n kiwix-compile-i18n
%defattr(-,root,root,-)

%{_bindir}/kiwix-compile-i18n

%{_mandir}/man1/kiwix-compile-i18n.1%{ext_man}

%files -n libkiwix%{sover}
%defattr(-,root,root,-)

%{_libdir}/libkiwix.so.*

%files devel
%defattr(-,root,root,0755)

%{_includedir}/kiwix

%{_libdir}/libkiwix.so
%{_libdir}/pkgconfig/libkiwix.pc

%changelog