File openstack-heat.spec of Package openstack-heat

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


%define component heat
%define groupname %{component}
%define username %{component}

%define version_unconverted 11.0.3.dev35

Name:           openstack-%{component}
Version:        11.0.3~dev35
Release:        0
Summary:        Openstack Orchestration (Heat)
License:        Apache-2.0
Group:          System/Management
URL:            https://launchpad.net/heat
Source:         http://tarballs.openstack.org/heat/heat-stable-rocky.tar.gz
Source2:        %{name}.logrotate
Source3:        %{name}-api.service
Source4:        %{name}-api-cfn.service
Source6:        %{name}-engine.service
Source10:       %{name}.conf
Source50:       README.config
Source99:       rpmlintrc
# PATCH-FIX-UPSTREAM use-www-authenticate-uri.patch https://review.openstack.org/#/c/620374/
Patch1:         use-www-authenticate-uri.patch
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-Paste
BuildRequires:  python-PasteDeploy >= 1.5.0
BuildRequires:  python-Routes >= 2.3.1
BuildRequires:  python-WebOb >= 1.7.1
BuildRequires:  python-cryptography
BuildRequires:  python-devel
BuildRequires:  python-eventlet >= 0.13.0
BuildRequires:  python-keystoneclient
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-lxml >= 2.3
BuildRequires:  python-openstackdocstheme
BuildRequires:  python-oslo.cache
BuildRequires:  python-oslo.concurrency
BuildRequires:  python-oslo.config >= 1.2.0
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslo.serialization
BuildRequires:  python-oslo.service
BuildRequires:  python-oslo.utils
BuildRequires:  python-oslo.versionedobjects
BuildRequires:  python-osprofiler
BuildRequires:  python-pbr >= 0.5.21
BuildRequires:  python-yaql >= 1.1.3
# Documentation requirements:
BuildRequires:  python-Babel >= 2.3.4
BuildRequires:  python-Sphinx >= 1.1.2
BuildRequires:  python-oslo.i18n
BuildRequires:  python-oslosphinx
BuildRequires:  python-sphinxcontrib-apidoc
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
Requires:       logrotate
Requires:       openstack-heat-templates
Requires:       python >= 2.7
Requires:       python-heat = %{version}
%if 0%{?suse_version}
Requires(pre):  pwdutils
%else
Requires(pre):  /usr/bin/getent /usr/sbin/useradd /usr/sbin/userdel /usr/sbin/groupadd /usr/sbin/groupdel
%endif
BuildArch:      noarch

%description
Heat is a service to orchestrate multiple composite cloud applications using
templates, through both an OpenStack-native ReST API and a
CloudFormation-compatible Query API.

%package -n python-heat
Summary:        Openstack Orchestration (Heat) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.7
Requires:       python-Babel >= 2.3.4
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-PyYAML >= 3.12
Requires:       python-Routes >= 2.3.1
Requires:       python-SQLAlchemy >= 1.0.10
Requires:       python-WebOb >= 1.7.1
Requires:       python-aodhclient >= 0.9.0
Requires:       python-barbicanclient >= 4.5.2
Requires:       python-ceilometerclient >= 2.5.0
Requires:       python-cinderclient >= 3.3.0
Requires:       python-croniter >= 0.3.4
Requires:       python-cryptography >= 2.1
Requires:       python-designateclient >= 2.7.0
Requires:       python-eventlet >= 0.18.2
Requires:       python-heatclient >= 1.10.0
Requires:       python-keystoneauth1 >= 3.4.0
Requires:       python-keystoneclient >= 3.8.0
Requires:       python-keystonemiddleware >= 4.17.0
Requires:       python-kombu >= 4.0.0
Requires:       python-lxml >= 3.4.1
Requires:       python-magnumclient >= 2.1.0
Requires:       python-manilaclient >= 1.16.0
Requires:       python-mistralclient >= 3.1.0
Requires:       python-monascaclient >= 1.12.0
Requires:       python-netaddr >= 0.7.18
Requires:       python-neutron-lib >= 1.14.0
Requires:       python-neutronclient >= 6.7.0
Requires:       python-novaclient >= 9.1.0
Requires:       python-openstackclient >= 3.12.0
Requires:       python-openstacksdk >= 0.11.2
Requires:       python-oslo.cache >= 1.26.0
Requires:       python-oslo.config >= 5.2.0
Requires:       python-oslo.context >= 2.19.2
Requires:       python-oslo.db >= 4.27.0
Requires:       python-oslo.i18n >= 3.15.3
Requires:       python-oslo.log >= 3.36.0
Requires:       python-oslo.messaging >= 5.29.0
Requires:       python-oslo.middleware >= 3.31.0
Requires:       python-oslo.policy >= 1.30.0
Requires:       python-oslo.reports >= 1.18.0
Requires:       python-oslo.serialization >= 2.18.0
Requires:       python-oslo.service >= 1.24.0
Requires:       python-oslo.utils >= 3.33.0
Requires:       python-oslo.versionedobjects >= 1.31.2
Requires:       python-osprofiler >= 1.4.0
Requires:       python-pbr >= 2.0.0
Requires:       python-pytz >= 2013.6
Requires:       python-requests >= 2.14.2
Requires:       python-saharaclient >= 1.4.0
Requires:       python-six >= 1.10.0
Requires:       python-sqlalchemy-migrate >= 0.11.0
Requires:       python-stevedore >= 1.20.0
Requires:       python-swiftclient >= 3.2.0
Requires:       python-tenacity >= 4.4.0
Requires:       python-troveclient >= 2.2.0
Requires:       python-yaql >= 1.1.3
Requires:       python-zaqarclient >= 1.0.0

%description -n python-heat
This package contains the core Python module of OpenStack Heat.

%package api
Summary:        OpenStack Orchestration (Heat) - API
Group:          System/Management
Requires:       %{name} = %{version}

%description api
This package contains the OpenStack Heat API.

%package api-cfn
Summary:        OpenStack Orchestration (Heat) - CloudFormation API
Group:          System/Management
Requires:       %{name} = %{version}

%description api-cfn
This package contains the OpenStack Heat CloudFormation API.

%package engine
Summary:        OpenStack Orchestration (Heat) - Engine
Group:          System/Management
Requires:       %{name} = %{version}

%description engine
This package contains the OpenStack Heat Engine.

%package plugin-heat_docker
Summary:        OpenStack Orchestration (Heat) - Support for Docker
Group:          System/Management
Requires:       %{name} = %{version}
Requires:       %{name}-engine
Requires:       python-docker-py >= 0.2.2

%description plugin-heat_docker
This plugin enables using Docker containers as resources in a Heat template.

%package test
Summary:        Openstack Orchestration (Heat) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-glanceclient >= 2.8.0
Requires:       python-mock >= 2.0.0
Requires:       python-mox3 >= 0.20.0
Requires:       python-oslotest >= 3.2.0
Requires:       python-psycopg2 >= 2.6.2
Requires:       python-testrepository >= 0.0.18
Requires:       python-testresources >= 2.0.0
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 2.2.0

%description test
This package contains testsuite files for %{name}.

%prep
%setup -q -n openstack-%{component}-%{version_unconverted}
%patch1 -p 1
sed -i "s/qpid-python.*//" requirements.txt
%openstack_cleanup_prep
#NOTE(saschpe): Kill heat Sphinx extension, we're only building manpages:
sed -i -e "s/'ext.resources',\{0,1\}//" doc/source/conf.py

grep -q -E '#!/(usr/)?bin' heat/cloudinit/loguserdata.py || {
  echo "Somebody removes shebangs again :-( Fix the stupid script!"
  exit 1
}

%build
python setup.py build
PBR_VERSION=%{version_unconverted} sphinx-build -b man doc/source/ doc/build/man

pushd contrib/heat_docker
OSLO_PACKAGE_VERSION=%{version} python setup.py build
popd

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

pushd contrib/heat_docker
OSLO_PACKAGE_VERSION=%{version} python setup.py install --prefix=%{_prefix} --root=%{buildroot}
# no need for the egg-info file
rm -r %{buildroot}%{python_sitelib}/heat_contrib_docker-*.egg-info
popd

### directories
install -d -m 750 %{buildroot}%{_localstatedir}/lib/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/{cache,log}/%{component}
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf

### configuration files
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/
mv %{buildroot}/usr/etc/heat/* %{buildroot}%{_sysconfdir}/%{component}/
PYTHONPATH=. oslo-config-generator --config-file=config-generator.conf --output etc/heat/heat.conf
PYTHONPATH=. oslopolicy-sample-generator --config-file=etc/heat/heat-policy-generator.conf --output etc/heat/policy.json
rm etc/heat/heat-policy-generator.conf
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/%{component}/README.config
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/
install -p -m 644 etc/heat/*.{conf,json,ini} %{buildroot}%{_sysconfdir}/%{component}/
install -d -m 755  %{buildroot}%{_sysconfdir}/%{component}/{environment.d,templates}
install -p -m 644 etc/heat/environment.d/*.yaml %{buildroot}%{_sysconfdir}/%{component}/environment.d
install -p -m 644 etc/heat/templates/*.yaml %{buildroot}%{_sysconfdir}/%{component}/templates

### set default configuration
%define heat_conf %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
crudini --set %{heat_conf} DEFAULT log_dir /var/log/%{component}
crudini --set %{heat_conf} oslo_concurrency lock_path %{_rundir}/%{component}

### bash-completion/logrotate/etc.
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# Install systemd unit files
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir}
install -p -D -m 444 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}-api.service
install -p -D -m 444 %{SOURCE4} %{buildroot}%{_unitdir}/%{name}-api-cfn.service
install -p -D -m 444 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}-engine.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api-cfn
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-engine

### documentation
install -d %{buildroot}%{_mandir}/man1
install -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1

### test subpackage
%openstack_test_package_install
%fdupes %{buildroot}%{_localstatedir}/lib/%{name}-test

### misc
%fdupes %{buildroot}%{python_sitelib}/%{component}

%pre
%openstack_pre_user_group_create %{username} %{groupname}

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

%pre api
%service_add_pre %{name}-api.service

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

%preun api
%stop_on_removal %{name}-api
%service_del_preun %{name}-api.service

%postun api
%restart_on_update %{name}-api.service
%service_del_postun %{name}-api.service

%pre api-cfn
%service_add_pre %{name}-api-cfn.service

%post api-cfn
%service_add_post %{name}-api-cfn.service

%preun api-cfn
%stop_on_removal %{name}-api-cfn
%service_del_preun %{name}-api-cfn.service

%postun api-cfn
%restart_on_update %{name}-api-cfn.service
%service_del_postun %{name}-api-cfn.service

%pre engine
%service_add_pre %{name}-engine.service

%post engine
%service_add_post %{name}-engine.service

%preun engine
%stop_on_removal %{name}-engine
%service_del_preun %{name}-engine.service

%postun engine
%restart_on_update %{name}-engine
%service_del_postun %{name}-engine.service

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/lib/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%{_tmpfilesdir}/%{name}.conf
%dir %{_sysconfdir}/%{component}
%dir %{_sysconfdir}/%{component}/%{component}.conf.d/
%{_sysconfdir}/%{component}/README.config
%config %{_sysconfdir}/%{component}/policy.json
%config %{_sysconfdir}/%{component}/environment.d
%config %{_sysconfdir}/%{component}/templates
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/heat.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/api-paste.ini
%{_bindir}/heat-db-setup
%{_bindir}/heat-manage
%{_bindir}/heat-keystone-setup
%{_bindir}/heat-keystone-setup-domain
%{_bindir}/heat-all
%{_mandir}/man1/%{component}-manage.1%{?ext_man}
%{_mandir}/man1/%{component}-db-setup.1%{?ext_man}
%{_mandir}/man1/%{component}-keystone-setup.1%{?ext_man}
%{_mandir}/man1/%{component}-keystone-setup-domain.1%{?ext_man}

%files -n python-%{component}
%defattr(-,root,root,-)
%doc LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/openstack_%{component}-*.egg-info
%{python_sitelib}/heat_integrationtests

%files api
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/heat-*api
%{_sbindir}/rc%{name}-api
%{_unitdir}/%{name}-api.service
%{_mandir}/man1/%{component}-api.1%{?ext_man}

%files api-cfn
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/heat-*api-cfn
%{_sbindir}/rc%{name}-api-cfn
%{_unitdir}/%{name}-api-cfn.service
%{_mandir}/man1/%{component}-api-cfn.1%{?ext_man}

%files engine
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/heat-engine
%{_sbindir}/rc%{name}-engine
%{_unitdir}/%{name}-engine.service
%dir %{_prefix}/lib/heat/
%{_mandir}/man1/%{component}-engine.1%{?ext_man}

%files plugin-heat_docker
%defattr(-,root,root,-)
%{_prefix}/lib/heat/docker/

%files test
%defattr(-,root,root)
%{_localstatedir}/lib/%{name}-test/

%changelog