]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/platforms/redhat/bacula.spec
Add Macro BTHREAD_MUTEX_PRIORITY(p) and lib/mutex_list.h to manage locks
[bacula/bacula] / bacula / platforms / redhat / bacula.spec
index e7e816e6a26f9aa1b95b4895457b6d1c5c571d0f..2775678c8ae9be92e9aac6de82f9e2dba1020629 100644 (file)
@@ -6,10 +6,7 @@
 
 # basic defines for every build
 %define _release           1
-%define _version           3.0.2
-%define docs_version       3.0.2
-%define depkgs_version     18Feb09
-%define depkgs_qt_version  28Jul09
+%define _version           3.0.3
 %define _packager D. Scott Barninger <barninger@fairfieldcomputers.com>
 
 %define single_dir 0
@@ -21,7 +18,6 @@
 %define _sbindir       /opt/bacula/bin
 %define _bindir        /opt/bacula/bin
 %define _subsysdir     /opt/bacula/working
-%define sqlite_bindir  /opt/bacula/sqlite
 %define _mandir        /usr/share/man
 %define sysconf_dir    /opt/bacula/etc
 %define script_dir     /opt/bacula/scripts
@@ -34,7 +30,6 @@
 %define _sbindir       %_prefix/sbin
 %define _bindir        %_prefix/bin
 %define _subsysdir     /var/lock/subsys
-%define sqlite_bindir  %_libdir/bacula/sqlite
 %define _mandir        %_prefix/share/man
 %define sysconf_dir    /etc/bacula
 %define script_dir     %_libdir/bacula
@@ -86,7 +81,7 @@
 
 # choose database backend here
 # postgres, mysql, sqlite
-%define build_postgresql 1
+%define build_mysql 1
 
 # Build Service: Determine Distribution
 
@@ -225,11 +220,13 @@ Packager: %{_packager}
 Prefix: %{_prefix}
 
 Source0: http://www.prdownloads.sourceforge.net/bacula/%{name}-%{version}.tar.gz
+# opensuse build service changes the release itself
+%if 0%{?opensuse_bs}
+Source1: Release_Notes-%{version}-1.tar.gz
+%else
 Source1: Release_Notes-%{version}-%{release}.tar.gz
-Source2: http://www.prdownloads.sourceforge.net/bacula/%{name}-docs-%{docs_version}.tar.gz
-Source3: http://www.prdownloads.sourceforge.net/bacula/depkgs-%{depkgs_version}.tar.gz
-Source4: http://www.prdownloads.sourceforge.net/bacula/depkgs-qt-%{depkgs_qt_version}.tar.gz
-Source5: bacula-2.2.7-postgresql.patch
+%endif
+Source2: bacula-2.2.7-postgresql.patch
 
 # define the basic package description
 %define blurb Bacula - It comes by night and sucks the vital essence from your computers.
@@ -241,11 +238,6 @@ Source5: bacula-2.2.7-postgresql.patch
 %define blurb7 features that make it easy to find and recover lost or damaged files.
 %define blurb8 Bacula source code has been released under the GPL version 2 license.
 
-# Source directory locations
-%define _docsrc   ../%{name}-docs-%{docs_version}
-%define depkgs    ../depkgs
-%define depkgs_qt ../depkgs-qt
-
 %define user_file  /etc/passwd
 %define group_file /etc/group
 
@@ -358,6 +350,7 @@ Source5: bacula-2.2.7-postgresql.patch
 %define scil 1
 %endif
 
+
 # test for a platform definition
 %if !%{rhat} && !%{rhel} && !%{fed} && !%{wb3} && !%{suse} && !%{mdk}
 %{error: You must specify a platform. Please examine the spec file.}
@@ -426,12 +419,29 @@ exit 1
 %define _dist %(grep Mand /etc/mandrake-release)
 %endif
 %{?DISTNAME:%define _dist %{DISTNAME}}
+
+# only set Disribution if not in opensuse build service, as it sets it itself
+%if ! 0%{?opensuse_bs}
+%{?DISTNAME:%define _dist %{DISTNAME}}
 Distribution: %{_dist}
+%endif
+
+%if 0%{?opensuse_bs} &&  %{mysql} && %{suse}
+# needed in opensuse_bs, as rpm is installed during build process
+BuildRequires: libmysqlclient-devel
+BuildRequires: mysql-client
+BuildRequires: mysql
+%endif
+%if 0%{?opensuse_bs} &&  %{suse} && %{postgresql}
+BuildRequires: postgresql
+BuildRequires: postgresql-server
+%endif
+BuildRequires: openssl
 
-# Should we build bat
-# requires >= Qt-4.2
-%define bat 0
-%{?build_bat:%define bat 1}
+%if 0%{?opensuse_bs} && %{suse}
+BuildRequires: pwdutils
+BuildRequires: sysconfig
+%endif
 
 # should we turn on python support
 %define python 0
@@ -492,23 +502,18 @@ BuildRequires: glibc-static-devel
 BuildRequires: libtermcap-devel
 %endif
 %if !%{rh7} && !%{su9} && !%{su10} && !%{su102} && !%{su103} && !%{su110} && !%{su111} && !%{mdk} && !%{fc3} && !%{fc4} && !%{fc5} && !%{fc6} && !%{fc7} && !%{fc8} && !%{fc9}
-BuildRequires: libtermcap-devel
-%endif
-
-%if %{sqlite}
-BuildRequires: sqlite-devel
+#BuildRequires: libtermcap-devel
 %endif
 
-%if %{mysql} && ! %{mysql4} && ! %{mysql5}
-BuildRequires: mysql-devel >= 3.23
+%if %{sqlite} && %{su10}
+BuildRequires: sqlite2-devel
 %endif
-
-%if %{mysql} && %{mysql4}
-BuildRequires: mysql-devel >= 4.0
+%if %{sqlite} && ! %{su10}
+BuildRequires: sqlite-devel
 %endif
 
-%if %{mysql} && %{mysql5}
-BuildRequires: mysql-devel >= 5.0
+%if %{mysql}
+BuildRequires: mysql-devel
 %endif
 
 %if %{postgresql} && %{wb3}
@@ -696,81 +701,22 @@ Group: System Environment/Daemons
 
 This package installs the Bacula pdf and html documentation.
 
-%if %{bat}
-%package bat
-Summary: Bacula - The Network Backup Solution
-Group: System Environment/Daemons
-
-%if %{suse}
-Requires: openssl
-Requires: glibc
-Requires: fontconfig
-Requires: freetype2
-Requires: libgcc
-Requires: libpng
-Requires: libstdc++
-Requires: zlib
-%else
-Requires: openssl
-Requires: glibc
-Requires: fontconfig
-Requires: freetype
-Requires: libgcc
-Requires: libpng
-Requires: libstdc++
-Requires: zlib
-%endif
-
-%description bat
-%{blurb}
-
-%{blurb2}
-%{blurb3}
-%{blurb4}
-%{blurb5}
-%{blurb6}
-%{blurb7}
-%{blurb8}
-
-This is the Bacula Administration Tool (bat) graphical user interface package. 
-It is an add-on to the client or server packages.
-%endif
-
 # Must explicitly enable debug pkg on SuSE
+# but not in opensuse_bs
+%if ! 0%{?opensuse_bs}
 %if %{suse}
 %debug_package
 export LDFLAGS="${LDFLAGS} -L/usr/lib/termcap"
 %endif
+%endif
 
 %prep
-
 %setup
 %setup -T -D -b 1
-%setup -T -D -b 2
-%setup -T -D -b 3
-%setup -T -D -b 4
-%setup -T -D -b 5
+#%setup -T -D -b 2
 
 %build
 
-cwd=${PWD}
-%if %{bat}
-#export QTDIR=$(pkg-config --variable=prefix QtCore)
-#export QTINC=$(pkg-config --variable=includedir QtCore)
-#export QTLIB=$(pkg-config --variable=libdir QtCore)
-#export PATH=${QTDIR}/bin/:${PATH}
-cd %{depkgs_qt}
-make qt4 <<EOF
-yes
-EOF
-qtdir=${PWD}
-export PATH=${qtdir}/qt4/bin:$PATH
-export QTDIR=${qtdir}/qt4/
-export QTINC=${qtdir}/qt4/include/
-export QTLIB=${qtdir}/qt4/lib/
-cd ${cwd}
-%endif
-
 %if %{wb3} || %{old_pgsql}
 patch -p3 src/cats/postgresql.c < %SOURCE5
 %endif
@@ -779,18 +725,18 @@ patch -p3 src/cats/postgresql.c < %SOURCE5
 
 # patch the make_sqlite_tables script for installation bindir
 #patch src/cats/make_sqlite_tables.in src/cats/make_sqlite_tables.in.patch
-patch src/cats/make_sqlite3_tables.in src/cats/make_sqlite3_tables.in.patch
+#patch src/cats/make_sqlite3_tables.in src/cats/make_sqlite3_tables.in.patch
 
 # patch the create_sqlite_database script for installation bindir
 #patch src/cats/create_sqlite_database.in src/cats/create_sqlite_database.in.patch
-patch src/cats/create_sqlite3_database.in src/cats/create_sqlite3_database.in.patch
+#patch src/cats/create_sqlite3_database.in src/cats/create_sqlite3_database.in.patch
 
 # patch the make_catalog_backup script for installation bindir
-patch src/cats/make_catalog_backup.in src/cats/make_catalog_backup.in.patch
+#patch src/cats/make_catalog_backup.in src/cats/make_catalog_backup.in.patch
 
 # patch the update_sqlite_tables script for installation bindir
 #patch src/cats/update_sqlite_tables.in src/cats/update_sqlite_tables.in.patch
-patch src/cats/update_sqlite3_tables.in src/cats/update_sqlite3_tables.in.patch
+#patch src/cats/update_sqlite3_tables.in src/cats/update_sqlite3_tables.in.patch
 
 # patch the bacula-dir init script to remove sqlite service
 %if %{sqlite} && %{su9}
@@ -830,12 +776,6 @@ export LDFLAGS="${LDFLAGS} -L/usr/lib64/python%{pyver}"
 %if %{rhel5} || %{centos5} || %{sl5}
 %define qt_path 1
 %endif
-#%if %{bat} && %{qt_path} && %{x86_64}
-#export PATH=/usr/lib64/qt4/bin/:$PATH
-#export QTDIR=/usr/lib64/qt4/
-#export QTINC=/usr/lib64/qt4/include/
-#export QTLIB=/usr/lib64/qt4/
-#%endif
 
 # Main Bacula configuration
 %configure \
@@ -849,19 +789,24 @@ export LDFLAGS="${LDFLAGS} -L/usr/lib64/python%{pyver}"
         --with-pid-dir=%{pid_dir} \
         --with-subsys-dir=%{_subsysdir} \
         --enable-smartalloc \
+        --disable-gome \
+        --disable-bwx-console \
+        --disable-tray-monitor \
 %if %{mysql}
         --with-mysql \
 %endif
 %if %{sqlite}
+%if %{su9} || %{su10}
+        --with-sqlite \
+%else
         --with-sqlite3 \
 %endif
+%endif # sqlite?
 %if %{postgresql}
         --with-postgresql \
 %endif
-%if %{bat}
-        --enable-bat \
+        --disable-bat \
         --without-qwt \
-%endif
 %if %{python}
         --with-python \
 %endif
@@ -885,7 +830,7 @@ export LDFLAGS="${LDFLAGS} -L/usr/lib64/python%{pyver}"
         --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
         --with-openssl
 
-make
+make -j3
 
 %install
  
@@ -893,45 +838,19 @@ cwd=${PWD}
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
 mkdir -p $RPM_BUILD_ROOT/etc/init.d
 mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
-mkdir -p $RPM_BUILD_ROOT/etc/log.d/conf/logfiles
-mkdir -p $RPM_BUILD_ROOT/etc/log.d/conf/services
-mkdir -p $RPM_BUILD_ROOT/etc/log.d/scripts/services
+mkdir -p $RPM_BUILD_ROOT/etc/logwatch/conf/logfiles
+mkdir -p $RPM_BUILD_ROOT/etc/logwatch/conf/services
+mkdir -p $RPM_BUILD_ROOT/etc/logwatch/scripts/services
 mkdir -p $RPM_BUILD_ROOT%{script_dir}/updatedb
 
-%if %{bat}
-mkdir -p $RPM_BUILD_ROOT/usr/share/applications
-mkdir -p $RPM_BUILD_ROOT/usr/share/pixmaps
-%define usermode_iftrick 1
-%else
-%define usermode_iftrick 0
-%endif
-
-%if %{usermode_iftrick} && ! %{su9} && ! %{su10} && ! %{su102} && ! %{su103} && ! %{su110} && ! %{su111}
 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
-mkdir -p $RPM_BUILD_ROOT/etc/security/console.apps
 mkdir -p $RPM_BUILD_ROOT%{_sbindir}
 #mkdir -p $RPM_BUILD_ROOT%{_bindir}
-%endif
-
-%if %{sqlite}
-mkdir -p $RPM_BUILD_ROOT%{sqlite_bindir}
-%endif
 
 make DESTDIR=$RPM_BUILD_ROOT install
 
-
-# make install in manpages installs _everything_ shotgun style
-# so now delete what we will not be packaging
-rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bwxconsole.1.%{manpage_ext}
-rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bgnome-console.1.%{manpage_ext}
-rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-tray-monitor.1.%{manpage_ext}
-
-%if ! %{bat}
-rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bat.1.%{manpage_ext}
-%endif
-
 %if %{client_only}
-rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bsmtp.1.%{manpage_ext}
+# Program docs not installed on client
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bacula-dir.8.%{manpage_ext}
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bacula-sd.8.%{manpage_ext}
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bcopy.8.%{manpage_ext}
@@ -940,7 +859,13 @@ rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bls.8.%{manpage_ext}
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/bscan.8.%{manpage_ext}
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/btape.8.%{manpage_ext}
 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/dbcheck.8.%{manpage_ext}
+rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bsmtp.1.%{manpage_ext}
 %endif
+# Docs for programs that are depreciated
+rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bgnome-console.1.%{manpage_ext}
+rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-bwxconsole.1.%{manpage_ext}
+rm -f $RPM_BUILD_ROOT%{_mandir}/man1/bacula-tray-monitor.1.%{manpage_ext}
+rm -f $RPM_BUILD_ROOT%{script_dir}/gconsole
 
 # fixme - make installs the mysql scripts for sqlite build
 %if %{sqlite}
@@ -955,9 +880,6 @@ rm -f $RPM_BUILD_ROOT%{script_dir}/startmysql
 rm -f $RPM_BUILD_ROOT%{script_dir}/stopmysql
 %endif
 
-rm -f $RPM_BUILD_ROOT%{script_dir}/gconsole
-rm -f $RPM_BUILD_ROOT%{_sbindir}/static-bacula-fd
-
 # install the init scripts
 %if %{suse}
 cp -p platforms/suse/bacula-dir $RPM_BUILD_ROOT/etc/init.d/bacula-dir
@@ -980,31 +902,6 @@ rm -f $RPM_BUILD_ROOT/etc/init.d/bacula-dir
 rm -f $RPM_BUILD_ROOT/etc/init.d/bacula-sd
 %endif
 
-# install the menu stuff
-%if %{bat}
-cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
-cp -p scripts/bat.desktop.xsu $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
-%endif
-%if %{rh8} || %{rh9} || %{wb3} || %{fc1} || %{fc3} || %{fc4} || %{fc5} || %{fc6} || %{fc7} || %{fc8} || %{fc9} || %{mdk}
-%define iftrick 1
-%else
-%define iftrick 0
-%endif
-%if %{bat} && %{iftrick}
-cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
-cp -p scripts/bat.desktop.consolehelper $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
-cp -p scripts/bat.console_apps $RPM_BUILD_ROOT/etc/security/console.apps/bat
-cp -p scripts/bat.pamd $RPM_BUILD_ROOT/etc/pam.d/bat
-ln -sf consolehelper $RPM_BUILD_ROOT/%{_sbindir}/bat
-%endif
-
-# install sqlite
-%if %{sqlite}
-cp -p %{depkgs}/sqlite3/sqlite3 $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite3
-cp -p %{depkgs}/sqlite3/sqlite3.h $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite3.h
-cp -p %{depkgs}/sqlite3/libsqlite3.a $RPM_BUILD_ROOT%{sqlite_bindir}/libsqlite3.a
-%endif
-
 # install the logrotate file
 cp -p scripts/logrotate $RPM_BUILD_ROOT/etc/logrotate.d/bacula
 
@@ -1013,37 +910,13 @@ cp -p updatedb/* $RPM_BUILD_ROOT%{script_dir}/updatedb/
 
 # install the logwatch scripts
 %if ! %{client_only}
-cp -p scripts/logwatch/bacula $RPM_BUILD_ROOT/etc/log.d/scripts/services/bacula
-cp -p scripts/logwatch/logfile.bacula.conf $RPM_BUILD_ROOT/etc/log.d/conf/logfiles/bacula.conf
-cp -p scripts/logwatch/services.bacula.conf $RPM_BUILD_ROOT/etc/log.d/conf/services/bacula.conf
-chmod 755 $RPM_BUILD_ROOT/etc/log.d/scripts/services/bacula
-chmod 644 $RPM_BUILD_ROOT/etc/log.d/conf/logfiles/bacula.conf
-chmod 644 $RPM_BUILD_ROOT/etc/log.d/conf/services/bacula.conf
-%endif
-
-# install docs for single dir installation
-mkdir $RPM_BUILD_ROOT%{_prefix}/doc
-cp COPYING $RPM_BUILD_ROOT%{_prefix}/doc/
-cp ChangeLog $RPM_BUILD_ROOT%{_prefix}/doc/
-cp ReleaseNotes $RPM_BUILD_ROOT%{_prefix}/doc/
-cp VERIFYING $RPM_BUILD_ROOT%{_prefix}/doc/
-cp LICENSE $RPM_BUILD_ROOT%{_prefix}/doc/
-cp kernstodo $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/catalog/catalog $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/catalog/catalog.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/concepts/concepts $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/concepts/concepts.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/console/console $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/console/console.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/developers/developers $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/developers/developers.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/install/install $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/install/install.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/problems/problems $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/problems/problems.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp -r %{_docsrc}/manuals/en/utility/utility $RPM_BUILD_ROOT%{_prefix}/doc/
-cp %{_docsrc}/manuals/en/utility/utility.pdf $RPM_BUILD_ROOT%{_prefix}/doc/
-cp ../Release_Notes-%{version}-%{release}.txt $RPM_BUILD_ROOT%{_prefix}/doc/
+cp -p scripts/logwatch/bacula $RPM_BUILD_ROOT/etc/logwatch/scripts/services/bacula
+cp -p scripts/logwatch/logfile.bacula.conf $RPM_BUILD_ROOT/etc/logwatch/conf/logfiles/bacula.conf
+cp -p scripts/logwatch/services.bacula.conf $RPM_BUILD_ROOT/etc/logwatch/conf/services/bacula.conf
+chmod 755 $RPM_BUILD_ROOT/etc/logwatch/scripts/services/bacula
+chmod 644 $RPM_BUILD_ROOT/etc/logwatch/conf/logfiles/bacula.conf
+chmod 644 $RPM_BUILD_ROOT/etc/logwatch/conf/services/bacula.conf
+%endif
 
 # now clean up permissions that are left broken by the install
 chmod o-rwx $RPM_BUILD_ROOT%{working_dir}
@@ -1067,9 +940,12 @@ rm -f $RPM_BUILD_ROOT%{_sbindir}/bacula
 
 %clean
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
-rm -rf $RPM_BUILD_DIR/%{name}-docs-%{docs_version}
-rm -rf $RPM_BUILD_DIR/depkgs
+%if 0%{?opensuse_bs}
+rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-1.txt
+%else
 rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
+%endif
+
 
 %if %{mysql}
 # MySQL specific files
@@ -1086,6 +962,17 @@ rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
 %endif
 
 %if %{sqlite}
+%if  %{su9} ||  %{su10}
+# use sqlite2 on SLE_10 and SLES9
+%files sqlite
+%defattr(-,root,root)
+%attr(-, root, %{daemon_group}) %{script_dir}/create_sqlite_database
+%attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite_database
+%attr(-, root, %{daemon_group}) %{script_dir}/grant_sqlite_privileges
+%attr(-, root, %{daemon_group}) %{script_dir}/make_sqlite_tables
+%attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite_tables
+%attr(-, root, %{daemon_group}) %{script_dir}/update_sqlite_tables
+%else
 %files sqlite
 %defattr(-,root,root)
 %attr(-, root, %{daemon_group}) %{script_dir}/create_sqlite3_database
@@ -1094,11 +981,11 @@ rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
 %attr(-, root, %{daemon_group}) %{script_dir}/make_sqlite3_tables
 %attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite3_tables
 %attr(-, root, %{daemon_group}) %{script_dir}/update_sqlite3_tables
-%{sqlite_bindir}/libsqlite3.a
-%{sqlite_bindir}/sqlite3.h
-%{sqlite_bindir}/sqlite3
+%endif # sqlite?
 %endif
 
+
+
 %if %{postgresql}
 %files postgresql
 %defattr(-,root,root)
@@ -1108,9 +995,17 @@ rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
 %attr(-, root, %{daemon_group}) %{script_dir}/drop_postgresql_tables
 %attr(-, root, %{daemon_group}) %{script_dir}/update_postgresql_tables
 %attr(-, root, %{daemon_group}) %{script_dir}/grant_postgresql_privileges
+# The rest is DB backend independent
 %endif
+# opensuse_bs: directories not owned by any package
+/etc/bacula
+/etc/logwatch
+/etc/logwatch/conf
+/etc/logwatch/conf/logfiles
+/etc/logwatch/conf/services
+/etc/logwatch/scripts
+/etc/logwatch/scripts/services
 
-# The rest is DB backend independent
 %if ! %{client_only}
 %attr(-, root, %{daemon_group}) %dir %{script_dir}
 %attr(-, root, %{daemon_group}) %{script_dir}/bacula
@@ -1138,13 +1033,13 @@ rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
 %attr(-, root, %{storage_daemon_group}) %{script_dir}/mtx-changer.conf
 
 /etc/logrotate.d/bacula
-/etc/log.d/scripts/services/bacula
+/etc/logwatch/scripts/services/bacula
 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-dir.conf
 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-fd.conf
 %attr(-, root, %{storage_daemon_group}) %config(noreplace) %{sysconf_dir}/bacula-sd.conf
 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bconsole.conf
-%attr(-, root, %{daemon_group}) %config(noreplace) /etc/log.d/conf/logfiles/bacula.conf
-%attr(-, root, %{daemon_group}) %config(noreplace) /etc/log.d/conf/services/bacula.conf
+%attr(-, root, %{daemon_group}) %config(noreplace) /etc/logwatch/conf/logfiles/bacula.conf
+%attr(-, root, %{daemon_group}) %config(noreplace) /etc/logwatch/conf/services/bacula.conf
 %attr(-, root, %{daemon_group}) %config(noreplace) %{script_dir}/query.sql
 
 %attr(-, %{storage_daemon_user}, %{daemon_group}) %dir %{working_dir}
@@ -1177,6 +1072,7 @@ rm -f $RPM_BUILD_DIR/Release_Notes-%{version}-%{release}.txt
 %{_mandir}/man8/btraceback.8.%{manpage_ext}
 %{_mandir}/man8/dbcheck.8.%{manpage_ext}
 %{_mandir}/man1/bsmtp.1.%{manpage_ext}
+%{_mandir}/man1/bat.1.%{manpage_ext}
 %{_libdir}/libbac*
 /usr/share/doc/*
 %endif
@@ -1190,31 +1086,10 @@ DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
 
 %if %{sqlite}
 %pre sqlite
-# are we upgrading from sqlite to sqlite3?
-if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite ];then
-    echo "This version of bacula-sqlite involves an upgrade to sqlite3."
-    echo "Your catalog database file is not compatible with sqlite3, thus"
-    echo "you will need to dump the data, delete the old file, and re-run"
-    echo "this rpm upgrade."
-    echo ""
-    echo "Backing up your current database..."
-    echo ".dump" | %{sqlite_bindir}/sqlite %{working_dir}/bacula.db > %{working_dir}/bacula_backup.sql
-    mv %{working_dir}/bacula.db %{working_dir}/bacula.db.old
-    echo "Your catalog data has been saved in %{working_dir}/bacula_backup.sql and your"
-    echo "catalog file has been renamed %{working_dir}/bacula.db.old."
-    echo ""
-    echo "Please re-run this rpm package upgrade."
-    echo "After the upgrade is complete, restore your catalog"
-    echo "with the following commands:"
-    echo "%{script_dir}/drop_sqlite3_tables"
-    echo "cd %{working_dir}"
-    echo "%{sqlite_bindir}/sqlite3 $* bacula.db < bacula_backup.sql"
-    echo "chown bacula.bacula bacula.db"
-    exit 1
-fi
 # test for bacula database older than version 10 and sqlite3
-if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite3 ];then
-        DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
+if [ -s %{working_dir}/bacula.db ]; then
+        DB_VER=`echo "select * from Version;" | sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
+fi
 %endif
 
 %if %{postgresql}
@@ -1234,9 +1109,6 @@ if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "10" ]; then
 fi
 %endif
 
-%if %{sqlite}
-fi
-%endif
 
 %if ! %{client_only}
 # check for and copy %{sysconf_dir}/console.conf to bconsole.conf
@@ -1304,10 +1176,15 @@ fi
 %if %{postgresql}
 %post postgresql
 %endif
-
 %if ! %{client_only}
 # add our links
 if [ "$1" -ge 1 ] ; then
+%if %{suse} && %{mysql}
+  /sbin/chkconfig --add mysql
+%endif
+%if %{suse} && %{postgresql}
+  /sbin/chkconfig --add postgresql
+%endif
   /sbin/chkconfig --add bacula-dir
   /sbin/chkconfig --add bacula-fd
   /sbin/chkconfig --add bacula-sd
@@ -1315,6 +1192,10 @@ fi
 %endif
 
 %if %{mysql}
+
+#check, if mysql can be called successfully at all
+if mysql 2>/dev/null bacula -e 'select * from Version;' ; then
+
 # test for an existing database
 # note: this ASSUMES no password has been set for bacula database
 DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
@@ -1338,18 +1219,19 @@ elif [ "$DB_VER" -lt "11" ]; then
     %{script_dir}/update_mysql_tables
     echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
 
+fi
 fi
 %endif
 
 %if %{sqlite}
 # test for an existing database
 if [ -s %{working_dir}/bacula.db ]; then
-    DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
+    DB_VER=`echo "select * from Version;" | sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
     # check to see if we need to upgrade a 2.x database
     if [ "$DB_VER" -lt "11" ] && [ "$DB_VER" -ge "10" ]; then
         echo "This release requires an upgrade to your bacula database."
         echo "Backing up your current database..."
-        echo ".dump" | %{sqlite_bindir}/sqlite3 %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2
+        echo ".dump" | sqlite3 %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2
         echo "Upgrading bacula database ..."
         %{script_dir}/update_sqlite3_tables
         echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
@@ -1366,6 +1248,9 @@ fi
 %endif
 
 %if %{postgresql}
+# check if psql can be called successfully at all
+if echo 'select * from Version;' | psql bacula 2>/dev/null; then
+
 # test for an existing database
 # note: this ASSUMES no password has been set for bacula database
 DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
@@ -1389,6 +1274,7 @@ elif [ "$DB_VER" -lt "11" ]; then
     %{script_dir}/update_postgresql_tables
     echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
         
+fi
 fi
 %endif
 
@@ -1398,26 +1284,21 @@ if [ -d %{sysconf_dir} ]; then
    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
       pass=`openssl rand -base64 33`
       for file in *.conf; do
-         need_password=`grep ${string} $file 2>/dev/null`
-         if [ -n "$need_password" ]; then
-            sed "s@${string}@${pass}@g" $file > $file.new
-            cp -f $file.new $file; rm -f $file.new
-         fi
+         sed "s@${string}@${pass}@g" $file > $file.new
+         cp -f $file.new $file; rm -f $file.new
       done
    done
 # put actual hostname in conf file
    host=`hostname`
    string="XXX_HOSTNAME_XXX"
    for file in *.conf; do
-      need_host=`grep ${string} $file 2>/dev/null`
-      if [ -n "$need_host" ]; then
-         sed "s@${string}@${host}@g" $file >$file.new
-         cp -f $file.new $file; rm -f $file.new
-      fi
+      sed "s@${string}@${host}@g" $file >$file.new
+      cp -f $file.new $file; rm -f $file.new
    done
 fi
-/sbin/ldconfig
 %endif
+/sbin/ldconfig
+exit 0 # always exit successfull, as otherwise opensuse build service complains
 
 %if %{mysql}
 %preun mysql
@@ -1436,20 +1317,20 @@ if [ $1 = 0 ]; then
   /sbin/chkconfig --del bacula-fd
   /sbin/chkconfig --del bacula-sd
 fi
+/sbin/ldconfig
 %endif
 
+# added: run ldconfig in postun
 %if %{mysql}
 %postun mysql
-/sbin/ldconfig
 %endif
 %if %{sqlite}
 %postun sqlite
-/sbin/ldconfig
 %endif
 %if %{postgresql}
 %postun postgresql
-/sbin/ldconfig
 %endif
+/sbin/ldconfig
 
 %files client
 %defattr(-,root,root)
@@ -1472,12 +1353,14 @@ fi
 %{_mandir}/man8/bacula.8.%{manpage_ext}
 %{_mandir}/man8/bconsole.8.%{manpage_ext}
 %{_mandir}/man8/btraceback.8.%{manpage_ext}
+%{_mandir}/man1/bat.1.%{manpage_ext}
 %{_libdir}/libbac.*
 %{_libdir}/libbaccfg.*
 %{_libdir}/libbacfind.*
 %{_libdir}/libbacpy.*
 /usr/share/doc/*
-
+#opensuse_bs: directories not owned by any package
+/etc/bacula
 
 %pre client
 # create the daemon group and user
@@ -1513,27 +1396,21 @@ if [ -d %{sysconf_dir} ]; then
    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
       pass=`openssl rand -base64 33`
       for file in *.conf; do
-         need_password=`grep ${string} $file 2>/dev/null`
-         if [ -n "$need_password" ]; then
-            sed "s@${string}@${pass}@g" $file > $file.new
-            cp -f $file.new $file; rm -f $file.new
-         fi
+         sed "s@${string}@${pass}@g" $file > $file.new
+         cp -f $file.new $file; rm -f $file.new
       done
    done
 # put actual hostname in conf file
    host=`hostname`
    string="XXX_HOSTNAME_XXX"
    for file in *.conf; do
-      need_host=`grep ${string} $file 2>/dev/null`
-      if [ -n "$need_host" ]; then
-         sed "s@${string}@${host}@g" $file >$file.new
-         cp -f $file.new $file; rm -f $file.new
-      fi
+      sed "s@${string}@${host}@g" $file >$file.new
+      cp -f $file.new $file; rm -f $file.new
    done
 fi
 
 /sbin/ldconfig
-
+exit 0
 %preun client
 # delete our link
 if [ $1 = 0 ]; then
@@ -1547,6 +1424,8 @@ fi
 %files updatedb
 %defattr(-,root,%{daemon_group})
 %{script_dir}/updatedb/*
+#oensuse_bs: directories not owned by any package
+%{script_dir}/updatedb
 
 %pre updatedb
 # create the daemon group
@@ -1561,72 +1440,9 @@ fi
 echo "The database update scripts were installed to %{script_dir}/updatedb"
 %endif
 
-%files docs
-%doc COPYING ChangeLog ReleaseNotes LICENSE VERIFYING kernstodo ../Release_Notes-%{version}-%{release}.txt
-%doc %{_docsrc}/manuals/en/catalog/catalog %{_docsrc}/manuals/en/catalog/catalog.pdf
-%doc %{_docsrc}/manuals/en/concepts/concepts %{_docsrc}/manuals/en/concepts/concepts.pdf
-%doc %{_docsrc}/manuals/en/console/console %{_docsrc}/manuals/en/console/console.pdf
-%doc %{_docsrc}/manuals/en/developers/developers %{_docsrc}/manuals/en/developers/developers.pdf
-%doc %{_docsrc}/manuals/en/install/install %{_docsrc}/manuals/en/install/install.pdf
-%doc %{_docsrc}/manuals/en/problems/problems %{_docsrc}/manuals/en/problems/problems.pdf
-%doc %{_docsrc}/manuals/en/utility/utility %{_docsrc}/manuals/en/utility/utility.pdf
-%{_prefix}/doc/*
-
-%if %{bat}
-%files bat
-%defattr(-,root,root)
-%{_sbindir}/bat
-%attr(-, root, %{daemon_group}) %dir %{sysconf_dir}
-%attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bat.conf
-/usr/share/pixmaps/bat_icon.png
-/usr/share/applications/bat.desktop
-%{_mandir}/man1/bat.1.%{manpage_ext}
-%endif
-
-%if %{bat} && ! %{su9} && ! %{su10} && ! %{su102} && ! %{su103} && ! %{su110} && ! %{su111}
-# add the console helper files
-%config(noreplace,missingok) /etc/pam.d/bat
-%config(noreplace,missingok) /etc/security/console.apps/bat
-%endif
-
-%if %{bat}
-%pre bat
-# create the daemon group
-HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
-if [ -z "$HAVE_BACULA" ]; then
-    %{groupadd} -r %{daemon_group} > /dev/null 2>&1
-    echo "The group %{daemon_group} has been added to %{group_file}."
-    echo "See the manual chapter \"Running Bacula\" for details."
-fi
-
-%post bat
-if [ -d %{sysconf_dir} ]; then
-   cd %{sysconf_dir}
-   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
-      pass=`openssl rand -base64 33`
-      for file in *.conf; do
-         need_password=`grep ${string} $file 2>/dev/null`
-         if [ -n "$need_password" ]; then
-            sed "s@${string}@${pass}@g" $file > $file.new
-            cp -f $file.new $file; rm -f $file.new
-         fi
-      done
-   done
-# put actual hostname in conf file
-   host=`hostname`
-   string="XXX_HOSTNAME_XXX"
-   for file in *.conf; do
-      need_host=`grep ${string} $file 2>/dev/null`
-      if [ -n "$need_host" ]; then
-         sed "s@${string}@${host}@g" $file >$file.new
-         cp -f $file.new $file; rm -f $file.new
-      fi
-   done
-fi
-
-%endif
-
 %changelog
+* Mon Aug 10 2009 Philipp Storz <philipp.storz@dass-it.de>
+- changes to work with opensuse build service
 * Sat Jun 20 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>
 - Fix bat install which is now handled by make and uses shared libs
 * Sat May 16 2009 D. Scott Barninger <barninger@fairfieldcomputers.com>