]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/mandrake/bacula.spec.bluca.in
Update to sqlite3.
[bacula/bacula] / bacula / platforms / mandrake / bacula.spec.bluca.in
1 %define name bacula
2 %define version 1.32d
3 %define release 1mdk
4
5 %define MYSQL 0
6 %define GNOME 0
7 %define TCPW 1
8
9 %{?_with_mysql: %{expand: %%global MYSQL 1}}
10 %{?_without_mysql: %{expand: %%global MYSQL 0}}
11 %{?_with_gnome: %{expand: %%global GNOME 1}}
12 %{?_without_gnome: %{expand: %%global GNOME 0}}
13 %{?_with_wrap: %{expand: %%global TCPW 1}}
14 %{?_without_wrap: %{expand: %%global TCPW 0}}
15
16 %define blurb Bacula - It comes by night and sucks the vital essence from your computers.
17
18 Summary: Bacula - The Network Backup Solution
19 Name: %{name}
20 Version: %{version}
21 Release: %{release}
22 Group: Archiving/Backup
23 License: GPL
24 Source: http://www.prdownloads.sourceforge.net/bacula/%{name}-%{version}.tar.bz2
25 Source1: %{name}-icons.tar.bz2
26 BuildRoot: %{_tmppath}/%{name}-root
27 URL: http://www.bacula.org/
28 BuildRequires: readline-devel, perl-base, zlib-devel
29 %if %{TCPW}
30 BuildRequires: tcp_wrappers-devel
31 %endif
32 Patch0: bacula-1.32d-config.diff.bz2
33 Patch1: bacula-1.30a-prompt.diff.bz2
34
35 %description
36 %{blurb}
37 Bacula is a set of computer programs that permit you (or the system
38 administrator) to manage backup, recovery, and verification of computer
39 data across a network of computers of different kinds. In technical terms,
40 it is a network client/server based backup program. Bacula is relatively
41 easy to use and efficient, while offering many advanced storage management
42 features that make it easy to find and recover lost or damaged files.
43
44 %package dir
45 Summary: Bacula Director and Catalog services
46 Group: Archiving/Backup
47 Prereq: rpm-helper, perl-base
48 %if %{MYSQL}
49 Requires: MySQL >= 3.23
50 BuildRequires: MySQL-devel >= 3.23
51 %else
52 Requires: sqlite-tools
53 BuildRequires: sqlite-devel
54 %endif
55 Conflicts: bacula-fd < %{version}
56 Conflicts: bacula-sd < %{version}
57
58 %description dir
59 %{blurb}
60 Bacula Director is the program that supervises all the backup, restore, verify
61 and archive operations. The system administrator uses the Bacula Director to
62 schedule backups and to recover files.
63 Catalog services are comprised of the software programs responsible for
64 maintaining the file indexes and volume databases for all files backed up.
65 The Catalog services permit the System Administrator or user to quickly locate
66 and restore any desired file, since it maintains a record of all Volumes used,
67 all Jobs run, and all Files saved.
68 %if %{MYSQL}
69 This build requires MySQL to be installed separately as the catalog database.
70 %else
71 This build requires sqlite to be installed separately as the catalog database.
72 %endif
73
74 %package console
75 Summary: Bacula Console
76 Group: Archiving/Backup
77 Prereq: sed
78
79 %description console
80 %{blurb}
81 Bacula Console is the program that allows the administrator or user to
82 communicate with the Bacula Director.
83 This is the text only console interface.
84
85 %if %{GNOME}
86 %package console-gnome
87 Summary: Bacula Gnome Console
88 Group: Archiving/Backup
89 #BuildRequires: libgnome32-devel
90 BuildRequires: libgnomeui2-devel
91 Prereq: sed
92
93 %description console-gnome
94 %{blurb}
95 Bacula Console is the program that allows the administrator or user to
96 communicate with the Bacula Director.
97 This is the GNOME GUI interface.
98 %endif
99
100 %package fd
101 Summary: Bacula File services (Client)
102 Group: Archiving/Backup
103 Prereq: rpm-helper
104 Prereq: sed
105 Conflicts: bacula-dir < %{version}
106
107 %description fd
108 %{blurb}
109 Bacula File services (or Client program) is the software program that is
110 installed on the machine to be backed up. It is specific to the operating
111 system on which it runs and is responsible for providing the file attributes
112 and data when requested by the Director. The File services are also responsible
113 for the file system dependent part of restoring the file attributes and data
114 during a recovery operation.
115 This program runs as a daemon on the machine to be backed up, and in some of
116 the documentation, the File daemon is referred to as the Client (for example in
117 Bacula configuration file). 
118
119 %package sd
120 Summary: Bacula Storage services
121 Group: Archiving/Backup
122 Prereq: rpm-helper
123 Prereq: sed
124 Conflicts: bacula-dir < %{version}
125
126 %description sd
127 %{blurb}
128 Bacula Storage services consist of the software programs that perform the
129 storage and recovery of the file attributes and data to the physical backup
130 media or volumes. In other words, the Storage daemon is responsible for reading
131 and writing your tapes (or other storage media, e.g. files).
132 The Storage services runs as a daemon on the machine that has the backup
133 device (usually a tape drive).
134
135 %prep
136 %setup -q -c
137 cd %{name}-%{version}
138 %patch0 -p1 -b .config
139 %patch1 -p1 -b .prompt
140 mkdir doc/manual
141 mv doc/html-manual/*.html doc/manual
142 mv doc/html-manual/*.css doc/manual
143 mv doc/html-manual/*.gif doc/manual
144
145 %build
146 cd %{name}-%{version}
147 %serverbuild
148 %configure \
149         --enable-smartalloc \
150 %if %{MYSQL}
151         --with-mysql \
152 %else
153         --with-sqlite \
154 %endif
155 %if %{GNOME}
156                 --enable-gnome \
157 %endif
158 %if %{TCPW}
159                 --with-tcp-wrappers \
160 %endif
161         --sysconfdir=%{_sysconfdir}/%{name} \
162         --with-scriptdir=%{_libexecdir}/%{name} \
163         --with-working-dir=%{_localstatedir}/%{name} \
164         --with-subsys-dir=/var/lock/subsys \
165                 --with-dir-password="#FAKE#DIR#PASSWORD#" \
166                 --with-fd-password="#FAKE#FD#PASSWORD#" \
167                 --with-sd-password="#FAKE#SD#PASSWORD#"
168
169 %make
170
171 %install
172 cd %{name}-%{version}
173 rm -rf %{buildroot}
174 %makeinstall sysconfdir=%{buildroot}%{_sysconfdir}/%{name} scriptdir=%{buildroot}%{_libexecdir}/%{name} working_dir=%{buildroot}%{_localstatedir}/%{name}
175
176 # install the upgrade scripts
177 %if %{MYSQL}
178 install -m 755 src/cats/alter_mysql_tables %{buildroot}%{_libexecdir}/%{name}
179 %else
180 install -m 755 src/cats/alter_sqlite_tables %{buildroot}%{_libexecdir}/%{name}
181 %endif
182
183 # install the init scripts
184 mkdir -p %{buildroot}%{_initrddir}
185 install -m 755 platforms/mandrake/bacula-dir %{buildroot}%{_initrddir}/bacula-dir
186 install -m 755 platforms/mandrake/bacula-fd %{buildroot}%{_initrddir}/bacula-fd
187 install -m 755 platforms/mandrake/bacula-sd %{buildroot}%{_initrddir}/bacula-sd
188
189 # install the logrotate file
190 mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
191 cp scripts/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/bacula-dir
192
193 mkdir -p %{buildroot}%{_localstatedir}/%{name}
194
195 %if %{GNOME}
196 # install the menu stuff
197 mkdir -p $RPM_BUILD_ROOT%{_menudir}
198 cat << EOF > $RPM_BUILD_ROOT%{_menudir}/%{name}-console-gnome
199 ?package(%{name}-console-gnome): command="%{_sbindir}/gnome-console" icon="%{name}.png" needs="x11" title="Bacula Console" longtitle="Bacula Director Console" section="Applications/Archiving/Backup"
200 EOF
201 mkdir -p %{buildroot}%{_iconsdir}
202 tar jxvf %{SOURCE1} -C %{buildroot}%{_iconsdir}
203 %endif
204
205 perl -spi -e 's/"#FAKE#(\w+)#PASSWORD#"/#YOU MUST SET THE $1 PASSWORD#/' %{buildroot}%{_sysconfdir}/%{name}/*.conf
206 touch %{buildroot}%{_sysconfdir}/%{name}/.pw.sed
207
208 %clean
209 rm -rf %{buildroot}
210
211 %files dir
212 %defattr(644, root, root, 755)
213 %doc %{name}-%{version}/ChangeLog %{name}-%{version}/CheckList %{name}-%{version}/ReleaseNotes %{name}-%{version}/kernstodo
214 %doc %{name}-%{version}/doc/*.pdf %{name}-%{version}/doc/manual %{name}-%{version}/examples
215 %attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-dir.conf
216 %ghost %{_sysconfdir}/%{name}/.pw.sed
217 %config(noreplace) %{_sysconfdir}/logrotate.d/bacula-dir
218 %defattr (755, root, root)
219 %config(noreplace) %{_initrddir}/bacula-dir
220 %{_sbindir}/bacula-dir
221 %{_sbindir}/btraceback
222 %{_sbindir}/dbcheck
223 %{_sbindir}/smtp
224 %dir %{_libexecdir}/%{name}
225 %attr(644, root, root) %{_libexecdir}/%{name}/btraceback.gdb
226 %if %{MYSQL}
227 %{_libexecdir}/%{name}/create_mysql_database
228 %{_libexecdir}/%{name}/drop_mysql_tables
229 %{_libexecdir}/%{name}/grant_mysql_privileges
230 %{_libexecdir}/%{name}/make_mysql_tables
231 %{_libexecdir}/%{name}/alter_mysql_tables
232 %else
233 %{_libexecdir}/%{name}/create_sqlite_database
234 %{_libexecdir}/%{name}/drop_sqlite_tables
235 %exclude %{_libexecdir}/%{name}/grant_mysql_privileges
236 %{_libexecdir}/%{name}/make_sqlite_tables
237 %{_libexecdir}/%{name}/alter_sqlite_tables
238 %endif
239 %{_libexecdir}/%{name}/delete_catalog_backup
240 %{_libexecdir}/%{name}/drop_bacula_tables
241 %{_libexecdir}/%{name}/make_bacula_tables
242 %{_libexecdir}/%{name}/make_catalog_backup
243 %attr(644, root, root) %{_libexecdir}/%{name}/query.sql
244 %attr(700, root, root) %dir %{_localstatedir}/%{name}
245
246 %pre dir -p /usr/bin/perl
247 umask(0077);
248 if ( -f "%{_sysconfdir}/%{name}/.pw.sed") {
249         if ( -f "%{_sysconfdir}/%{name}/bacula-dir.conf") {
250         system "sed -e 's/s!\(.*\)!\(.*\)!/s!\2!\1!/' %{_sysconfdir}/%{name}/.pw.sed > %{_sysconfdir}/%{name}/.upw.sed";
251         system "sed -f %{_sysconfdir}/%{name}/.upw.sed %{_sysconfdir}/%{name}/bacula-dir.conf > %{_sysconfdir}/%{name}/bacula-dir.conf.tmp";
252         unlink "%{_sysconfdir}/%{name}/bacula-dir.conf";
253         rename "%{_sysconfdir}/%{name}/bacula-dir.conf.tmp", "%{_sysconfdir}/%{name}/bacula-dir.conf";
254         unlink "%{_sysconfdir}/%{name}/.upw.sed";
255         }
256 } else {
257         mkdir("%{_sysconfdir}/%{name}");
258         open(IN, "/dev/random") or die "$!";
259         open(OUT, ">%{_sysconfdir}/%{name}/.pw.sed") or die "$!";
260         foreach $c ("DIR","SD","FD") {
261                 read(IN, $buf, 32);
262                 my $res = pack("u", $buf);
263                 $res =~ s/^.//mg;
264                 $res =~ s/\n//g;
265                 $res =~ tr|` -_|AA-Za-z0-9+/|;
266                 print OUT "s!#YOU MUST SET THE $c PASSWORD#!\"$res\"!\n";
267         }
268         close (IN);
269         close (OUT);
270 }
271
272 %post dir
273 %if %{MYSQL}
274 # NOTE: IF THIS FAILS DUE TO MYSQL NEEDING A PASSWORD YOU ARE ON YOUR OWN
275 DB_VER=`mysql bacula -e 'select * from Version;'|tail -n 1 2>/dev/null`
276 if [ -z "$DB_VER" ]; then
277 # grant privileges and create tables
278         echo "Granting privileges for MySQL user bacula..."
279         %{_libexecdir}/%{name}/grant_mysql_privileges > dev/null
280         echo "Creating MySQL bacula database..."
281         %{_libexecdir}/%{name}/create_mysql_database > dev/null
282         echo "Creating bacula tables..."
283         %{_libexecdir}/%{name}/make_mysql_tables > dev/null
284 elif [ "$DB_VER" -lt "6" ]; then
285         echo "Backing up bacula tables"
286         mysqldump -f --opt bacula | bzip2 > %{_localstatedir}/%{name}/bacula_backup.sql.bz2
287         echo "Upgrading bacula tables"
288         %{_libexecdir}/%{name}/alter_mysql_tables
289         echo "If bacula works correctly you can remove the backup file %{_localstatedir}/%{name}/bacula_backup.sql.bz2"
290 fi
291 %else
292 if [ -s %{_localstatedir}/%{name}/bacula.db ]; then
293 DB_VER=`echo "select * from Version;" | sqlite %{_localstatedir}/%{name}/bacula.db|tail -n 1 2>/dev/null`
294         if [ "$DB_VER" -lt "6" ]; then
295                 echo "Backing up bacula tables"
296                 echo ".dump" | sqlite %{_localstatedir}/%{name}/bacula.db | bzip2 > %{_localstatedir}/%{name}/bacula_backup.sql.bz2
297                 echo "Upgrading bacula tables"
298                 %{_libexecdir}/%{name}/alter_sqlite_tables
299                 echo "If bacula works correctly you can remove the backup file %{_localstatedir}/%{name}/bacula_backup.sql.bz2"
300         fi
301 else
302 # create the tables
303         echo "Creating bacula tables..."
304         %{_libexecdir}/%{name}/make_sqlite_tables > dev/null
305 fi
306 %endif
307 chmod -R 600 %{_localstatedir}/%{name}/*
308 for i in %{_sysconfdir}/%{name}/*.conf %{_sysconfdir}/%{name}/*.conf.rpmnew %{_sysconfdir}/%{name}/*.conf.rpmsave; do
309         if [ -s $i ]; then
310         sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp
311 # this is needed if upgrading from 1.30a or lower
312         sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i
313         rm -f $i.tmp
314         fi
315 done
316 %_post_service bacula-dir
317
318 %preun dir
319 %_preun_service bacula-dir
320
321 %files fd
322 %defattr(755, root, root)
323 %attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-fd.conf
324 %config(noreplace) %{_initrddir}/bacula-fd
325 %{_sbindir}/bacula-fd
326 %{_sbindir}/btraceback
327 %{_sbindir}/smtp
328 %dir %{_libexecdir}/%{name}
329 %attr(644, root, root) %{_libexecdir}/%{name}/btraceback.gdb
330 %attr(700, root, root) %dir %{_localstatedir}/%{name}
331
332 %pre fd
333 umask 077
334 i=%{_sysconfdir}/%{name}/bacula-fd.conf
335 if [ -s %{_sysconfdir}/%{name}/.pw.sed -a -s $i ]; then
336         sed -e 's/s!\(.*\)!\(.*\)!/s!\2!\1!/' %{_sysconfdir}/%{name}/.pw.sed > %{_sysconfdir}/%{name}/.upw.sed
337         sed -f %{_sysconfdir}/%{name}/.upw.sed $i > $i.tmp
338         mv -f $i.tmp $i
339         rm -f %{_sysconfdir}/%{name}/.upw.sed
340 fi
341
342 %post fd
343 %_post_service bacula-fd
344 if [ -s %{_sysconfdir}/%{name}/.pw.sed ]; then
345         for i in %{_sysconfdir}/%{name}/bacula-fd.conf %{_sysconfdir}/%{name}/bacula-fd.conf.rpmnew %{_sysconfdir}/%{name}/bacula-fd.conf.rpmsave; do
346         if [ -s $i ]; then
347                 sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp
348 # this is needed if upgrading from 1.30a or lower
349                 sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i
350                 rm -f $i.tmp
351         fi
352         done
353 fi
354
355 %preun fd
356 %_preun_service bacula-fd
357
358 %files sd
359 %defattr(755, root, root)
360 %attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-sd.conf
361 %config(noreplace) %{_initrddir}/bacula-sd
362 %{_sbindir}/bacula-sd
363 %{_sbindir}/bcopy
364 %{_sbindir}/bextract
365 %{_sbindir}/bls
366 %{_sbindir}/bscan
367 %{_sbindir}/btape
368 %{_sbindir}/btraceback
369 %{_sbindir}/smtp
370 %dir %{_libexecdir}/%{name}
371 %attr(644, root, root) %{_libexecdir}/%{name}/btraceback.gdb
372 %{_libexecdir}/%{name}/mtx-changer
373 %attr(700, root, root) %dir %{_localstatedir}/%{name}
374
375 %pre sd
376 umask 077
377 i=%{_sysconfdir}/%{name}/bacula-sd.conf
378 if [ -s %{_sysconfdir}/%{name}/.pw.sed -a -s $i ]; then
379         sed -e 's/s!\(.*\)!\(.*\)!/s!\2!\1!/' %{_sysconfdir}/%{name}/.pw.sed > %{_sysconfdir}/%{name}/.upw.sed
380         sed -f %{_sysconfdir}/%{name}/.upw.sed $i > $i.tmp
381         mv -f $i.tmp $i
382         rm -f %{_sysconfdir}/%{name}/.upw.sed
383 fi
384
385 %post sd
386 %_post_service bacula-sd
387 if [ -s %{_sysconfdir}/%{name}/.pw.sed ]; then
388         for i in %{_sysconfdir}/%{name}/bacula-sd.conf %{_sysconfdir}/%{name}/bacula-sd.conf.rpmnew %{_sysconfdir}/%{name}/bacula-sd.conf.rpmsave; do
389         if [ -s $i ]; then
390                 sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp
391 # this is needed if upgrading from 1.30a or lower
392                 sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i
393                 rm -f $i.tmp
394         fi
395         done
396 fi
397
398 %preun sd
399 %_preun_service bacula-sd
400
401 %files console
402 %defattr(755, root, root)
403 %attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/console.conf
404 %{_sbindir}/console
405 %{_sbindir}/btraceback
406 %{_sbindir}/smtp
407 %dir %{_libexecdir}/%{name}
408 %attr(644, root, root) %{_libexecdir}/%{name}/btraceback.gdb
409
410 %pre console
411 umask 077
412 i=%{_sysconfdir}/%{name}/console.conf
413 if [ -s %{_sysconfdir}/%{name}/.pw.sed -a -s $i ]; then
414         sed -e 's/s!\(.*\)!\(.*\)!/s!\2!\1!/' %{_sysconfdir}/%{name}/.pw.sed > %{_sysconfdir}/%{name}/.upw.sed
415         sed -f %{_sysconfdir}/%{name}/.upw.sed $i > $i.tmp
416         mv -f $i.tmp $i
417         rm -f %{_sysconfdir}/%{name}/.upw.sed
418 fi
419
420 %post console
421 if [ -s %{_sysconfdir}/%{name}/.pw.sed ]; then
422         for i in %{_sysconfdir}/%{name}/console.conf %{_sysconfdir}/%{name}/console.conf.rpmnew %{_sysconfdir}/%{name}/console.conf.rpmsave; do
423         if [ -s $i ]; then
424                 sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp
425 # this is needed if upgrading from 1.30a or lower
426                 sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i
427                 rm -f $i.tmp
428         fi
429         done
430 fi
431
432 %if %{GNOME}
433 %files console-gnome
434 %defattr(644, root, root, 755)
435 %{_iconsdir}/bacula.png
436 %{_iconsdir}/mini/bacula.png
437 %{_iconsdir}/large/bacula.png
438 %{_menudir}/bacula-console-gnome
439 %attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/gnome-console.conf
440 %attr(755, root, root) %{_sbindir}/gnome-console
441 %attr(755, root, root) %{_sbindir}/btraceback
442 %attr(755, root, root) %{_sbindir}/smtp
443 %dir %{_libexecdir}/%{name}
444 %{_libexecdir}/%{name}/btraceback.gdb
445
446 %pre console-gnome
447 umask 077
448 i=%{_sysconfdir}/%{name}/gnome-console.conf
449 if [ -s %{_sysconfdir}/%{name}/.pw.sed -a -s $i ]; then
450         sed -e 's/s!\(.*\)!\(.*\)!/s!\2!\1!/' %{_sysconfdir}/%{name}/.pw.sed > %{_sysconfdir}/%{name}/.upw.sed
451         sed -f %{_sysconfdir}/%{name}/.upw.sed $i > $i.tmp
452         mv -f $i.tmp $i
453         rm -f %{_sysconfdir}/%{name}/.upw.sed
454 fi
455
456 %post console-gnome
457 %update_menus
458 if [ -s %{_sysconfdir}/%{name}/.pw.sed ]; then
459         for i in %{_sysconfdir}/%{name}/gnome-console.conf %{_sysconfdir}/%{name}/gnome-console.conf.rpmnew %{_sysconfdir}/%{name}/gnome-console.conf.rpmsave; do
460         if [ -s $i ]; then
461                 sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp
462 # this is needed if upgrading from 1.30a or lower
463                 sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i
464                 rm -f $i.tmp
465         fi
466         done
467 fi
468                 
469 %postun console-gnome
470 %clean_menus
471
472 %endif
473
474 %changelog
475 * Tue Nov 04 2003 Luca Berra <bluca@vodka.it> 1.32d-1mdk
476 - 1.32d
477 - use gnome2 for console
478 - use tcp_wrappers
479 - try not to create unneeded .rpmnew in configuration
480
481 * Fri Aug 12 2003 Luca Berra <bluca@vodka.it> 1.31a-1mdk
482 - 1.31a
483 - modified %%post script to upgrade database if needed and do not try to create if it already exists.
484 - %%post_service should be last in %%post script
485 - changed sql upgrade script to remove multiple Version rows introduced by %%post
486 - trying to create the tables multiple times in previous releases.
487 - smtp is required by btraceback which is required by every daemon.
488 - added conflicts for lower version
489
490 * Wed Aug  6 2003 Luca Berra <bluca@vodka.it> 1.30a-3mdk
491 - changed sqlite requires to match package in contrib
492 - set passwords for single components to produce an error until user changes them
493 - try to change passwords automatically if dir package is installed
494
495 * Sun Aug  3 2003 Luca Berra <bluca@vodka.it> 1.30a-2mdk
496 - many spec changes
497 - almost please rpmlint
498 - fixed readline eats last message bug in console
499
500 * Fri Aug  1 2003 Luca Berra <bluca@vodka.it> 1.30a-1mdk
501 - Initial spec file from spec by D. Scott Barninger <barninger at fairfieldcomputers.com>