File xdmod.spec of Package xdmod

#
# spec file for package xdmod
#
# Copyright (c) 2023 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 vers_suf -2

Name:           xdmod
Version:        10.0.2
Release:        0
Summary:        Data warehouse for resource managers
URL:            http://open.xdmod.org/
License:        LGPL-3.0-or-later
Source:         https://github.com/ubccr/xdmod/releases/download/v%{version}%{?vers_suf}/xdmod-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  cron
BuildRequires:  fdupes
BuildRequires:  php-cli
BuildRequires:  sysuser-tools
Requires:       chromium-headless >= 111
Requires:       crontabs
Requires:       httpd
Requires:       jq
Requires:       libreoffice-writer
Requires:       librsvg2-tools
Requires:       logrotate
Requires:       mariadb >= 10.3.17
Requires:       mod_ssl
Requires:       perl-Image-ExifTool
Requires:       php >= 7.2
Requires:       php-cli
Requires:       php-gd
Requires:       php-json
Requires:       php-mbstring
Requires:       php-mysqlnd
Requires:       php-pdo
Requires:       php-pecl-apcu
Requires:       php-posix
Requires:       php-xml
Requires:       php-zip
Requires:       nodejs(engine) >= 16.18.1

%description
XDMoD is a data warehouse and web portal for mining statistical data
from resource managers in high-performance computing environments.
XDMoD presents resource utilization over set time periods and provides
detailed interactive charts, graphs, and tables.

%define xdmod_export_dir %{_var}/spool/%{name}/export

%prep
%autosetup

%install
%make_install
DESTDIR=$RPM_BUILD_ROOT ./install \
    --quiet \
    --rpm \
    --bindir=%{_bindir} \
    --libdir=%{_prefix}/lib/%{name} \
    --sysconfdir=%{_sysconfdir}/%{name} \
    --datadir=%{_datadir}/%{name} \
    --docdir=%{_docdir}/%{name}-%{version}__PRERELEASE__ \
    --logdir=%{_localstatedir}/log/%{name} \
    --httpdconfdir=%{_sysconfdir}/httpd/conf.d \
    --logrotatedconfdir=%{_sysconfdir}/logrotate.d \
    --crondconfdir=%{_sysconfdir}/cron.d
mkdir -p $RPM_BUILD_ROOT%{xdmod_export_dir}
# create systemuser
echo "u xdmod -" > system-user-%{name}.conf
echo "g xdmod -" >> system-user-%{name}.conf
%sysusers_generate_pre system-user-%{name}.conf %{name} system-user-%{name}.conf
install -D -m 644 system-user-%{name}.conf %{buildroot}%{_sysusersdir}/system-user-%{name}.conf

%fdupes %{buildroot}%{_libdir}/%{name}
%fdupes %{buildroot}%{_datadir}/%{name}

#remove the env-script-interpreter
find %{buildroot} -path \*/bin/\* -type f -exec  sed -i 's%#!/usr/bin/env \([^/]*\)%#!/usr/bin/\1%' {} \;
find %{buildroot} -name \*.php -type f -exec  sed -i 's%#!/usr/bin/env \([^/]*\)%#!/usr/bin/\1%' {} \;
find %{buildroot} -name \*.js -type f -exec  sed -i 's%#!/usr/bin/env \([^/]*\)%#!/usr/bin/\1%' {} \;
find %{buildroot}%{_datadir}/%{name} -path \*vendor\* -name \*.[hc] -delete

%post

%postun

%files
%defattr(0750,root,xdmod,-)
%{_bindir}/%{name}-*
%{_bindir}/acl-*

%defattr(-,root,root,-)
%{_prefix}/lib/%{name}/
%{_datadir}/%{name}/
%{_docdir}/%{name}-%{version}__PRERELEASE__/

%dir %attr(0770,apache,xdmod) %{_localstatedir}/log/%{name}

%dir %{_sysconfdir}/%{name}
%config(noreplace) %attr(0440,apache,xdmod) %{_sysconfdir}/%{name}/portal_settings.ini
%config(noreplace) %{_sysconfdir}/%{name}/*.d/
%config(noreplace) %{_sysconfdir}/%{name}/*.json
%config(noreplace) %{_sysconfdir}/%{name}/email_templates/
%config(noreplace) %{_sysconfdir}/%{name}/etl/
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%config(noreplace) %{_datadir}/%{name}/html/robots.txt
%{_sysusersdir}/system-user-%{name}.conf

%dir %attr(0570,apache,xdmod) %{xdmod_export_dir}
%dir %{_var}/spool/%{name}

%changelog
openSUSE Build Service is sponsored by