File rhnpush.spec of Package rhnpush

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


%if (0%{?fedora} && 0%{?fedora} <= 29) || 0%{?rhel} >= 7
%{!?pylint2_check: %global pylint2_check 1}
%endif

%if 0%{?fedora} || 0%{?rhel} >= 8
%global build_py3   1
%global default_py3 1
%{!?pylint3_check: %global pylint3_check 1}
%endif

# we need python2 libs for server!
%global build_py2   1

%define pythonX %{?default_py3: python3}%{!?default_py3: python2}

Name:           rhnpush
Summary:        Package uploader for the Spacewalk or Red Hat Satellite Server
License:        GPL-2.0-only
URL:            https://github.com/spacewalkproject/spacewalk
Version:        5.5.120
Release:        1.git.0.e0506f8%{?dist}
Source0:        rhnpush-git-0.1c22677.tar.gz
BuildArch:      noarch
Requires:       %{pythonX}-%{name} = %{version}-%{release}
BuildRequires:  docbook-utils
BuildRequires:  gettext
%if 0%{?build_py2} && 0%{?pylint2_check}
BuildRequires:  spacewalk-python2-pylint
%endif
%if 0%{?build_py3} && 0%{?pylint3_check}
BuildRequires:  spacewalk-python3-pylint
%endif

%description
rhnpush uploads package headers to the Spacewalk or Red Hat Satellite
servers into specified channels and allows for several other channel
management operations relevant to controlling what packages are available
per channel.

%if 0%{?build_py2}
%package -n python2-%{name}
Summary:        Package uploader for the Spacewalk or Red Hat Satellite Server
%{?python_provide:%python_provide python2-%{name}}
Requires:       %{name} = %{version}-%{release}
%if 0%{?fedora} >= 28
Requires:       python2-rpm
BuildRequires:  python2-devel
%else
Requires:       rpm-python
BuildRequires:  python-devel
%endif
Requires:       python2-rhn-client-tools
Requires:       rhnlib >= 2.8.3
Requires:       spacewalk-backend-libs >= 1.7.17
Requires:       spacewalk-usix
BuildRequires:  python2-rhn-client-tools
BuildRequires:  spacewalk-backend-libs > 1.8.33

%description -n python2-%{name}
Python 2 specific files for rhnpush.
%endif

%if 0%{?build_py3}
%package -n python3-%{name}
Summary:        Package uploader for the Spacewalk or Red Hat Satellite Server
%{?python_provide:%python_provide python3-%{name}}
Requires:       %{name} = %{version}-%{release}
Requires:       python3-rhn-client-tools
Requires:       python3-rhnlib >= 2.8.3
Requires:       python3-spacewalk-backend-libs
Requires:       python3-spacewalk-usix
Requires:       rpm-python3
BuildRequires:  python3-devel
BuildRequires:  python3-rhn-client-tools
BuildRequires:  python3-rpm-macros
BuildRequires:  spacewalk-backend-libs > 1.8.33

%description -n python3-%{name}
Python 3 specific files for rhnpush.
%endif

%prep
%setup -q -n rhnpush-git-0.1c22677

%build
make -f Makefile.rhnpush all

%install
install -d $RPM_BUILD_ROOT/%{python_sitelib}
%if 0%{?build_py2}
make -f Makefile.rhnpush install PREFIX=$RPM_BUILD_ROOT ROOT=%{python_sitelib} \
    MANDIR=%{_mandir} PYTHON_VERSION=%{python_version}
%endif

%if 0%{?build_py3}
sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' rhnpush
install -d $RPM_BUILD_ROOT/%{python3_sitelib}
make -f Makefile.rhnpush install PREFIX=$RPM_BUILD_ROOT ROOT=%{python3_sitelib} \
    MANDIR=%{_mandir} PYTHON_VERSION=%{python3_version}
%endif

%define default_suffix %{?default_py3:-%{python3_version}}%{!?default_py3:-%{python_version}}
ln -s rhnpush%{default_suffix} $RPM_BUILD_ROOT%{_bindir}/rhnpush

%clean

%check
# check coding style
%if 0%{?build_py2} && 0%{?pylint2_check}
export PYTHONPATH=$RPM_BUILD_ROOT%{python_sitelib}
spacewalk-python2-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python_sitelib}
%endif
%if 0%{?build_py3} && 0%{?pylint3_check}
export PYTHONPATH=$RPM_BUILD_ROOT%{python3_sitelib}
spacewalk-python3-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python3_sitelib}
%endif

%files
%{_bindir}/rhnpush
%{_bindir}/rpm2mpm
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/sysconfig/rhn/rhnpushrc
%{_mandir}/man8/rhnpush.8*
%doc COPYING

%if 0%{?build_py2}
%files -n python2-%{name}
%attr(755,root,root) %{_bindir}/rhnpush-%{python_version}
%{python_sitelib}/rhnpush/
%endif

%if 0%{?build_py3}
%files -n python3-%{name}
%attr(755,root,root) %{_bindir}/rhnpush-%{python3_version}
%{python3_sitelib}/rhnpush/
%endif

%changelog
openSUSE Build Service is sponsored by