File libdnf.spec of Package libdnf

#
# spec file for package libdnf
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# 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/
#


%global libsolv_version 0.6.28

# Keep tests switched off for now, it bombs out on SUSE
%bcond_with check

# Keep valgrind tests switched off for now
%bcond_with valgrind

%{!?make_build: %global make_build %{__make} -O %{?_smp_mflags}}
%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}}

%define somajor 1
%define girapi %{somajor}.0
%define libname %{name}%{somajor}
%define girname typelib-1_0-Dnf-%{somajor}_0
%define devname %{name}-devel

Name:           libdnf
Version:        0.11.1
Release:        0
Summary:        Library providing simplified C and Python API to libsolv
License:        LGPL-2.0+
Group:          System/Packages
Url:            https://github.com/rpm-software-management/%{name}
Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz

# PATCH-FIX-UPSTREAM: Ensure SUSE kernel packages are recognized properly
# Proposed upstream: https://github.com/rpm-software-management/libdnf/pull/400
Patch0001:      0001-Add-multiversion-kernel-as-a-recognized-installonlyp.patch

# PATCH-FIX-OPENSUSE libdnf-0.9.3-with-static-libsolvext.patch  ngompa13@gmail.com -- Fix libdnf build with static libsolvext
Patch1000:      libdnf-0.9.3-with-static-libsolvext.patch

BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  libsolv-devel >= %{libsolv_version}
BuildRequires:  pkgconfig(check)
BuildRequires:  pkgconfig(librepo)
%if %{with valgrind}
BuildRequires:  valgrind
%endif
BuildRequires:  rpm-devel >= 4.11.0
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(gio-unix-2.0) >= 2.46.0
BuildRequires:  pkgconfig(gobject-introspection-1.0)
BuildRequires:  pkgconfig(gtk-doc)
BuildRequires:  pkgconfig(liblzma)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(zlib)

%description
This library provides a high level RPM package manager that can be integrated
into applications to manage software. It is currently used by DNF, RPM-OSTree,
and PackageKit.

%package -n %{libname}
Summary:        Library providing simplified interface to libsolv
Group:          System/Libraries

%description -n %{libname}
This library provides a simple interface to libsolv and is currently
used by PackageKit and rpm-ostree.

%package -n %{girname}
Summary:        GObject Introspection interface description for libdnf
Group:          System/Libraries
Requires:       %{libname}%{?_isa} = %{version}-%{release}

%description -n %{girname}
This packages provides the GObject Introspection interface description
for %{name}, enabling the usage of libdnf in programming languages
that support it.

%package -n %{devname}
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{girname}%{?_isa} = %{version}-%{release}
Requires:       %{libname}%{?_isa} = %{version}-%{release}

%description -n %{devname}
This package provides the headers and libraries for developing applications
that use %{name}.

%package -n hawkey-man
Summary:        Documentation for the hawkey Python bindings
Group:          Documentation/Man
BuildRequires:  python-Sphinx
BuildRequires:  python-nose
BuildArch:      noarch

%description -n hawkey-man
This package provides the man pages for the hawkey Python bindings.

%package -n python2-hawkey
Summary:        Python 2 bindings for the hawkey interface
Group:          Development/Libraries/Python
Provides:       python-hawkey = %{version}-%{release}
BuildRequires:  python-devel
BuildRequires:  python-nose
Requires:       %{libname}%{?_isa} = %{version}-%{release}
Requires:       hawkey-man = %{version}-%{release}

%description -n python2-hawkey
This package provides the Python 2 bindings for %{name} through
the hawkey interface.

%package -n python3-hawkey
Summary:        Python 3 bindings for the hawkey interface
Group:          Development/Libraries/Python
BuildRequires:  python3-devel
BuildRequires:  python3-nose
Requires:       %{libname}%{?_isa} = %{version}-%{release}
Requires:       hawkey-man = %{version}-%{release}

%description -n python3-hawkey
This package provides the Python 3 bindings for %{name} through
the hawkey interface.

%prep
%autosetup -p1

mkdir build-py2
mkdir build-py3

%build
pushd build-py2
  %cmake %{!?with_valgrind:-DDISABLE_VALGRIND=1} ../../
  %make_build
popd

pushd build-py3
  %cmake -DPYTHON_DESIRED:str=3 -DWITH_GIR=0 -DWITH_MAN=0 -Dgtkdoc=0 %{!?with_valgrind:-DDISABLE_VALGRIND=1} ../../
  %make_build
popd

%if %{with check}
%check
# The test suite doesn't automatically know to look at the "built"
# library, so we force it by creating an LD_LIBRARY_PATH
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}

if [ "$(id -u)" == "0" ] ; then
        cat <<ERROR 1>&2
Package tests cannot be run under superuser account.
Please build the package as non-root user.
ERROR
        exit 1
fi
pushd build-py2/build
  make ARGS="-V" test
popd

# FOR THE PYTHON 3 BUILD
# Run just the Python tests, not all of them, since
# we have coverage of the core from the first build
pushd build-py3/build/python/hawkey/tests
  make ARGS="-V" test
popd
%endif

%install
pushd build-py2/build
  %make_install
popd

pushd build-py3/build
  %make_install
popd

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

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

%files -n %{libname}
%license COPYING
%doc README.md AUTHORS
%{_libdir}/%{name}.so.%{somajor}

%files -n %{girname}
%{_libdir}/girepository-1.0/Dnf-%{girapi}.typelib

%files -n %{devname}
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/%{name}/
%doc %{_datadir}/gtk-doc/html/%{name}/
%{_datadir}/gtk-doc/html/%{name}/*
%{_datadir}/gir-1.0/Dnf-*.gir

%files -n hawkey-man
%{_mandir}/man3/hawkey.3*

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

%files -n python3-hawkey
%{python3_sitearch}/hawkey/

%changelog
openSUSE Build Service is sponsored by