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