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