File openstack-freezer.spec of Package openstack-freezer

#
# spec file for package openstack-freezer
#
# Copyright (c) 2020 SUSE LLC
#
# 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/
#


%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           openstack-freezer
Version:        7.2.1~dev3
Release:        0
Summary:        OpenStack Backup and Restore
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://launchpad.net/freezer
Source0:        freezer-stable-train.tar.gz
Source1:        openstack-freezer.logrotate
Source2:        openstack-freezer-scheduler.service
BuildRequires:  openstack-macros
BuildRequires:  openstack-tempest
BuildRequires:  python3-APScheduler
BuildRequires:  python3-Babel
BuildRequires:  python3-PyMySQL
BuildRequires:  python3-botocore
BuildRequires:  python3-cinderclient
BuildRequires:  python3-cryptography
BuildRequires:  python3-ddt
BuildRequires:  python3-fixtures
BuildRequires:  python3-freezerclient
BuildRequires:  python3-glanceclient
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-keystoneclient
BuildRequires:  python3-mock
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-os-brick
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.service
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-paramiko
BuildRequires:  python3-pbr
BuildRequires:  python3-psutil
BuildRequires:  python3-pymongo
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-stestr
BuildRequires:  python3-swiftclient
Requires:       python3-freezer = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
Requires(pre):  pwdutils
%{?systemd_requires}
%endif
%if 0%{?rdo}
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(pre):  shadow-utils
Requires(preun): systemd
%endif

%description
OpenStack Swift incremental backup and restore automation tool for
file system, MongoDB, MySQL. LVM snapshot and encryption support.

%package -n     python3-freezer
Summary:        Freezer Python libraries
Group:          Applications/System
Requires:       python3-APScheduler
Requires:       python3-Babel
Requires:       python3-PyMySQL
Requires:       python3-botocore
Requires:       python3-cinderclient
Requires:       python3-cryptography
Requires:       python3-freezerclient
Requires:       python3-glanceclient
Requires:       python3-keystoneauth1
Requires:       python3-keystoneclient
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-os-brick
Requires:       python3-oslo.config
Requires:       python3-oslo.log
Requires:       python3-oslo.service
Requires:       python3-oslo.utils
Requires:       python3-paramiko
Requires:       python3-psutil
Requires:       python3-pymongo
Requires:       python3-six
Requires:       python3-swiftclient

%description -n python3-freezer
OpenStack Swift incremental backup and restore automation tool for
file system, MongoDB, MySQL. LVM snapshot and encryption support.

This package contains the Freezer python libraries.

%package agent
Summary:        OpenStack Freezer - Agent service
Group:          Applications/System
Requires:       %{name} = %{version}-%{release}

%description agent
OpenStack Swift incremental backup and restore automation tool for
file system, MongoDB, MySQL. LVM snapshot and encryption support.

This package contains the Freezer agent code.

%package scheduler
Summary:        OpenStack Freezer - Scheduler service
Group:          Applications/System
Requires:       %{name} = %{version}-%{release}

%description scheduler
OpenStack Swift incremental backup and restore automation tool for
file system, MongoDB, MySQL. LVM snapshot and encryption support.

This package contains the Freezer scheduler agent.

%package doc
Summary:        Documentation for OpenStack Backup Service
Group:          Documentation/HTML
BuildRequires:  fdupes
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinxcontrib-apidoc

%description doc
OpenStack Swift incremental backup and restore automation tool for
file system, MongoDB, MySQL. LVM snapshot and encryption support.

This package contains the documentation

%prep
%autosetup -p1 -n freezer-7.2.1.dev3
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION=7.2.1.dev3 %sphinx_build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%fdupes doc/build/html/
# config file generation
PYTHONPATH=. oslo-config-generator --config-file etc/config-generator.conf \
    --output-file etc/scheduler.conf.sample

%install
%{py3_install}
install -d -m 755 %{buildroot}%{_sysconfdir}/freezer
install -d -m 755 %{buildroot}%{_localstatedir}/{lib,log}/freezer
install -d -m 755 %{buildroot}%{_sysconfdir}/freezer/freezer.conf.d/
install -d -m 750 %{buildroot}%{_sysconfdir}/freezer/scheduler/
install -d -m 750 %{buildroot}%{_sysconfdir}/freezer/scheduler/conf.d/
install -p -D -m 640 etc/scheduler.conf.sample %{buildroot}%{_sysconfdir}/freezer/scheduler.conf
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-freezer
install -p -D -m 755 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}-scheduler.service
# install symlinks on SUSE
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-scheduler
%endif

# remove duplicates
%fdupes %{buildroot}%{python3_sitelib}

# remove Windows script
rm -fr %{buildroot}%{_prefix}/freezer/scripts/vss.ps1

%pre
%openstack_pre_user_group_create freezer freezer /sbin/nologin

#POST actions
%post scheduler
%systemd_post %{name}-scheduler.service

#PREUN actions
%preun scheduler
%systemd_preun %{name}-scheduler.service

#POSTUN actions
%postun scheduler
%systemd_postun_with_restart %{name}-scheduler.service

%check
export OS_TEST_PATH=./freezer/tests/unit
%if 0%{?suse_version}
PYTHON=python3 stestr run
%endif
%if 0%{?rdo}
stestr-3 run
%endif

%files
%license LICENSE
%doc README.rst
%dir %attr(0750, root, freezer) %{_sysconfdir}/freezer/
%dir %attr(0750, root, freezer) %{_sysconfdir}/freezer/freezer.conf.d/
%dir %attr(0750, root, freezer) %{_sysconfdir}/freezer/scheduler/
%dir %attr(0750, root, freezer) %{_sysconfdir}/freezer/scheduler/conf.d/
%config(noreplace) %attr(0640, root, freezer) %{_sysconfdir}/freezer/scheduler.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-freezer
%dir %attr(0755, freezer, freezer) %{_localstatedir}/lib/freezer
%dir %attr(0750, freezer, freezer) %{_localstatedir}/log/freezer

%files -n python3-freezer
%doc README.rst
%license LICENSE
%{python3_sitelib}/freezer*
%{python3_sitelib}/freezer-*.egg-info

%files agent
%license LICENSE
%{_bindir}/freezer-agent

%files scheduler
%license LICENSE
%{_bindir}/freezer-scheduler
%{_unitdir}/%{name}-scheduler.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-scheduler
%endif

%files doc
%license LICENSE
%doc doc/build/html

%changelog
openSUSE Build Service is sponsored by