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