File python-rsa.spec of Package python-rsa.9598

#
# spec file for package python-rsa
#
# Copyright (c) 2018 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 https://bugs.opensuse.org/
#


%define execs pyrsa-priv2pub pyrsa-keygen pyrsa-encrypt pyrsa-decrypt pyrsa-sign pyrsa-verify pyrsa-encrypt-bigfile pyrsa-decrypt-bigfile

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-rsa
Version:        3.1.4
Release:        0
Url:            http://stuvel.eu/rsa
Summary:        Pure-Python RSA Implementation
License:        Apache-2.0
Group:          Development/Languages/Python
Source:         http://pypi.python.org/packages/source/r/rsa/rsa-%{version}.tar.gz
Patch0:         cve_2016-1494.diff
Patch1:         remove_unittest2.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module pyasn1}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires(pre):  coreutils
Requires:       python-pyasn1
Requires(pre):  coreutils
Requires(post): update-alternatives
Requires(postun): update-alternatives
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif
%python_subpackages

%description
Python-RSA is a pure-Python RSA implementation. It supports encryption and
decryption, signing and verifying signatures, and key generation according to
PKCS#1 version 1.5.

%prep
%setup -q -n rsa-%{version}
%patch0 -p1
%patch1 -p1

%build
%python_build

%install
%python_install

# for update-alternatives
for f in %{execs}; do
    %python_clone -a %{buildroot}%{_bindir}/${f}
done

%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
%python_exec run_tests.py

%pre
# Since binaries became ghosted to be used with update-alternatives, we
# have to get rid of the old binary resulting from the
# non-update-alternativies-ified package:
for f in %{execs}; do
    [ -h %{_bindir}/${f} ] || rm -f %{_bindir}/${f}
done

%post
%python_install_alternative pyrsa-priv2pub
%python_install_alternative pyrsa-keygen
%python_install_alternative pyrsa-encrypt
%python_install_alternative pyrsa-decrypt
%python_install_alternative pyrsa-sign
%python_install_alternative pyrsa-verify
%python_install_alternative pyrsa-encrypt-bigfile
%python_install_alternative pyrsa-decrypt-bigfile

%postun
%python_uninstall_alternative pyrsa-priv2pub
%python_uninstall_alternative pyrsa-keygen
%python_uninstall_alternative pyrsa-encrypt
%python_uninstall_alternative pyrsa-decrypt
%python_uninstall_alternative pyrsa-sign
%python_uninstall_alternative pyrsa-verify
%python_uninstall_alternative pyrsa-encrypt-bigfile
%python_uninstall_alternative pyrsa-decrypt-bigfile

%files %{python_files}
%defattr(-,root,root,-)
%license LICENSE
%doc README.rst
%python_alternative %{_bindir}/pyrsa-priv2pub
%python_alternative %{_bindir}/pyrsa-keygen
%python_alternative %{_bindir}/pyrsa-encrypt
%python_alternative %{_bindir}/pyrsa-decrypt
%python_alternative %{_bindir}/pyrsa-sign
%python_alternative %{_bindir}/pyrsa-verify
%python_alternative %{_bindir}/pyrsa-encrypt-bigfile
%python_alternative %{_bindir}/pyrsa-decrypt-bigfile
%{python_sitelib}/*

%changelog
openSUSE Build Service is sponsored by