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