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