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