File baculum.spec of Package baculum
%global langs_api en pl pt ru
%global langs_web en pl pt ja ru
%global destdir build
%global metaname baculum
#Vendor: JSI Data Systems Ltd
#Distribution: openSUSE LEAP 15.0
Summary: Baculum WebGUI tool for Bacula Community program
Name: baculum
Version: 11.0.5.4
Release: 1
License: AGPLv3
Group: Productivity/Archiving/Backup
URL: http://bacula.org/
Source0: bacula-gui-11.0.5.4.tar.gz
Source1: baculum.sudoers
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
BuildRequires: checkpolicy
BuildRequires: apache2
BuildRequires: apache-rpm-macros-control
BuildRequires: lighttpd
# Lower version of PHP ( < 5.3.4) does not provide php-mysqlnd db driver
# and from this reason the lowest is 5.3.4
Requires: php >= 5.3.4
Requires: php-bcmath
#Requires: php-common
Requires: php-curl
Requires: php-mbstring
Requires: php-mysql
Requires: php-pdo
Requires: php-pgsql
Requires: php-xml
BuildArch: noarch
%description
The Baculum program allows the user to administer and manage Bacula jobs.
By using Baculum it is possible to execute backup/restore operations, monitor
current Bacula jobs, configure Bacula, media management and others. Baculum has
integrated web console that communicates with Bacula bconsole program.
%package common
Summary: Common libraries for Baculum
Group: Productivity/Archiving/Backup
%description common
This package provides the common libraries for Baculum.
This module is a part of Baculum.
%package api
Summary: Baculum API files
Requires: %name-common = %version-%release
Group: Productivity/Archiving/Backup
# Lower version of PHP ( < 5.3.4) does not provide php-mysqlnd db driver
# and from this reason the lowest is 5.3.4
Requires: php >= 5.3.4
Requires: php-bcmath
#Requires: php-common
Requires: php-json
Requires: php-mysql
Requires: php-pdo
Requires: php-pgsql
Requires: php-xml
%description api
This package provides the API files for Baculum.
This module is a part of Baculum.
%package web
Summary: Baculum API files
Requires: %name-common = %version-%release
Group: Productivity/Archiving/Backup
# Lower version of PHP ( < 5.3.4) does not provide php-mysqlnd db driver
# and from this reason the lowest is 5.3.4
Requires: php >= 5.3.4
#Requires: php-common
Requires: php-json
Requires: php-mbstring
Requires: php-xml
%description web
This package provides the Web files for Baculum.
This module is a part of Baculum.
%package api-apache
Summary: Apache configuration for Baculum API
Requires: %name-api = %version-%release
Group: Productivity/Archiving/Backup
Requires: apache2
# This conflict field is required because Lighttpd and Apache
# cannot listen on the same port at the same time. Even using diffeernt
# ports cause problems like shared framework cache and
# web server specific directories permissions (for lighttpd and apache
# users).
Conflicts: %{name}-api-lighttpd, %{name}-web-lighttpd
%description api-apache
This package provides the Apache configuration for Baculum API.
By using this module it is possible to run Baculum API in Apache environment.
%package api-lighttpd
Summary: Lighttpd configuration for Baculum API
Requires: %name-api = %version-%release
Group: Productivity/Archiving/Backup
Requires: lighttpd
Requires: lighttpd-fastcgi
# This conflict field is required because Lighttpd and Apache
# cannot listen on the same port at the same time. Even using diffeernt
# ports cause problems like shared framework cache and
# web server specific directories permissions (for lighttpd and apache
# users).
Conflicts: %{name}-api-apache, %{name}-web-apache
%description api-lighttpd
This package provides the Lighttpd configuration for Baculum API.
By using this module it is possible to run Baculum API in Lighttpd environment.
%package web-apache
Summary: Apache configuration for Baculum WebGUI
Requires: %name-web = %version-%release
Group: Productivity/Archiving/Backup
Requires: apache2
# This conflict field is required because Lighttpd and Apache
# cannot listen on the same port at the same time. Even using diffeernt
# ports cause problems like shared framework cache and
# web server specific directories permissions (for lighttpd and apache
# users).
Conflicts: %{name}-web-lighttpd, %{name}-api-lighttpd
%description web-apache
This package provides the Apache configuration for Baculum WebGUI.
By using this module it is possible to run Baculum WebGUI in Apache environment.
%package web-lighttpd
Summary: Lighttpd configuration for Baculum WebGUI
Requires: %name-web = %version-%release
Group: Productivity/Archiving/Backup
Requires: lighttpd
Requires: lighttpd-fastcgi
# This conflict field is required because Lighttpd and Apache
# cannot listen on the same port at the same time. Even using diffeernt
# ports cause problems like shared framework cache and
# web server specific directories permissions (for lighttpd and apache
# users).
Conflicts: %{name}-web-apache, %{name}-api-apache
%description web-lighttpd
This package provides the Lighttpd configuration for Baculum WebGUI.
By using this module it is possible to run Baculum WebGUI in Lighttpd environment.
%prep
%setup -n bacula-gui-%version/baculum
cp -p %{SOURCE1} baculum.sudoers
%build
# Execute files preparation in build directory by Makefile
make build DEFHTTPDNAME=apache2 DESTDIR=%{destdir}
# Remove these cache directories, because here will be symbolic links
rmdir %{destdir}/%{_datadir}/%{metaname}/htdocs/assets
rmdir %{destdir}/%{_datadir}/%{metaname}/htdocs/protected/runtime
for lang in %{langs_api}; do
rm %{destdir}/%{_datadir}/%{metaname}/htdocs/protected/API/Lang/${lang}/messages.mo
done
for lang in %{langs_web}; do
rm %{destdir}/%{_datadir}/%{metaname}/htdocs/protected/Web/Lang/${lang}/messages.mo
done
# rm %{destdir}/%{metaname}-install-checker.sh
%install
cp -ra build/. %{buildroot}
%{__install} -d -m750 %{buildroot}/%{_sysconfdir}/sudoers.d
%{__install} -D -m440 baculum.sudoers %{buildroot}/%{_sysconfdir}/sudoers.d/baculum.sudoers
%{__install} -D -m750 build/%{metaname}-install-checker.sh %{buildroot}/%{_sysconfdir}/%{metaname}/%{metaname}-install-checker.sh
rm %{buildroot}/%{metaname}-install-checker.sh
%find_lang %{metaname} --all-name
%post common
if [ $1 -ge 1 ] ; then
# these symbolic links indicates to Baculum's cache directory
[ -e %{_datadir}/%{metaname}/htdocs/assets ] ||
ln -s %{_localstatedir}/cache/%{metaname} %{_datadir}/%{metaname}/htdocs/assets
[ -e %{_datadir}/%{metaname}/htdocs/protected/runtime ] ||
ln -s %{_localstatedir}/cache/%{metaname} %{_datadir}/%{metaname}/htdocs/protected/runtime
fi
%post api-apache
%service_add_post apache2.service
if [ $1 -eq 1 ] ; then
ln -s %{_sysconfdir}/%{metaname}/Config-api-apache %{_datadir}/%{metaname}/htdocs/protected/API/Config
fi
%post api-lighttpd
%service_add_post baculum-api-lighttpd.service
if [ $1 -eq 1 ] ; then
ln -s %{_sysconfdir}/%{metaname}/Config-api-lighttpd %{_datadir}/%{metaname}/htdocs/protected/API/Config
fi
%post web-apache
%service_add_post apache2.service
if [ $1 -eq 1 ] ; then
ln -s %{_sysconfdir}/%{metaname}/Config-web-apache %{_datadir}/%{metaname}/htdocs/protected/Web/Config
fi
%post web-lighttpd
%service_add_post baculum-web-lighttpd.service
if [ $1 -eq 1 ] ; then
ln -s %{_sysconfdir}/%{metaname}/Config-web-lighttpd %{_datadir}/%{metaname}/htdocs/protected/Web/Config
fi
%pre api-apache
%service_add_pre apache2.service
%pre web-apache
%service_add_pre apache2.service
%pre api-lighttpd
%service_add_pre baculum-api-lighttpd.service
%pre web-lighttpd
%service_add_pre baculum-web-lighttpd.service
%preun common
if [ $1 -lt 1 ] ; then
rm %{_datadir}/%{metaname}/htdocs/assets
rm %{_datadir}/%{metaname}/htdocs/protected/runtime
fi
%preun api
if [ $1 -lt 1 ] ; then
for lang in %{langs_api}; do
rm %{_datadir}/%{metaname}/htdocs/protected/API/Lang/${lang}/messages.mo
done
# Clear old debug file to be able to remove directory or link containing it
if [ -e %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api.log ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api.log*
fi
# In older versions it might be directory, thus check if it is link
if [ -L %{_datadir}/%{metaname}/htdocs/protected/API/Logs ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/API/Logs
elif [ -d %{_datadir}/%{metaname}/htdocs/protected/API/Logs ] ; then
rmdir %{_datadir}/%{metaname}/htdocs/protected/API/Logs
fi
fi
%preun web
if [ $1 -lt 1 ] ; then
for lang in %{langs_web}; do
rm %{_datadir}/%{metaname}/htdocs/protected/Web/Lang/${lang}/messages.mo
done
# Clear old debug file to be able to remove directory or link containing it
if [ -e %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web.log ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web.log*
fi
# In older versions it might be directory, thus check if it is link
if [ -L %{_datadir}/%{metaname}/htdocs/protected/Web/Logs ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
elif [ -d %{_datadir}/%{metaname}/htdocs/protected/Web/Logs ] ; then
rmdir %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
fi
fi
%preun api-apache
%service_del_preun apache2.service
if [ $1 -lt 1 ] ; then
# Rename settings if exist.
# Note, 'config' macro cannot be used because this file is created after successful
# installation via wizard. Also using 'config' macro to /usr location strictly forbidden
# by Packaging Guidelines.
[ ! -e %{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf ] ||
mv %{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf \
%{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf.apache
# remove debug files if any
if [ -L %{_datadir}/%{metaname}/htdocs/protected/API/Config ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/API/Config
fi
# Clear old debug files for case changing web server (privileges issue)
if [ -e %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api.log ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api.log*
fi
fi
%preun web-apache
%service_del_preun apache2.service
if [ $1 -lt 1 ] ; then
# Rename settings if exist.
# Note, 'config' macro cannot be used because this file is created after successful
# installation via wizard. Also using 'config' macro to /usr location strictly forbidden
# by Packaging Guidelines.
[ ! -e %{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf ] ||
mv %{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf \
%{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf.apache
[ ! -e %{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf ] ||
mv %{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf \
%{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf.apache
# remove debug files if any
if [ -L %{_datadir}/%{metaname}/htdocs/protected/Web/Config ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/Web/Config
fi
# Clear old debug files for case changing web server (privileges issue)
if [ -e %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web.log ] ; then
rm %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web.log*
fi
fi
%preun api-lighttpd
%service_del_preun baculum-api-lighttpd.service
#if [ $1 -lt 1 ] ; then
# # stop api service
# /sbin/service baculum-api-lighttpd stop &>/dev/null || :
# # Rename settings if exist.
# # Note, 'config' macro cannot be used because this file is created after successful
# # installation via wizard. Also using 'config' macro to /usr location strictly forbidden
# # by Packaging Guidelines.
# [ ! -e %{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf ] ||
# mv %{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf \
# %{_datadir}/%{metaname}/htdocs/protected/API/Config/api.conf.lighttpd
# # remove debug files if any
# [ ! -e %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api.log ] ||
# rm %{_datadir}/%{metaname}/htdocs/protected/API/Logs/baculum-api*.log
# rm %{_datadir}/%{metaname}/htdocs/protected/API/Config
#fi
%preun web-lighttpd
%service_del_preun baculum-web-lighttpd.service
#if [ $1 -lt 1 ] ; then
# # stop web service
# /sbin/service baculum-web-lighttpd stop &>/dev/null || :
# # Rename settings if exist.
# # Note, 'config' macro cannot be used because this file is created after successful
# # installation via wizard. Also using 'config' macro to /usr location strictly forbidden
# # by Packaging Guidelines.
# [ ! -e %{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf ] ||
# mv %{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf \
# %{_datadir}/%{metaname}/htdocs/protected/Web/Config/settings.conf.lighttpd
# [ ! -e %{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf ] ||
# mv %{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf \
# %{_datadir}/%{metaname}/htdocs/protected/Web/Config/hosts.conf.lighttpd
# # remove debug files if any
# [ ! -e %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web.log ] ||
# rm %{_datadir}/%{metaname}/htdocs/protected/Web/Logs/baculum-web*.log
# rm %{_datadir}/%{metaname}/htdocs/protected/Web/Config
#fi
%postun api-apache
%service_del_postun apache2.service
%postun web-apache
%service_del_postun apache2.service
%postun api-lighttpd
%service_del_postun baculum-api-lighttpd.service
%postun web-lighttpd
%service_del_postun baculum-web-lighttpd.service
%posttrans api
# because framework does not use system locale dir, here are linked
# locale files to framework location
for lang in %{langs_api}; do
[ -e %{_datadir}/%{metaname}/htdocs/protected/API/Lang/${lang}/messages.mo ] ||
cp %{_datadir}/locale/${lang}/LC_MESSAGES/%{metaname}-api.mo \
%{_datadir}/%{metaname}/htdocs/protected/API/Lang/${lang}/messages.mo
done
# check if exists for case uninstall prev version and install new one
[ -e %{_datadir}/%{metaname}/htdocs/protected/API/Logs ] ||
ln -s %{_localstatedir}/lib/%{metaname} %{_datadir}/%{metaname}/htdocs/protected/API/Logs
%posttrans web
# because framework does not use system locale dir, here are linked
# locale files to framework location
for lang in %{langs_web}; do
[ -e %{_datadir}/%{metaname}/htdocs/protected/Web/Lang/${lang}/messages.mo ] ||
cp %{_datadir}/locale/${lang}/LC_MESSAGES/%{metaname}-web.mo \
%{_datadir}/%{metaname}/htdocs/protected/Web/Lang/${lang}/messages.mo
done
# check if exists for case uninstall prev version and install new one
[ -e %{_datadir}/%{metaname}/htdocs/protected/Web/Logs ] ||
ln -s %{_localstatedir}/lib/%{metaname} %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
%files -f %{metaname}.lang common
%defattr(-,root,root,-)
%dir %{_datadir}/%{metaname}
%dir %{_datadir}/%{metaname}/htdocs
%dir %{_datadir}/%{metaname}/htdocs/protected
%{_datadir}/%{metaname}/htdocs/protected/Common
%{_datadir}/%{metaname}/htdocs/protected/application.xml
%{_datadir}/%{metaname}/htdocs/framework
%{_datadir}/%{metaname}/htdocs/themes
%{_datadir}/%{metaname}/htdocs/LICENSE
%{_datadir}/%{metaname}/htdocs/AUTHORS
%{_datadir}/%{metaname}/htdocs/README
%{_datadir}/%{metaname}/htdocs/INSTALL
%{_datadir}/%{metaname}/htdocs/index.php
%license LICENSE
%doc AUTHORS README
%dir %{_sysconfdir}/sudoers.d
%config %{_sysconfdir}/sudoers.d/baculum.sudoers
%{_sysconfdir}/%{metaname}/%{metaname}-install-checker.sh
%files api
%defattr(-,root,root,-)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/API/Config
%exclude %{_datadir}/%{metaname}/htdocs/protected/API/Logs
%{_datadir}/%{metaname}/htdocs/protected/API
%files web
%defattr(-,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/Web/Config
%exclude %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
%{_datadir}/%{metaname}/htdocs/protected/Web
%files api-apache
%defattr(644,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/API/Config
# Apache logs are stored in /var/log/apache2/
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{metaname}-api.conf
%attr(755,wwwrun,www) %{_localstatedir}/cache/%{metaname}/
%dir %{_sysconfdir}/%{metaname}
%attr(750,wwwrun,www) %{_sysconfdir}/%{metaname}/Config-api-apache/
# % attr(640,wwwrun,www) % config(noreplace) % {_sysconfdir}/% {metaname}/Config-api-apache/% {metaname}.users
%attr(755,wwwrun,www) %{_datadir}/%{metaname}/htdocs/protected/API/Logs
%files web-apache
%defattr(644,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/Web/Config
# Apache logs are stored in /var/log/apache2/
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{metaname}-web.conf
%attr(755,wwwrun,www) %{_localstatedir}/cache/%{metaname}/
%dir %{_sysconfdir}/%{metaname}
%attr(750,wwwrun,www) %{_sysconfdir}/%{metaname}/Config-web-apache/
# % attr(640,wwwrun,www) % config(noreplace) % {_sysconfdir}/% {metaname}/Config-web-apache/% {metaname}.users
%attr(755,wwwrun,www) %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
%files api-lighttpd
%defattr(644,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/API/Config
# Lighttpd logs are stored in /var/log/lighttpd
%attr(755,lighttpd,lighttpd) %{_localstatedir}/cache/%{metaname}/
%dir %{_sysconfdir}/%{metaname}
%attr(700,lighttpd,lighttpd) %{_sysconfdir}/%{metaname}/Config-api-lighttpd/
# % config(noreplace) % attr(600,lighttpd,lighttpd) % {_sysconfdir}/% {metaname}/Config-api-lighttpd/% {metaname}.users
%attr(755,lighttpd,lighttpd) %{_datadir}/%{metaname}/htdocs/protected/API/Logs
%{_unitdir}/%{metaname}-api-lighttpd.service
%config(noreplace) %{_sysconfdir}/%{metaname}/%{metaname}-api-lighttpd.conf
%attr(750,lighttpd,lighttpd) %{_localstatedir}/lib/%{metaname}/
%files web-lighttpd
%defattr(644,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{metaname}/htdocs/protected/Web/Config
# Lighttpd logs are stored in /var/log/lighttpd
%attr(755,lighttpd,lighttpd) %{_localstatedir}/cache/%{metaname}/
%dir %{_sysconfdir}/%{metaname}
%attr(700,lighttpd,lighttpd) %{_sysconfdir}/%{metaname}/Config-web-lighttpd/
# % config(noreplace) % attr(600,lighttpd,lighttpd) % {_sysconfdir}/% {metaname}/Config-web-lighttpd/% {metaname}.users
%attr(755,lighttpd,lighttpd) %{_datadir}/%{metaname}/htdocs/protected/Web/Logs
%{_unitdir}/%{metaname}-web-lighttpd.service
%config(noreplace) %{_sysconfdir}/%{metaname}/%{metaname}-web-lighttpd.conf
%attr(750,lighttpd,lighttpd) %{_localstatedir}/lib/%{metaname}/
%changelog