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