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