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