Wed, 07 Jan 2009 22:13:49 +0100
Import package vendor original specs for necessary manipulations.
1 ##
2 ## bacula.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2008 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 # package information
25 Name: bacula
26 Summary: Network Backup Tool
27 URL: http://www.bacula.org/
28 Vendor: Kern Sibbald
29 Packager: OpenPKG Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: PLUS
32 Group: System
33 License: GPL
34 Version: 2.4.3
35 Release: 20081118
37 # package options
38 %option with_server yes
39 %option with_ssl yes
40 %option with_wrap no
41 %option with_dvd no
42 %option with_mtx no
43 %option with_python no
44 %option with_db_sqlite no
45 %option with_db_pgsql no
46 %option with_db_mysql no
48 # package option sanity check
49 %if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
50 %undefine with_db_sqlite
51 %define with_db_sqlite yes
52 %endif
54 # list of sources
55 Source0: http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
56 Source1: rc.bacula
57 Source2: bexec.sh
58 Patch0: bacula.patch
60 # build information
61 Prefix: %{l_prefix}
62 BuildRoot: %{l_buildroot}
63 BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, gcc::with_cxx = yes
64 PreReq: OpenPKG, openpkg >= 20060823
65 BuildPreReq: ncurses, readline, zlib
66 PreReq: ncurses, readline, zlib
67 %if "%{with_ssl}" == "yes"
68 BuildPreReq: openssl >= 0.9.8
69 PreReq: openssl >= 0.9.8
70 %endif
71 %if "%{with_wrap}" == "yes"
72 BuildPreReq: tcpwrappers
73 PreReq: tcpwrappers
74 %endif
75 %if "%{with_db_sqlite}" == "yes"
76 BuildPreReq: sqlite
77 PreReq: sqlite
78 %endif
79 %if "%{with_db_mysql}" == "yes"
80 BuildPreReq: mysql
81 PreReq: mysql
82 %endif
83 %if "%{with_db_pgsql}" == "yes"
84 BuildPreReq: postgresql
85 PreReq: postgresql
86 %endif
87 %if "%{with_dvd}" == "yes"
88 BuildPreReq: dvdrw-tools
89 PreReq: dvdrw-tools
90 %endif
91 %if "%{with_mtx}" == "yes"
92 BuildPreReq: mtx
93 PreReq: mtx
94 %endif
95 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
96 BuildPreReq: python
97 PreReq: python
98 %endif
99 AutoReq: no
100 AutoReqProv: no
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://prdownloads.sourceforge.net/bacula/
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
123 %build
124 # generate a random director password
125 password="`openssl rand -base64 33`"
127 # for the same reason remove version informations from config files
128 %{l_shtool} subst \
129 -e "s;For Bacula release @VERSION@ .*;;" \
130 `find . -name "*.conf.in"`
132 # help specific platforms find fdatasync(3)
133 libs=""
134 case "%{l_platform -t}" in
135 *-sunos* ) libs="-lrt" ;;
136 esac
138 # use localhost as default host
139 %{l_shtool} subst \
140 -e 's;hostname=.*;hostname=localhost;g' \
141 -e 's;\(CONS_LIBS="-lreadline.*\)-ltermcap;\1-lncurses;g' \
142 configure
144 # configure
145 LIBS=
146 case "%{l_platform -t}" in
147 *-linux*) LIBS="-L/usr/lib/termcap";;
148 esac
149 CC="%{l_cc}" \
150 CFLAGS="%{l_cflags -O}" \
151 CPPFLAGS="%{l_cppflags ncurses}" \
152 LDFLAGS="%{l_ldflags} $LIBS" \
153 LIBS="$libs" \
154 ./configure \
155 --prefix=%{l_prefix} \
156 --with-dir-user=%{l_rusr} \
157 --with-dir-group=%{l_rgrp} \
158 --with-sd-user=%{l_rusr} \
159 --with-sd-group=%{l_rgrp} \
160 --with-fd-user=%{l_susr} \
161 --with-fd-group=%{l_sgrp} \
162 --with-dir-password="$password" \
163 --with-fd-password="$password" \
164 --with-sd-password="$password" \
165 --with-mon-dir-password="$password" \
166 --with-mon-fd-password="$password" \
167 --with-mon-sd-password="$password" \
168 --disable-conio \
169 --enable-readline \
170 --with-readline=%{l_prefix} \
171 %if "%{with_server}" != "yes"
172 --enable-client-only \
173 %endif
174 %if "%{with_ssl}" == "yes"
175 --with-openssl=%{l_prefix} \
176 %endif
177 %if "%{with_wrap}" == "yes"
178 --with-tcp-wrappers=yes \
179 %endif
180 %if "%{with_db_sqlite}" == "yes"
181 --with-sqlite3=%{l_prefix} \
182 %endif
183 %if "%{with_db_mysql}" == "yes"
184 --with-mysql=%{l_prefix} \
185 %endif
186 %if "%{with_db_pgsql}" == "yes"
187 --with-postgresql=%{l_prefix} \
188 %endif
189 %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
190 --with-python=%{l_prefix} \
191 %endif
192 --enable-wx-console=no \
193 --sysconfdir=%{l_prefix}/etc/bacula \
194 --libexecdir=%{l_prefix}/libexec/bacula \
195 --mandir=%{l_prefix}/man \
196 --with-scriptdir=%{l_prefix}/libexec/bacula \
197 --with-working-dir=%{l_prefix}/var/bacula \
198 --with-pid-dir=%{l_prefix}/var/bacula/run \
199 --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
200 --with-archivedir=/tmp \
201 --with-sbin-perm=0755 \
202 --disable-nls
204 # build
205 %{l_make} %{l_mflags -O}
207 %install
208 rm -rf $RPM_BUILD_ROOT
210 # create installation hierarchy
211 %{l_shtool} mkdir -f -p -m 755 \
212 $RPM_BUILD_ROOT%{l_prefix}/bin \
213 $RPM_BUILD_ROOT%{l_prefix}/sbin \
214 $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
215 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
216 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
217 $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
218 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
219 $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
220 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
221 $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
222 $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
223 $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
224 $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \
225 $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config
227 # install
228 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
230 # strip down installation
231 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
232 ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
233 for unwanted in startmysql stopmysql; do
234 rm -f $unwanted
235 done
236 ) || exit $?
238 # install additional files
239 %{l_shtool} install -c -m 754 %{l_value -s -a} \
240 %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
241 %{l_shtool} install -c -m 640 \
242 src/console/bconsole.conf $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/
244 ## wrap binaries to avoid to specify "-c" for each run
245 #( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
246 # for bin in bacula-dir bacula-fd bacula-sd \
247 # bconsole bcopy bextract bls bscan dbcheck \
248 # tray-monitor wx-console; do
249 # if [ -x $bin ]; then
250 # mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
251 # ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
252 # fi
253 # done
254 #) || exit $?
256 # install run-command script
257 %{l_shtool} install -c -m 755 %{l_value -s -a} \
258 -e 's,@with_server@,%{with_server},g' \
259 %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
261 # determine installation files
262 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
263 %{l_files_std} \
264 '%attr(640,%{l_musr},%{l_mgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \
265 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula' \
266 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \
267 '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \
268 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \
269 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \
270 %if "%{with_server}" == "yes"
271 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
272 '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\
273 '%config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
274 '%config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
275 %endif
276 '%config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \
277 %if "%{with_server}" == "yes"
278 '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-dir.conf' \
279 '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-sd.conf' \
280 %endif
281 '%attr(640,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/bacula/bacula-fd.conf'
283 %files -f files
285 %clean
286 rm -rf $RPM_BUILD_ROOT
288 %post
289 # create initial database
290 if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
291 $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
292 chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
293 chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
294 fi
296 # after upgrade, restart service
297 [ $1 -eq 2 ] || exit 0
298 eval `%{l_rc} bacula status 2>/dev/null`
299 [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
300 exit 0
302 %preun
303 # before erase, stop service and remove working files
304 [ $1 -eq 0 ] || exit 0
305 %{l_rc} bacula stop 2>/dev/null
306 rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
307 exit 0