File orthos2.spec of Package orthos2
#
# spec file for package orthos2
#
# 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/
#
Name: orthos2
Version: 1.3.51+git.127edfa
Release: 0
Summary: Machine administration
URL: https://github.com/openSUSE/orthos2
Group: Productivity/Networking/Boot/Servers
%{?systemd_ordering}
License: GPL-2.0-or-later
Source: orthos2-%{version}.tar.gz
%if 0%{?suse_version}
Source1: orthos2.rpmlintrc
%endif
Source2: system-user-orthos.conf
BuildArch: noarch
BuildRequires: fdupes
BuildRequires: systemd-rpm-macros
# For /etc/nginx{,/conf.d} creation
BuildRequires: nginx
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires(post): sudo
%if 0%{?suse_version}
BuildRequires: python-rpm-macros
%endif
BuildRequires: sysuser-tools
%sysusers_requires
# Finds python dependencies based on egg info generated by setup.py
# Theoretically distro independent and should work this way, but has
# quite some pitfalls. Only works after SLE 15 SP2, due to build service
# restrictions (be careful, there they messed it up and
# python_enable_dependency_generator macro is defined, but does not do
# anything. This check still also needs to explicitly check for SLE 15 SP2...
%if 0%{?sle_version} <= 150300
%undefine python_enable_dependency_generator
%undefine python_disable_dependency_generator
%endif
%{?python_enable_dependency_generator}
%if ! (%{defined python_enable_dependency_generator} || %{defined python_disable_dependency_generator})
Requires: python3-Django >= 3.2
Requires: python3-django-auth-ldap
Requires: python3-django-extensions
Requires: python3-djangorestframework
Requires: python3-ldap
Requires: python3-netaddr
Requires: python3-paramiko
Requires: python3-psycopg2
Requires: python3-validators
%endif
# Needed to install /etc/logrotate.d/orthos2
Requires: python3-Django >= 3.2
Requires: /sbin/service
Requires: ansible
Requires: logrotate
Requires: nginx
Requires: uwsgi
Requires: uwsgi-python3
Requires: user(orthos)
Requires: group(orthos)
Provides: orthos2-%{version}-%{release}
%description
Orthos is the machine administration tool of the development network at SUSE. It is used for following tasks:
getting the state of the machine
overview about the hardware
overview about the installed software (installations)
reservation of the machines
generating the DHCP configuration (via Cobbler)
reboot the machines remotely
managing remote (serial) consoles
%package docs
Summary: HTML documentation for orthos2
BuildRequires: python3-Sphinx
BuildRequires: python3-django >= 3.2
BuildRequires: python3-django-auth-ldap
BuildRequires: python3-django-extensions
BuildRequires: python3-djangorestframework
BuildRequires: python3-ldap
BuildRequires: python3-netaddr
BuildRequires: python3-paramiko
BuildRequires: python3-sphinx_rtd_theme
BuildRequires: python3-validators
%package -n system-user-orthos
Summary: Orthos user and group
Group: System
Requires(pre): pwdutils
Provides: group(orthos)
Provides: user(orthos)
BuildArch: noarch
%description -n system-user-orthos
Orthos user and group required by orthos2 package
%define orthos_web_docs /srv/www/orthos2/docs
%description docs
HTML documentation that can be put into a web servers htdocs directory for publishing.
%prep
%setup
%build
%sysusers_generate_pre %{SOURCE2} orthos system-user-orthos.conf
%py3_build
cd docs
make html
%install
install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/system-user-orthos.conf
%py3_install
# docs
mkdir -p %{buildroot}%{orthos_web_docs}
# client is built via separate spec file to reduce build dependencies
rm %{buildroot}/usr/bin/orthos2
cp -r docs/_build/html/* %{buildroot}%{orthos_web_docs}
%fdupes %{buildroot}/%{orthos_web_docs}
#systemd
ln -sr %{buildroot}%{python3_sitelib}/orthos2 %{buildroot}/usr/lib/orthos2/orthos2
cp -r ansible %{buildroot}/usr/lib/orthos2/ansible
%pre -n system-user-orthos -f orthos.pre
%pre
%service_add_pre orthos2.service orthos2_taskmanager.service orthos2.socket orthos2_debug.service
%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post orthos2.service orthos2_taskmanager.service orthos2.socket orthos2_debug.service
echo "no sudo available..... and no i will not think of workaround for this for obs..."
echo "run orthos-admin migrate"
echo "run orthos-admin collectstatic --noinput"
%preun
%service_del_preun orthos2.service orthos2_taskmanager.service orthos2.socket orthos2_debug.service
%postun
%service_del_postun orthos2.service orthos2_taskmanager.service orthos2.socket orthos2_debug.service
%files
%{python3_sitelib}/orthos2-*
%{_unitdir}/orthos2_taskmanager.service
%{_unitdir}/orthos2.service
%{_unitdir}/orthos2_debug.service
%{_unitdir}/orthos2.socket
%{_tmpfilesdir}/orthos2.conf
%dir %{python3_sitelib}/orthos2/
%{python3_sitelib}/orthos2/*
%dir %{_sysconfdir}/orthos2
%config %{_sysconfdir}/orthos2/orthos2.ini
%config %{_sysconfdir}/orthos2/settings
%config %{_sysconfdir}/logrotate.d/orthos2
%config(noreplace) %{_sysconfdir}/nginx/conf.d/orthos2_nginx.conf
%dir /usr/lib/orthos2
%dir /usr/lib/orthos2/scripts
%dir /usr/share/orthos2
%dir /usr/share/orthos2/fixtures
/usr/share/orthos2/fixtures/*
/usr/lib/orthos2/*
%attr(755,orthos,orthos) %{_bindir}/orthos-admin
%attr(755,orthos,orthos) %dir /srv/www/orthos2
%ghost %dir /run/%{name}
%ghost %dir /run/%{name}/tmp
%ghost %dir /run/%{name}/ansible
%ghost %dir /run/%{name}/ansible_lastrun
%ghost %dir /run/%{name}/ansible_archive
%attr(755,orthos,orthos) %dir /var/log/orthos2
%attr(775,orthos,orthos) %dir /var/lib/orthos2
%attr(775,orthos,orthos) %dir /var/lib/orthos2/archiv
%attr(775,orthos,orthos) %dir /var/lib/orthos2/orthos-vm-images
%attr(775,orthos,orthos) %dir /var/lib/orthos2/database
%attr(700,orthos,orthos) %dir /var/lib/orthos2/.ssh
# defattr(fileattr, user, group, dirattr)
# Add whole ansible directory with correct attr for dirs and files
# Always keep this at the end with defattr
#%%defattr(664, orthos, orthos, 775)
#/usr/lib/orthos2/ansible
%files docs
%dir %{orthos_web_docs}
%{orthos_web_docs}/*
%files -n system-user-orthos
%{_sysusersdir}/system-user-orthos.conf
%changelog