File openstack-keystone.spec of Package openstack-keystone

#
# spec file for package openstack-keystone
#
# Copyright (c) 2017 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.

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


%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           openstack-keystone
Version:        12.0.0.0~rc2~dev40
Release:        0
Summary:        OpenStack Identity Service
License:        Apache-2.0
Group:          Applications/System
Url:            https://launchpad.net/keystone
Source0:        keystone-master.tar.gz
Source1:        openstack-keystone.logrotate
Source2:        openstack-keystone.sysctl
Source3:        openstack-keystone.tmpfiles
Source4:        openstack-keystone.defaultconf
Source5:        openstack-keystone.README.config
BuildRequires:  openstack-macros
BuildRequires:  openstack-tempest
BuildRequires:  python-WebTest >= 2.0
BuildRequires:  python-bcrypt >= 3.1.3
BuildRequires:  python-devel
BuildRequires:  python-fixtures >= 3.0.0
BuildRequires:  python-freezegun >= 0.3.6
BuildRequires:  python-lxml >= 2.3
BuildRequires:  python-mock >= 2.0
BuildRequires:  python-os-api-ref >= 1.0.0
BuildRequires:  python-os-testr >= 0.8.0
BuildRequires:  python-oslo.cache >= 1.5.0
BuildRequires:  python-oslo.config >= 4.0.0
BuildRequires:  python-oslotest >= 1.10.0
BuildRequires:  python-osprofiler >= 1.4.0
BuildRequires:  python-pbr >= 2.0.0
BuildRequires:  python-python-subunit >= 0.0.18
BuildRequires:  python-reno >= 1.8.0
BuildRequires:  python-requests >= 2.14.2
BuildRequires:  python-scrypt >= 0.8.0
BuildRequires:  python-testrepository >= 0.0.18
BuildRequires:  python-testresources >= 0.2.4
BuildRequires:  python-testtools >= 1.4.0
Requires:       python-keystone = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  libxmlsec1-openssl1
Requires(pre):  pwdutils
%endif
%if 0%{?rdo}
BuildRequires:  xmlsec1-openssl
Requires(pre):  shadow-utils
%endif

%description
Keystone is a Python implementation of the OpenStack
(http://www.openstack.org) identity service API.
.
This package contains the keystone python libraries.

%package -n     python-keystone
Summary:        Keystone Python libraries
Group:          Applications/System
Requires:       python-Babel >= 2.3.4
Requires:       python-Paste
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-PyMySQL >= 0.7.6
Requires:       python-Routes >= 2.3.1
Requires:       python-SQLAlchemy >= 1.0.10
Requires:       python-WebOb >= 1.7.1
Requires:       python-bcrypt >= 3.1.3
Requires:       python-cryptography >= 1.6
Requires:       python-dogpile.cache >= 0.6.2
Requires:       python-jsonschema >= 2.0.0
Requires:       python-keystoneclient >= 3.8.0
Requires:       python-keystonemiddleware >= 4.12.0
Requires:       python-ldappool >= 2.0.0
Requires:       python-msgpack-python >= 0.4.0
Requires:       python-oauthlib >= 0.6
Requires:       python-oslo.cache >= 1.5.0
Requires:       python-oslo.concurrency >= 3.8.0
Requires:       python-oslo.config >= 4.0.0
Requires:       python-oslo.context >= 2.14.0
Requires:       python-oslo.db >= 4.23.0
Requires:       python-oslo.i18n >= 2.1.0
Requires:       python-oslo.log >= 3.22.0
Requires:       python-oslo.messaging >= 5.24.2
Requires:       python-oslo.middleware >= 3.27.0
Requires:       python-oslo.policy >= 1.23.0
Requires:       python-oslo.serialization >= 1.10.0
Requires:       python-oslo.utils >= 3.20.0
Requires:       python-osprofiler >= 1.4.0
Requires:       python-passlib >= 1.7.0
Requires:       python-pbr >= 2.0.0
Requires:       python-pycadf >= 1.1.0
Requires:       python-pysaml2 >= 2.4.0
Requires:       python-python-memcached >= 1.56
Requires:       python-six >= 1.9.0
Requires:       python-sqlalchemy-migrate >= 0.11.0
Requires:       python-stevedore >= 1.20.0
%if 0%{?suse_version}
Requires:       python-pyldap >= 2.4.20
%endif
%if 0%{?rdo}
Requires:       python-ldap
%endif

%description -n   python-keystone
Keystone is a Python implementation of the OpenStack
(http://docs.openstack.org/developer/keystone/) identity service API.
This package contains the Keystone Python library.

%package doc
Summary:        Documentation for OpenStack Identity Service
Group:          Documentation
BuildRequires:  python-PasteDeploy >= 1.5.0
BuildRequires:  python-Routes >= 2.3.1
BuildRequires:  python-Sphinx
BuildRequires:  python-cryptography >= 1.6
BuildRequires:  python-dogpile.cache >= 0.6.2
BuildRequires:  python-jsonschema >= 2.0.0
BuildRequires:  python-keystonemiddleware >= 4.12.0
BuildRequires:  python-ldappool >= 2.0.0
BuildRequires:  python-msgpack-python >= 0.4.0
BuildRequires:  python-oauthlib >= 0.6
BuildRequires:  python-oslo.concurrency >= 3.8.0
BuildRequires:  python-oslo.db >= 4.23.0
BuildRequires:  python-oslo.i18n >= 2.1.0
BuildRequires:  python-oslo.log >= 3.22.0
BuildRequires:  python-oslo.messaging >= 5.24.2
BuildRequires:  python-oslo.middleware >= 3.27.0
BuildRequires:  python-oslo.policy >= 1.23.0
BuildRequires:  python-oslosphinx >= 4.7.0
BuildRequires:  python-passlib >= 1.7.0
BuildRequires:  python-pysaml2 >= 2.4.0
BuildRequires:  python-python-memcached >= 1.56

%description doc
OpenStack Keystone documentaion.
.
This package contains the documentation

%prep
%autosetup -p1 -n keystone-12.0.0.0rc2.dev40
%py_req_cleanup
%if 0%{?rdo}
find . \( -name .gitignore -o -name .placeholder \) -delete
find keystone -name \*.py -exec sed -i '/\/usr\/bin\/env python/d' {} \;
# adjust paths to WSGI scripts
sed -i 's#/local/bin#/bin#' httpd/wsgi-keystone.conf
sed -i 's#apache2#httpd#' httpd/wsgi-keystone.conf
%endif
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg

%build
%{py2_build}

%{__python2} setup.py build_sphinx --builder=html,man
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
# config file generation
oslo-config-generator --config-file config-generator/keystone.conf \
--output-file etc/keystone.conf.sample
# policy file generation
oslopolicy-sample-generator --config-file config-generator/keystone-policy-generator.conf --output-file etc/keystone.policy.yaml

%install
%{py2_install}
mkdir -p %{buildroot}%{_mandir}/man1
install -d -m 755 %{buildroot}%{_sysconfdir}/keystone
install -d -m 755 %{buildroot}%{_sysconfdir}/sysctl.d
install -d -m 755 %{buildroot}%{_localstatedir}/{lib,log}/keystone
install -d -m 750 %{buildroot}%{_localstatedir}/cache/keystone
install -d -m 755 %{buildroot}%{_sysconfdir}/keystone/keystone.conf.d/
# default dir for fernet tokens
install -d -m 750 %{buildroot}%{_sysconfdir}/keystone/credential-keys/
install -D -m 644 %{SOURCE3} %{buildroot}/%{_tmpfilesdir}/keystone.conf
install -p -D -m 640 etc/keystone.conf.sample %{buildroot}%{_sysconfdir}/keystone/keystone.conf
install -D -m 640 %{SOURCE4} %{buildroot}/%{_sysconfdir}/keystone/keystone.conf.d/010-keystone.conf
install -D -m 440 %{SOURCE5} %{buildroot}/%{_sysconfdir}/keystone/README.config
install -p -D -m 640 etc/logging.conf.sample %{buildroot}%{_sysconfdir}/keystone/logging.conf
install -p -D -m 640 etc/keystone-paste.ini %{buildroot}%{_sysconfdir}/keystone/keystone-paste.ini
install -p -D -m 640 etc/keystone.policy.yaml %{buildroot}%{_sysconfdir}/keystone/keystone.policy.yaml
install -p -D -m 640 etc/default_catalog.templates %{buildroot}%{_sysconfdir}/keystone/default_catalog.templates
install -p -D -m 640 etc/sso_callback_template.html %{buildroot}%{_sysconfdir}/keystone/sso_callback_template.html
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-keystone
install -p -D -m 644 etc/policy.v3cloudsample.json %{buildroot}%{_datadir}/keystone/policy.v3cloudsample.json
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysctl.d/openstack-keystone.conf
install -p -D -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1/
# Install sample data script.
install -p -D -m 755 tools/sample_data.sh %{buildroot}%{_datadir}/keystone/sample_data.sh
# Install apache configuration files
install -p -D -m 644 httpd/wsgi-keystone.conf  %{buildroot}%{_datadir}/keystone/

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

%check
# don't want to depend on hacking for package building
rm keystone/tests/unit/test_hacking_checks.py
%{__python2} setup.py testr

%post
%tmpfiles_create %{_tmpfilesdir}/keystone.conf
%sysctl_apply openstack-keystone.conf

%files
%license LICENSE
%doc README.rst
%{_mandir}/man1/keystone*.1.gz
%{_bindir}/keystone-wsgi-admin
%{_bindir}/keystone-wsgi-public
%{_bindir}/keystone-manage
%_tmpfilesdir/keystone.conf
%dir %{_datadir}/keystone
%attr(0644, root, keystone) %{_datadir}/keystone/policy.v3cloudsample.json
%attr(0755, root, root) %{_datadir}/keystone/sample_data.sh
%attr(0644, root, keystone) %{_datadir}/keystone/wsgi-keystone.conf
%dir %attr(0750, root, keystone) %{_sysconfdir}/keystone/
%dir %attr(0750, root, keystone) %{_sysconfdir}/keystone/keystone.conf.d/
%{_sysconfdir}/keystone/README.config
%config(noreplace) %attr(0640, root, keystone) %{_sysconfdir}/keystone/keystone.conf
%config(noreplace) %attr(0640, root, keystone) %{_sysconfdir}/keystone/keystone.conf.d/010-keystone.conf
%config(noreplace) %attr(0640, root, keystone) %{_sysconfdir}/keystone/keystone-paste.ini
%config(noreplace) %attr(0640, root, keystone) %{_sysconfdir}/keystone/logging.conf
%config(noreplace) %attr(0640, root, keystone) %{_sysconfdir}/keystone/default_catalog.templates
%config(noreplace) %attr(0640, keystone, keystone) %{_sysconfdir}/keystone/keystone.policy.yaml
%config(noreplace) %attr(0640, keystone, keystone) %{_sysconfdir}/keystone/sso_callback_template.html
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-keystone
%dir %attr(0755, %{keystone}, %{keystone}) %{_localstatedir}/lib/keystone
%dir %attr(0750, %{keystone}, %{keystone}) %{_localstatedir}/log/keystone
%dir %attr(0750, %{keystone}, %{keystone}) %{_localstatedir}/cache/keystone
%{_sysconfdir}/sysctl.d/openstack-keystone.conf

%files -n python-keystone
%defattr(-,root,root,-)
%doc README.rst
%license LICENSE
%{python2_sitelib}/keystone*
%{python2_sitelib}/keystone-*.egg-info

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

%changelog