]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/examples/rpm/baculum.spec
baculum: Add sample files to build rpm packages
[bacula/bacula] / gui / baculum / examples / rpm / baculum.spec
1 Summary:        WebGUI tool for Bacula Community program
2 Name:           baculum
3 Version:        7.0.6
4 Release:        0.3.b%{?dist}
5 License:        AGPLv3
6 Group:          Applications/Internet
7 URL:            http://bacula.org/
8 Source0:        http://bacula.org/downloads/baculum/baculum-7.0.6b.tar.gz
9 Source1:        baculum.users
10 Source2:        baculum-apache.conf
11 Source3:        baculum-lighttpd.conf
12 Source4:        baculum-lighttpd.service
13 BuildRequires:  systemd-units
14 BuildRequires:  selinux-policy
15 BuildRequires:  selinux-policy-devel
16 BuildRequires:  checkpolicy
17 Requires:       bacula-console
18 # Lower version of PHP ( < 5.3.4) does not provide php-mysqlnd db driver
19 # and from this reason the lowest is 5.3.4
20 Requires:       php >= 5.3.4
21 Requires:       php-bcmath
22 Requires:       php-common
23 Requires:       php-mbstring
24 Requires:       php-mysqlnd
25 Requires:       php-pdo
26 Requires:       php-pgsql
27 Requires:       php-xml
28 BuildArch:      noarch
29
30 %description
31 The Baculum program allows the user to administer and manage Bacula jobs.
32 By using Baculum it is possible to execute backup/restore operations, monitor
33 current Bacula jobs, media management and others. Baculum has integrated web
34 console that communicates with Bacula bconsole program.
35
36 %package selinux
37 Summary:                SELinux module for Baculum WebGUI tool
38 Requires:               %name = %version-%release
39 Group:                  Applications/Internet
40 Requires(post):         policycoreutils-python
41 Requires(preun):        policycoreutils-python
42
43 %description selinux
44 This package provides an SELinux module for Baculum WebGUI tool.
45 You should install this package if you are using SELinux, that Baculum
46 can be run in enforcing mode.
47
48 %package httpd
49 Summary:                Apache configuration for Baculum WebGUI tool
50 Requires:               %name = %version-%release
51 Group:                  Applications/Internet
52 Requires:               httpd
53 # This conflict field is required because Lighttpd and Apache
54 # cannot listen on the same port at the same time. Even using diffeernt
55 # ports cause problems like shared framework cache and
56 # web server specific directories permissions (for lighttpd and apache
57 # users).
58 Conflicts:              %{name}-lighttpd
59
60 %description httpd
61 This package provides the Apache configuration for Baculum WebGUI tool.
62 By using this module it is possible to run Baculum in Apache environment.
63
64 %package lighttpd
65 Summary:                Lighttpd configuration for Baculum WebGUI tool
66 Requires:               %name = %version-%release
67 Group:                  Applications/Internet
68 Requires:               lighttpd
69 Requires:               lighttpd-fastcgi
70 # This conflict field is required because Lighttpd and Apache
71 # cannot listen on the same port at the same time. Even using diffeernt
72 # ports cause problems like shared framework cache and
73 # web server specific directories permissions (for lighttpd and apache
74 # users).
75 Conflicts:              %{name}-httpd
76
77 %description lighttpd
78 This package provides the Lighttpd configuration for Baculum WebGUI tool.
79 By using this module it is possible to run Baculum in Lighttpd environment.
80
81 %prep
82 %autosetup
83
84 %build
85 # Execute files preparation in build directory by Makefile
86 make build
87 # Compilation SELinuxu policies before loading them
88 make -C examples/selinux/ -f %{_datadir}/selinux/devel/Makefile %{name}.pp
89
90 %install
91 mkdir -p %{buildroot}%{_datadir}/%{name}/htdocs/protected
92 mkdir -p %{buildroot}%{_sysconfdir}/%{name}
93 mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
94 mkdir -p %{buildroot}%{_unitdir}
95 mkdir -p %{buildroot}%{_localstatedir}/cache/%{name}
96 mkdir -p %{buildroot}%{_var}/log/%{name}
97 mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
98
99 cp -ra build/. %{buildroot}%{_datadir}/%{name}/htdocs
100 install -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf
101 install -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/
102 install -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/
103 install -m 600 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
104 install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}.pp
105 # these symbolic links indicates to Baculum's cache directory
106 ln -s  %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/assets
107 ln -s  %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/protected/runtime
108
109 %post lighttpd
110 %systemd_post baculum.service
111
112 %post selinux
113 if [ $1 -le 1 ] ; then
114     # Write access is possible for web servers user only to two directories
115     # -  Data/ directory stores settings and web server HTTP Basic credentials
116     # - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
117     #   by symbolic links to cache directory
118     semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
119     restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
120     semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
121     restorecon -i -R %{_localstatedir}/cache/%{name} || :
122     semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
123 fi
124
125 %preun
126 if [ $1 -lt 1 ] ; then
127     # remove settings and logs if exist
128     [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/settings.conf ] ||
129         rm %{_datadir}/%{name}/htdocs/protected/Data/settings.conf
130     [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.log ] ||
131         rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.log
132 fi
133
134 %preun lighttpd
135 %systemd_preun baculum-lighttpd.service
136
137 %postun lighttpd
138 %systemd_postun_with_restart baculum-lighttpd.service
139
140 %postun selinux
141 if [ $1 -eq 0 ] ; then
142     semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
143     semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
144     semodule -r %{name} 2>/dev/null || :
145 fi
146
147 %files
148 %defattr(-,root,root)
149 # directory excluded here, because it needs to be provided
150 # with selected web server privileges (lighttpd or apache)
151 %exclude %{_datadir}/%{name}/htdocs/protected/Data/
152 %{_datadir}/%{name}
153 %license LICENSE
154 %doc AUTHORS INSTALL README
155
156 %files selinux
157 %defattr(-,root,root)
158 %{_datadir}/selinux/packages/%{name}/%{name}.pp
159
160 %files httpd
161 %defattr(644,root,root)
162 # Apache logs are stored in /var/log/httpd/
163 %config %{_sysconfdir}/httpd/conf.d/%{name}.conf
164 %attr(700,apache,apache) %{_localstatedir}/cache/%{name}/
165 %attr(700,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/
166
167 %files lighttpd
168 %defattr(-,root,root)
169 # Lighttpd logs are stored in /var/log/baculum
170 %attr(750,lighttpd,lighttpd) %{_var}/log/%{name}/
171 %attr(700,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
172 %attr(700,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/
173 %{_unitdir}/%{name}-lighttpd.service
174 %config %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
175
176 %changelog
177  * Tue Jul 14 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.3.b
178  - Separate to subpackage Lighttpd support
179  - Add Apache subpackage
180  - Use upstream Makefile to prepare build files
181  - Cache symlbolic links only in install section
182  - Add comments to Spec
183  - Compile SELinux policies instead of install pre-compiled
184  - Add source files: baculum.users, baculum-apache.conf
185    baculum-lighttpd.conf and baculum-lighttpd.service
186  * Mon Jul 13 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.2.b
187  - Remove chkconfig and service dependencies from Spec
188  - Change Spec sections order
189  - Correct package description typos and errors
190  * Mon Jul 06 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.1.b
191  - Spec create