File bacula.spec of Package bacula

# My compilation preferences:
#
# Resulting packages: bacula-libs, bacula-fd, bacula-bat, bacula-gnome-console, 
#                     bacula-wxconsole, bacula-bconsole, bacula-....
# 
# Resulting packages(mysql): bacula-libs-mysql, bacula-sd-mysql, bacula-dir-mysql
# Resulting packages(sqlite3): bacula-libs-sqlite3, bacula-sd-sqlite3, bacula-dir-sqlite3
# Resulting packages(postgresql): bacula-libs-postgresql, bacula-sd-postgresql, 
#                                 bacula-dir-postgresql
#
# With this scheme, 4 compilations are necessary in order to complete all packages
# for all database backends that are available on SLE platforms at the moment.

%define mysql             0
%define postgresql        0
%define sqlite3           0

%define build_sd     1
%define build_dir    1
%define kdeconsole   1
%define gnomeconsole 1
%define wxconsole    1

%define db_be none

%if %{mysql}
  %define db_be MySQL
  %define db_backend mysql
  %define otherdb_be_1 PostgreSQL
  %define otherdb_be_2 Sqlite3

%else 

  %if %{postgresql}
    %define db_be PostgreSQL
    %define db_backend postgresql
    %define otherdb_be_1 MySQL
    %define otherdb_be_2 Sqlite3

  %else

    %if %{sqlite3}
      %define db_be Sqlite3
      %define db_backend sqlite3
      %define otherdb_be_1 PostgreSQL
      %define otherdb_be_2 MySQL
    %endif

  %endif

%endif

%if %{db_be} == "none"
  %{error:You must specify 1 database support: mysql, postgresql or sqlite3. Check .spec file defines.}
  _exit
%endif


####################################################################################################
# LOCAL DEFINES (not to edit)
####################################################################################################

%define dd_grp bacula
%define dd_usr bacula
%define sd_grp bacula
%define sd_usr disk
%define fd_grp root
%define fd_usr bacula


# SLE PLATFORM package re-naming for BuildRequires
# /END package re-naming for BuildRequires

%define console      1
%define openssl      1
%define python       1

%define scriptdir    %{_sysconfdir}/bacula/addon-scripts
%define working_dir  %{_localstatedir}/lib/bacula

####################################################################################################
# PACKAGE DEFINITIONS
####################################################################################################

Name:           bacula
Version:        3.0.2
Release:        1
License:        GPL v2
Source:         http://www.prdownloads.sourceforge.net/bacula/%{name}-%{version}.tar.gz
Source1:        http://www.prdownloads.sourceforge.net/bacula/depkgs-18Feb09.tar.gz
URL:            http://www.bacula.org
Group:          Productivity/Archiving/Backup
Summary:        Client/Server Backup Solution
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-c++ libacl-devel libattr-devel
%if %{openssl}
BuildRequires:  libopenssl-devel
%endif
%if %{python}
BuildRequires:  python-devel
%endif
%if %{mysql}
BuildRequires:  libmysqlclient-devel
%endif
%if %{postgresql}
BuildRequires:  postgresql-devel
%endif
%if %{sqlite3}
BuildRequires:  sqlite3-devel
%endif
%if %{kdeconsole}
BuildRequires:  libqt4-devel 
BuildRequires:  freetype2-devel fontconfig-devel
%endif
%if %{gnomeconsole}
BuildRequires:  atk-devel pango-devel cairo-devel gtk2-devel glib2-devel 
BuildRequires:  freetype2-devel fontconfig-devel scrollkeeper pkg-config
BuildRequires:  gconf2-devel libgnome-devel libgnomeui-devel update-desktop-files
BuildRequires:  libgnomecanvas-devel libxml2-devel
%endif
%if %{wxconsole}
BuildRequires:  wxGTK-devel
%endif
%if %{console}
BuildRequires:  readline-devel ncurses-devel termcap
%endif

%description
Bacula is a set of computer programs that permits the system
administrator to manage backup, recovery, and verification of computer
data across a network of computers of different kinds. Bacula can also
run entirely upon a single computer and can backup to various types of
media, including tape and disk.


%package libs
Summary: Bacula - Base Libraries
Group: Productivity/Archiving/Backup
%description libs
Bacula base libraries required by all bacula packages.

%package fd
Summary: Bacula - Client agent (File daemon)
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
%description fd
Bacula file daemon is a client agent for the Bacula backup system.

%package bat
Summary: Bacula - Administration Tool (BAT) for KDE Desktops
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: libgnomesu
%description bat
Bacula bat is a client application for monitoring bacula daemons built
for KDE Desktops.

%package bgnome-console
Summary: Bacula - Console for Gnome Desktops
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: libgnomesu
%description bgnome-console
Bacula bgnome-console is a client application for monitoring bacula daemons built 
for Gnome Desktops.

%package bwx-console
Summary: Bacula - Console for WxWindows framework.
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: libgnomesu
%description bwx-console
Bacula bwx-console is a client application for monitoring bacula daemons built 
with the WxWindows Framework.

%package bconsole
Summary: Bacula - Console command.
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
%description bconsole
Bacula bconsole is a client application for monitoring bacula director daemon 
from the command line.

%package mtx
Summary: Bacula - Tape utilities.
Group: Productivity/Archiving/Backup
%description mtx
Bacula's version of mtx tape utilities for Linux distributions that
do not provide their own mtx package

%package libs-%{db_be}
Summary: Bacula - Libraries for accessing %{db_be} database
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: bacula-utils-%{db_be} = %version
Conflicts: libs-%{otherdb_be_1}
Conflicts: libs-%{otherdb_be_2}
%description libs-%{db_be}
Required library for %{db_be} database access.

%package utils-%{db_be}
Summary: Bacula - Utilities for %{db_be} database management
Group: Productivity/Archiving/Backup
Conflicts: utils-%{otherdb_be_1}
Conflicts: utils-%{otherdb_be_2}
%description utils-%{db_be}
Bacula provided scripts for %{db_be} database basic management and setup.
Database update from previous version is also provided.

%package sd-%{db_be}
Summary: Bacula - Storage daemon for %{db_be} database
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: bacula-libs-%{db_be} = %version
%description sd-%{db_be}
Bacula storage daemon with %{db_be} database backend. 

%package dir-%{db_be}
Summary: Bacula - Director for %{db_be} database
Group: Productivity/Archiving/Backup
Requires: bacula-libs = %version
Requires: bacula-libs-%{db_be} = %version
%description dir-%{db_be}
Bacula director daemon with %{db_be} database backend.


####################################################################################################
# PREP
####################################################################################################

%prep
%setup -q

%setup -q -T -D -a 1


####################################################################################################
# BUILD
####################################################################################################

%build

CFLAGS="$RPM_OPT_FLAGS -I/usr/include/readline"
export CFLAGS
CXXFLAGS="$RPM_OPT_FLAGS -I/usr/include/readline"
export CXXFLAGS
LDFLAGS="$LDFLAGS -L%{_libdir}/termcap"
export LDFLAGS

# Build Dependencies Packages
pushd depkgs
make mtx
%if %{kdeconsole}
    make qwt
%endif
popd


%configure \
        --prefix=%{_prefix} \
        --sbindir=%{_sbindir} \
        --libdir=%{_libdir}/bacula \
        --docdir=%{_docdir}/bacula/ \
        --mandir=%{_mandir} \
        --infodir=%{_infodir} \
        --sysconfdir=%{_sysconfdir}/bacula \
        --with-plugindir=%{_libdir}/bacula/plugins \
        --with-scriptdir=%{scriptdir} \
        --with-pid-dir=%{_localstatedir}/run/bacula \
        --with-working-dir=%{working_dir} \
        --with-subsys-dir=%{_localstatedir}/lock/subsys \
%if %{python}
	--with-python \
%endif
%if %{openssl}
	--with-openssl \
%endif
%if %{console}
        --with-readline \
        --enable-readline \
        --disable-conio \
%endif
%if %{wxconsole}
        --enable-bwx-console \
%endif
%if %{kdeconsole}
        --enable-tray-monitor \
        --enable-bat \
        --with-qwt=${PWD}/depkgs/qwt \
%endif
%if %{gnomeconsole}
        --enable-tray-monitor \
        --enable-gnome \
%endif
	--with-dir-user=%{dd_usr} \
	--with-dir-group=%{dd_grp} \
	--with-sd-user=%{sd_usr} \
	--with-sd-group=%{sd_grp} \
	--with-fd-user=%{fd_usr} \
	--with-fd-group=%{fd_grp} \
	--with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
	--with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
	--with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
	--with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
	--with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
	--with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX"  \
%if %{mysql}
	--with-mysql \
%endif
%if %{sqlite3}
	--with-sqlite3 \
%endif
%if %{postgresql}
	--with-postgresql \
%endif
%if %{build_dir} 
        --enable-build-dird \
%else
        --disable-build-dird \
%endif
%if %{build_sd} 
        --enable-build-stored \
%else
        --disable-build-stored \
%endif
	--enable-smartalloc \
	--enable-batchinsert

make



####################################################################################################
# INSTALL
####################################################################################################  

%install

make DESTDIR=%buildroot install


# file cleanup 

rm %{buildroot}%{_sbindir}/bacula
rm %{buildroot}%{scriptdir}/bacula
rm %{buildroot}%{scriptdir}/bacula-ctl*
rm %{buildroot}%{scriptdir}/start*
rm %{buildroot}%{scriptdir}/stop*
rm %{buildroot}%{scriptdir}/gconsole
rm %{buildroot}%{_libdir}/bacula/*.la
rm %{buildroot}%{_libdir}/bacula/*.so

mkdir -p %{buildroot}/sbin
mkdir -p %{buildroot}/etc/init.d
mkdir -p %{buildroot}/%{_docdir}/bacula-bat
mkdir -p %{buildroot}/usr/share/pixmaps
mkdir -p %{buildroot}/usr/share/applications
mkdir -p %{buildroot}/var/run/bacula
mkdir -p %{buildroot}/etc/logrotate.d


# fix for BAT
mv %{buildroot}%{_docdir}/bacula/bacula/html %{buildroot}%{_docdir}/bacula-bat
install -m755 ${PWD}/src/qt-console/bat %{buildroot}/%{_sbindir}

# fix for MTX
mv %{buildroot}%{scriptdir}/mtx-changer.conf %{buildroot}%{_sysconfdir}/bacula
mv %{buildroot}%{scriptdir}/mtx-changer %{buildroot}%{_sbindir}
pushd depkgs
make \
    prefix=$RPM_BUILD_ROOT%{_prefix} \
    sbindir=$RPM_BUILD_ROOT%{_sbindir} \
    mandir=$RPM_BUILD_ROOT%{_mandir} \
    mtx-install
popd

# fix for manpages and command names
mv %{buildroot}%{_mandir}/man1/bacula-bgnome-console.1.gz %{buildroot}%{_mandir}/man1/bgnome-console.1.gz 
mv %{buildroot}%{_mandir}/man1/bacula-bwxconsole.1.gz %{buildroot}%{_mandir}/man1/bwx-console.1.gz 

# init.d scripts and suse links
install -m755 platforms/suse/bacula-fd %{buildroot}/etc/init.d
ln -s /etc/init.d/bacula-fd %{buildroot}/sbin/rcbacula-fd 

# addons for gnome/kde/wxwindows console
install -m644 src/tray-monitor/generic.xpm $RPM_BUILD_ROOT/usr/share/pixmaps/bacula-tray-monitor.xpm
install -m644 scripts/bacula-tray-monitor.desktop $RPM_BUILD_ROOT/usr/share/applications/bacula-tray-monitor.desktop
install -m644 scripts/bacula.png $RPM_BUILD_ROOT/usr/share/pixmaps/bgnome-console.png
sed -e 's@bacula.png@bgnome-console.png@g' scripts/bacula.desktop.gnome2.xsu > $RPM_BUILD_ROOT/usr/share/applications/bgnome-console.desktop

install -m644 src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat.png
sed -e 's@bat_icon.png@bat.png@g' scripts/bat.desktop.xsu > $RPM_BUILD_ROOT/usr/share/applications/bat.desktop

install -m644 src/wx-console/wxwin16x16.xpm $RPM_BUILD_ROOT/usr/share/pixmaps/bwx-console.xpm
sed -e 's@wxwin16x16.xpm@bwx-console.xpm@g' scripts/wxconsole.desktop.xsu > $RPM_BUILD_ROOT/usr/share/applications/bwx-console.desktop

# call to suse_update_desktop_files
%suse_update_desktop_file bacula-tray-monitor -r System Backup
%suse_update_desktop_file bgnome-console -r System Backup
%suse_update_desktop_file bat -r System Backup
%suse_update_desktop_file bwx-console -r System Backup

# init.d scripts and suse links
install -m755 platforms/suse/bacula-sd %{buildroot}/etc/init.d
ln -s /etc/init.d/bacula-sd %{buildroot}/sbin/rcbacula-sd 
install -m755 platforms/suse/bacula-dir %{buildroot}/etc/init.d
ln -s /etc/init.d/bacula-dir %{buildroot}/sbin/rcbacula-dir 

# logrotate
install -m644 scripts/logrotate $RPM_BUILD_ROOT/etc/logrotate.d/bacula


### STRIP executables and libraries

for file in $RPM_BUILD_ROOT%{_sbindir}/* $RPM_BUILD_ROOT/%{_libdir}/bacula
do
    if [ -e $file ]; then
        MIMETYPE=`file $file | cut -d' ' -f2`
        if [ "X$MIMETYPE" == "Xapplication/x-executable" ]; then
            strip $file
        fi
    fi
done

### COMPRESS manpages

for file in $RPM_BUILD_ROOT%{_mandir}/man1/*.1 $RPM_BUILD_ROOT%{_mandir}/man1/*.8
do
    if [ -e $file ]; then
        gzip $file
    fi
done


####################################################################################################
# PRE/POST/PREUN/POSTUN SCRIPTS
####################################################################################################

%preun libs
usr_list=`printf %{dd_usr}\n%{sd_usr}\n%{fd_usr}\n | sort -u`
echo -n " Users:" 
for usr in $usr_list
do
   echo -n " $usr"
done
echo " were not removed from the system. You have to delete them manually if you care about it."

grp_list=`printf %{dd_grp}\n%{sd_grp}\n%{fd_grp}\n | sort -u`
echo -n "Groups:" 
for grp in $grp_list
do
   echo -n " $grp"
done
echo " were not removed from the system. You have to delete them manually if you care about it."

exit 0


%pre libs
for grp in %{dd_grp} %{sd_grp} %{fd_grp}
do
    if [ "X$grp" != "Xroot" -a "X$grp" != "X" ]; then
        HAVE_BACULA=`getent group $grp`
        if [ -z "$HAVE_BACULA" ]; then
            /usr/sbin/groupadd -r $grp > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                echo "The group $grp has been added."
                echo "See the manual chapter \"Running Bacula\" for details."
            else
                echo "Problems creating group $grp."
                exit 1
            fi
        fi
    fi
done

# Note: all users are member of Director Daemon Group (dd_grp).
# user dd_usr (Director)
usr=%{dd_usr}
grp=%{dd_grp}
if [ "X$usr" != "Xroot" -a "X$usr" != "X" ]; then
    /usr/sbin/useradd -r -c "Bacula" -d %{working_dir} -g ${grp} -M -s /sbin/nologin ${usr} > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "The user ${usr} has been added."
        echo "See the manual chapter \"Running Bacula\" for details."
    else
        echo "Problems creating user $usr."
        exit 1
    fi
fi

# user sd_usr (Storage)
usr=%{sd_usr}
grp=%{sd_grp}
if [ "X$usr" != "Xroot" -a "X$usr" != "X" ]; then
    /usr/sbin/useradd -r -c "Bacula" -d %{working_dir} -g ${grp} -G %{dd_grp} -M -s /sbin/nologin ${usr} > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "The user ${usr} has been added."
        echo "See the manual chapter \"Running Bacula\" for details."
    else
        echo "Problems creating user $grp."
        exit 1
    fi
fi

# user fd_usr (File)
usr=%{fd_usr}
grp=%{fd_grp}
if [ "X$usr" != "Xroot" -a "X$usr" != "X" ]; then
    /usr/sbin/useradd -r -c "Bacula" -d %{working_dir} -g ${grp} -G %{dd_grp} -M -s /sbin/nologin ${usr} > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "The user ${usr} has been added."
        echo "See the manual chapter \"Running Bacula\" for details."
    else
        echo "Problems creating user $grp."
        exit 1
    fi
fi
exit 0

%post libs
/sbin/ldconfig
exit 0

%postun libs
/sbin/ldconfig
exit 0

# trigger for file daemon
%post fd
/sbin/chkconfig --add bacula-fd

file=%{sysconfdir}/bacula/bacula-fd.conf
for string in XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX 
do
    need_password=`grep $string $file 2>/dev/null`
    if [ -n "$need_password" ]; then
        pass=`openssl rand -base64 33`
        sed "s-$string-$pass-g" $file > $file.new
        cp -f $file.new $file; rm -f $file.new
    fi
done
exit 0

%preun fd
if [ "$1" = 0 ]; then
    /sbin/bacula-fd stop > /dev/null 2>&1
    /sbin/chkconfig --del bacula-fd
fi
exit 0



# trigger for DB dependent libraries
%pre libs-%{db_be}
%if %{mysql}
# test for bacula database older than version 10
# 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`
%endif
%if %{postgresql}
DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
%endif
%if %{sqlite3}
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 [ -n "$DB_VER" ] && [ "$DB_VER" -lt "10" ]; then
    echo "This bacula upgrade will update a bacula database from version 10 to 11."
    echo "You appear to be running database version $DB_VER. You must first update"
    echo "your database to version 10 and then install this upgrade. The alternative"
    echo "is to use %{script_dir}/drop_%{db_backend}_tables to delete all your your current"
    echo "catalog information, then do the upgrade. Information on updating a"
    echo "database older than version 10 can be found in the release notes."
    exit 1
fi
exit 0

%post libs-%{db_be}
DB_VER=""
%if %{mysql}
# test for bacula database older than version 10
# 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`
DB_BACKUP_CMD="mysqldump -f --opt bacula"
%endif
%if %{postgresql}
DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
DB_BACKUP_CMD="pgdump bacula"
%endif
%if %{sqlite3}
if [ -s %{working_dir}/bacula.db ]; then
    DB_VER=`echo "select * from Version;" | sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
    DB_BACKUP_CMD="echo '.dump' | sqlite3 %{working_dir}/bacula.db"
fi
%endif

# grant privileges and create tables if they do not exist ... 
# sequence for creation depends apparently on db_type. 
# That's why I had to put all those nasty %ifs ....

if [ -z "$DB_VER" ]; then
        echo "Hmm, doesn't look like you have an existing database."
%if %{db_be} == "MySQL"
        echo "Granting privileges for %{db_be} to user bacula..."
        %{script_dir}/grant_%{db_backend}_privileges
%endif
        echo "Creating %{db_be} bacula database..."
        %{script_dir}/create_%{db_backend}_database
%if %{db_be} == "Sqlite3"
        chown %{dd_usr}.%{dd_grp} %{working_dir}/bacula.db
%endif
        echo "Creating %{db_be} bacula tables..."
        %{script_dir}/make_%{db_backend}_tables
%if %{db_be} == "PostgreSQL"
        echo "Granting privileges for %{db_be} to user bacula..."
        %{script_dir}/grant_%{db_backend}_privileges
%endif

# check to see if we need to upgrade a 2.x database
elif [ "$DB_VER" -lt "11" ]; then
        echo "This release requires an upgrade to your bacula database."
        echo "Backing up your current database..."
        $DB_BACKUP_CMD | bzip2 > %{working_dir}/bacula_backup.sql.bz2
        echo "Upgrading bacula database ..."
        %{script_dir}/update_%{db_backend}_tables
        echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
fi

/sbin/ldconfig
exit 0

%postun libs-%{db_be}
/sbin/ldconfig
exit 0

# trigger for director
%post dir-%{db_be}
/sbin/chkconfig --add bacula-dir

file=%{sysconfdir}/bacula/bacula-dir.conf
for string in XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX 
do
    need_password=`grep $string $file 2>/dev/null`
    if [ -n "$need_password" ]; then
        pass=`openssl rand -base64 33`
        sed "s-$string-$pass-g" $file > $file.new
        cp -f $file.new $file; rm -f $file.new
    fi
done
exit 0

%preun dir-%{db_be}
if [ "$1" = 0 ]; then
    /sbin/rcbacula-dir stop > /dev/null 2>&1
    /sbin/chkconfig --del bacula-dir
fi
exit 0

# trigger for storage daemon
%post sd-%{db_be}
/sbin/chkconfig --add bacula-sd

file=%{sysconfdir}/bacula/bacula-sd.conf
for string in XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX 
do
    need_password=`grep $string $file 2>/dev/null`
    if [ -n "$need_password" ]; then
        pass=`openssl rand -base64 33`
        sed "s-$string-$pass-g" $file > $file.new
        cp -f $file.new $file; rm -f $file.new
    fi
done
exit 0

%preun sd-%{db_be}
if [ $1 = 0 ]; then
    /sbin/rcbacula-sd stop > /dev/null 2>&1
    /sbin/chkconfig --del bacula-sd
fi
exit 0


####################################################################################################
# CLEAN
####################################################################################################

%clean
rm -rf %buildroot


####################################################################################################
# FILES
####################################################################################################

%files libs
%defattr(-,root,root)
%{scriptdir}/btraceback.gdb
%{scriptdir}/btraceback.dbx
%{_libdir}/bacula/libbac.so.1
%{_libdir}/bacula/libbac.so.1.0.0
%{_libdir}/bacula/libbaccfg.so.1
%{_libdir}/bacula/libbaccfg.so.1.0.0
%{_libdir}/bacula/libbacpy.so.1
%{_libdir}/bacula/libbacpy.so.1.0.0
%{_libdir}/bacula/libbacfind.so.1
%{_libdir}/bacula/libbacfind.so.1.0.0
%{_libdir}/bacula/plugins/bpipe-fd.so
/usr/sbin/btraceback
%doc /usr/share/man/man8/bacula.8.gz
%doc /usr/share/man/man8/btraceback.8.gz
%doc /usr/share/doc/packages/bacula/VERIFYING
%doc /usr/share/doc/packages/bacula/technotes
%doc /usr/share/doc/packages/bacula/ChangeLog
%doc /usr/share/doc/packages/bacula/README
%doc /usr/share/doc/packages/bacula/ReleaseNotes
%doc /usr/share/doc/packages/bacula/LICENSE
%doc /usr/share/doc/packages/bacula/INSTALL
%attr(770,%{dd_usr},%{dd_grp}) %dir %{working_dir}
%attr(770,%{dd_usr},%{dd_grp}) %dir %{_localstatedir}/run/bacula

%files fd
%defattr(-,root,root)
%attr(-,root,%{fd_grp}) %config(noreplace) /etc/bacula/bacula-fd.conf
%attr(-,root,%{fd_grp}) /etc/init.d/bacula-fd
%attr(-,root,%{fd_grp}) /usr/sbin/bacula-fd
/sbin/rcbacula-fd
/usr/share/man/man8/bacula-fd.8.gz

%files bconsole
%defattr(-,root,root)
%attr(-,root,%{fd_grp}) %config(noreplace) /etc/bacula/bconsole.conf
%{scriptdir}/bconsole
%attr(-,root,%{fd_grp}) /usr/sbin/bconsole
%doc /usr/share/man/man8/bconsole.8.gz

%files bat
%defattr(-,root,root)
%attr(-,root,%{fd_grp}) %config(noreplace) /etc/bacula/bat.conf
%attr(-,root,%{fd_grp}) /usr/sbin/bat
%doc /usr/share/man/man1/bat.1.gz
%doc %{_docdir}/bacula-bat/html
/usr/share/pixmaps/bat.png
/usr/share/applications/bat.desktop

%files bgnome-console
%defattr(-,root,root)
%attr(-,root,%{fd_grp}) %config(noreplace) /etc/bacula/bgnome-console.conf
%attr(644,root,%{fd_grp}) %config(noreplace) /etc/bacula/tray-monitor.conf
%attr(-,root,%{fd_grp}) /usr/sbin/bgnome-console
%attr(755,root,%{fd_grp}) /usr/sbin/bacula-tray-monitor
%doc /usr/share/man/man1/bgnome-console.1.gz
%doc /usr/share/man/man1/bacula-tray-monitor.1.gz
/usr/share/pixmaps/bgnome-console.png
/usr/share/pixmaps/bacula-tray-monitor.xpm
/usr/share/applications/bacula-tray-monitor.desktop
/usr/share/applications/bgnome-console.desktop

%files bwx-console
%defattr(-,root,root)
%config(noreplace) /etc/bacula/bwx-console.conf
%attr(-,root,%{fd_grp}) /usr/sbin/bwx-console
%doc /usr/share/man/man1/bwx-console.1.gz
/usr/share/pixmaps/bwx-console.xpm
/usr/share/applications/bwx-console.desktop

%files mtx
%defattr(-,root,root)
%attr(-,root,%{sd_grp}) %config(noreplace) /etc/bacula/mtx-changer.conf
%attr(-,root,%{sd_grp}) /usr/sbin/mtx-changer
%attr(-,root,%{sd_grp}) /usr/sbin/mtx
%attr(-,root,%{sd_grp}) /usr/sbin/scsieject
%attr(-,root,%{sd_grp}) /usr/sbin/scsitape
%attr(-,root,%{sd_grp}) /usr/sbin/loaderinfo
%attr(-,root,%{sd_grp}) /usr/sbin/tapeinfo
%doc /usr/share/man/man1/mtx.1.gz
%doc /usr/share/man/man1/tapeinfo.1.gz
%doc /usr/share/man/man1/scsitape.1.gz
%doc /usr/share/man/man1/scsieject.1.gz
%doc /usr/share/man/man1/loaderinfo.1.gz


%files libs-%{db_be}
%defattr(-,root,root)
%{_libdir}/bacula/libbacsql.so.1
%{_libdir}/bacula/libbacsql.so.1.0.0

%files sd-%{db_be}
%defattr(-,root,root)
%attr(-,root,%{sd_grp}) %config(noreplace) /etc/bacula/bacula-sd.conf
%attr(-,root,%{sd_grp}) /etc/init.d/bacula-sd
/sbin/rcbacula-sd
%attr(-,root,%{sd_grp}) /usr/sbin/bacula-sd
%attr(-,root,%{sd_grp}) /usr/sbin/bcopy
%attr(-,root,%{sd_grp}) /usr/sbin/bextract
%attr(-,root,%{sd_grp}) /usr/sbin/bls
%attr(-,root,%{sd_grp}) /usr/sbin/bscan
%attr(-,root,%{sd_grp}) /usr/sbin/btape
%doc /usr/share/man/man8/bacula-sd.8.gz
%doc /usr/share/man/man8/bcopy.8.gz
%doc /usr/share/man/man8/bextract.8.gz
%doc /usr/share/man/man8/bls.8.gz
%doc /usr/share/man/man8/bscan.8.gz
%doc /usr/share/man/man8/btape.8.gz
%attr(-,root,%{sd_grp}) %{scriptdir}/disk-changer
%attr(-,root,%{sd_grp}) %{scriptdir}/dvd-handler

%files utils-%{db_be}
%defattr(-,root,root)
%{scriptdir}/create*
%{scriptdir}/update*
%{scriptdir}/make*
%{scriptdir}/drop*
%{scriptdir}/grant*
%{scriptdir}/delete*

%files dir-%{db_be}
%defattr(-,root,root)
%attr(-,root,%{dd_grp}) %config(noreplace) /etc/bacula/bacula-dir.conf
%{scriptdir}/query.sql
%attr(-,root,%{dd_grp}) /etc/init.d/bacula-dir
/etc/logrotate.d/bacula
/sbin/rcbacula-dir
%attr(-,root,%{dd_grp}) /usr/sbin/bacula-dir
%attr(-,root,%{dd_grp}) /usr/sbin/dbcheck
%attr(-,root,%{dd_grp}) /usr/sbin/bwild
%attr(-,root,%{dd_grp}) /usr/sbin/bregex
/usr/sbin/bsmtp
%doc /usr/share/man/man1/bsmtp.1.gz
%doc /usr/share/man/man8/bacula-dir.8.gz
%doc /usr/share/man/man8/dbcheck.8.gz

####################################################################################################
# CHANGELOG
####################################################################################################

%changelog
* Wed Aug 19 2009 Luca.Bolcioni@yacme.com
- triggers were largely inspired and copied from Kern Sibbald / Scott Barninger 
- original SPEC file which has been reduced to be compiled on SLES targets only.
* Wed Aug 12 2009 Luca.Bolcioni@yacme.com
- revised and updated to be split in basic packages
* Mon Jun 22 2009 Luca.Bolcioni@yacme.com
- packaged bacula version 3.0.1 using the buildservice spec file wizard