File s3cmd.spec of Package s3cmd

#
# spec file for package s3cmd
#
# Copyright (c) 2015 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.
%if 0%{?suse_version}
%if 0%{?suse_version} < 1020
%define use_elementtree 1
%else
%define use_python_xml 1
%endif
%endif

%if 0%{?rhel_version} || 0%{?centos_version}
%if (0%{?rhel_version} < 600) && (0%{?centos_version} < 600)
%define use_elementtree 1
%endif
%endif

%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()")}
%endif

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           s3cmd
Version:        2.1.0
Release:        1
License:        GPL-2.0
Url:            http://s3tools.org/s3cmd
Summary:        Command line tool for managing Amazon S3 and CloudFront services
Group:          System/Management
Source:         https://github.com/s3tools/s3cmd/releases/download/v%{version}/%{name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version} >= 1500
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
#BuildRequires:  python3-xml
BuildRequires:  python3-rpm-macros
#Requires:       python3-xml
Requires:	python3-dateutil

%define pyth python3
%define py_sitelib %{python3_sitelib}
%else
BuildRequires:  python-devel
BuildRequires:  python-setuptools
#BuildRequires:  python-xml

%if 0%{?suse_version} == 0 || 0%{?suse_version} >= 1200
BuildArch:      noarch
%endif

%if 0%{?suse_version} >= 1200
BuildRequires:  python-rpm-macros
%endif

#Requires:       python-xml
Requires:	python-dateutil

%if (0%{?fedora_version} > 29)
%define pyth python2
%define py_sitelib %{python2_sitelib}
%else
%define pyth python
%define py_sitelib %{python_sitelib}
%endif

%endif

#%if %%{defined suse_version} && 0%%{?suse_version} < 1400
#% { py_requires}
#%endif

%if %{defined use_elementtree}
BuildRequires:  %{pyth}-elementtree
Requires:       %{pyth}-elementtree
%endif

%if %{defined use_python_xml}
BuildRequires:  %{pyth}-xml
Requires:       %{pyth}-xml
%endif

%description
S3cmd (`s3cmd`) is a free command line tool and client for uploading, retrieving
and managing data in Amazon S3 and other cloud storage service providers that use
the S3 protocol, such as Ceph, Google Cloud Storage or DreamHost DreamObjects. It is
best suited for power users who are familiar with command line programs.

%prep
%setup -q

%build
export S3CMD_PACKAGING=1
%pyth setup.py build

%install
export S3CMD_PACKAGING=1

%if %{defined suse_version}
RECORD_ARG=--record-rpm
%else
RECORD_ARG=--record
%endif

%pyth setup.py install --root=$RPM_BUILD_ROOT --prefix=%{_prefix} $RECORD_ARG=INSTALLED_FILES
sed -i '/\S3.pyc$/d' INSTALLED_FILES

%clean
rm -rf "$RPM_BUILD_ROOT"

%files
%defattr(-,root,root,-)
%{py_sitelib}/*egg-info
%{py_sitelib}/S3/
/usr/bin/%{name}
openSUSE Build Service is sponsored by