Tue, 28 Aug 2012 18:36:20 +0200
Blindly commit previous changes before reworking for forthcoming stack release.
1 ##
2 ## bacula.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # MSvB:
25 # MSvB: Note, see http://www.bacula.org/en/?page=news
26 # MSvB: for information on new configuration options.
27 # MSvB: Warning! -L /pfx/lib is placed before locally
28 # MSvB: built libraries (bacula-<ver>/src/cats...)
29 # MSvB: which causes the old version of bacula to
30 # MSvB: supply logic to the new version build!
31 # MSvB:
33 # package information
34 Name: bacula
35 Summary: Network Backup Tool
36 URL: http://www.bacula.org/
37 Vendor: Kern Sibbald
38 Packager: OpenPKG Foundation e.V.
39 Distribution: OpenPKG Community
40 Class: PLUS
41 Group: System
42 License: GPL
43 Version: 5.0.3
44 Release: 20120208
46 # package options
47 %option with_server yes
48 %option with_ssl yes
49 %option with_wrap no
50 %option with_dvd no
51 %option with_mtx no
52 %option with_python no
53 %option with_db_sqlite no
54 %option with_db_pgsql no
55 %option with_db_mysql no
57 # package option sanity check
58 %if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
59 %undefine with_db_sqlite
60 %define with_db_sqlite yes
61 %endif
63 # list of sources
64 Source0: http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
65 Source1: rc.bacula
66 Source2: bexec.sh
67 Patch0: bacula.patch
69 # build information
70 Prefix: %{l_prefix}
71 BuildRoot: %{l_buildroot}
72 BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, gcc::with_cxx = yes
73 PreReq: OpenPKG, openpkg >= 20060823
74 BuildPreReq: ncurses, readline, zlib
75 PreReq: ncurses, readline, zlib
76 %if "%{with_ssl}" == "yes"
77 BuildPreReq: openssl >= 0.9.8, openssl::with_threads = yes
78 PreReq: openssl >= 0.9.8, openssl::with_threads = yes
79 %endif
80 %if "%{with_wrap}" == "yes"
81 BuildPreReq: tcpwrappers
82 PreReq: tcpwrappers
83 %endif
84 %if "%{with_db_sqlite}" == "yes"
85 BuildPreReq: sqlite
86 PreReq: sqlite
87 %endif
88 %if "%{with_db_mysql}" == "yes"
89 BuildPreReq: mysql
90 PreReq: mysql
91 %endif
92 %if "%{with_db_pgsql}" == "yes"
93 BuildPreReq: postgresql
94 PreReq: postgresql
95 %endif
96 %if "%{with_dvd}" == "yes"
97 BuildPreReq: dvdrw-tools
98 PreReq: dvdrw-tools
99 %endif
100 %if "%{with_mtx}" == "yes"
101 BuildPreReq: mtx
102 PreReq: mtx
103 %endif
104 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
105 BuildPreReq: python
106 PreReq: python
107 %endif
108 AutoReq: no
109 AutoReqProv: no
111 %description
112 Bacula is a set of computer programs that permit you (or the system
113 administrator) to manage backup, recovery, and verification of
114 computer data across a network of computers of different kinds. In
115 technical terms, it is a network client/server based backup program.
116 Bacula is relatively easy to use and efficient, while offering many
117 advanced storage management features that make it easy to find and
118 recover lost or damaged files.
120 %track
121 prog bacula = {
122 version = %{version}
123 url = http://sourceforge.net/projects/bacula/files/
124 regex = bacula-(\d+\.\d*[02468]\.\d+)\.tar\.gz
125 }
127 %prep
128 %setup -q
129 %patch -p0
130 rm -f src/lib/tcpd.h
132 %build
133 # generate a random director password
134 password="`openssl rand -base64 33`"
136 # for the same reason remove version informations from config files
137 %{l_shtool} subst \
138 -e "s;For Bacula release @VERSION@ .*;;" \
139 `find . -name "*.conf.in"`
141 # help specific platforms find fdatasync(3)
142 libs=""
143 case "%{l_platform -t}" in
144 *-sunos* ) libs="-lrt" ;;
145 esac
147 # use localhost as default host
148 %{l_shtool} subst \
149 -e 's;hostname=.*;hostname=localhost;g' \
150 -e 's;\(CONS_LIBS="-lreadline.*\)-ltermcap;\1-lncurses;g' \
151 configure
153 # configure
154 LIBS=
155 case "%{l_platform -t}" in
156 *-linux*) ldfl="-L/usr/lib/termcap" ;;
157 *-sunos*) ldfl="-ldl" ;;
158 esac
159 CC="%{l_cc}" \
160 CFLAGS="%{l_cflags -O}" \
161 CPPFLAGS="%{l_cppflags ncurses}" \
162 LDFLAGS="%{l_ldflags} $ldfl" \
163 LIBS="$libs -lz" \
164 GREP="grep" \
165 ./configure \
166 --prefix=%{l_prefix} \
167 --with-dir-user=%{l_rusr} \
168 --with-dir-group=%{l_rgrp} \
169 --with-sd-user=%{l_rusr} \
170 --with-sd-group=%{l_rgrp} \
171 --with-fd-user=%{l_susr} \
172 --with-fd-group=%{l_sgrp} \
173 --with-dir-password="$password" \
174 --with-fd-password="$password" \
175 --with-sd-password="$password" \
176 --with-mon-dir-password="$password" \
177 --with-mon-fd-password="$password" \
178 --with-mon-sd-password="$password" \
179 --disable-conio \
180 --enable-readline \
181 --with-readline=%{l_prefix} \
182 %if "%{with_server}" != "yes"
183 --enable-client-only \
184 %endif
185 %if "%{with_ssl}" == "yes"
186 --with-openssl=%{l_prefix} \
187 %endif
188 %if "%{with_wrap}" == "yes"
189 --with-tcp-wrappers=yes \
190 %endif
191 %if "%{with_db_sqlite}" == "yes"
192 --with-sqlite3=%{l_prefix} \
193 %endif
194 %if "%{with_db_mysql}" == "yes"
195 --with-mysql=%{l_prefix} \
196 %endif
197 %if "%{with_db_pgsql}" == "yes"
198 --with-postgresql=%{l_prefix} \
199 %endif
200 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
201 --with-python=%{l_prefix} \
202 %endif
203 --enable-wx-console=no \
204 --sysconfdir=%{l_prefix}/etc/bacula \
205 --libexecdir=%{l_prefix}/libexec/bacula \
206 --mandir=%{l_prefix}/man \
207 --with-scriptdir=%{l_prefix}/libexec/bacula \
208 --with-working-dir=%{l_prefix}/var/bacula \
209 --with-pid-dir=%{l_prefix}/var/bacula/run \
210 --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
211 --with-archivedir=/tmp \
212 --with-sbin-perm=0755 \
213 --disable-shared \
214 --disable-libtool \
215 --disable-nls
217 # build
218 %{l_make} %{l_mflags -O}
220 %install
221 # clean up build cruft
222 rm -rf $RPM_BUILD_ROOT
224 # create installation hierarchy
225 %{l_shtool} mkdir -f -p -m 755 \
226 $RPM_BUILD_ROOT%{l_prefix}/bin \
227 $RPM_BUILD_ROOT%{l_prefix}/sbin \
228 $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
229 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
230 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
231 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
232 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
233 $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
234 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
235 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
236 $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
237 $RPM_BUILD_ROOT%{l_prefix}/man/man8
239 # install
240 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
242 # strip down installation
243 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
244 ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
245 for unwanted in startmysql stopmysql; do
246 rm -f $unwanted
247 done
248 ) || exit $?
250 # install additional files
251 %{l_shtool} install -c -m 754 %{l_value -s -a} \
252 %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
253 %{l_shtool} install -c -m 640 \
254 src/console/bconsole.conf $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/
256 ## wrap binaries to avoid to specify "-c" for each run
257 #( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
258 # for bin in bacula-dir bacula-fd bacula-sd \
259 # bconsole bcopy bextract bls bscan dbcheck \
260 # tray-monitor wx-console; do
261 # if [ -x $bin ]; then
262 # mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
263 # ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
264 # fi
265 # done
266 #) || exit $?
268 # install runcommand script
269 %{l_shtool} install -c -m 755 %{l_value -s -a} \
270 -e 's,@with_server@,%{with_server},g' \
271 %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
273 # determine installation files
274 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
275 %{l_files_std} \
276 '%config(noreplace) %{l_prefix}/etc/bacula/*.conf' \
277 %if "%{with_server}" == "yes"
278 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
279 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
280 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup' \
281 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
282 %endif
283 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \
284 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \
285 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \
286 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \
287 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula'
289 %files -f files
291 %clean
292 rm -rf $RPM_BUILD_ROOT
294 %post
295 # create initial database
296 if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
297 $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
298 chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
299 chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
300 fi
302 # after upgrade, restart service
303 [ $1 -eq 2 ] || exit 0
304 eval `%{l_rc} bacula status 2>/dev/null`
305 [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
306 exit 0
308 %preun
309 # before erase, stop service and remove working files
310 [ $1 -eq 0 ] || exit 0
311 %{l_rc} bacula stop 2>/dev/null
312 rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
313 exit 0