File libcomps.spec of Package libcomps
#
# spec file for package libcomps
#
# Copyright (c) 2017 Neal Gompa <ngompa13@gmail.com>.
#
# 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/
#
%bcond_without python3
%define major 0
%define minor 1
%define patch 6
%define libname %{name}%{major}_%{minor}_%{patch}
%define devname %{name}-devel
%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}
Name: libcomps
Version: 0.1.8
Release: 0
Summary: Comps XML file manipulation library
License: GPL-2.0+
Group: System/Libraries
Url: https://github.com/rpm-software-management/libcomps
Source0: %{url}/archive/%{name}-%{version}/%{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE libcomps-0.1.7-Add-zlib-as-an-explicit-dependency.patch ngompa13@gmail.com -- Fixes zlib linking issues
Patch1000: libcomps-0.1.7-Add-zlib-as-an-explicit-dependency.patch
BuildRequires: check-devel
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libexpat-devel
BuildRequires: libxml2-devel
BuildRequires: zlib-devel
# prevent provides from nonstandard paths:
%define __provides_exclude ^(%{python2_sitearch}/.*\\.so\\|%{python3_sitearch}/.*\\.so)$
%description
Libcomps is library for structure-like manipulation with content of
comps XML files. Supports read/write XML file, structure(s) modification.
%package -n %{libname}
Summary: Libraries for %{name}
Group: System/Libraries
%description -n %{libname}
Libraries for %{name}
%package -n %{devname}
Summary: Development files for libcomps library
Group: Development/Libraries/C and C++
Requires: %{libname}%{?_isa} = %{version}-%{release}
Requires: pkg-config
%description -n %{devname}
Development files for %{name}.
%package doc
Summary: Documentation files for libcomps library
Group: Documentation
BuildArch: noarch
BuildRequires: doxygen
%description doc
Documentation files for libcomps library
%package -n python-libcomps-doc
Summary: Documentation files for python bindings libcomps library
Group: Documentation
BuildArch: noarch
BuildRequires: python-Sphinx
%description -n python-libcomps-doc
Documentation files for python bindings libcomps library
%package -n python2-libcomps
Summary: Python 2 bindings for libcomps library
Group: Development/Libraries/Python
BuildRequires: python-devel
Provides: python-%{name} = %{version}-%{release}
Requires: %{libname}%{?_isa} = %{version}-%{release}
%description -n python2-libcomps
Python2 bindings for libcomps library
%if %{with python3}
%package -n python3-libcomps
Summary: Python 3 bindings for libcomps library
Group: Development/Libraries/Python
BuildRequires: python3-devel
Requires: %{libname}%{?_isa} = %{version}-%{release}
%description -n python3-libcomps
Python3 bindings for libcomps library
%endif
%prep
%autosetup -n %{name}-%{name}-%{version} -p1
%if %{with python3}
rm -rf py3
mkdir py3
%endif
%build
%cmake -DPYTHON_DESIRED:STRING=2 ../libcomps/
make %{?_smp_mflags}
make docs
make pydocs
%if %{with python3}
pushd ../py3
%cmake -DPYTHON_DESIRED:STRING=3 ../../libcomps/
make %{?_smp_mflags}
popd
%endif
%check
pushd ./build
make test
popd
%if %{with python3}
pushd ./py3/build
make pytest
popd
%endif
%install
pushd ./build
%make_install
popd
%if %{with python3}
pushd ./py3/build
%make_install
popd
%endif
mkdir -p %{buildroot}%{_datadir}/doc/libcomps/
cp -a build/docs/libcomps-doc/html %{buildroot}%{_datadir}/doc/libcomps/
mkdir -p %{buildroot}%{_datadir}/doc/python-libcomps/
rm build/src/python/docs/html/.doctrees/environment.pickle
cp -a build/src/python/docs/html %{buildroot}%{_datadir}/doc/python-libcomps/
%fdupes %{buildroot}%{_datadir}/doc/libcomps
%fdupes %{buildroot}%{_datadir}/doc/python-libcomps
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%files -n %{libname}
%{_libdir}/libcomps.so.%{major}.%{minor}.%{patch}
%doc README.md COPYING
%files -n %{devname}
%{_libdir}/libcomps.so
%{_includedir}/*
%files doc
%doc %{_datadir}/doc/libcomps
%files -n python-libcomps-doc
%doc %{_datadir}/doc/python-libcomps
%files -n python2-libcomps
%{python2_sitearch}/libcomps
%if %{with python3}
%files -n python3-libcomps
%{python3_sitearch}/libcomps
%endif
%changelog