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