]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/redhat/bacula.spec
Apply Philipp's fix for dbcheck use by make_catalog_backup.pl
[bacula/bacula] / bacula / platforms / redhat / bacula.spec
1 # Bacula RPM spec file
2 #
3 # Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
4
5 # Platform Build Configuration
6
7 # basic defines for every build
8 %define _release           1
9 %define _version           5.0.0
10 %define _packager D. Scott Barninger <barninger@fairfieldcomputers.com>
11 %define depkgs_version 18Dec09
12
13 %define single_dir 0
14 %{?single_dir_install:%define single_dir 1}
15
16 # Installation Directory locations
17 %if %{single_dir}
18 %define _prefix        /opt/bacula
19 %define _sbindir       /opt/bacula/bin
20 %define _bindir        /opt/bacula/bin
21 %define _subsysdir     /opt/bacula/working
22 %define sqlite_bindir /opt/bacula/sqlite
23 %define _mandir        /usr/share/man
24 %define sysconf_dir    /opt/bacula/etc
25 %define script_dir     /opt/bacula/scripts
26 %define working_dir    /opt/bacula/working
27 %define pid_dir        /opt/bacula/working
28 %define plugin_dir     /opt/bacula/plugins
29 %define lib_dir        /opt/bacula/lib
30 %else
31 %define _prefix        /usr
32 %define _sbindir       %_prefix/sbin
33 %define _bindir        %_prefix/bin
34 %define _subsysdir     /var/lock/subsys
35 %define sqlite_bindir %_libdir/bacula/sqlite
36 %define _mandir        %_prefix/share/man
37 %define sysconf_dir    /etc/bacula
38 %define script_dir     %_libdir/bacula
39 %define working_dir    /var/lib/bacula
40 %define pid_dir        /var/run
41 %define plugin_dir     %_libdir/bacula/plugins
42 %define lib_dir        %_libdir/bacula/lib
43 %endif
44
45 # Daemon user:group Don't change them unless you know what you are doing
46 %define director_daemon_user    bacula
47 %define storage_daemon_user     bacula
48 %define file_daemon_user        root
49 %define daemon_group            bacula
50 # group that has write access to tape devices, usually disk on Linux
51 %define storage_daemon_group    disk
52
53 %define depkgs ../depkgs
54
55 # probems with mandriva build: 
56 # nothing provides libbonobo2_0-devel, nothing provides libbonoboui2_0-devel
57
58 # set Macros by opensuse_bs, see http://en.opensuse.org/Build_Service/cross_distribution_package_how_to
59 #openSUSE 11.1          %if 0%{?suse_version} == 1110  
60 #openSUSE 11.0          %if 0%{?suse_version} == 1100   
61 #openSUSE 10.3          %if 0%{?suse_version} == 1030   
62 #openSUSE 10.2          %if 0%{?suse_version} == 1020   
63 #SUSE Linux 10.1        %if 0%{?suse_version} == 1010   
64 #SUSE Linux 10.0        %if 0%{?suse_version} == 1000   
65 #SUSE Linux 9.3         %if 0%{?suse_version} == 930    
66 #SLES 9                 %if 0%{?sles_version} == 9      also set: %if 0%{?suse_version} == 910
67 #SLE 10                 %if 0%{?sles_version} == 10     also set: %if 0%{?suse_version} == 1010
68 #SLE 11                 %if 0%{?sles_version} == 11     also set: %if 0%{?suse_version} == 1110
69 #CentOS 5               %if 0%{?centos_version} == 501  
70 #RHEL 4                 %if 0%{?rhel_version} == 406    
71 #RHEL 5                 %if 0%{?rhel_version} == 501    
72 #Fedora 6 with Extras   %if 0%{?fedora_version} == 6    
73 #Fedora 7 with Extras   %if 0%{?fedora_version} == 7    
74 #Fedora 8 with Extras   %if 0%{?fedora_version} == 8    
75 #Fedora 9 with Extras   %if 0%{?fedora_version} == 9    
76 #Fedora 10 with Extras  %if 0%{?fedora_version} == 10   
77 #Mandriva 2006          %if 0%{?mandriva_version} == 2006       
78 #Mandriva 2007          %if 0%{?mandriva_version} == 2007       
79 #Mandriva 2008          %if 0%{?mandriva_version} == 2008       
80
81
82 %if 0%{?opensuse_bs}
83 # am I running in opensuse build service?
84 # TODO: seems to make problems
85
86 # choose database backend here
87 # postgres, mysql, sqlite
88 %define build_mysql 1
89
90 # Build Service: Determine Distribution
91
92 %ifarch x86_64
93  %define build_x86_64 1
94 %endif
95
96
97 %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
98 BuildRequires: GConf2-devel
99 BuildRequires: freetype-devel
100 BuildRequires: libtermcap-devel
101 BuildRequires: shadow-utils
102 %endif
103
104
105 %if 0%{?mandriva_version} == 2007
106 %define build_mdv 1
107 %define _dist "Mandriva 2007"
108 %endif
109
110 %if 0%{?fedora_version} == 8
111 %define build_fc8 1
112 %define _dist "Fedora Core 8"
113 BuildRequires: redhat-release
114 %endif
115
116 %if 0%{?fedora_version} == 9
117 %define build_fc9 1
118 %define _dist "Fedora Core 9"
119 BuildRequires: redhat-release
120 %endif
121
122
123 %if 0%{?fedora_version} == 10
124 %define build_fc9 1
125 %define _dist "Fedora Core 10"
126 BuildRequires: PolicyKit-gnome
127 BuildRequires: fedora-release
128 %endif
129
130 %if 0%{?fedora_version} == 11
131 %define build_fc9 1
132 %define _dist "Fedora Core 11"
133 BuildRequires: PolicyKit-gnome
134 BuildRequires: fedora-release
135 %endif
136
137 %if 0%{?rhel_version} == 501
138 %define build_rhel5 1
139 %define _dist "Red Hat Enterprise Linux Server release 5"
140 BuildRequires: redhat-release
141 %endif
142
143 %if 0%{?rhel_version} == 406
144 %define build_rhel4 1
145 %define _dist "Red Hat Enterprise Linux Server release 4"
146 BuildRequires: redhat-release
147 %endif
148
149
150 %if 0%{?centos_version} == 501
151 %define build_centos5 1
152 %define _dist "CentOS 5"
153 BuildRequires: redhat-release
154 %endif
155
156
157 %if 0%{?suse_version} == 1020
158 %define build_su102 1
159 %define _dist "OpenSUSE 10.2"
160 BuildRequires: suse-release
161 %endif
162
163
164 %if 0%{?suse_version} == 1030
165 %define build_su103 1
166 %define _dist "OpenSUSE 10.3"
167 BuildRequires: suse-release
168 %endif
169
170 %if 0%{?suse_version} == 1100
171 %define build_su110 1
172 %define _dist "SUSE 11"
173 BuildRequires: suse-release
174 %endif
175
176
177 %if 0%{?suse_version} == 1110
178 %define build_su111 1
179 %define _dist "SUSE 11"
180 %endif
181
182 %if 0%{?suse_version} == 1120
183 %define build_su112 1
184 %define _dist "SUSE 11"
185 %endif
186
187
188 %if 0%{?sles_version} == 9
189 %define build_su9 1
190 %define _dist "SLES 9"
191 %endif
192
193
194 %if 0%{?sles_version} == 10
195 %define build_su10 1
196 %define _dist "SLE 10"
197 %endif
198
199
200 %if 0%{?sles_version} == 11
201 %define build_su111 1
202 %define _dist "SLES 11"
203 %endif
204
205 %endif 
206 # opensuse-bs?
207
208
209 # any patches for this release
210 # be sure to check the setup section for patch macros
211
212 #--------------------------------------------------------------------------
213 # it should not be necessary to change anything below here for a release
214 # except for patch macros in the setup section
215 #--------------------------------------------------------------------------
216
217 %{?contrib_packager:%define _packager %{contrib_packager}}
218
219 Summary: Bacula - The Network Backup Solution
220 Name: bacula
221 Version: %{_version}
222 Release: %{_release}
223 Group: System Environment/Daemons
224 License: GPL v2
225 BuildRoot: %{_tmppath}/%{name}-root
226 URL: http://www.bacula.org/
227 Vendor: The Bacula Team
228 Packager: %{_packager}
229 Prefix: %{_prefix}
230
231 Source0: http://www.prdownloads.sourceforge.net/bacula/%{name}-%{version}.tar.gz
232 # opensuse build service changes the release itself
233 %if 0%{?opensuse_bs}
234 Source1: Release_Notes-%{version}-1.tar.gz
235 %else
236 Source1: Release_Notes-%{version}-%{release}.tar.gz
237 %endif
238 Source2: bacula-2.2.7-postgresql.patch
239 Source3: http://www.prdownloads.sourceforge.net/bacula/depkgs-%{depkgs_version}.tar.gz
240
241 # define the basic package description
242 %define blurb Bacula - It comes by night and sucks the vital essence from your computers.
243 %define blurb2 Bacula is a set of computer programs that permit you (or the system
244 %define blurb3 administrator) to manage backup, recovery, and verification of computer
245 %define blurb4 data across a network of computers of different kinds. In technical terms,
246 %define blurb5 it is a network client/server based backup program. Bacula is relatively
247 %define blurb6 easy to use and efficient, while offering many advanced storage management
248 %define blurb7 features that make it easy to find and recover lost or damaged files.
249 %define blurb8 Bacula source code has been released under the GPL version 2 license.
250
251 %define user_file  /etc/passwd
252 %define group_file /etc/group
253
254 # program locations
255 %define useradd  /usr/sbin/useradd
256 %define groupadd /usr/sbin/groupadd
257 %define usermod  /usr/sbin/usermod
258
259 # platform defines - set one below or define the build_xxx on the command line
260 # RedHat builds
261 %define rh7 0
262 %{?build_rh7:%define rh7 1}
263 %define rh8 0
264 %{?build_rh8:%define rh8 1}
265 %define rh9 0
266 %{?build_rh9:%define rh9 1}
267 # Fedora Core build
268 %define fc1 0
269 %{?build_fc1:%define fc1 1}
270 %define fc3 0
271 %{?build_fc3:%define fc3 1}
272 %define fc4 0
273 %{?build_fc4:%define fc4 1}
274 %define fc5 0
275 %{?build_fc5:%define fc5 1}
276 %define fc6 0
277 %{?build_fc6:%define fc6 1}
278 %define fc7 0
279 %{?build_fc7:%define fc7 1}
280 %define fc8 0
281 %{?build_fc8:%define fc8 1}
282 %define fc9 0
283 %{?build_fc9:%define fc9 1}
284 %define fc10 0
285 %{?build_fc10:%define fc10 1}
286 # Whitebox Enterprise build
287 %define wb3 0
288 %{?build_wb3:%define wb3 1}
289 # RedHat Enterprise builds
290 %define rhel3 0
291 %{?build_rhel3:%define rhel3 1}
292 %{?build_rhel3:%define wb3 1}
293 %define rhel4 0
294 %{?build_rhel4:%define rhel4 1}
295 %{?build_rhel4:%define fc3 1}
296 %define rhel5 0
297 %{?build_rhel5:%define rhel5 1}
298 %{?build_rhel5:%define fc6 1}
299 # CentOS build
300 %define centos3 0
301 %{?build_centos3:%define centos3 1}
302 %{?build_centos3:%define wb3 1}
303 %define centos4 0
304 %{?build_centos4:%define centos4 1}
305 %{?build_centos4:%define fc3 1}
306 %define centos5 0
307 %{?build_centos5:%define centos5 1}
308 %{?build_centos5:%define fc6 1}
309 # SL build
310 %define sl3 0
311 %{?build_sl3:%define sl3 1}
312 %{?build_sl3:%define wb3 1}
313 %define sl4 0
314 %{?build_sl4:%define sl4 1}
315 %{?build_sl4:%define fc3 1}
316 %define sl5 0
317 %{?build_sl5:%define sl5 1}
318 %{?build_sl5:%define fc6 1}
319 # SuSE build
320 %define su9 0
321 %{?build_su9:%define su9 1}
322 %define su10 0
323 %{?build_su10:%define su10 1}
324 %define su102 0
325 %{?build_su102:%define su102 1}
326 %define su103 0
327 %{?build_su103:%define su103 1}
328 %define su110 0
329 %{?build_su110:%define su110 1}
330 %define su111 0
331 %{?build_su111:%define su111 1}
332 %define su112 0
333 %{?build_su112:%define su112 1}
334 # Mandrake builds
335 %define mdk 0
336 %{?build_mdk:%define mdk 1}
337 %define mdv 0
338 %{?build_mdv:%define mdv 1}
339 %{?build_mdv:%define mdk 1}
340
341 # client only build
342 %define client_only 0
343 %{?build_client_only:%define client_only 1}
344
345 # Setup some short cuts
346 %define rhat 0
347 %if %{rh7} || %{rh8} || %{rh9}
348 %define rhat 1
349 %endif
350 %define fed 0
351 %if %{fc1} || %{fc3} || %{fc4} || %{fc5} || %{fc6} || %{fc7} || %{fc8} || %{fc9} || %{fc10}
352 %define fed 1
353 %endif
354 %define suse 0
355 %if %{su9} || %{su10} || %{su102} || %{su103} || %{su110} || %{su111} || %{su112}
356 %define suse 1
357 %endif
358 %define rhel 0
359 %if %{rhel3} || %{rhel4} || %{rhel5} || %{centos3} || %{centos4} || %{centos5}
360 %define rhel 1
361 %endif
362 %define scil 0
363 %if %{sl3} || %{sl4} || %{sl5}
364 %define scil 1
365 %endif
366
367
368 # test for a platform definition
369 %if !%{rhat} && !%{rhel} && !%{fed} && !%{wb3} && !%{suse} && !%{mdk}
370 %{error: You must specify a platform. Please examine the spec file.}
371 exit 1
372 %endif
373
374 # distribution-specific directory for logwatch
375 %if %{wb3} || %{rh7} || %{rh8} || %{rh9} || %{fc1} || %{fc3} || %{fc4}
376 %define logwatch_dir /etc/log.d
377 %else
378 %define logwatch_dir /etc/logwatch
379 %endif
380
381 # database defines
382 # set for database support desired or define the build_xxx on the command line
383 %define mysql 0
384 %{?build_mysql:%define mysql 1}
385 # if using mysql 4.x define this and mysql above
386 # currently: Mandrake 10.1, SuSE 9.x & 10.0, RHEL4 and Fedora Core 4
387 %define mysql4 0
388 %{?build_mysql4:%define mysql4 1}
389 %{?build_mysql4:%define mysql 1}
390 # if using mysql 5.x define this and mysql above
391 # currently: SuSE 10.1 and Fedora Core 5
392 %define mysql5 0
393 %{?build_mysql5:%define mysql5 1}
394 %{?build_mysql5:%define mysql 1}
395 %define sqlite 0
396 %{?build_sqlite:%define sqlite 1}
397 %define postgresql 0
398 %{?build_postgresql:%define postgresql 1}
399
400 # test for a database definition
401 %if ! %{mysql} && ! %{sqlite} && ! %{postgresql} && ! %{client_only}
402 %{error: You must specify database support. Please examine the spec file.}
403 exit 1
404 %endif
405
406 %if %{mysql}
407 %define db_backend mysql
408 %endif
409 %if %{sqlite}
410 %define db_backend sqlite3
411 %endif
412 %if %{postgresql}
413 %define db_backend postgresql
414 %endif
415
416 # 64 bit support
417 %define x86_64 0
418 %{?build_x86_64:%define x86_64 1}
419
420 # check what distribution we are
421 %if %{rhat} || %{rhel}
422 %define _dist %(grep Red /etc/redhat-release)
423 %endif
424 %if %{fc1} || %{fc3} || %{fc4} || %{fc5} || %{fc7} || %{fc8} || %{fc9} || %{fc10}
425 %define _dist %(grep Fedora /etc/redhat-release)
426 %endif
427 %if %{centos5} || %{centos4} || %{centos3}
428 %define _dist %(grep CentOS /etc/redhat-release)
429 %endif
430 %if %{sl5} ||%{sl4} || %{sl3}
431 %define _dist %(grep 'Scientific Linux' /etc/redhat-release)
432 %endif
433 %if %{wb3} && ! %{rhel3} && ! %{centos3} && ! %{sl3}
434 %define _dist %(grep White /etc/whitebox-release)
435 %endif
436 %if %{suse}
437 %define _dist %(grep -i SuSE /etc/SuSE-release)
438 %endif
439 %if %{mdk}
440 %define _dist %(grep Mand /etc/mandrake-release)
441 %endif
442 %{?DISTNAME:%define _dist %{DISTNAME}}
443
444 # only set Disribution if not in opensuse build service, as it sets it itself
445 %if ! 0%{?opensuse_bs}
446 %{?DISTNAME:%define _dist %{DISTNAME}}
447 Distribution: %{_dist}
448 %endif
449
450 %if 0%{?opensuse_bs} &&  %{mysql} && %{suse}
451 # needed in opensuse_bs, as rpm is installed during build process
452 BuildRequires: libmysqlclient-devel
453 BuildRequires: mysql-client
454 BuildRequires: mysql
455 %endif
456 %if 0%{?opensuse_bs} &&  %{suse} && %{postgresql}
457 BuildRequires: postgresql
458 BuildRequires: postgresql-server
459 %endif
460 BuildRequires: openssl
461
462 %if 0%{?opensuse_bs} && %{suse}
463 BuildRequires: pwdutils
464 BuildRequires: sysconfig
465 %endif
466
467 # should we turn on python support
468 %define python 0
469 %{?build_python:%define python 1}
470
471 # specifically disallow build of mtx package if desired
472 %define mtx 0
473 %{?nobuild_mtx:%define mtx 0}
474
475 # do we need to patch for old postgresql version?
476 %define old_pgsql 0
477 %{?build_old_pgsql:%define old_pgsql 1}
478
479 # Mandriva somehow forces the manpage file extension to bz2 rather than gz
480 %if %{mdk}
481 %define manpage_ext bz2
482 %else
483 %define manpage_ext gz
484 %endif
485
486 # for client only build
487 %if %{client_only}
488 %define mysql 0
489 %define mysql4 0
490 %define mysql5 0
491 %define postgresql 0
492 %define sqlite 0
493 %endif
494
495 BuildRequires: gcc, gcc-c++, make, autoconf
496 BuildRequires: glibc, glibc-devel
497 BuildRequires: ncurses-devel, perl
498 BuildRequires: libstdc++-devel, zlib-devel
499 BuildRequires: openssl-devel
500 BuildRequires: libacl-devel
501 BuildRequires: pkgconfig
502 %if ! %{rh7}
503 BuildRequires: libxml2-devel
504 %endif
505 %if %{python}
506 BuildRequires: python, python-devel
507 %{expand: %%define pyver %(python -c 'import sys;print(sys.version[0:3])')}
508 %endif
509
510 %if %{rh7}
511 BuildRequires: libtermcap-devel
512 BuildRequires: libxml-devel
513 %endif
514 %if %{suse}
515 BuildRequires: termcap
516 %endif
517 %if %{mdk}
518 BuildRequires: libtermcap-devel
519 BuildRequires: libstdc++-static-devel
520 BuildRequires: glibc-static-devel
521 %endif
522 %if %{fc1} || %{fc3} || %{fc4} || %{fc5} || %{fc7} || %{fc8}
523 BuildRequires: libtermcap-devel
524 %endif
525 %if %{sqlite}
526 BuildRequires: sqlite-devel
527 %endif
528
529 %if %{mysql}
530 BuildRequires: mysql-devel
531 %endif
532
533 %if %{postgresql} && %{wb3}
534 BuildRequires: rh-postgresql-devel >= 7
535 %endif
536
537 %if %{postgresql} && ! %{wb3}
538 BuildRequires: postgresql-devel >= 7
539 %endif
540
541 %description
542 %{blurb}
543
544 %{blurb2}
545 %{blurb3}
546 %{blurb4}
547 %{blurb5}
548 %{blurb6}
549 %{blurb7}
550 %{blurb8}
551
552 %if %{mysql}
553 %package mysql
554 %endif
555 %if %{sqlite}
556 %package sqlite
557 %endif
558 %if %{postgresql}
559 %package postgresql
560 %endif
561
562 Summary: Bacula - The Network Backup Solution
563 Group: System Environment/Daemons
564 Provides: bacula-dir, bacula-sd, bacula-fd, bacula-server
565 Conflicts: bacula-client
566
567 Requires: ncurses, libstdc++, zlib, openssl
568 Requires: glibc
569
570 %if %{rhel} || %{rhat} || %{fed}
571 Requires: libtermcap
572 %endif
573 %if %{suse}
574 Conflicts: bacula
575 Requires: termcap
576 %endif
577
578 %if %{mysql}
579 Requires: mysql
580
581 %if %{suse} || %{mdk}
582 Requires: mysql-client
583 %else
584 Requires: mysql-server
585 %endif
586 %endif
587
588 %if %{postgresql} && %{wb3}
589 Requires: rh-postgresql >= 7
590 Requires: rh-postgresql-server >= 7
591 %endif
592 %if %{postgresql} && ! %{wb3}
593 Requires: postgresql >= 7
594 Requires: postgresql-server >= 7
595 %endif
596
597 %if %{mysql}
598 %description mysql
599 %endif
600 %if %{sqlite}
601 %description sqlite
602 %endif
603 %if %{postgresql}
604 %description postgresql
605 %endif
606
607 %if %{python}
608 Requires: python >= %{pyver}
609 %endif
610
611 %{blurb}
612
613 %{blurb2}
614 %{blurb3}
615 %{blurb4}
616 %{blurb5}
617 %{blurb6}
618 %{blurb7}
619 %{blurb8}
620
621 %if %{mysql}
622 This build requires MySQL to be installed separately as the catalog database.
623 %endif
624 %if %{postgresql}
625 This build requires PostgreSQL to be installed separately as the catalog database.
626 %endif
627 %if %{sqlite}
628 This build incorporates sqlite3 as the catalog database, statically compiled.
629 %endif
630 %if %{python}
631 This build includes python scripting support.
632 %endif
633
634 %package client
635 Summary: Bacula - The Network Backup Solution
636 Group: System Environment/Daemons
637 Provides: bacula-fd
638 Conflicts: bacula-mysql
639 Conflicts: bacula-sqlite
640 Conflicts: bacula-postgresql
641
642 %if %{suse}
643 Provides: bacula
644 %endif
645
646 Requires: libstdc++, zlib, openssl
647 Requires: glibc
648
649 %if %{suse}
650 Requires: termcap
651 %else
652 Requires: libtermcap
653 %endif
654
655 %if %{python}
656 Requires: python >= %{pyver}
657 %endif
658
659 %description client
660 %{blurb}
661
662 %{blurb2}
663 %{blurb3}
664 %{blurb4}
665 %{blurb5}
666 %{blurb6}
667 %{blurb7}
668 %{blurb8}
669
670 This is the File daemon (Client) only package. It includes the command line 
671 console program.
672 %if %{python}
673 This build includes python scripting support.
674 %endif
675
676 %if ! %{client_only}
677 %package updatedb
678
679 Summary: Bacula - The Network Backup Solution
680 Group: System Environment/Daemons
681
682 %description updatedb
683 %{blurb}
684
685 %{blurb2}
686 %{blurb3}
687 %{blurb4}
688 %{blurb5}
689 %{blurb6}
690 %{blurb7}
691 %{blurb8}
692
693 This package installs scripts for updating older versions of the bacula
694 database.
695 %endif
696
697 # Must explicitly enable debug pkg on SuSE
698 # but not in opensuse_bs
699 %if %{suse} && ! 0%{?opensuse_bs}
700 %debug_package
701 %endif
702
703 %prep
704 %setup
705 %setup -T -D -b 1
706 %setup -T -D -b 3
707
708 %build
709
710 %if %{suse}
711 export LDFLAGS="${LDFLAGS} -L/usr/lib/termcap"
712 %endif
713
714 cwd=${PWD}
715 %if %{sqlite}
716 cd %{depkgs}
717 make sqlite3
718 cd ${cwd}
719 %endif
720
721 %if %{wb3} || %{old_pgsql}
722 patch -p3 src/cats/postgresql.c < %SOURCE2
723 %endif
724
725 # patches for the bundled sqlite scripts
726
727 # patch the make_sqlite_tables script for installation bindir
728 patch src/cats/make_sqlite3_tables.in src/cats/make_sqlite3_tables.in.patch
729
730 # patch the create_sqlite_database script for installation bindir
731 patch src/cats/create_sqlite3_database.in src/cats/create_sqlite3_database.in.patch
732
733 # patch the make_catalog_backup script for installation bindir
734 patch src/cats/make_catalog_backup.in src/cats/make_catalog_backup.in.patch
735
736 # patch the update_sqlite_tables script for installation bindir
737 patch src/cats/update_sqlite3_tables.in src/cats/update_sqlite3_tables.in.patch
738
739 # patch the bacula-dir init script to remove sqlite service
740 %if %{sqlite} && %{suse}
741 patch platforms/suse/bacula-dir.in platforms/suse/bacula-dir-suse-sqlite.patch
742 %endif
743
744 # 64 bit lib location hacks
745 # as of 1.39.18 it should not be necessary to enable x86_64 as configure is
746 # reported to be fixed to properly detect lib locations.
747 %if %{x86_64}
748 export LDFLAGS="${LDFLAGS} -L/usr/lib64"
749 %endif
750 %if %{mysql} && %{x86_64}
751 export LDFLAGS="${LDFLAGS} -L/usr/lib64/mysql"
752 %endif
753 %if %{python} && %{x86_64}
754 export LDFLAGS="${LDFLAGS} -L/usr/lib64/python%{pyver}"
755 %endif
756
757 # Main Bacula configuration
758 %configure \
759         --prefix=%{_prefix} \
760         --sbindir=%{_sbindir} \
761         --sysconfdir=%{sysconf_dir} \
762         --mandir=%{_mandir} \
763         --with-scriptdir=%{script_dir} \
764         --with-working-dir=%{working_dir} \
765         --with-plugindir=%{script_dir} \
766         --with-pid-dir=%{pid_dir} \
767         --with-subsys-dir=%{_subsysdir} \
768         --enable-smartalloc \
769         --disable-gnome \
770         --disable-bwx-console \
771         --disable-tray-monitor \
772 %if %{mysql}
773         --with-mysql \
774 %endif
775 %if %{sqlite}
776         --with-sqlite3=${cwd}/%{depkgs}/sqlite3 \
777 %endif
778 %if %{postgresql}
779         --with-postgresql \
780 %endif
781         --disable-bat \
782         --without-qwt \
783 %if %{python}
784         --with-python \
785 %endif
786 %if %{client_only}
787         --enable-client-only \
788 %endif
789 %if %{rh7} || %{rh8} || %{rh9} || %{fc1} || %{fc3} || %{wb3} 
790         --disable-batch-insert \
791 %endif
792         --with-dir-user=%{director_daemon_user} \
793         --with-dir-group=%{daemon_group} \
794         --with-sd-user=%{storage_daemon_user} \
795         --with-sd-group=%{storage_daemon_group} \
796         --with-fd-user=%{file_daemon_user} \
797         --with-fd-group=%{daemon_group} \
798         --with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
799         --with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
800         --with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
801         --with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
802         --with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
803         --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
804         --with-openssl
805
806 make -j3
807
808 %install
809  
810 cwd=${PWD}
811 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
812 mkdir -p $RPM_BUILD_ROOT/etc/init.d
813 mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
814 mkdir -p $RPM_BUILD_ROOT%{logwatch_dir}/conf/logfiles
815 mkdir -p $RPM_BUILD_ROOT%{logwatch_dir}/conf/services
816 mkdir -p $RPM_BUILD_ROOT%{logwatch_dir}/scripts/services
817 mkdir -p $RPM_BUILD_ROOT%{logwatch_dir}/scripts/shared
818 mkdir -p $RPM_BUILD_ROOT%{script_dir}/updatedb
819
820 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
821 mkdir -p $RPM_BUILD_ROOT%{_sbindir}
822
823 %if %{sqlite}
824 mkdir -p $RPM_BUILD_ROOT%{sqlite_bindir}
825 %endif
826
827 make DESTDIR=$RPM_BUILD_ROOT install
828
829 %if %{client_only}
830 # Program docs not installed on client
831 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bacula-dir.8.%{manpage_ext}
832 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bacula-sd.8.%{manpage_ext}
833 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bcopy.8.%{manpage_ext}
834 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bextract.8.%{manpage_ext}
835 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bls.8.%{manpage_ext}
836 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bscan.8.%{manpage_ext}
837 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/btape.8.%{manpage_ext}
838 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/dbcheck.8.%{manpage_ext}
839 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bsmtp.1.%{manpage_ext}
840 %endif
841 # Docs for programs that are depreciated
842 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bgnome-console.1.%{manpage_ext}
843 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bwxconsole.1.%{manpage_ext}
844 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-tray-monitor.1.%{manpage_ext}
845 rm -f $RPM_BUILD_ROOT%{script_dir}/gconsole
846
847 # fixme - make installs the mysql scripts for sqlite build
848 %if %{sqlite}
849 rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql
850 rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql
851 rm -f $RPM_BUILD_ROOT%{script_dir}/grant_mysql_privileges
852 %endif
853
854 # fixme - make installs the mysql scripts for postgresql build
855 %if %{postgresql}
856 rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql
857 rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql
858 %endif
859
860 # install the init scripts
861 %if %{suse}
862 cp -p platforms/suse/bacula-dir $RPM_BUILD_ROOT/etc/init.d/bacula-dir
863 cp -p platforms/suse/bacula-fd $RPM_BUILD_ROOT/etc/init.d/bacula-fd
864 cp -p platforms/suse/bacula-sd $RPM_BUILD_ROOT/etc/init.d/bacula-sd
865 %endif
866 %if %{mdk}
867 cp -p platforms/mandrake/bacula-dir $RPM_BUILD_ROOT/etc/init.d/bacula-dir
868 cp -p platforms/mandrake/bacula-fd $RPM_BUILD_ROOT/etc/init.d/bacula-fd
869 cp -p platforms/mandrake/bacula-sd $RPM_BUILD_ROOT/etc/init.d/bacula-sd
870 %endif
871 %if ! %{suse} && ! %{mdk}
872 cp -p platforms/redhat/bacula-dir $RPM_BUILD_ROOT/etc/init.d/bacula-dir
873 cp -p platforms/redhat/bacula-fd $RPM_BUILD_ROOT/etc/init.d/bacula-fd
874 cp -p platforms/redhat/bacula-sd $RPM_BUILD_ROOT/etc/init.d/bacula-sd
875 %endif
876 chmod 0754 $RPM_BUILD_ROOT/etc/init.d/*
877 %if %{client_only}
878 rm -f $RPM_BUILD_ROOT/etc/init.d/bacula-dir
879 rm -f $RPM_BUILD_ROOT/etc/init.d/bacula-sd
880 %endif
881
882 # install sqlite
883 %if %{sqlite}
884 cp -p %{depkgs}/sqlite3/sqlite3 $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite3
885 cp -p %{depkgs}/sqlite3/sqlite3.h $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite3.h
886 cp -p %{depkgs}/sqlite3/libsqlite3.a $RPM_BUILD_ROOT%{sqlite_bindir}/libsqlite3.a
887 %endif
888
889
890 # install the logrotate file
891 cp -p scripts/logrotate $RPM_BUILD_ROOT/etc/logrotate.d/bacula
892
893 # install the updatedb scripts
894 cp -p updatedb/* $RPM_BUILD_ROOT%{script_dir}/updatedb/
895
896 # install the logwatch scripts
897 %if ! %{client_only}
898 cp -p scripts/logwatch/bacula $RPM_BUILD_ROOT%{logwatch_dir}/scripts/services/bacula
899 cp -p scripts/logwatch/applybaculadate $RPM_BUILD_ROOT%{logwatch_dir}/scripts/shared/applybaculadate
900 cp -p scripts/logwatch/logfile.bacula.conf $RPM_BUILD_ROOT%{logwatch_dir}/conf/logfiles/bacula.conf
901 cp -p scripts/logwatch/services.bacula.conf $RPM_BUILD_ROOT%{logwatch_dir}/conf/services/bacula.conf
902 chmod 755 $RPM_BUILD_ROOT%{logwatch_dir}/scripts/services/bacula
903 chmod 755 $RPM_BUILD_ROOT%{logwatch_dir}/scripts/shared/applybaculadate
904 chmod 644 $RPM_BUILD_ROOT%{logwatch_dir}/conf/logfiles/bacula.conf
905 chmod 644 $RPM_BUILD_ROOT%{logwatch_dir}/conf/services/bacula.conf
906 %endif
907
908 # now clean up permissions that are left broken by the install
909 chmod o-rwx $RPM_BUILD_ROOT%{working_dir}
910
911 # fix me - building enable-client-only installs files not included in bacula-client package
912 %if %{client_only}
913 rm -f $RPM_BUILD_ROOT%{script_dir}/bacula
914 rm -f $RPM_BUILD_ROOT%{script_dir}/bacula-ctl-dir
915 rm -f $RPM_BUILD_ROOT%{script_dir}/bacula-ctl-sd
916 rm -f $RPM_BUILD_ROOT%{script_dir}/disk-changer
917 rm -f $RPM_BUILD_ROOT%{script_dir}/dvd-handler
918 rm -f $RPM_BUILD_ROOT%{script_dir}/mtx-changer
919 rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql
920 rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql
921 rm -rf $RPM_BUILD_ROOT%{script_dir}/updatedb
922 rm -f $RPM_BUILD_ROOT%{script_dir}/bconsole
923 rm -f $RPM_BUILD_ROOT%{script_dir}/bpipe-fd.so
924 rm -f $RPM_BUILD_ROOT%{script_dir}/mtx-changer.conf
925 rm -f $RPM_BUILD_ROOT%{_sbindir}/bacula
926 %endif
927
928 %clean
929 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
930 %if 0%{?opensuse_bs}
931 rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-1.txt
932 %else
933 rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
934 %endif
935
936
937 %if %{mysql}
938 # MySQL specific files
939 %files mysql
940 %defattr(-, root, root)
941 %attr(-, root, %{daemon_group}) %{script_dir}/create_mysql_database
942 %attr(-, root, %{daemon_group}) %{script_dir}/drop_mysql_database
943 %attr(-, root, %{daemon_group}) %{script_dir}/make_mysql_tables
944 %attr(-, root, %{daemon_group}) %{script_dir}/drop_mysql_tables
945 %attr(-, root, %{daemon_group}) %{script_dir}/update_mysql_tables
946 %attr(-, root, %{daemon_group}) %{script_dir}/grant_mysql_privileges
947 %attr(-, root, %{daemon_group}) %{script_dir}/startmysql
948 %attr(-, root, %{daemon_group}) %{script_dir}/stopmysql
949 %endif
950
951 %if %{sqlite}
952 %files sqlite
953 %defattr(-,root,root)
954 %attr(-, root, %{daemon_group}) %{script_dir}/create_sqlite3_database
955 %attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite3_database
956 %attr(-, root, %{daemon_group}) %{script_dir}/grant_sqlite3_privileges
957 %attr(-, root, %{daemon_group}) %{script_dir}/make_sqlite3_tables
958 %attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite3_tables
959 %attr(-, root, %{daemon_group}) %{script_dir}/update_sqlite3_tables
960 %{sqlite_bindir}/libsqlite3.a
961 %{sqlite_bindir}/sqlite3.h
962 %{sqlite_bindir}/sqlite3
963 %endif
964
965
966
967 %if %{postgresql}
968 %files postgresql
969 %defattr(-,root,root)
970 %attr(-, root, %{daemon_group}) %{script_dir}/create_postgresql_database
971 %attr(-, root, %{daemon_group}) %{script_dir}/drop_postgresql_database
972 %attr(-, root, %{daemon_group}) %{script_dir}/make_postgresql_tables
973 %attr(-, root, %{daemon_group}) %{script_dir}/drop_postgresql_tables
974 %attr(-, root, %{daemon_group}) %{script_dir}/update_postgresql_tables
975 %attr(-, root, %{daemon_group}) %{script_dir}/grant_postgresql_privileges
976 # The rest is DB backend independent
977 %endif
978 # opensuse_bs: directories not owned by any package
979 #/etc/bacula
980
981 %if ! %{client_only}
982 %attr(-, root, %{daemon_group}) %dir %{script_dir}
983 %attr(-, root, %{daemon_group}) %{script_dir}/bacula
984 %attr(-, root, %{daemon_group}) %{script_dir}/bacula_config
985 %attr(-, root, %{daemon_group}) %{script_dir}/bconsole
986 %attr(-, root, %{daemon_group}) %{script_dir}/create_bacula_database
987 %attr(-, root, %{daemon_group}) %{script_dir}/drop_bacula_database
988 %attr(-, root, %{daemon_group}) %{script_dir}/grant_bacula_privileges
989 %attr(-, root, %{daemon_group}) %{script_dir}/make_bacula_tables
990 %attr(-, root, %{daemon_group}) %{script_dir}/drop_bacula_tables
991 %attr(-, root, %{daemon_group}) %{script_dir}/update_bacula_tables
992 %attr(-, root, %{daemon_group}) %{script_dir}/make_catalog_backup
993 %attr(-, root, %{daemon_group}) %{script_dir}/make_catalog_backup.pl
994 %attr(-, root, %{daemon_group}) %{script_dir}/delete_catalog_backup
995 %attr(-, root, %{daemon_group}) %{script_dir}/btraceback.dbx
996 %attr(-, root, %{daemon_group}) %{script_dir}/btraceback.gdb
997 %attr(-, root, %{daemon_group}) %{script_dir}/disk-changer
998 %attr(-, root, %{daemon_group}) %{script_dir}/bacula-ctl-dir
999 %attr(-, root, %{daemon_group}) %{script_dir}/bacula-ctl-fd
1000 %attr(-, root, %{daemon_group}) %{script_dir}/bacula-ctl-sd
1001 %attr(-, root, %{daemon_group}) %{script_dir}/bpipe-fd.so
1002 %attr(-, root, %{daemon_group}) /etc/init.d/bacula-dir
1003 %attr(-, root, %{daemon_group}) /etc/init.d/bacula-fd
1004 %attr(-, root, %{storage_daemon_group}) %{script_dir}/dvd-handler
1005 %attr(-, root, %{storage_daemon_group}) /etc/init.d/bacula-sd
1006 %attr(-, root, %{storage_daemon_group}) %{script_dir}/mtx-changer
1007 %attr(-, root, %{storage_daemon_group}) %{script_dir}/mtx-changer.conf
1008
1009 /etc/logrotate.d/bacula
1010 %{logwatch_dir}/scripts/services/bacula
1011 %{logwatch_dir}/scripts/shared/applybaculadate
1012 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-dir.conf
1013 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-fd.conf
1014 %attr(-, root, %{storage_daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-sd.conf
1015 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bconsole.conf
1016 %attr(-, root, %{daemon_group}) %config(noreplace) %{logwatch_dir}/conf/logfiles/bacula.conf
1017 %attr(-, root, %{daemon_group}) %config(noreplace) %{logwatch_dir}/conf/services/bacula.conf
1018 %attr(-, root, %{daemon_group}) %config(noreplace) %{script_dir}/query.sql
1019
1020 %attr(-, %{storage_daemon_user}, %{daemon_group}) %dir %{working_dir}
1021
1022 %{_sbindir}/bacula-dir
1023 %{_sbindir}/bacula-fd
1024 %{_sbindir}/bacula-sd
1025 %{_sbindir}/bacula
1026 %{_sbindir}/bcopy
1027 %{_sbindir}/bextract
1028 %{_sbindir}/bls
1029 %{_sbindir}/bscan
1030 %{_sbindir}/btape
1031 %{_sbindir}/btraceback
1032 %{_sbindir}/bconsole
1033 %attr(-, root, %{daemon_group}) %{_sbindir}/dbcheck
1034 %{_sbindir}/bsmtp
1035 %{_sbindir}/bregex
1036 %{_sbindir}/bwild
1037 %{_mandir}/man8/bacula-fd.8.%{manpage_ext}
1038 %{_mandir}/man8/bacula-dir.8.%{manpage_ext}
1039 %{_mandir}/man8/bacula-sd.8.%{manpage_ext}
1040 %{_mandir}/man8/bacula.8.%{manpage_ext}
1041 %{_mandir}/man8/bconsole.8.%{manpage_ext}
1042 %{_mandir}/man8/bcopy.8.%{manpage_ext}
1043 %{_mandir}/man8/bextract.8.%{manpage_ext}
1044 %{_mandir}/man8/bls.8.%{manpage_ext}
1045 %{_mandir}/man8/bscan.8.%{manpage_ext}
1046 %{_mandir}/man8/btape.8.%{manpage_ext}
1047 %{_mandir}/man8/btraceback.8.%{manpage_ext}
1048 %{_mandir}/man8/dbcheck.8.%{manpage_ext}
1049 %{_mandir}/man1/bsmtp.1.%{manpage_ext}
1050 %{_mandir}/man1/bat.1.%{manpage_ext}
1051 %{_libdir}/libbac*
1052 %_prefix/share/doc/*
1053
1054 # opensuse build service changes the release itself
1055 %if 0%{?opensuse_bs}
1056 %doc ../Release_Notes-%{version}-1.txt
1057 %else
1058 %doc ../Release_Notes-%{version}-%{release}.txt
1059 %endif
1060 %endif
1061
1062 %if %{mysql}
1063 %pre mysql
1064 # test for bacula database older than version 12
1065 # note: this ASSUMES no password has been set for bacula database
1066 DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
1067 %endif
1068
1069 %if %{sqlite}
1070 %pre sqlite
1071 # are we upgrading from sqlite to sqlite3?
1072 if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite ];then
1073         echo "This version of bacula-sqlite involves an upgrade to sqlite3."
1074         echo "Your catalog database file is not compatible with sqlite3, thus"
1075         echo "you will need to dump the data, delete the old file, and re-run"
1076         echo "this rpm upgrade."
1077         echo ""
1078         echo "Backing up your current database..."
1079         echo ".dump" | %{sqlite_bindir}/sqlite %{working_dir}/bacula.db > %{working_dir}/bacula_backup.sql
1080         mv %{working_dir}/bacula.db %{working_dir}/bacula.db.old
1081         echo "Your catalog data has been saved in %{working_dir}/bacula_backup.sql and your"
1082         echo "catalog file has been renamed %{working_dir}/bacula.db.old."
1083         echo ""
1084         echo "Please re-run this rpm package upgrade."
1085         echo "After the upgrade is complete, restore your catalog"
1086         echo "with the following commands:"
1087         echo "%{script_dir}/drop_sqlite3_tables"
1088         echo "cd %{working_dir}"
1089         echo "%{sqlite_bindir}/sqlite3 $* bacula.db < bacula_backup.sql"
1090         echo "chown bacula.bacula bacula.db"
1091         exit 1
1092 fi
1093 # test for bacula database older than version 11 and sqlite3
1094 if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite3 ];then
1095         DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
1096 %endif
1097
1098 %if %{postgresql}
1099 %pre postgresql
1100 DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
1101 %endif
1102
1103 %if ! %{client_only}
1104 if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "11" ]; then
1105     echo "This bacula upgrade will update a bacula database from version 11 to 12."
1106     echo "You appear to be running database version $DB_VER. You must first update"
1107     echo "your database to version 11 and then install this upgrade. The alternative"
1108     echo "is to use %{script_dir}/drop_%{db_backend}_tables to delete all your your current"
1109     echo "catalog information, then do the upgrade. Information on updating a"
1110     echo "database older than version 11 can be found in the release notes."
1111     exit 1
1112 fi
1113 %endif
1114
1115 %if %{sqlite}
1116 fi
1117 %endif
1118
1119 %if ! %{client_only}
1120 # check for and copy %{sysconf_dir}/console.conf to bconsole.conf
1121 if [ -s %{sysconf_dir}/console.conf ];then
1122     cp -p %{sysconf_dir}/console.conf %{sysconf_dir}/bconsole.conf
1123 fi
1124
1125 # create the daemon users and groups
1126 # first create the groups if they don't exist
1127 HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
1128 if [ -z "$HAVE_BACULA" ]; then
1129         %{groupadd} -r %{daemon_group} > /dev/null 2>&1
1130         echo "The group %{daemon_group} has been added to %{group_file}."
1131         echo "See the manual chapter \"Running Bacula\" for details."
1132 fi
1133 HAVE_BACULA=`grep %{storage_daemon_group} %{group_file} 2>/dev/null`
1134 if [ -z "$HAVE_BACULA" ]; then
1135         %{groupadd} -r %{storage_daemon_group} > /dev/null 2>&1
1136         echo "The group %{storage_daemon_group} has been added to %{group_file}."
1137         echo "See the manual chapter \"Running Bacula\" for details."
1138 fi
1139 # now create the users if they do not exist
1140 # we do not use the -g option allowing the primary group to be set to system default
1141 # this will be a unique group on redhat type systems or the group users on some systems
1142 HAVE_BACULA=`grep %{storage_daemon_user} %{user_file} 2>/dev/null`
1143 if [ -z "$HAVE_BACULA" ]; then
1144         %{useradd} -r -c "Bacula" -d %{working_dir} -g %{storage_daemon_group} -M -s /sbin/nologin %{storage_daemon_user} > /dev/null 2>&1
1145         echo "The user %{storage_daemon_user} has been added to %{user_file}."
1146         echo "See the manual chapter \"Running Bacula\" for details."
1147 fi
1148 HAVE_BACULA=`grep %{director_daemon_user} %{user_file} 2>/dev/null`
1149 if [ -z "$HAVE_BACULA" ]; then
1150         %{useradd} -r -c "Bacula" -d %{working_dir} -g %{daemon_group} -M -s /sbin/nologin %{director_daemon_user} > /dev/null 2>&1
1151         echo "The user %{director_daemon_user} has been added to %{user_file}."
1152         echo "See the manual chapter \"Running Bacula\" for details."
1153 fi
1154 HAVE_BACULA=`grep %{file_daemon_user} %{user_file} 2>/dev/null`
1155 if [ -z "$HAVE_BACULA" ]; then
1156         %{useradd} -r -c "Bacula" -d %{working_dir} -g %{daemon_group} -M -s /sbin/nologin %{file_daemon_user} > /dev/null 2>&1
1157         echo "The user %{file_daemon_user} has been added to %{user_file}."
1158         echo "See the manual chapter \"Running Bacula\" for details."
1159 fi
1160 # now we add the supplementary groups, this is ok to call even if the users already exist
1161 # we only do this if the user is NOT root
1162 IS_ROOT=%{director_daemon_user}
1163 if [ "$IS_ROOT" != "root" ]; then
1164 %{usermod} -G %{daemon_group} %{director_daemon_user}
1165 fi
1166 IS_ROOT=%{storage_daemon_user}
1167 if [ "$IS_ROOT" != "root" ]; then
1168 %{usermod} -G %{daemon_group},%{storage_daemon_group} %{storage_daemon_user}
1169 fi
1170 IS_ROOT=%{file_daemon_user}
1171 if [ "$IS_ROOT" != "root" ]; then
1172 %{usermod} -G %{daemon_group} %{file_daemon_user}
1173 fi
1174 %endif
1175
1176 %if %{mysql}
1177 %post mysql
1178 %endif
1179 %if %{sqlite}
1180 %post sqlite
1181 %endif
1182 %if %{postgresql}
1183 %post postgresql
1184 %endif
1185 %if ! %{client_only}
1186 # add our links
1187 if [ "$1" -ge 1 ] ; then
1188 %if %{suse} && %{mysql}
1189   /sbin/chkconfig --add mysql
1190 %endif
1191 %if %{suse} && %{postgresql}
1192   /sbin/chkconfig --add postgresql
1193 %endif
1194   /sbin/chkconfig --add bacula-dir
1195   /sbin/chkconfig --add bacula-fd
1196   /sbin/chkconfig --add bacula-sd
1197 fi
1198 %endif
1199
1200 %if %{mysql}
1201
1202 #check, if mysql can be called successfully at all
1203 if mysql 2>/dev/null bacula -e 'select * from Version;' ; then
1204
1205 # test for an existing database
1206 # note: this ASSUMES no password has been set for bacula database
1207 DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
1208
1209 # grant privileges and create tables if they do not exist
1210 if [ -z "$DB_VER" ]; then
1211     echo "Hmm, it doesn't look like you have an existing database."
1212     echo "Granting privileges for MySQL user bacula..."
1213     %{script_dir}/grant_mysql_privileges
1214     echo "Creating MySQL bacula database..."
1215     %{script_dir}/create_mysql_database
1216     echo "Creating bacula tables..."
1217     %{script_dir}/make_mysql_tables
1218
1219 # check to see if we need to upgrade a 3.x database
1220 elif [ "$DB_VER" -lt "11" ]; then
1221     echo "This release requires an upgrade to your bacula database."
1222     echo "Backing up your current database..."
1223     mysqldump -f --opt bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2
1224     echo "Upgrading bacula database ..."
1225     %{script_dir}/update_mysql_tables
1226     echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
1227
1228 fi
1229 fi
1230 %endif
1231
1232 %if %{sqlite}
1233 # test for an existing database
1234 if [ -s %{working_dir}/bacula.db ]; then
1235         DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
1236         # check to see if we need to upgrade a 3.x database
1237         if [ "$DB_VER" -lt "12" ] && [ "$DB_VER" -ge "11" ]; then
1238                 echo "This release requires an upgrade to your bacula database."
1239                 echo "Backing up your current database..."
1240                 echo ".dump" | %{sqlite_bindir}/sqlite3 %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2
1241                 echo "Upgrading bacula database ..."
1242                 %{script_dir}/update_sqlite3_tables
1243                 echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
1244         fi
1245 else
1246         # create the database and tables
1247         echo "Hmm, doesn't look like you have an existing database."
1248         echo "Creating SQLite database..."
1249         %{script_dir}/create_sqlite3_database
1250         chown %{director_daemon_user}.%{daemon_group} %{working_dir}/bacula.db
1251         echo "Creating the SQLite tables..."
1252         %{script_dir}/make_sqlite3_tables
1253 fi
1254 %endif
1255
1256 %if %{postgresql}
1257 # check if psql can be called successfully at all
1258 if echo 'select * from Version;' | psql bacula 2>/dev/null; then
1259
1260 # test for an existing database
1261 # note: this ASSUMES no password has been set for bacula database
1262 DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
1263
1264 # grant privileges and create tables if they do not exist
1265 if [ -z "$DB_VER" ]; then
1266     echo "Hmm, doesn't look like you have an existing database."
1267     echo "Creating PostgreSQL bacula database..."
1268     %{script_dir}/create_postgresql_database
1269     echo "Creating bacula tables..."
1270     %{script_dir}/make_postgresql_tables
1271     echo "Granting privileges for PostgreSQL user bacula..."
1272     %{script_dir}/grant_postgresql_privileges
1273
1274 # check to see if we need to upgrade a 3.x database
1275 elif [ "$DB_VER" -lt "12" ]; then
1276     echo "This release requires an upgrade to your bacula database."
1277     echo "Backing up your current database..."
1278     pg_dump bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2
1279     echo "Upgrading bacula database ..."
1280     %{script_dir}/update_postgresql_tables
1281     echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
1282         
1283 fi
1284 fi
1285 %endif
1286
1287 %if ! %{client_only}
1288 if [ -d %{sysconf_dir} ]; then
1289    cd %{sysconf_dir}
1290    for string in XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX; do
1291       pass=`openssl rand -base64 33`
1292       for file in *.conf; do
1293          sed "s@${string}@${pass}@g" $file > $file.new
1294          cp -f $file.new $file; rm -f $file.new
1295       done
1296    done
1297 # put actual hostname in conf file
1298    host=`hostname`
1299    string="XXX_HOSTNAME_XXX"
1300    for file in *.conf; do
1301       sed "s@${string}@${host}@g" $file >$file.new
1302       cp -f $file.new $file; rm -f $file.new
1303    done
1304 fi
1305 %endif
1306 /sbin/ldconfig
1307 exit 0 # always exit successfull, as otherwise opensuse build service complains
1308
1309 %if %{mysql}
1310 %preun mysql
1311 %endif
1312 %if %{sqlite}
1313 %preun sqlite
1314 %endif
1315 %if %{postgresql}
1316 %preun postgresql
1317 %endif
1318
1319 %if ! %{client_only}
1320 # delete our links
1321 if [ $1 = 0 ]; then
1322   /sbin/chkconfig --del bacula-dir
1323   /sbin/chkconfig --del bacula-fd
1324   /sbin/chkconfig --del bacula-sd
1325 fi
1326 /sbin/ldconfig
1327 %endif
1328
1329 # added: run ldconfig in postun
1330 %if %{mysql}
1331 %postun mysql
1332 %endif
1333 %if %{sqlite}
1334 %postun sqlite
1335 %endif
1336 %if %{postgresql}
1337 %postun postgresql
1338 %endif
1339 /sbin/ldconfig
1340
1341 %files client
1342 %defattr(-,root,root)
1343 %attr(-, root, %{daemon_group}) %dir %{script_dir}
1344 %{script_dir}/bacula-ctl-fd
1345 /etc/init.d/bacula-fd
1346
1347 /etc/logrotate.d/bacula
1348
1349 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-fd.conf
1350 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bconsole.conf
1351 %attr(-, root, %{daemon_group}) %dir %{working_dir}
1352
1353 %{_sbindir}/bacula-fd
1354 %{_sbindir}/btraceback
1355 %attr(-, root, %{daemon_group}) %{script_dir}/btraceback.gdb
1356 %attr(-, root, %{daemon_group}) %{script_dir}/btraceback.dbx
1357 %{_sbindir}/bconsole
1358 %{_mandir}/man8/bacula-fd.8.%{manpage_ext}
1359 %{_mandir}/man8/bacula.8.%{manpage_ext}
1360 %{_mandir}/man8/bconsole.8.%{manpage_ext}
1361 %{_mandir}/man8/btraceback.8.%{manpage_ext}
1362 %{_mandir}/man1/bat.1.%{manpage_ext}
1363 %{_libdir}/libbac.*
1364 %{_libdir}/libbaccfg.*
1365 %{_libdir}/libbacfind.*
1366 %{_libdir}/libbacpy.*
1367 %_prefix/share/doc/*
1368
1369 #opensuse_bs: directories not owned by any package
1370 #/etc/bacula
1371
1372 %pre client
1373 # create the daemon group and user
1374 HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
1375 if [ -z "$HAVE_BACULA" ]; then
1376     %{groupadd} -r %{daemon_group} > /dev/null 2>&1
1377     echo "The group %{daemon_group} has been added to %{group_file}."
1378     echo "See the manual chapter \"Running Bacula\" for details."
1379 fi
1380 # we do not use the -g option allowing the primary group to be set to system default
1381 # this will be a unique group on redhat type systems or the group users on some systems
1382 HAVE_BACULA=`grep %{file_daemon_user} %{user_file} 2>/dev/null`
1383 if [ -z "$HAVE_BACULA" ]; then
1384     %{useradd} -r -c "Bacula" -d %{working_dir} -g %{daemon_group} -M -s /sbin/nologin %{file_daemon_user} > /dev/null 2>&1
1385     echo "The user %{file_daemon_user} has been added to %{user_file}."
1386     echo "See the manual chapter \"Running Bacula\" for details."
1387 fi
1388 # now we add the supplementary group, this is ok to call even if the user already exists
1389 # we only do this if the user is NOT root
1390 IS_ROOT=%{file_daemon_user}
1391 if [ "$IS_ROOT" != "root" ]; then
1392 %{usermod} -G %{daemon_group} %{file_daemon_user}
1393 fi
1394
1395 %post client
1396 # add our link
1397 if [ "$1" -ge 1 ] ; then
1398    /sbin/chkconfig --add bacula-fd
1399 fi
1400
1401 if [ -d %{sysconf_dir} ]; then
1402    cd %{sysconf_dir}
1403    for string in XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX; do
1404       pass=`openssl rand -base64 33`
1405       for file in *.conf; do
1406          sed "s@${string}@${pass}@g" $file > $file.new
1407          cp -f $file.new $file; rm -f $file.new
1408       done
1409    done
1410 # put actual hostname in conf file
1411    host=`hostname`
1412    string="XXX_HOSTNAME_XXX"
1413    for file in *.conf; do
1414       sed "s@${string}@${host}@g" $file >$file.new
1415       cp -f $file.new $file; rm -f $file.new
1416    done
1417 fi
1418
1419 /sbin/ldconfig
1420 exit 0
1421 %preun client
1422 # delete our link
1423 if [ $1 = 0 ]; then
1424    /sbin/chkconfig --del bacula-fd
1425 fi
1426
1427 %postun client
1428 /sbin/ldconfig
1429
1430 %if ! %{client_only}
1431 %files updatedb
1432 %defattr(-,root,%{daemon_group})
1433 %{script_dir}/updatedb/*
1434 #oensuse_bs: directories not owned by any package
1435 #%{script_dir}/updatedb
1436
1437 %pre updatedb
1438 # create the daemon group
1439 HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
1440 if [ -z "$HAVE_BACULA" ]; then
1441     %{groupadd} -r %{daemon_group} > /dev/null 2>&1
1442     echo "The group %{daemon_group} has been added to %{group_file}."
1443     echo "See the manual chapter \"Running Bacula\" for details."
1444 fi
1445
1446 %post updatedb
1447 echo "The database update scripts were installed to %{script_dir}/updatedb"
1448 %endif
1449
1450 %changelog
1451 * Sat Jan 30 2010 D. Scott Barninger <barninger@fairfieldcomputers.com>
1452 - 5.0.0
1453 - add su112 and fc10 builds, remove doc package declaration.
1454 - fix source path for logwatch files.
1455 - restore static bundled build of sqlite (who took that out?) and remove use
1456 - of system sqlite. we don't support use of sqlite2.
1457 - upgrade database from version 11 to 12.
1458 * Mon Aug 10 2009 Philipp Storz <philipp.storz@dass-it.de>
1459 - changes to work with opensuse build service
1460 * Sat Aug 1 2009 Kern Sibbald <kern@sibbald.com>
1461 - Split docs into separate bacula-docs.spec, bacula-bat.spec and bacula-mtx.spec
1462 - removed build of rescue, gnome console and wxconsole
1463 * Sat Jun 20 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1464 - Fix bat install which is now handled by make and uses shared libs
1465 * Sat May 16 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1466 - fix libxml dependency for rh7 per Pasi Kärkkäinen <pasik@iki.fi>
1467 * Mon May 04 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1468 - Fix post ldconfig problem in client only build
1469 * Sun May 03 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1470 - remove more files installed by client-only build not needed by client package
1471 - remove libbacsql files from client package
1472 * Sat May 02 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1473 - 3.0.1
1474 - update for new docs configuration
1475 * Sat Apr 25 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1476 - add switch to pass Distribution tag
1477 * Sun Apr 5 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
1478 - 3.0.0 release
1479 - database update version 10 to 11
1480 - make now installs docs so we rm from buildroot
1481 - add shared libs in %_libdir and other misc new files
1482 * Wed Dec 31 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1483 - add su111 target
1484 * Sat Nov 08 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1485 - set paths for QT using pkgconfig
1486 * Sat Oct 11 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1487 - release 2.4.3 update depkgs to 11Sep08 remove file nmshack from mtx package
1488 * Sun Sep 07 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1489 - adjust /opt/bacula install
1490 - add build switch to supress rescue package
1491 * Sun Aug 24 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1492 - add support for install to /opt/bacula
1493 * Sun Aug 17 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1494 - remove libtermcap dependancy for FC9
1495 * Mon Aug 04 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1496 - fix bat dependencies
1497 * Sat Jun 28 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1498 - add su110 target
1499 * Sat May 24 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1500 - add fc9 target
1501 * Sun Mar 30 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1502 - FHS compatibility changes
1503 * Sat Feb 16 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1504 - remove fix for false buffer overflow detection with glibc >= 2.7
1505 * Sat Feb 09 2008 D. Scott Barninger <barninger@fairfieldcomputers.com>
1506 - fix for false buffer overflow detection with glibc >= 2.7