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