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