File RackTables.spec of Package RackTables

#
# spec file for package RackTables
#
# Copyright (c) 2019 SUSE LCC
#
# 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 app_dir %{_datadir}/%{name}
%define app_config_dir %{_sysconfdir}/%{name}
Name:           RackTables
Version:        0.22.0
Release:        0
Summary:        A solution for datacenter and server room asset management
License:        GPL-2.0-only
Group:          Productivity/Databases/Tools
URL:            http://racktables.org/
Source0:        %{name}-%{version}.tar.gz
Source1:        racktables.abstraction.apparmor
Source2:        racktables.conf
Source4:        RackTables-search.xml
Source5:        pageheaders.php
Source6:        README.SUSE
Source7:        RackTables-rpmlintrc
Source8:        racktables.conf.snipplet
BuildRequires:  sed
Requires:       http_daemon
Requires:       mod_php_any
Requires:       php-bcmath
Requires:       php-ctype
Requires:       php-curl
Requires:       php-gd
Requires:       php-json
Requires:       php-ldap
Requires:       php-mbstring
Requires:       php-mysql
Requires:       php-openssl
Requires:       php-pcntl
Requires:       php-pdo
Requires:       php-snmp
Recommends:     apache2-mod_apparmor
Recommends:     php-iconv
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Racktables is a nifty and robust solution for datacenter and server room asset
management. It helps document hardware assets, network addresses, space in
racks, networks configuration and much much more!

%prep
%setup -q
# fix env usage
for file in scripts/*.php ; do
	sed -i "s|/usr/bin/env php|%{_bindir}/php|g" "$file"
done
sed -i "s|/usr/bin/env python|%{_bindir}/python|g" gateways/ucssdk
sed -i "s|/usr/bin/env perl|%{_bindir}/perl|g" gateways/*

%build
#
%install
mkdir -p %{buildroot}%{app_config_dir}/ %{buildroot}/%{app_dir}/plugins
make DESTDIR=%{buildroot} prefix=%{_prefix} docdir=%{_defaultdocdir}/%{name} install install-docs
# config.php
mv wwwroot/inc/config.php %{buildroot}%{app_config_dir}/
ln -s %{app_config_dir}/config.php %{buildroot}/%{app_dir}/wwwroot/
install -D -m 0640 %{SOURCE1} %{buildroot}%{_sysconfdir}/apparmor.d/abstractions/%{name}
# Apache configuration
install -D -m 0640 %{SOURCE2} %{buildroot}%{_sysconfdir}/apache2/vhosts.d/%{name}.conf.in
install -D -m 0640 %{SOURCE8} %{buildroot}%{_sysconfdir}/apache2/conf.d/racktables.conf
# RackTables-search.xml
install -m 0644 %{SOURCE4} %{buildroot}/%{app_config_dir}/RackTables-search.xml
ln -s %{app_config_dir}/RackTables-search.xml %{buildroot}/%{app_dir}/wwwroot/
# adapt default MySQL socket suggested by the installer:
sed -i "s|%{_localstatedir}/lib/mysql/mysql.sock|/run/mysql/mysql.sock|g" %{buildroot}/%{app_dir}/wwwroot/inc/install.php
# secret.php as ghost
touch %{buildroot}/%{app_config_dir}/secret.php
# pageheaders.php
install -m 0644 %{SOURCE5} %{buildroot}/%{app_config_dir}/pageheaders.php
ln -s %{app_config_dir}/pageheaders.php %{buildroot}%{app_dir}/plugins/pageheaders.php
install -m 644 %{SOURCE6} %{buildroot}%{_defaultdocdir}/%{name}/README.SUSE
test -d %{buildroot}/%{app_dir}/wwwroot/inc/inc && rmdir %{buildroot}/%{app_dir}/wwwroot/inc/inc
# plugins
cp -a plugins/* %{buildroot}%{app_dir}/plugins/

%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name}/*
%dir %{_defaultdocdir}/%{name}
%dir %{app_config_dir}
%dir %{app_dir}
%dir %{_sysconfdir}/apparmor.d/
%dir %{_sysconfdir}/apparmor.d/abstractions
%config(noreplace) %{_sysconfdir}/apparmor.d/abstractions/%{name}
%dir %{_sysconfdir}/apache2
%dir %{_sysconfdir}/apache2/vhosts.d/
%dir %{_sysconfdir}/apache2/conf.d/
%config %{_sysconfdir}/apache2/vhosts.d/%{name}.conf.in
%config(noreplace) %{_sysconfdir}/apache2/conf.d/racktables.conf
%{app_dir}/*
# config.php contains just the current version of the application, which is used to
# identify if an upgrade is needed. So using (noreplace) here does not make sense.
%attr(0640,root,www) %config %{app_config_dir}/config.php
# normal configuration files that can be changed by the user
%attr(0644,root,root) %config(noreplace) %{app_config_dir}/RackTables-search.xml
%attr(0644,root,root) %config(noreplace) %{app_config_dir}/pageheaders.php
%ghost %config(noreplace) %{app_config_dir}/secret.php
# also package the two example plugins for reference
%{app_dir}/plugins/README
%dir %{app_dir}/plugins/cacti
%{app_dir}/plugins/cacti/*
%dir %{app_dir}/plugins/munin
%{app_dir}/plugins/munin/*

%changelog
openSUSE Build Service is sponsored by