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