File librepo.spec of Package librepo

#
# spec file for package librepo
#
# Copyright (c) 2018 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/
#


# Disable python3 due to missing deps
%if 0%{?suse_version} >= 1330
%bcond_without python3
%else
%bcond_with python3
%endif

# The tests involving gpg checks are too unstable and fail randomly
# So the tests are disabled by default for now until this is resolved.
%bcond_with tests

%define major 0
%define libname %{name}%{major}
%define devname %{name}-devel

%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}

Name:           librepo
Version:        1.8.1
Release:        0
Summary:        Repodata downloading library
License:        LGPL-2.0+
Group:          System/Libraries

Url:            https://github.com/rpm-software-management/librepo
Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz

BuildRequires:  check-devel
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  glib2-devel >= 2.26.0
BuildRequires:  gpgme-devel
BuildRequires:  libattr-devel
BuildRequires:  libcurl-devel >= 7.19.0
BuildRequires:  libexpat-devel
BuildRequires:  openssl-devel
%if 0%{?suse_version} >= 1330 || 0%{?leap_version} >= 420300
BuildRequires:  python-rpm-macros
%endif

# prevent provides from nonstandard paths:
%global __provides_exclude ^(%{python2_sitearch}/.*\\.so\\|%{python3_sitearch}/.*\\.so)$

%description
A library providing C and Python (libcURL like) API to downloading repository
metadata.

%package -n %{libname}
Summary:        Libraries for %{name}
Group:          System/Libraries

%description -n %{libname}
Libraries for %{name}

%package -n %{devname}
Summary:        Repodata downloading library
Group:          Development/Languages/C and C++
Provides:       %{name}-devel = %{version}-%{release}
Requires:       %{libname}%{?_isa} = %{version}-%{release}

%description -n %{devname}
Development files for %{name}.

%package -n python2-librepo
Summary:        Python bindings for the librepo library
Group:          Development/Languages/Python
BuildRequires:  python-devel
BuildRequires:  python-gpgme
%if %{with tests}
BuildRequires:  python-Flask
BuildRequires:  python-nose
%endif
BuildRequires:  python-Sphinx
BuildRequires:  python-xattr
Provides:       python-%{name} = %{version}-%{release}
Requires:       %{libname}%{?_isa} = %{version}-%{release}

%description -n python2-librepo
Python 2 bindings for the librepo library.

%if %{with python3}
%package -n python3-librepo
Summary:        Python 3 bindings for the librepo library
Group:          Development/Languages/Python
BuildRequires:  python3-devel
BuildRequires:  python3-gpgme
%if %{with tests}
BuildRequires:  python3-Flask
BuildRequires:  python3-nose
%endif
BuildRequires:  python3-Sphinx
BuildRequires:  python3-xattr
Requires:       %{libname}%{?_isa} = %{version}-%{release}

%description -n python3-librepo
Python 3 bindings for the librepo library.
%endif

%prep
%setup -q

%if %{with python3}
rm -rf py3
mkdir py3
%endif

%build
%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo
make %{?_smp_mflags}

%if %{with python3}
pushd ../py3
%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPYTHON_DESIRED:str=3 ../../
make %{?_smp_mflags}
popd
%endif

%check
%if %{with tests}
pushd ./build
make ARGS="-V" test
make clean
popd

%if %{with python3}
pushd ./py3/build
make ARGS="-V" test
popd
%endif
%endif

%install
pushd ./build
%make_install
popd
%if %{with python3}
pushd ./py3/build
%make_install
popd
%endif

%post -n %{libname} -p /sbin/ldconfig

%postun -n %{libname} -p /sbin/ldconfig

%files -n %{libname}
%doc COPYING README.md
%{_libdir}/librepo.so.%{major}

%files -n %{devname}
%{_libdir}/librepo.so
%{_libdir}/pkgconfig/librepo.pc
%{_includedir}/librepo/

%files -n python2-librepo
%{python2_sitearch}/librepo

%if %{with python3}
%files -n python3-librepo
%{python3_sitearch}/librepo
%endif

%changelog
openSUSE Build Service is sponsored by