File openstack-designate.spec of Package openstack-designate

#
# spec file for package openstack-designate
#
# 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/
#


%global with_doc 1
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           openstack-designate
Version:        11.1.0~dev28
Release:        0
Summary:        OpenStack DNS Service (Designate)
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/designate
Source0:        designate-master.tar.gz
Source1:        openstack-designate.logrotate
Source2:        openstack-designate.sudoers
Source3:        openstack-designate.tmpfiles
Source4:        openstack-designate.defaultconf
# systemd service files
Source20:       openstack-designate-api.service
Source21:       openstack-designate-sink.service
Source22:       openstack-designate-central.service
Source23:       openstack-designate-agent.service
Source24:       openstack-designate-producer.service
Source25:       openstack-designate-worker.service
Source26:       openstack-designate-mdns.service
Source50:       openstack-designate.README.config
BuildRequires:  openstack-macros
BuildRequires:  python3-edgegrid-python
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-mock
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.reports
BuildRequires:  python3-oslo.rootwrap
BuildRequires:  python3-oslo.serialization
BuildRequires:  python3-oslo.service
BuildRequires:  python3-oslo.upgradecheck
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-oslo.versionedobjects
BuildRequires:  python3-oslotest
BuildRequires:  python3-pbr
BuildRequires:  python3-python-memcached
BuildRequires:  python3-requests
BuildRequires:  python3-requests-mock
BuildRequires:  python3-stestr
BuildRequires:  python3-tooz
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-designate = %{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
Designate is an OpenStack inspired DNSaaS.

%package -n python3-designate
Summary:        OpenStack DNS Service (Designate) - Python module
Group:          Development/Languages/Python
Requires:       python3-Babel
Requires:       python3-Flask
Requires:       python3-Jinja2
Requires:       python3-Paste
Requires:       python3-PasteDeploy
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-Werkzeug
Requires:       python3-debtcollector
Requires:       python3-designateclient
Requires:       python3-dnspython
Requires:       python3-edgegrid-python
Requires:       python3-eventlet
Requires:       python3-futurist
Requires:       python3-greenlet
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystonemiddleware
Requires:       python3-monasca-statsd
Requires:       python3-netaddr
Requires:       python3-neutronclient
Requires:       python3-os-win
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.reports
Requires:       python3-oslo.rootwrap
Requires:       python3-oslo.serialization
Requires:       python3-oslo.service
Requires:       python3-oslo.upgradecheck
Requires:       python3-oslo.utils
Requires:       python3-oslo.versionedobjects
Requires:       python3-pbr
Requires:       python3-pecan
Requires:       python3-python-memcached
Requires:       python3-requests
Requires:       python3-six
Requires:       python3-sqlalchemy-migrate
Requires:       python3-stevedore
Requires:       python3-suds-jurko
Requires:       python3-tenacity
Requires:       python3-tooz
Requires:       sudo

%description -n python3-designate
Designate is an OpenStack inspired DNSaaS.

This package contains the Python module.

%if 0%{?with_doc}
%package doc
Summary:        OpenStack DNS Service (Designate) - Documentation
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinxcontrib-blockdiag
BuildRequires:  python3-sphinxcontrib-httpdomain

%description doc
Designate is an OpenStack inspired DNSaaS.

This package contains the documentation.
%endif

%package api
Summary:        OpenStack DNS Service (Designate) - API
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description api
Designate is an OpenStack inspired DNSaaS.

This package contains the API server.

%package sink
Summary:        OpenStack DNS Service (Designate) - Sink
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description sink
Designate is an OpenStack inspired DNSaaS.

This package contains the sink server.

%package central
Summary:        OpenStack DNS Service (Designate) - Central
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description central
Designate is an OpenStack inspired DNSaaS.

This package contains the central server.

%package agent
Summary:        OpenStack DNS Service (Designate) - Agent
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description agent
Designate is an OpenStack inspired DNSaaS.

This package contains the agent.

%package producer
Summary:        OpenStack DNS Service (Designate) - Producer
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description producer
Designate is an OpenStack inspired DNSaaS.

This package contains the producer.

%package worker
Summary:        OpenStack DNS Service (Designate) - Worker
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description worker
Designate is an OpenStack inspired DNSaaS.

This package contains the worker.

%package mdns
Summary:        OpenStack DNS Service (Designate) - mdns
Group:          Development/Languages/Python
Requires:       python3-designate = %{version}-%{release}

%description mdns
Designate is an OpenStack inspired DNSaaS.

This package contains the mdns.

%prep
%autosetup -p1 -n designate-11.1.0.dev28
%py_req_cleanup

%build
%{py3_build}

# build documentation
%if 0%{?with_doc}
PYTHONPATH=. PBR_VERSION=11.1.0.dev28 %sphinx_build -b html doc/source doc/build/html
PYTHONPATH=. PBR_VERSION=11.1.0.dev28 %sphinx_build -b man doc/source doc/build/man
rm -rf doc/build/html/.{doctrees,buildinfo}
rm -rf doc/build/man/.{doctrees,buildinfo}
%endif

# generate the sample config files
PYTHONPATH=. oslo-config-generator --config-file etc/designate/designate-config-generator.conf --output-file etc/designate/designate.conf.sample
# generate the sample policy
PYTHONPATH=. oslopolicy-sample-generator --config-file=etc/designate/designate-policy-generator.conf --output etc/designate/policy.json.sample

%install
%{py3_install}

# Setup directories
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log,cache}/designate
install -d -m 755 %{buildroot}%{_sysconfdir}/designate
install -d -m 755 %{buildroot}%{_sysconfdir}/designate/designate.conf.d

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

# Install sudoers
install -p -D -m 440 %{SOURCE2} %{buildroot}%{_sysconfdir}/sudoers.d/openstack-designate

# install tmpfiles
install -D -m 644 %{SOURCE3} %{buildroot}/%_tmpfilesdir/%{name}.conf

# install rootwrap filters
install -d -m 755 %{buildroot}%{_datarootdir}/designate/rootwrap
mv %{buildroot}/%{_prefix}/%{_sysconfdir}/designate/rootwrap.d/* %{buildroot}%{_datarootdir}/designate/rootwrap

# install config files
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/designate/README.config
install -p -D -m 640 %{SOURCE4} %{buildroot}%{_sysconfdir}/designate/designate.conf.d/010-designate.conf
install -p -D -m 644 etc/designate/rootwrap.conf.sample %{buildroot}%{_sysconfdir}/designate/rootwrap.conf
install -D -m 644 etc/designate/designate.conf.sample %{buildroot}%{_sysconfdir}/designate/
install -D -m 644 etc/designate/policy.json.sample %{buildroot}%{_sysconfdir}/designate/
install -D -m 644 etc/designate/pools.yaml.sample-bind %{buildroot}%{_sysconfdir}/designate/pools.yaml
mv %{buildroot}/%{_prefix}/%{_sysconfdir}/designate/* %{buildroot}%{_sysconfdir}/designate/.
for f in %{buildroot}%{_sysconfdir}/designate/*.sample ; do mv $f ${f/.sample} ; done

# install systemd service files
install -p -D -m 644 %{SOURCE20} %{buildroot}%{_unitdir}/openstack-designate-api.service
install -p -D -m 644 %{SOURCE21} %{buildroot}%{_unitdir}/openstack-designate-sink.service
install -p -D -m 644 %{SOURCE22} %{buildroot}%{_unitdir}/openstack-designate-central.service
install -p -D -m 644 %{SOURCE23} %{buildroot}%{_unitdir}/openstack-designate-agent.service
install -p -D -m 644 %{SOURCE24} %{buildroot}%{_unitdir}/openstack-designate-producer.service
install -p -D -m 644 %{SOURCE25} %{buildroot}%{_unitdir}/openstack-designate-worker.service
install -p -D -m 644 %{SOURCE26} %{buildroot}%{_unitdir}/openstack-designate-mdns.service

# install symlinks on SUSE
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-sink
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-central
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-agent
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-producer
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-worker
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-mdns
%endif

# man pages
%if 0%{?with_doc}
mkdir -p %{buildroot}%{_mandir}/man1
install -p -D -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1/
%endif

%pre
%openstack_pre_user_group_create designate designate /sbin/nologin
exit 0

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf

#TODO: enable testing when all BuildRequires are py3 ready
##%%check
##%stestr run

%post api
%systemd_post %{name}-api.service

%preun api
%systemd_preun %{name}-api.service

%postun api
%systemd_postun_with_restart %{name}-api.service

%post sink
%systemd_post %{name}-sink.service

%preun sink
%systemd_preun %{name}-sink.service

%postun sink
%systemd_postun_with_restart %{name}-sink.service

%post central
%systemd_post %{name}-central.service

%preun central
%systemd_preun %{name}-central.service

%postun central
%systemd_postun_with_restart %{name}-central.service

%post agent
%systemd_post %{name}-agent.service

%preun agent
%systemd_preun %{name}-agent.service

%postun agent
%systemd_postun_with_restart %{name}-agent.service

%post producer
%systemd_post %{name}-producer.service

%preun producer
%systemd_preun %{name}-producer.service

%postun producer
%systemd_postun_with_restart %{name}-producer.service

%post worker
%systemd_post %{name}-worker.service

%preun worker
%systemd_preun %{name}-worker.service

%postun worker
%systemd_postun_with_restart %{name}-worker.service

%post mdns
%systemd_post %{name}-mdns.service

%preun mdns
%systemd_preun %{name}-mdns.service

%postun mdns
%systemd_postun_with_restart %{name}-mdns.service

%files
%license LICENSE
%dir %attr(0750, designate, designate) %{_localstatedir}/log/designate
%dir %attr(0750, designate, designate) %{_localstatedir}/lib/designate
%dir %attr(0750, root, designate) %{_sysconfdir}/designate
%dir %attr(0750, root, designate) %{_sysconfdir}/designate/designate.conf.d/
%{_sysconfdir}/designate/README.config
%config(noreplace) %attr(0640, designate, designate) %{_sysconfdir}/designate/designate.conf
%config(noreplace) %attr(0640, designate, designate) %{_sysconfdir}/designate/designate.conf.d/010-designate.conf
%config(noreplace) %attr(-, designate, designate) %{_sysconfdir}/designate/api-paste.ini
%config(noreplace) %attr(-, root, designate) %{_sysconfdir}/designate/rootwrap.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-designate
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-designate
%config(noreplace) %{_sysconfdir}/designate/policy.json
%config(noreplace) %{_sysconfdir}/designate/pools.yaml
%_tmpfilesdir/%name.conf
%dir %{_datarootdir}/designate
%dir %{_datarootdir}/designate/rootwrap
%{_datarootdir}/designate/rootwrap/bind9.filters
%{_datarootdir}/designate/rootwrap/djbdns.filters
%{_datarootdir}/designate/rootwrap/knot2.filters
%{_bindir}/designate-manage
%{_bindir}/designate-rootwrap
%{_bindir}/designate-status
%if 0%{?with_doc}
%{_mandir}/man1/designate-manage.1.gz
%{_mandir}/man1/designate-status.1.gz
%endif

%files -n python3-designate
%license LICENSE
%{python3_sitelib}/designate*

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

%files api
%license LICENSE
%{_bindir}/designate-api
%{_bindir}/designate-api-wsgi
%{_unitdir}/openstack-designate-api.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-api
%endif

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

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

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

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

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

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

%changelog