Wed, 29 Aug 2012 21:07:25 +0200
Correct flawed build condition assuming no preinstalled overriding bacula libs.
1 ##
2 ## bacula.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2012 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: Note, see http://www.bacula.org/en/?page=news
25 # MSvB: for information on new configuration options.
28 # package information
29 Name: bacula
30 Summary: Network Backup Tool
31 URL: http://www.bacula.org/
32 Vendor: Kern Sibbald
33 Packager: OpenPKG Foundation e.V.
34 Distribution: OpenPKG Community
35 Class: PLUS
36 Group: System
37 License: GPL
38 Version: 5.2.10
39 Release: 20120800
41 # package options
42 %option with_server yes
43 %option with_ssl yes
44 %option with_wrap no
45 %option with_dvd no
46 %option with_mtx no
47 %option with_python no
48 %option with_db_sqlite no
49 %option with_db_pgsql no
50 %option with_db_mysql no
52 # package option sanity check
53 %if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
54 %undefine with_db_sqlite
55 %define with_db_sqlite yes
56 %endif
58 # list of sources
59 Source0: http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
60 Source1: rc.bacula
61 Source2: bexec.sh
62 Patch0: bacula.patch
64 # build information
65 BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc, gcc::with_cxx = yes
66 PreReq: OpenPKG, openpkg >= 20100101
67 BuildPreReq: ncurses, readline, zlib
68 PreReq: ncurses, readline, zlib
69 %if "%{with_ssl}" == "yes"
70 BuildPreReq: openssl >= 0.9.8, openssl::with_threads = yes
71 PreReq: openssl >= 0.9.8, openssl::with_threads = yes
72 %endif
73 %if "%{with_wrap}" == "yes"
74 BuildPreReq: tcpwrappers
75 PreReq: tcpwrappers
76 %endif
77 %if "%{with_db_sqlite}" == "yes"
78 BuildPreReq: sqlite
79 PreReq: sqlite
80 %endif
81 %if "%{with_db_mysql}" == "yes"
82 BuildPreReq: mysql
83 PreReq: mysql
84 %endif
85 %if "%{with_db_pgsql}" == "yes"
86 BuildPreReq: postgresql
87 PreReq: postgresql
88 %endif
89 %if "%{with_dvd}" == "yes"
90 BuildPreReq: dvdrw-tools
91 PreReq: dvdrw-tools
92 %endif
93 %if "%{with_mtx}" == "yes"
94 BuildPreReq: mtx
95 PreReq: mtx
96 %endif
97 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
98 BuildPreReq: python
99 PreReq: python
100 %endif
102 %description
103 Bacula is a set of computer programs that permit you (or the system
104 administrator) to manage backup, recovery, and verification of
105 computer data across a network of computers of different kinds. In
106 technical terms, it is a network client/server based backup program.
107 Bacula is relatively easy to use and efficient, while offering many
108 advanced storage management features that make it easy to find and
109 recover lost or damaged files.
111 %track
112 prog bacula = {
113 version = %{version}
114 url = http://sourceforge.net/projects/bacula/files/
115 regex = bacula-(\d+\.\d*[02468]\.\d+)\.tar\.gz
116 }
118 %prep
119 %setup -q
120 %patch -p0
121 rm -f src/lib/tcpd.h
122 %{l_shtool} subst \
123 -e 's;\( *\$(LDFLAGS)\)\(.*-L\.\.\/findlib\);\2\1;g' \
124 -e 's;\( *\$(LDFLAGS)\)\(.*-L\.\.\/cats\);\2\1;g' \
125 -e 's;\( *\$(LDFLAGS)\)\(.*-L\.\.\/lib\);\2\1;g' \
126 src/stored/Makefile.in \
127 src/console/Makefile.in \
128 src/dird/Makefile.in \
129 src/filed/Makefile.in \
130 src/tools/Makefile.in \
131 src/tray-monitor/Makefile.in \
133 %build
134 # generate a random director password
135 #password=`tr -dc A-Za-z0-9 </dev/urandom | head -c 33`
136 password=`%{l_openssl} rand -base64 33`
138 # for the same reason remove version informations from config files
139 %{l_shtool} subst \
140 -e "s;For Bacula release @VERSION@ .*;;" \
141 `find . -name "*.conf.in"`
143 # help specific platforms find fdatasync(3)
144 libs=""
145 case "%{l_platform -t}" in
146 *-sunos* ) libs="-lrt" ;;
147 esac
149 # use localhost as default host
150 %{l_shtool} subst \
151 -e 's;hostname=.*;hostname=localhost;g' \
152 configure
154 # configure
155 LIBS=
156 case "%{l_platform -t}" in
157 *-sunos*) LIBS="-ldl" ;;
158 esac
159 CC="%{l_cc}" \
160 CFLAGS="%{l_cflags -O}" \
161 CPPFLAGS="%{l_cppflags ncurses}" \
162 LDFLAGS="%{l_ldflags} $LIBS" \
163 ./configure \
164 --prefix=%{l_prefix} \
165 --with-dir-user=%{l_rusr} \
166 --with-dir-group=%{l_rgrp} \
167 --with-sd-user=%{l_rusr} \
168 --with-sd-group=%{l_rgrp} \
169 --with-fd-user=%{l_susr} \
170 --with-fd-group=%{l_sgrp} \
171 --with-dir-password="$password" \
172 --with-fd-password="$password" \
173 --with-sd-password="$password" \
174 --with-mon-dir-password="$password" \
175 --with-mon-fd-password="$password" \
176 --with-mon-sd-password="$password" \
177 --disable-conio \
178 --enable-readline \
179 --with-readline=%{l_prefix} \
180 %if "%{with_server}" != "yes"
181 --enable-client-only \
182 %endif
183 %if "%{with_ssl}" == "yes"
184 --with-openssl=%{l_prefix} \
185 %endif
186 %if "%{with_wrap}" == "yes"
187 --with-tcp-wrappers=yes \
188 %endif
189 %if "%{with_db_sqlite}" == "yes"
190 --with-sqlite3=%{l_prefix} \
191 %endif
192 %if "%{with_db_mysql}" == "yes"
193 --with-mysql=%{l_prefix} \
194 %endif
195 %if "%{with_db_pgsql}" == "yes"
196 --with-postgresql=%{l_prefix} \
197 %endif
198 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
199 --with-python=%{l_prefix} \
200 %endif
201 --sysconfdir=%{l_prefix}/etc/bacula \
202 --mandir=%{l_prefix}/man \
203 --with-scriptdir=%{l_prefix}/libexec/bacula \
204 --with-working-dir=%{l_prefix}/var/bacula \
205 --with-pid-dir=%{l_prefix}/var/bacula/run \
206 --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
207 --with-archivedir=/tmp \
208 --with-sbin-perm=0755 \
209 --disable-libtool \
210 --disable-nls
212 # build
213 %{l_make} %{l_mflags -O}
215 %install
216 # create installation hierarchy
217 %{l_shtool} mkdir -f -p -m 755 \
218 $RPM_BUILD_ROOT%{l_prefix}/bin \
219 $RPM_BUILD_ROOT%{l_prefix}/sbin \
220 $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
221 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
222 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
223 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
224 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
225 $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
226 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
227 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
228 $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
229 $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
230 $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \
231 $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config
233 # install
234 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
236 # strip down installation
237 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
238 ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
239 for unwanted in bconsole startmysql stopmysql; do
240 rm -f $unwanted
241 done
242 ) || exit $?
243 ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
244 rm -f bacula-bwxconsole.1 bacula-tray-monitor.1 bat.1
245 ) || exit $?
247 # install additional files
248 %{l_shtool} install -c -m 754 %{l_value -s -a} \
249 %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
251 ## wrap binaries to avoid specifying '-c' on each run
252 #( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
253 # for bin in bacula-dir bacula-fd bacula-sd \
254 # bconsole bcopy bextract bls bscan dbcheck \
255 # tray-monitor wx-console; do
256 # if [ -x $bin ]; then
257 # mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
258 # ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
259 # fi
260 # done
261 #) || exit $?
263 # install runcommand script
264 %{l_shtool} install -c -m 755 %{l_value -s -a} \
265 -e 's,@with_server@,%{with_server},g' \
266 %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
268 # determine installation files
269 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
270 %{l_files_std} \
271 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula' \
272 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \
273 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \
274 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \
275 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \
276 %if "%{with_server}" == "yes"
277 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
278 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\
279 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
280 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
281 %endif
282 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \
283 '%attr(-,%{l_musr},%{l_rgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \
284 '%attr(750,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/clients' \
285 '%attr(750,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/scripts'
287 %files -f files
289 %clean
291 %post
292 # create initial database
293 %if "%{with_server}" == "yes"
294 if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
295 $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
296 chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
297 chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
298 fi
299 %endif
301 # after upgrade, restart service
302 [ $1 -eq 2 ] || exit 0
303 eval `%{l_rc} bacula status 2>/dev/null`
304 [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
305 exit 0
307 %preun
308 # before erase, stop service and remove working files
309 [ $1 -eq 0 ] || exit 0
310 %{l_rc} bacula stop 2>/dev/null
311 rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
312 exit 0