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