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