File openstack-karbor.spec of Package openstack-karbor

#
# spec file for package openstack-karbor
#
# Copyright (c) 2021 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-karbor
Epoch:          0
Version:        1.5.0
Release:        0
Summary:        OpenStack Application Data Protection Service
License:        Apache-2.0
URL:            https://launchpad.net/karbor
Source0:        karbor-stable-ussuri.tar.gz
Source1:        openstack-karbor.logrotate
Source2:        openstack-karbor-operationengine.service
Source3:        openstack-karbor-protection.service
BuildRequires:  openstack-macros
BuildRequires:  openstack-tempest
BuildRequires:  python3-Babel
BuildRequires:  python3-Paste
BuildRequires:  python3-PasteDeploy
BuildRequires:  python3-Routes
BuildRequires:  python3-SQLAlchemy
BuildRequires:  python3-WebOb
BuildRequires:  python3-WebTest
BuildRequires:  python3-abclient
BuildRequires:  python3-bcrypt
BuildRequires:  python3-cinderclient
BuildRequires:  python3-croniter
BuildRequires:  python3-eventlet
BuildRequires:  python3-fixtures
BuildRequires:  python3-freezegun
BuildRequires:  python3-glanceclient
BuildRequires:  python3-greenlet
BuildRequires:  python3-heatclient
BuildRequires:  python3-icalendar
BuildRequires:  python3-karborclient
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-lxml
BuildRequires:  python3-manilaclient
BuildRequires:  python3-mock
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-os-api-ref
BuildRequires:  python3-oslo.concurrency
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.context
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.i18n
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.messaging
BuildRequires:  python3-oslo.middleware
BuildRequires:  python3-oslo.policy
BuildRequires:  python3-oslo.serialization
BuildRequires:  python3-oslo.service
BuildRequires:  python3-oslo.versionedobjects
BuildRequires:  python3-requests
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-sqlalchemy-migrate
BuildRequires:  python3-stevedore
BuildRequires:  python3-swiftclient
BuildRequires:  python3-taskflow
Requires:       logrotate
Requires:       python3-karbor = %{epoch}:%{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
Requires(pre):  pwdutils
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun):systemd
Requires(pre):  shadow-utils
Requires(preun):systemd
%endif

%description
Karbor is a Python implementation of the OpenStack
(http://www.openstack.org) Application Data Protection API.
.
This package contains the karbor python libraries.

%package -n     python3-karbor
Summary:        Karbor Python libraries
Group:          Applications/System
Requires:       python3-Babel
Requires:       python3-Paste
Requires:       python3-PasteDeploy
Requires:       python3-Routes
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-abclient
Requires:       python3-cinderclient
Requires:       python3-croniter
Requires:       python3-eventlet
Requires:       python3-glanceclient
Requires:       python3-greenlet
Requires:       python3-heatclient
Requires:       python3-icalendar
Requires:       python3-karborclient
Requires:       python3-keystoneauth1
Requires:       python3-keystonemiddleware
Requires:       python3-manilaclient
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-oslo.concurrency
Requires:       python3-oslo.config
Requires:       python3-oslo.context
Requires:       python3-oslo.db
Requires:       python3-oslo.i18n
Requires:       python3-oslo.log
Requires:       python3-oslo.messaging
Requires:       python3-oslo.middleware
Requires:       python3-oslo.policy
Requires:       python3-oslo.serialization
Requires:       python3-oslo.service
Requires:       python3-oslo.versionedobjects
Requires:       python3-requests
Requires:       python3-six
Requires:       python3-sqlalchemy-migrate
Requires:       python3-stevedore
Requires:       python3-swiftclient
Requires:       python3-taskflow

%description -n   python3-karbor
Karbor is a Python implementation of the OpenStack
(https://docs.openstack.org/developer/karbor/) Application Data Protection API.
This package contains the Karbor Python library.

%if 0%{?with_doc}
%package doc
Summary:        Documentation for OpenStack Application Data Protection Service
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-oslosphinx

%description doc
OpenStack Karbor documentaion.
.
This package contains the documentation
%endif

%package api
%if 0%{?suse_version}
%define apache_name         apache2
%define apache_site_dir     %{_sysconfdir}/%{apache_name}/vhosts.d/
BuildRequires:  apache2-mod_wsgi-python3
Requires:       apache2-mod_wsgi-python3
%else
%define apache_name         httpd
%define apache_site_dir     %{_sysconfdir}/%{apache_name}/conf.d/
BuildRequires:  python3-mod_wsgi
Requires:       python3-mod_wsgi
%endif
Summary:        OpenStack Karbor - API service
Group:          Applications/System
Requires:       %{name} = %{version}

%description api
OpenStack Karbor API service.

%package        operationengine
Summary:        OpenStack Karbor OperationEngine service
Requires:       %{name} = %{version}

%description    operationengine
OpenStack Karbor OperationEngine service.

%package        protection
Summary:        OpenStack Karbor Protection service
Requires:       %{name} = %{version}

%description    protection
OpenStack Karbor Protection service.

%prep
%autosetup -p1 -n karbor-1.5.0
%py_req_cleanup

%build
%{py3_build}
export PYTHONPATH="."
# config file generation
oslo-config-generator --config-file etc/oslo-config-generator/karbor.conf \
--output-file etc/karbor.conf.sample
%if 0%{?with_doc}
%{__python3} setup.py build_sphinx
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif

%install
%{py3_install}

# Install config files
mkdir -p %{buildroot}%{_sysconfdir}/karbor/
mkdir -p %{buildroot}%{_sysconfdir}/karbor/providers.d/
install -p -D -m 640 etc/karbor.conf.sample %{buildroot}%{_sysconfdir}/karbor/karbor.conf
install -p -D -m 640 etc/api-paste.ini %{buildroot}%{_sysconfdir}/karbor/api-paste.ini
install -p -D -m 640 etc/providers.d/*.conf %{buildroot}%{_sysconfdir}/karbor/providers.d/

# remove wrongly installed tree
rm -rv  %{buildroot}/%{_prefix}%{_sysconfdir}/

# Setup log directory
mkdir -p %{buildroot}%{_localstatedir}/log/karbor

# Install logrotate
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-karbor

# Install apache configuration files
sed -i 's#/local/bin#/bin#' etc/apache2/apache-karbor-api.conf
%if 0%{?rdo}
# adjust paths to WSGI scripts
sed -i 's#apache2#httpd#' etc/apache2/apache-karbor-api.conf
%endif
install -d -m 755 %{buildroot}%{apache_site_dir}
install -p -D -m 644 etc/apache2/apache-karbor-api.conf  %{buildroot}%{_datarootdir}/karbor/wsgi-karbor.conf
install -p -D -m 644 etc/apache2/apache-karbor-api.conf  %{buildroot}%{apache_site_dir}/karbor.conf

# systemd unitfiles
install -p -D -m 644 %SOURCE2 %{buildroot}%{_unitdir}/openstack-karbor-operationengine.service
install -p -D -m 644 %SOURCE3 %{buildroot}%{_unitdir}/openstack-karbor-protection.service

%pre
%openstack_pre_user_group_create karbor karbor

%post operationengine
%systemd_post openstack-karbor-operationengine.service

%preun operationengine
%systemd_preun openstack-karbor-operationengine.service

%postun operationengine
%systemd_postun_with_restart openstack-karbor-operationengine.service

%post protection
%systemd_post openstack-karbor-protection.service

%preun protection
%systemd_preun openstack-karbor-protection.service

%postun protection
%systemd_postun_with_restart openstack-karbor-protection.service

%files
%license LICENSE
%doc README.rst
%dir %{_datarootdir}/karbor/
%dir %attr(0750, root, karbor) %{_sysconfdir}/karbor/
%dir %attr(0750, root, karbor) %{_sysconfdir}/karbor/providers.d/
%dir %attr(0750, karbor, karbor) %{_localstatedir}/log/karbor
%{_bindir}/karbor-manage
%{_bindir}/karbor-status
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-karbor
%config(noreplace) %attr(0640, root, karbor) %{_sysconfdir}/karbor/karbor.conf
%config(noreplace) %attr(0640, root, karbor) %{_sysconfdir}/karbor/api-paste.ini
%config(noreplace) %attr(0640, root, karbor) %{_sysconfdir}/karbor/providers.d/*.conf

%files -n python3-karbor
%license LICENSE
%{python3_sitelib}/karbor/
%{python3_sitelib}/karbor-*.egg-info

%files api
%{_bindir}/karbor-api
%{_bindir}/karbor-wsgi
%{_datarootdir}/karbor/wsgi-karbor.conf
%{apache_site_dir}/karbor.conf

%files operationengine
%{_bindir}/karbor-operationengine
%{_unitdir}/openstack-karbor-operationengine.service

%files protection
%{_bindir}/karbor-protection
%{_unitdir}/openstack-karbor-protection.service

%if 0%{?with_doc}
%files doc
%license LICENSE
%doc doc/build/html
%endif

%changelog
openSUSE Build Service is sponsored by