+%global langs en pl
+%global destdir build
+
Summary: WebGUI tool for Bacula Community program
Name: baculum
Version: 7.0.6
-Release: 0.3.b%{?dist}
+Release: 0.5.b%{?dist}
License: AGPLv3
Group: Applications/Internet
URL: http://bacula.org/
-Source0: http://bacula.org/downloads/baculum/baculum-7.0.6b.tar.gz
-Source1: baculum.users
-Source2: baculum-apache.conf
-Source3: baculum-lighttpd.conf
-Source4: baculum-lighttpd.service
+Source0: http://bacula.pl/downloads/baculum/baculum-7.0.6b.tar.gz
BuildRequires: systemd-units
BuildRequires: selinux-policy
BuildRequires: selinux-policy-devel
%build
# Execute files preparation in build directory by Makefile
-make build
+make build DESTDIR=%{destdir}
# Compilation SELinuxu policies before loading them
make -C examples/selinux/ -f %{_datadir}/selinux/devel/Makefile %{name}.pp
+# Remove these cache directories, because here will be symbolic links
+rmdir %{destdir}/%{_datadir}/%{name}/htdocs/assets
+rmdir %{destdir}/%{_datadir}/%{name}/htdocs/protected/runtime
+for lang in %{langs}; do
+ rm %{destdir}/%{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
%install
-mkdir -p %{buildroot}%{_datadir}/%{name}/htdocs/protected
-mkdir -p %{buildroot}%{_sysconfdir}/%{name}
-mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
-mkdir -p %{buildroot}%{_unitdir}
-mkdir -p %{buildroot}%{_localstatedir}/cache/%{name}
-mkdir -p %{buildroot}%{_var}/log/%{name}
-mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
-
-cp -ra build/. %{buildroot}%{_datadir}/%{name}/htdocs
-install -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf
-install -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/
-install -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/
-install -m 600 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
-install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}.pp
-# these symbolic links indicates to Baculum's cache directory
-ln -s %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/assets
-ln -s %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/protected/runtime
+cp -ra build/. %{buildroot}
+%find_lang %{name} --all-name
+install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/
-%post lighttpd
-%systemd_post baculum.service
+%post
+# these symbolic links indicates to Baculum's cache directory
+ln -s %{_localstatedir}/cache/%{name} %{_datadir}/%{name}/htdocs/assets
+ln -s %{_localstatedir}/cache/%{name} %{_datadir}/%{name}/htdocs/protected/runtime
+# because framework does not use system locale dir, here are linked
+# locale files to framework location
+for lang in %{langs}; do
+ ln -s %{_datadir}/locale/${lang}/LC_MESSAGES/%{name}.mo \
+ %{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
%post selinux
if [ $1 -le 1 ] ; then
-# Write access is possible for web servers user only to two directories
-# - Data/ directory stores settings and web server HTTP Basic credentials
-# - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
-# by symbolic links to cache directory
- semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
- restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
- semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
- restorecon -i -R %{_localstatedir}/cache/%{name} || :
- semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
+ # Write access is possible for web servers user only to two directories
+ # - Data/ directory stores settings and web server HTTP Basic credentials
+ # - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
+ # by symbolic links to cache directory
+ semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+ restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
+ semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+ restorecon -i -R %{_localstatedir}/cache/%{name} || :
+ semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
fi
+%post httpd
+%systemd_post httpd.service
+
+%post lighttpd
+%systemd_post baculum-lighttpd.service
+
%preun
+for lang in %{langs}; do
+ rm %{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
+rm %{_datadir}/%{name}/htdocs/assets
+rm %{_datadir}/%{name}/htdocs/protected/runtime
+
+%preun httpd
+%systemd_preun httpd.service
if [ $1 -lt 1 ] ; then
- # remove settings and logs if exist
- [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/settings.conf ] ||
- rm %{_datadir}/%{name}/htdocs/protected/Data/settings.conf
- [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.log ] ||
- rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.log
+ # 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}/%{name}/htdocs/protected/Data/settings.conf ] ||
+ mv %{_datadir}/%{name}/htdocs/protected/Data/settings.conf \
+ %{_datadir}/%{name}/htdocs/protected/Data/settings.conf.apache
+ # remove debug files if any
+ [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.dbg ] ||
+ rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.dbg
fi
%preun lighttpd
%systemd_preun baculum-lighttpd.service
-
-%postun lighttpd
-%systemd_postun_with_restart baculum-lighttpd.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}/%{name}/htdocs/protected/Data/settings.conf ] ||
+ mv %{_datadir}/%{name}/htdocs/protected/Data/settings.conf \
+ %{_datadir}/%{name}/htdocs/protected/Data/settings.conf.lighttpd
+ # remove debug files if any
+ [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.dbg ] ||
+ rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.dbg
+fi
%postun selinux
if [ $1 -eq 0 ] ; then
- semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
- semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
- semodule -r %{name} 2>/dev/null || :
+ semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+ semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+ semodule -r %{name} 2>/dev/null || :
fi
-%files
+%postun httpd
+%systemd_postun_with_restart httpd.service
+
+%postun lighttpd
+%systemd_postun_with_restart baculum-lighttpd.service
+
+%files -f %{name}.lang
%defattr(-,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{name}/htdocs/protected/Data/
%{_datadir}/%{name}
%license LICENSE
-%doc AUTHORS INSTALL README
+%doc AUTHORS README
%files selinux
%defattr(-,root,root)
%files httpd
%defattr(644,root,root)
# Apache logs are stored in /var/log/httpd/
-%config %{_sysconfdir}/httpd/conf.d/%{name}.conf
-%attr(700,apache,apache) %{_localstatedir}/cache/%{name}/
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
+%attr(755,apache,apache) %{_localstatedir}/cache/%{name}/
%attr(-,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/
+%attr(600,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
%files lighttpd
%defattr(644,root,root)
-# Lighttpd logs are stored in /var/log/baculum
-%attr(750,lighttpd,lighttpd) %{_var}/log/%{name}/
-%attr(700,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
+# Lighttpd logs are stored in /var/log/lighttpd
+%attr(755,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
%attr(-,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/
+%attr(600,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
%{_unitdir}/%{name}-lighttpd.service
-%config %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
+%config(noreplace) %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
%changelog
+ * Sat Jul 18 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.5.b
+ - Change baculum.users and Data/ directory permissions to more
+ restrictive
+ - Add noreplace param to Lighttpd config file
+ - Add systemd macros for httpd subpackage
+ - Fix systemd action in post section
+ - Move DESTDIR target and languages to global variables
+ - Do not remove settings file when a web server specific package
+ is removed (used move action)
+ - Drop storing Lighttpd logs in separate logs directory
+ - Define locale files
+ * Fri Jul 17 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.4.b
+ - Remove source files: baculum.users, baculum-apache.conf
+ baculum-lighttpd.conf and baculum-lighttpd.service
+ - Use reorganized upstream Makefile
* Tue Jul 14 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.3.b
- Separate to subpackage Lighttpd support
- Add Apache subpackage
- Compile SELinux policies instead of install pre-compiled
- Add source files: baculum.users, baculum-apache.conf
baculum-lighttpd.conf and baculum-lighttpd.service
+ - Change Source0 URL
* Mon Jul 13 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.2.b
- Remove chkconfig and service dependencies from Spec
- Change Spec sections order
+%global langs en pl
+%global destdir build
+
Summary: WebGUI tool for Bacula Community program
Name: baculum
Version: 7.0.6
-Release: 0.3.b%{?dist}
+Release: 0.5.b%{?dist}
License: AGPLv3
Group: Applications/Internet
URL: http://bacula.org/
-Source0: http://bacula.org/downloads/baculum/baculum-7.0.6b.tar.gz
-Source1: baculum.users
-Source2: baculum-apache.conf
-Source3: baculum-lighttpd.conf
-Source4: baculum-lighttpd.service
+Source0: http://bacula.pl/downloads/baculum/baculum-7.0.6b.tar.gz
BuildRequires: systemd-units
BuildRequires: selinux-policy
BuildRequires: selinux-policy-devel
%build
# Execute files preparation in build directory by Makefile
-make build
+make build DESTDIR=%{destdir}
# Compilation SELinuxu policies before loading them
make -C examples/selinux/ -f %{_datadir}/selinux/devel/Makefile %{name}.pp
+# Remove these cache directories, because here will be symbolic links
+rmdir %{destdir}/%{_datadir}/%{name}/htdocs/assets
+rmdir %{destdir}/%{_datadir}/%{name}/htdocs/protected/runtime
+for lang in %{langs}; do
+ rm %{destdir}/%{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
%install
-mkdir -p %{buildroot}%{_datadir}/%{name}/htdocs/protected
-mkdir -p %{buildroot}%{_sysconfdir}/%{name}
-mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
-mkdir -p %{buildroot}%{_unitdir}
-mkdir -p %{buildroot}%{_localstatedir}/cache/%{name}
-mkdir -p %{buildroot}%{_var}/log/%{name}
-mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
-
-cp -ra build/. %{buildroot}%{_datadir}/%{name}/htdocs
-install -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf
-install -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/
-install -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/
-install -m 600 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
-install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}.pp
-# these symbolic links indicates to Baculum's cache directory
-ln -s %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/assets
-ln -s %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/protected/runtime
+cp -ra build/. %{buildroot}
+%find_lang %{name} --all-name
+install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/
-%post lighttpd
-%systemd_post baculum.service
+%post
+# these symbolic links indicates to Baculum's cache directory
+ln -s %{_localstatedir}/cache/%{name} %{_datadir}/%{name}/htdocs/assets
+ln -s %{_localstatedir}/cache/%{name} %{_datadir}/%{name}/htdocs/protected/runtime
+# because framework does not use system locale dir, here are linked
+# locale files to framework location
+for lang in %{langs}; do
+ ln -s %{_datadir}/locale/${lang}/LC_MESSAGES/%{name}.mo \
+ %{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
%post selinux
if [ $1 -le 1 ] ; then
-# Write access is possible for web servers user only to two directories
-# - Data/ directory stores settings and web server HTTP Basic credentials
-# - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
-# by symbolic links to cache directory
- semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
- restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
- semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
- restorecon -i -R %{_localstatedir}/cache/%{name} || :
- semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
+ # Write access is possible for web servers user only to two directories
+ # - Data/ directory stores settings and web server HTTP Basic credentials
+ # - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
+ # by symbolic links to cache directory
+ semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+ restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
+ semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+ restorecon -i -R %{_localstatedir}/cache/%{name} || :
+ semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
fi
+%post httpd
+%systemd_post httpd.service
+
+%post lighttpd
+%systemd_post baculum-lighttpd.service
+
%preun
+for lang in %{langs}; do
+ rm %{_datadir}/%{name}/htdocs/protected/Lang/${lang}/messages.mo
+done
+rm %{_datadir}/%{name}/htdocs/assets
+rm %{_datadir}/%{name}/htdocs/protected/runtime
+
+%preun httpd
+%systemd_preun httpd.service
if [ $1 -lt 1 ] ; then
- # remove settings and logs if exist
- [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/settings.conf ] ||
- rm %{_datadir}/%{name}/htdocs/protected/Data/settings.conf
- [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.log ] ||
- rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.log
+ # 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}/%{name}/htdocs/protected/Data/settings.conf ] ||
+ mv %{_datadir}/%{name}/htdocs/protected/Data/settings.conf \
+ %{_datadir}/%{name}/htdocs/protected/Data/settings.conf.apache
+ # remove debug files if any
+ [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.dbg ] ||
+ rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.dbg
fi
%preun lighttpd
%systemd_preun baculum-lighttpd.service
-
-%postun lighttpd
-%systemd_postun_with_restart baculum-lighttpd.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}/%{name}/htdocs/protected/Data/settings.conf ] ||
+ mv %{_datadir}/%{name}/htdocs/protected/Data/settings.conf \
+ %{_datadir}/%{name}/htdocs/protected/Data/settings.conf.lighttpd
+ # remove debug files if any
+ [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.dbg ] ||
+ rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.dbg
+fi
%postun selinux
if [ $1 -eq 0 ] ; then
- semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
- semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
- semodule -r %{name} 2>/dev/null || :
+ semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+ semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+ semodule -r %{name} 2>/dev/null || :
fi
-%files
+%postun httpd
+%systemd_postun_with_restart httpd.service
+
+%postun lighttpd
+%systemd_postun_with_restart baculum-lighttpd.service
+
+%files -f %{name}.lang
%defattr(-,root,root)
# directory excluded here, because it needs to be provided
# with selected web server privileges (lighttpd or apache)
%exclude %{_datadir}/%{name}/htdocs/protected/Data/
%{_datadir}/%{name}
%license LICENSE
-%doc AUTHORS INSTALL README
+%doc AUTHORS README
%files selinux
%defattr(-,root,root)
%files httpd
%defattr(644,root,root)
# Apache logs are stored in /var/log/httpd/
-%config %{_sysconfdir}/httpd/conf.d/%{name}.conf
-%attr(700,apache,apache) %{_localstatedir}/cache/%{name}/
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
+%attr(755,apache,apache) %{_localstatedir}/cache/%{name}/
%attr(-,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/
+%attr(600,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
%files lighttpd
%defattr(644,root,root)
-# Lighttpd logs are stored in /var/log/baculum
-%attr(750,lighttpd,lighttpd) %{_var}/log/%{name}/
-%attr(700,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
+# Lighttpd logs are stored in /var/log/lighttpd
+%attr(755,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
%attr(-,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/
+%attr(600,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
%{_unitdir}/%{name}-lighttpd.service
-%config %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
+%config(noreplace) %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
%changelog
+ * Sat Jul 18 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.5.b
+ - Change baculum.users and Data/ directory permissions to more
+ restrictive
+ - Add noreplace param to Lighttpd config file
+ - Add systemd macros for httpd subpackage
+ - Fix systemd action in post section
+ - Move DESTDIR target and languages to global variables
+ - Do not remove settings file when a web server specific package
+ is removed (used move action)
+ - Drop storing Lighttpd logs in separate logs directory
+ - Define locale files
+ * Fri Jul 17 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.4.b
+ - Remove source files: baculum.users, baculum-apache.conf
+ baculum-lighttpd.conf and baculum-lighttpd.service
+ - Use reorganized upstream Makefile
* Tue Jul 14 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.3.b
- Separate to subpackage Lighttpd support
- Add Apache subpackage
- Compile SELinux policies instead of install pre-compiled
- Add source files: baculum.users, baculum-apache.conf
baculum-lighttpd.conf and baculum-lighttpd.service
+ - Change Source0 URL
* Mon Jul 13 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.2.b
- Remove chkconfig and service dependencies from Spec
- Change Spec sections order