File openstack-keystone.spec of Package openstack-keystone

#
# spec file for package openstack-keystone
#
# Copyright (c) 2024 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-keystone
Epoch:          0
Version:        25.1.0~dev65
Release:        0
Summary:        OpenStack Identity Service
License:        Apache-2.0
URL:            https://docs.openstack.org/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:  python3-Flask
BuildRequires:  python3-Flask-RESTful
BuildRequires:  python3-WebTest
BuildRequires:  python3-bcrypt
BuildRequires:  python3-fixtures
BuildRequires:  python3-freezegun
BuildRequires:  python3-jsonschema
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-ldappool
BuildRequires:  python3-lxml
BuildRequires:  python3-oauthlib
BuildRequires:  python3-oslo.cache
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.messaging
BuildRequires:  python3-oslo.policy
BuildRequires:  python3-oslo.upgradecheck
BuildRequires:  python3-oslotest
BuildRequires:  python3-osprofiler
BuildRequires:  python3-passlib
BuildRequires:  python3-pbr
BuildRequires:  python3-pysaml2
BuildRequires:  python3-requests
BuildRequires:  python3-scrypt
BuildRequires:  python3-sqlparse
BuildRequires:  python3-stestr
BuildRequires:  python3-testresources
BuildRequires:  python3-testscenarios
BuildRequires:  python3-testtools
BuildRequires:  which
Requires:       logrotate
Requires:       python3-keystone = %{epoch}:%{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     python3-keystone
Summary:        Keystone Python libraries
Group:          Applications/System
Requires:       python-ldap
Requires:       python3-Babel
Requires:       python3-Flask
Requires:       python3-Flask-RESTful
Requires:       python3-PyJWT
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-bcrypt
Requires:       python3-cryptography
Requires:       python3-dogpile.cache
Requires:       python3-jsonschema
Requires:       python3-keystoneclient
Requires:       python3-keystonemiddleware
Requires:       python3-ldappool
Requires:       python3-msgpack
Requires:       python3-oauthlib
Requires:       python3-oslo.cache
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.upgradecheck
Requires:       python3-oslo.utils
Requires:       python3-osprofiler
Requires:       python3-passlib
Requires:       python3-pbr
Requires:       python3-pycadf
Requires:       python3-pysaml2
Requires:       python3-python-memcached
Requires:       python3-pytz
Requires:       python3-scrypt
Requires:       python3-sqlalchemy-migrate
Requires:       python3-stevedore

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

%package -n python3-keystone-tests
Summary:        Keystone tests
Requires:       openstack-keystone = %{epoch}:%{version}-%{release}
Provides:       python-keystone-tests = %{epoch}:%{version}-%{release}

%description -n python3-keystone-tests
Keystone is a Python implementation of the OpenStack
(https://docs.openstack.org/keystone/latest/) identity service API.

This package contains the Keystone test files.

%if 0%{?with_doc}
%package doc
Summary:        Documentation for OpenStack Identity Service
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinx-feature-classification
BuildRequires:  python3-sphinxcontrib-apidoc
BuildRequires:  python3-sphinxcontrib-blockdiag
BuildRequires:  python3-sphinxcontrib-seqdiag

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

%prep
%autosetup -p1 -n keystone-25.1.0.dev65
%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

%build
%{py3_build}

# doc
%if 0%{?with_doc}
PYTHONPATH=. PBR_VERSION=25.1.0.dev65 %sphinx_build -b html doc/source doc/build/html
PYTHONPATH=. PBR_VERSION=25.1.0.dev65 %sphinx_build -b man doc/source doc/build/man
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
rm -rf doc/build/man/.{doctrees,buildinfo}
%endif

# config file generation
PYTHONPATH=. 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
%{py3_install}
install -d -m 755 %{buildroot}%{_sysconfdir}/keystone
install -d -m 755 %{buildroot}%{_sysconfdir}/sysctl.d
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log,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.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 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysctl.d/openstack-keystone.conf
# remove wrongly installed tree
rm -rv  %{buildroot}/%{_prefix}%{_sysconfdir}/
# 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/

# 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 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
%if 0%{?suse_version}
PYTHON=python3 stestr run --exclude-regex keystone.tests.unit.test_policy.GeneratePolicyFileTestCase.test_policy_generator_from_command_line
%endif
%if 0%{?rdo}
stestr-3 run --exclude-regex keystone.tests.unit.test_policy.GeneratePolicyFileTestCase.test_policy_generator_from_command_line
%endif

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

%files
%license LICENSE
%doc README.rst
%{_bindir}/keystone-wsgi-admin
%{_bindir}/keystone-wsgi-public
%{_bindir}/keystone-manage
%{_bindir}/keystone-status
%_tmpfilesdir/keystone.conf
%dir %{_datadir}/keystone
%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/
%dir %attr(0750, root, keystone) %{_sysconfdir}/keystone/credential-keys
%{_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/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(0750, 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
%if 0%{?with_doc}
%{_mandir}/man1/keystone-manage.1.gz
%endif

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

%files -n python3-keystone-tests
%license LICENSE
%{python3_sitelib}/keystone/tests

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

%changelog
openSUSE Build Service is sponsored by