Blob Blame History Raw
%global uid 133
%global username bacula

Name:                   bacula
Version:                5.0.3
Release:                35%{?dist}
Summary:                Cross platform network backup for Linux, Unix, Mac and Windows
# See LICENSE for details
License:                AGPLv3 with exceptions
Group:                  System Environment/Daemons
URL:                    http://www.bacula.org
BuildRoot:              %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

Source0:                http://download.sourceforge.net/bacula/bacula-%{version}.tar.gz
Source2:                bacula.logrotate
Source3:                bacula-checkconf
Source4:                bacula-fd.init
Source5:                bacula-dir.init
Source6:                bacula-sd.init
Source7:                bacula-fd.service
Source8:                bacula-dir.service
Source9:                bacula-sd.service
Source10:               bacula-wxconsole.desktop
Source11:               bacula-traymonitor.desktop
Source12:               bacula-bat.desktop
Source13:               bacula-traymonitor.console_apps
Source14:               bacula-wxconsole.console_apps
Source15:               bacula-fd.sysconfig
Source16:               bacula-dir.sysconfig
Source17:               bacula-sd.sysconfig
Source18:               bacula-sd.sysconfig.el5

Patch1:                 bacula-5.0.3-config.patch
Patch2:                 bacula-5.0.3-nagios-ent-fd.patch
Patch3:                 bacula-5.0.3-pamd.patch
Patch4:                 bacula-5.0.2-openssl.patch
Patch5:                 bacula-5.0.3-queryfile.patch
Patch6:                 bacula-5.0.2-python27.patch
Patch7:                 bacula-5.0.3-log-path.patch
Patch8:                 bacula-5.0.3-sqlite-priv.patch
Patch9:                 bacula-5.0.3-tray-dir.patch
Patch10:                bacula-5.0.3-mysql55.patch
Patch11:                bacula-5.0.3-maxvalue.patch
Patch12:                bacula-5.0.3-acl.patch

BuildRequires:          atk-devel
BuildRequires:          bonobo-activation-devel
BuildRequires:          desktop-file-utils
BuildRequires:          GConf2-devel
BuildRequires:          glibc-devel
BuildRequires:          gtk2-devel
BuildRequires:          libacl-devel
BuildRequires:          libbonobo-devel
BuildRequires:          libbonoboui-devel
BuildRequires:          libcap-devel
BuildRequires:          libgnomeui-devel
BuildRequires:          libstdc++-devel
BuildRequires:          libxml2-devel
BuildRequires:          lzo-devel
BuildRequires:          mysql-devel
BuildRequires:          ncurses-devel
BuildRequires:          openssl-devel
BuildRequires:          ORBit2-devel
BuildRequires:          pango-devel
BuildRequires:          perl
BuildRequires:          pkgconfig
BuildRequires:          postgresql-devel
BuildRequires:          python-devel
BuildRequires:          readline-devel
BuildRequires:          sed
BuildRequires:          sqlite-devel
BuildRequires:          zlib-devel

%if ! 0%{?rhel}
BuildRequires:          wxGTK-devel
%endif

%if 0%{?fedora} || 0%{?rhel} >= 6
BuildRequires:          qt4-devel >= 4.6.2
BuildRequires:          tcp_wrappers-devel
%else
BuildRequires:          tcp_wrappers
%endif

%if 0%{?fedora} || 0%{?rhel} > 6
BuildRequires:          systemd-units
%endif


%description
Bacula is a set of programs that allow you to manage the backup,
recovery, and verification of computer data across a network of
different computers. It is based on a client/server architecture and is
efficient and relatively easy to use, while offering many advanced
storage management features that make it easy to find and recover lost
or damaged files.


%package libs
Summary:                Bacula libraries
Group:                  System Environment/Daemons

%description libs
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains basic Bacula libraries, which are used by all Bacula
programs.


%package libs-mysql
Summary:                Bacula libraries
Group:                  System Environment/Daemons

%description libs-mysql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains basic Bacula libraries, which are used by all Bacula
programs. These libraries support MySQL databases.


%package libs-sqlite
Summary:                Bacula libraries
Group:                  System Environment/Daemons

%description libs-sqlite
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains basic Bacula libraries, which are used by all Bacula
programs. These libraries support SQLite databases.


%package libs-postgresql
Summary:                Bacula libraries
Group:                  System Environment/Daemons

%description libs-postgresql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains basic Bacula libraries, which are used by all Bacula
programs. These libraries support PostgreSQL databases.


%package director-mysql
Summary:                Bacula Director with MySQL database support
Group:                  System Environment/Daemons
Provides:               bacula-director = %{version}-%{release}
Requires:               bacula-director-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-mysql = %{version}-%{release}

%description director-mysql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the bacula director, the server which controls your
backup run. This director has support for the MySQL database.


%package director-sqlite
Summary:                Bacula Director with SQLite database support
Group:                  System Environment/Daemons
Provides:               bacula-director = %{version}-%{release}
Requires:               bacula-director-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-sqlite = %{version}-%{release}

%description director-sqlite
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the bacula director, the server which controls your
backup run. This director has support for the SQLite database.


%package director-postgresql
Summary:                Bacula Director with PostgresSQL database support
Group:                  System Environment/Daemons
Provides:               bacula-director = %{version}-%{release}
Requires:               bacula-director-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-postgresql = %{version}-%{release}

%description director-postgresql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the bacula director, the server which controls your
backup run. This director has support for the PostgresSQL database.


%package director-common
Summary:                Common Bacula Director files
Group:                  System Environment/Daemons
Requires:               bacula-director = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               logwatch
Requires(pre):          shadow-utils
Requires(postun):       shadow-utils
%if 0%{?fedora} || 0%{?rhel} > 6
Requires(post):         systemd-sysv
Requires(post):         systemd-units
Requires(preun):        systemd-units
Requires(postun):       systemd-units
%else
Requires(post):         /sbin/chkconfig
Requires(preun):        /sbin/chkconfig
Requires(preun):        /sbin/service
Requires(postun):       /sbin/service
%endif

%description director-common
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the common director files, which are shared between all
database backends. You have to select a possible database backend though, which
provides the needed bacula-director dependency. Please choose from
bacula-director-mysql, bacula-director-sqlite or bacula-director-postgresql.


%package client
Summary:                Bacula backup client
Group:                  System Environment/Daemons
Requires:               bacula-common = %{version}-%{release}
%if 0%{?fedora} || 0%{?rhel} > 6
Requires(post):         systemd-sysv
Requires(post):         systemd-units
Requires(preun):        systemd-units
Requires(postun):       systemd-units
%else
Requires(post):         /sbin/chkconfig
Requires(preun):        /sbin/chkconfig
Requires(preun):        /sbin/service
Requires(postun):       /sbin/service
%endif

%description client
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the bacula client, the daemon running on the system to be
backed up.


%package storage-common
Summary:                Common Bacula storage daemon files
Group:                  System Environment/Daemons
Requires:               bacula-storage = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
%if 0%{?fedora} || 0%{?rhel} > 6
Requires(post):         systemd-sysv
Requires(post):         systemd-units
Requires(preun):        systemd-units
Requires(postun):       systemd-units
%else
Requires(post):         /sbin/chkconfig
Requires(preun):        /sbin/chkconfig
Requires(preun):        /sbin/service
Requires(postun):       /sbin/service
%endif

%description storage-common
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the storage daemon, the daemon responsible for writing
the data received from the clients onto tape drives or other mass storage
devices.


%package storage-mysql
Summary:                MySQL Bacula storage daemon files
Group:                  System Environment/Daemons
Provides:               bacula-storage = %{version}-%{release}
Requires:               bacula-storage-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-mysql = %{version}-%{release}

%description storage-mysql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the storage daemon, the daemon responsible for writing
the data received from the clients onto tape drives or other mass storage
devices. This storage daemon has support for the MySQL database.


%package storage-sqlite
Summary:                SQLite Bacula storage daemon files
Group:                  System Environment/Daemons
Provides:               bacula-storage = %{version}-%{release}
Requires:               bacula-storage-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-sqlite = %{version}-%{release}

%description storage-sqlite
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the storage daemon, the daemon responsible for writing
the data received from the clients onto tape drives or other mass storage
devices. This storage daemon has support for the SQLite database.


%package storage-postgresql
Summary:                Common Bacula storage daemon files
Group:                  System Environment/Daemons
Provides:               bacula-storage = %{version}-%{release}
Requires:               bacula-storage-common = %{version}-%{release}
Requires:               bacula-common = %{version}-%{release}
Requires:               bacula-libs-postgresql = %{version}-%{release}

%description storage-postgresql
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the storage daemon, the daemon responsible for writing
the data received from the clients onto tape drives or other mass storage
devices. This storage daemon has support for the PostgreSQL database.


%package common
Summary:                Common Bacula utilities
Group:                  System Environment/Daemons
Obsoletes:              bacula-console-gnome <= 3.0.3

%description common
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains common files to all bacula related components.


%package console
Summary:                Bacula management console
Group:                  System Environment/Daemons
Requires:               bacula-common = %{version}-%{release}

%description console
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the command-line management console for the bacula backup
system.


%if 0%{?fedora} || 0%{?rhel} >= 6

%package console-bat
Summary:                Bacula bat console
Group:                  System Environment/Daemons
Requires:               bacula-common = %{version}-%{release}
Requires:               usermode

%description console-bat
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the bat version of the bacula management console.

%endif


%package console-wxwidgets
Summary:                Bacula console using the wx widgets toolkit
Group:                  System Environment/Daemons
Requires:               bacula-common = %{version}-%{release}
Requires:               usermode

%description console-wxwidgets
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the wxWidgets version of the bacula management console.


%package traymonitor
Summary:                Bacula monitor for the Gnome and KDE system tray
Group:                  System Environment/Daemons
Requires:               bacula-common = %{version}-%{release}

%description traymonitor
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This package contains the Gnome- and KDE-compatible tray monitor to monitor
your bacula server.


%package devel
Summary:                Bacula development files
Group:                  Development/Libraries

%description devel
Bacula is a set of programs that allow you to manage the backup, recovery, and
verification of computer data across a network of different computers. It is
based on a client/server architecture.

This development package contains static libraries and header files.


%package -n nagios-plugins-bacula
Summary:                Nagios Plugin - check_bacula
Group:                  Applications/System

%description -n nagios-plugins-bacula
Provides check_bacula support for Nagios.


%prep
%setup -q -c -n bacula-%{version}

pushd bacula-%{version}
%patch1 -p1 -b .config
%patch2 -p1 -b .nagios-ent-fd
%patch3 -p1 -b .pamd
%patch4 -p2 -b .openssl
%patch5 -p1 -b .queryfile
%patch6 -p0 -b .python27
%patch7 -p1 -b .log-path
%patch8 -p0 -b .priv
%patch9 -p2 -b .tray-dir
%patch10 -p0 -b .mysql55
%patch11 -p1 -b .maxvalue
%patch12 -p2 -b .acl

# Remove execution permissions from files we're packaging as docs later on
find updatedb -type f | xargs chmod -x
popd

# Remove cvs left-overs
find -name '.cvsignore' | xargs rm -f 

# Fix perms of c files to silent rpmlint
find -type f -name '*.c' | xargs chmod -x 
find -type f -name '*.h' | xargs chmod -x 

# We are building the source several times, each with a different storage backend
# and all the common files separated so we can also reduce compilation time
# and build graphical consoles where allowed.
mkdir bacula-mysql bacula-postgresql bacula-sqlite bacula-base

%build
# Shell function to configure and build a Bacula tree
build() {
cp -rl ../bacula-%{version}/* .
export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/ncurses"
export CPPFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/ncurses"
%configure \
        --sysconfdir=%{_sysconfdir}/bacula \
        --with-dir-password=@@DIR_PASSWORD@@ \
        --with-fd-password=@@FD_PASSWORD@@ \
        --with-sd-password=@@SD_PASSWORD@@ \
        --with-mon-dir-password=@@MON_DIR_PASSWORD@@ \
        --with-mon-fd-password=@@MON_FD_PASSWORD@@ \
        --with-mon-sd-password=@@MON_SD_PASSWORD@@ \
        --with-working-dir=%{_localstatedir}/spool/bacula \
        --with-logdir=%{_localstatedir}/log/bacula \
        --with-scriptdir=%{_libexecdir}/bacula \
        --with-smtp-host=localhost \
        --with-subsys-dir=%{_localstatedir}/lock/subsys \
        --with-pid-dir=%{_localstatedir}/run \
        --with-plugindir=%{_libdir}/bacula \
        --disable-conio \
        --enable-readline \
        --enable-largefile \
        --with-openssl \
        --with-tcp-wrappers \
        --with-python \
        --enable-smartalloc \
        --with-x \
        $*

if test $? != 0; then 
  tail -500 config.log
  : configure failed
  exit 1
fi

# Remove RPATH
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

%{__make} %{?_smp_mflags} NO_ECHO=

}                               

# Regen bat QT project file and build tools
pushd bacula-base
        %if 0%{?fedora} || 0%{?rhel} >= 6
        export QMAKE=/usr/bin/qmake-qt4
        build \
                --enable-bat \
                --htmldir=%{_datadir}/doc/bacula-console-bat-%{version} \
        %if ! 0%{?rhel}
                --enable-bwx-console \
        %endif
                --enable-tray-monitor \
                --enable-client-only
        pushd src/qt-console
                /usr/bin/qmake-qt4
                make
        popd
        %else
        build \
                --disable-bat \
                --enable-bwx-console \
                --enable-tray-monitor \
                --enable-client-only
        %endif
        pushd examples/nagios/check_bacula
                CFLAGS="%{optflags}" %{__make} LIBS="-lpthread -ldl -lssl -lcrypto -lz"
        popd
popd

# Build sqlite director
pushd bacula-sqlite
        build \
                --disable-bat \
                --disable-bwx-console \
                --disable-tray-monitor \
                --enable-build-stored \
                --enable-build-dird \
                --enable-batch-insert \
                --with-sqlite3
popd

# Build MySQL director
pushd bacula-mysql
        build \
                --disable-bat \
                --disable-bwx-console \
                --disable-tray-monitor \
                --enable-build-stored \
                --enable-build-dird \
                --enable-batch-insert \
                --with-mysql
popd

# Build PostgreSQL director
pushd bacula-postgresql
        build \
                --disable-bat \
                --disable-bwx-console \
                --disable-tray-monitor \
                --enable-build-stored \
                --enable-build-dird \
                --enable-batch-insert \
                --with-postgresql
popd


%install
rm -rf %{buildroot}

pushd bacula-base
        make install DESTDIR=%{buildroot}

        # install the nagios plugin
        %{__mkdir_p} %{buildroot}%{_libdir}/nagios/plugins
        %{__install} -m0755 examples/nagios/check_bacula/.libs/check_bacula %{buildroot}%{_libdir}/nagios/plugins/

        # Desktop Integration
        mkdir -p %{buildroot}%{_bindir}

        %if ! 0%{?rhel}
        # bwxconsole
        install -m 644 -D src/wx-console/wxwin16x16.xpm %{buildroot}%{_datadir}/pixmaps/wxwin16x16.xpm
        install -m 644 -D scripts/wxconsole.pamd %{buildroot}%{_sysconfdir}/pam.d/bwxconsole
        install -m 644 -D %{SOURCE14} %{buildroot}%{_sysconfdir}/security/console.apps/bwxconsole
        ln -sf consolehelper %{buildroot}%{_bindir}/bwxconsole
        desktop-file-install --vendor="fedora" --dir=%{buildroot}%{_datadir}/applications %{SOURCE10}
        %endif

        install -m 644 -D src/tray-monitor/generic.xpm %{buildroot}%{_datadir}/pixmaps/bacula-tray-monitor.xpm
        install -m 644 -D scripts/bgnome-console.pamd %{buildroot}%{_sysconfdir}/pam.d/bacula-tray-monitor
        install -m 644 -D %{SOURCE13} %{buildroot}%{_sysconfdir}/security/console.apps/bacula-tray-monitor
        ln -sf consolehelper %{buildroot}%{_bindir}/bacula-tray-monitor
        desktop-file-install --vendor="fedora" --dir=%{buildroot}%{_datadir}/applications %{SOURCE11}

        %if 0%{?fedora} || 0%{?rhel} >= 6
        install -m 644 -D src/qt-console/images/bat_icon.png %{buildroot}%{_datadir}/pixmaps/bat_icon.png
        install -m 644 -D scripts/bgnome-console.pamd %{buildroot}%{_sysconfdir}/pam.d/bat
        install -m 644 -D scripts/bat.console_apps %{buildroot}%{_sysconfdir}/security/console.apps/bat
        ln -sf consolehelper %{buildroot}%{_bindir}/bat
        desktop-file-install --vendor="fedora" --dir=%{buildroot}%{_datadir}/applications %{SOURCE12}
        install -m 755 -D src/qt-console/.libs/bat %{buildroot}%{_sbindir}
        install -m 644 -D src/qt-console/bat.conf %{buildroot}%{_sysconfdir}/bacula/bat.conf
        install -m 644 -D scripts/bacula.png %{buildroot}%{_datadir}/pixmaps/bacula.png
        %endif
popd

pushd bacula-sqlite
        make install DESTDIR=%{buildroot}
        mv %{buildroot}%{_sbindir}/bacula-dir  %{buildroot}%{_sbindir}/bacula-dir.sqlite
        mv %{buildroot}%{_sbindir}/dbcheck  %{buildroot}%{_sbindir}/dbcheck.sqlite
        mv %{buildroot}%{_sbindir}/bcopy  %{buildroot}%{_sbindir}/bcopy.sqlite
        mv %{buildroot}%{_sbindir}/bscan  %{buildroot}%{_sbindir}/bscan.sqlite
        mv %{buildroot}%{_sbindir}/btape  %{buildroot}%{_sbindir}/btape.sqlite
        mv %{buildroot}%{_libdir}/libbacsql-%{version}.so %{buildroot}%{_libdir}/libbacsql-%{version}.so.sqlite
        rm -f %{buildroot}%{_libdir}/libbacsql.so

        for script in create_bacula_database drop_bacula_database drop_bacula_tables \
                        grant_bacula_privileges make_bacula_tables make_catalog_backup \
                        update_bacula_tables bacula_config; do
                mv %{buildroot}%{_libexecdir}/bacula/${script} %{buildroot}%{_libexecdir}/bacula/${script}.sqlite
        done
popd

pushd bacula-mysql
        make install DESTDIR=%{buildroot}
        mv %{buildroot}%{_sbindir}/bacula-dir  %{buildroot}%{_sbindir}/bacula-dir.mysql
        mv %{buildroot}%{_sbindir}/dbcheck  %{buildroot}%{_sbindir}/dbcheck.mysql
        mv %{buildroot}%{_sbindir}/bcopy  %{buildroot}%{_sbindir}/bcopy.mysql
        mv %{buildroot}%{_sbindir}/bscan  %{buildroot}%{_sbindir}/bscan.mysql
        mv %{buildroot}%{_sbindir}/btape  %{buildroot}%{_sbindir}/btape.mysql
        mv %{buildroot}%{_libdir}/libbacsql-%{version}.so %{buildroot}%{_libdir}/libbacsql-%{version}.so.mysql
        rm -f %{buildroot}%{_libdir}/libbacsql.so

        for script in create_bacula_database drop_bacula_database drop_bacula_tables \
                        grant_bacula_privileges make_bacula_tables make_catalog_backup \
                        update_bacula_tables bacula_config; do
                mv %{buildroot}%{_libexecdir}/bacula/${script} %{buildroot}%{_libexecdir}/bacula/${script}.mysql
        done
popd

pushd bacula-postgresql
        make install DESTDIR=%{buildroot}
        mv %{buildroot}%{_sbindir}/bacula-dir  %{buildroot}%{_sbindir}/bacula-dir.postgresql
        mv %{buildroot}%{_sbindir}/dbcheck  %{buildroot}%{_sbindir}/dbcheck.postgresql
        mv %{buildroot}%{_sbindir}/bcopy  %{buildroot}%{_sbindir}/bcopy.postgresql
        mv %{buildroot}%{_sbindir}/bscan  %{buildroot}%{_sbindir}/bscan.postgresql
        mv %{buildroot}%{_sbindir}/btape  %{buildroot}%{_sbindir}/btape.postgresql
        mv %{buildroot}%{_libdir}/libbacsql-%{version}.so %{buildroot}%{_libdir}/libbacsql-%{version}.so.postgresql
        rm -f %{buildroot}%{_libdir}/libbacsql.so

        for script in create_bacula_database drop_bacula_database drop_bacula_tables \
                        grant_bacula_privileges make_bacula_tables make_catalog_backup \
                        update_bacula_tables bacula_config; do
                mv %{buildroot}%{_libexecdir}/bacula/${script} %{buildroot}%{_libexecdir}/bacula/${script}.postgresql
        done
popd

# Fix some wrapper braindeadness
rm -f %{buildroot}%{_libexecdir}/bacula/bconsole
rm -f %{buildroot}%{_libexecdir}/bacula/gconsole
%if ! 0%{?rhel}
mv %{buildroot}%{_sbindir}/bwx-console %{buildroot}%{_sbindir}/bwxconsole
mv %{buildroot}%{_sysconfdir}/bacula/bwx-console.conf %{buildroot}%{_sysconfdir}/bacula/bwxconsole.conf
%else
rm -f %{buildroot}%{_mandir}/man1/bacula-bwxconsole*
%endif

# logrotate
mkdir -p %{buildroot}%{_localstatedir}/log/bacula
install -m 644 -D %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/bacula

# And logwatch
install -m 755 -D bacula-base/scripts/logwatch/bacula %{buildroot}%{_sysconfdir}/logwatch/scripts/services/bacula
install -m 755 -D bacula-base/scripts/logwatch/applybaculadate %{buildroot}%{_sysconfdir}/logwatch/scripts/shared/applybaculadate
install -m 644 -D bacula-base/scripts/logwatch/logfile.bacula.conf %{buildroot}%{_sysconfdir}/logwatch/conf/logfiles/bacula.conf
install -m 644 -D bacula-base/scripts/logwatch/services.bacula.conf %{buildroot}%{_sysconfdir}/logwatch/conf/services/bacula.conf

install -m 755 -D %{SOURCE3} %{buildroot}%{_sbindir}/bacula-checkconf
%if 0%{?fedora} || 0%{?rhel} > 6
# Systemd unit files
mkdir -p %{buildroot}%{_unitdir}
install -m 755 -D %{SOURCE7}  %{buildroot}%{_unitdir}/bacula-fd.service
install -m 755 -D %{SOURCE8}  %{buildroot}%{_unitdir}/bacula-dir.service
install -m 755 -D %{SOURCE9}  %{buildroot}%{_unitdir}/bacula-sd.service
%else
# Initscripts
install -m 755 -D %{SOURCE4}  %{buildroot}%{_initrddir}/bacula-fd
install -m 755 -D %{SOURCE5}  %{buildroot}%{_initrddir}/bacula-dir
install -m 755 -D %{SOURCE6}  %{buildroot}%{_initrddir}/bacula-sd
%endif

# Sysconfig
install -m 644 -D %{SOURCE15}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-fd
install -m 644 -D %{SOURCE16}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-dir
%if 0%{?fedora} || 0%{?rhel} >= 6
install -m 644 -D %{SOURCE17}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-sd
%else
install -p -m 644 -D %{SOURCE18} %{buildroot}%{_sysconfdir}/sysconfig/bacula-sd
%endif

# Wipe backup files from the multiple make install calls
rm -vf %{buildroot}%{_sysconfdir}/bacula/*.{new,old}
rm -vf %{buildroot}%{_libexecdir}/bacula/*.{new,old}

# Create the spooling
mkdir -p %{buildroot}%{_localstatedir}/spool/bacula

# Move some files around
mv %{buildroot}%{_libexecdir}/bacula/query.sql %{buildroot}%{_sysconfdir}/bacula/query.sql

# Nuke the scripts we do not need
rm -vf %{buildroot}%{_libexecdir}/bacula/{bacula,bacula-ctl-*,startmysql,stopmysql} 
rm -vf %{buildroot}%{_sbindir}/bacula

# Fix up some perms so rpmlint does not complain too much
chmod 755 %{buildroot}%{_sbindir}/*
chmod 755 %{buildroot}%{_libexecdir}/bacula/*
chmod 644 %{buildroot}%{_libexecdir}/bacula/btraceback.*

# Remove extra docs
rm -rf %{buildroot}%{_datadir}/doc/bacula/

# Remove bat man page if bat is not built (gets installed unconditionally from make install)
%if 0%{?rhel} == 5
rm -f %{buildroot}%{_mandir}/man1/bat.1*
%endif

# Install headers
%{__mkdir_p} %{buildroot}%{_includedir}/bacula
pushd %{name}-%{version}
        for dir in src src/cats src/console src/dird src/filed src/findlib src/lib src/plugins/sd src/stored; do
                %{__mkdir_p} %{buildroot}%{_includedir}/bacula/$dir
                %{__install} -m 644 $dir/*.h %{buildroot}%{_includedir}/bacula/$dir
        done
popd


%clean
rm -rf %{buildroot}


%post libs
/sbin/ldconfig

%post libs-mysql
/usr/sbin/alternatives --install %{_libdir}/libbacsql.so libbacsql %{_libdir}/libbacsql-%{version}.so.mysql 50 \
        --slave %{_libdir}/libbacsql-%{version}.so libbacsql-%{version}.so %{_libdir}/libbacsql-%{version}.so.mysql
/sbin/ldconfig

%post libs-sqlite
/usr/sbin/alternatives --install %{_libdir}/libbacsql.so libbacsql %{_libdir}/libbacsql-%{version}.so.sqlite 40 \
        --slave %{_libdir}/libbacsql-%{version}.so libbacsql-%{version}.so %{_libdir}/libbacsql-%{version}.so.sqlite
/sbin/ldconfig

%post libs-postgresql
/usr/sbin/alternatives --install %{_libdir}/libbacsql.so libbacsql %{_libdir}/libbacsql-%{version}.so.postgresql 60 \
        --slave %{_libdir}/libbacsql-%{version}.so libbacsql-%{version}.so %{_libdir}/libbacsql-%{version}.so.postgresql
/sbin/ldconfig

%postun libs
/sbin/ldconfig
exit 0

%preun libs-mysql
if [ "$1" = 0 ]; then
        alternatives --remove libbacsql %{_libdir}/libbacsql-%{version}.so.mysql
fi

%preun libs-sqlite
if [ "$1" = 0 ]; then
        alternatives --remove libbacsql %{_libdir}/libbacsql-%{version}.so.sqlite
fi

%preun libs-postgresql
if [ "$1" = 0 ]; then
        alternatives --remove libbacsql %{_libdir}/libbacsql-%{version}.so.postgresql
fi

%postun libs-mysql
/sbin/ldconfig
exit 0

%postun libs-sqlite
/sbin/ldconfig
exit 0

%postun libs-postgresql
/sbin/ldconfig
exit 0

%post director-mysql
/usr/sbin/alternatives --install /usr/sbin/bacula-dir bacula-dir /usr/sbin/bacula-dir.mysql 50 \
        --slave /usr/sbin/dbcheck bacula-dbcheck /usr/sbin/dbcheck.mysql \
        --slave /usr/libexec/bacula/create_bacula_database create_bacula_database /usr/libexec/bacula/create_bacula_database.mysql \
        --slave /usr/libexec/bacula/drop_bacula_database drop_bacula_database /usr/libexec/bacula/drop_bacula_database.mysql \
        --slave /usr/libexec/bacula/drop_bacula_tables drop_bacula_tables /usr/libexec/bacula/drop_bacula_tables.mysql \
        --slave /usr/libexec/bacula/grant_bacula_privileges grant_bacula_privileges /usr/libexec/bacula/grant_bacula_privileges.mysql \
        --slave /usr/libexec/bacula/make_bacula_tables make_bacula_tables /usr/libexec/bacula/make_bacula_tables.mysql \
        --slave /usr/libexec/bacula/make_catalog_backup make_catalog_backup /usr/libexec/bacula/make_catalog_backup.mysql \
        --slave /usr/libexec/bacula/update_bacula_tables update_bacula_tables /usr/libexec/bacula/update_bacula_tables.mysql \
        --slave /usr/libexec/bacula/bacula_config bacula_config /usr/libexec/bacula/bacula_config.mysql

%post director-sqlite
/usr/sbin/alternatives --install /usr/sbin/bacula-dir bacula-dir /usr/sbin/bacula-dir.sqlite 40 \
        --slave /usr/sbin/dbcheck bacula-dbcheck /usr/sbin/dbcheck.sqlite \
        --slave /usr/libexec/bacula/create_bacula_database create_bacula_database /usr/libexec/bacula/create_bacula_database.sqlite \
        --slave /usr/libexec/bacula/drop_bacula_database drop_bacula_database /usr/libexec/bacula/drop_bacula_database.sqlite \
        --slave /usr/libexec/bacula/drop_bacula_tables drop_bacula_tables /usr/libexec/bacula/drop_bacula_tables.sqlite \
        --slave /usr/libexec/bacula/grant_bacula_privileges grant_bacula_privileges /usr/libexec/bacula/grant_bacula_privileges.sqlite \
        --slave /usr/libexec/bacula/make_bacula_tables make_bacula_tables /usr/libexec/bacula/make_bacula_tables.sqlite \
        --slave /usr/libexec/bacula/make_catalog_backup make_catalog_backup /usr/libexec/bacula/make_catalog_backup.sqlite \
        --slave /usr/libexec/bacula/update_bacula_tables update_bacula_tables /usr/libexec/bacula/update_bacula_tables.sqlite \
        --slave /usr/libexec/bacula/bacula_config bacula_config /usr/libexec/bacula/bacula_config.sqlite

%post director-postgresql
/usr/sbin/alternatives --install /usr/sbin/bacula-dir bacula-dir /usr/sbin/bacula-dir.postgresql 60 \
        --slave /usr/sbin/dbcheck bacula-dbcheck /usr/sbin/dbcheck.postgresql \
        --slave /usr/libexec/bacula/create_bacula_database create_bacula_database /usr/libexec/bacula/create_bacula_database.postgresql \
        --slave /usr/libexec/bacula/drop_bacula_database drop_bacula_database /usr/libexec/bacula/drop_bacula_database.postgresql \
        --slave /usr/libexec/bacula/drop_bacula_tables drop_bacula_tables /usr/libexec/bacula/drop_bacula_tables.postgresql \
        --slave /usr/libexec/bacula/grant_bacula_privileges grant_bacula_privileges /usr/libexec/bacula/grant_bacula_privileges.postgresql \
        --slave /usr/libexec/bacula/make_bacula_tables make_bacula_tables /usr/libexec/bacula/make_bacula_tables.postgresql \
        --slave /usr/libexec/bacula/make_catalog_backup make_catalog_backup /usr/libexec/bacula/make_catalog_backup.postgresql \
        --slave /usr/libexec/bacula/update_bacula_tables update_bacula_tables /usr/libexec/bacula/update_bacula_tables.postgresql \
        --slave /usr/libexec/bacula/bacula_config bacula_config /usr/libexec/bacula/bacula_config.postgresql

%preun director-mysql
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-dir /usr/sbin/bacula-dir.mysql
fi

%preun director-sqlite
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-dir /usr/sbin/bacula-dir.sqlite
fi

%preun director-postgresql
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-dir /usr/sbin/bacula-dir.postgresql
fi

%pre common
getent group %username >/dev/null || groupadd -g %uid -r %username &>/dev/null || :
getent passwd %username >/dev/null || useradd -u %uid -r -s /sbin/nologin \
        -d /var/spool/bacula -M -c 'Bacula Backup System' -g %username %username &>/dev/null || :
exit 0

%post storage-mysql
/usr/sbin/alternatives --install /usr/sbin/bcopy bacula-sd /usr/sbin/bcopy.mysql 50 \
        --slave /usr/sbin/bscan bacula-bscan /usr/sbin/bscan.mysql \
        --slave /usr/sbin/btape bacula-btape /usr/sbin/btape.mysql

%post storage-sqlite
/usr/sbin/alternatives --install /usr/sbin/bcopy bacula-sd /usr/sbin/bcopy.sqlite 40 \
        --slave /usr/sbin/bscan bacula-bscan /usr/sbin/bscan.sqlite \
        --slave /usr/sbin/btape bacula-btape /usr/sbin/btape.sqlite

%post storage-postgresql
/usr/sbin/alternatives --install /usr/sbin/bcopy bacula-sd /usr/sbin/bcopy.postgresql 60 \
        --slave /usr/sbin/bscan bacula-bscan /usr/sbin/bscan.postgresql \
        --slave /usr/sbin/btape bacula-btape /usr/sbin/btape.postgresql

%preun storage-mysql
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-sd /usr/sbin/bcopy.mysql
fi

%preun storage-sqlite
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-sd /usr/sbin/bcopy.sqlite
fi

%preun storage-postgresql
if [ "$1" = 0 ]; then
        /usr/sbin/alternatives --remove bacula-sd /usr/sbin/bcopy.postgresql
fi

%if 0%{?fedora} || 0%{?rhel} > 6

%post client
if [ $1 -eq 1 ] ; then 
    # Initial installation 
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi

%preun client
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable bacula-fd.service > /dev/null 2>&1 || :
    /bin/systemctl stop bacula-fd.service > /dev/null 2>&1 || :
fi

%postun client
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart bacula-fd.service >/dev/null 2>&1 || :
fi

%triggerun client -- bacula-client < 5.0.3-10
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply bacula-fd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save bacula-fd >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del bacula-fd >/dev/null 2>&1 || :
/bin/systemctl try-restart bacula-fd.service >/dev/null 2>&1 || :

%post director-common
if [ $1 -eq 1 ] ; then 
    # Initial installation 
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi

%preun director-common
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable bacula-dir.service > /dev/null 2>&1 || :
    /bin/systemctl stop bacula-dir.service > /dev/null 2>&1 || :
fi

%postun director-common
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart bacula-dir.service >/dev/null 2>&1 || :
fi

%triggerun director-common -- bacula-director-common < 5.0.3-10
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply bacula-dir
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save bacula-dir >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del bacula-dir >/dev/null 2>&1 || :
/bin/systemctl try-restart bacula-dir.service >/dev/null 2>&1 || :

%post storage-common
if [ $1 -eq 1 ] ; then 
    # Initial installation 
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi

%preun storage-common
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable bacula-sd.service > /dev/null 2>&1 || :
    /bin/systemctl stop bacula-sd.service > /dev/null 2>&1 || :
fi

%postun storage-common
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart bacula-sd.service >/dev/null 2>&1 || :
fi

%triggerun storage-common -- bacula-storage-common < 5.0.3-10 
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply bacula-sd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save bacula-sd >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del bacula-sd >/dev/null 2>&1 || :
/bin/systemctl try-restart bacula-sd.service >/dev/null 2>&1 || :

%else

%post client
/sbin/chkconfig --add bacula-fd


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


%postun client
if [ "$1" -ge "1" ]; then
        /sbin/service bacula-fd condrestart >/dev/null 2>&1 || :
fi


%post director-common
/sbin/chkconfig --add bacula-dir


%preun director-common
if [ "$1" = 0 ]; then
        /sbin/service bacula-dir stop >/dev/null 2>&1 || :
        /sbin/chkconfig --del bacula-dir
fi


%postun director-common
if [ "$1" -ge "1" ]; then
        /sbin/service bacula-dir condrestart >/dev/null 2>&1 || :
fi


%post storage-common
/sbin/chkconfig --add bacula-sd


%preun storage-common
if [ "$1" = 0 ]; then
        /sbin/service bacula-sd stop >/dev/null 2>&1 || :
        /sbin/chkconfig --del bacula-sd
fi


%postun storage-common
if [ "$1" -ge "1" ]; then
        /sbin/service bacula-sd condrestart >/dev/null 2>&1 || :
fi

%endif


%files libs
%defattr(-,root,root,-)
%{_libdir}/libbac-%{version}.so
%{_libdir}/libbaccfg-%{version}.so
%{_libdir}/libbacfind-%{version}.so
%{_libdir}/libbacpy-%{version}.so

%files libs-mysql
%defattr(-,root,root,-)
%{_libdir}/libbacsql-%{version}.so.mysql

%files libs-sqlite
%defattr(-,root,root,-)
%{_libdir}/libbacsql-%{version}.so.sqlite

%files libs-postgresql
%defattr(-,root,root,-)
%{_libdir}/libbacsql-%{version}.so.postgresql

%files common
%defattr(-,root,root,-)
%doc bacula-%{version}/AUTHORS bacula-%{version}/ChangeLog bacula-%{version}/LICENSE
%doc bacula-%{version}/SUPPORT bacula-%{version}/ReleaseNotes
%config(noreplace) %{_sysconfdir}/logrotate.d/bacula
%dir %{_sysconfdir}/bacula
%dir %{_libexecdir}/bacula
%{_sbindir}/bacula-checkconf
%{_sbindir}/bsmtp
%{_sbindir}/btraceback
%{_libexecdir}/bacula/btraceback.dbx
%{_libexecdir}/bacula/btraceback.gdb
%{_libexecdir}/bacula/btraceback.mdb
%{_libexecdir}/bacula/mtx-changer.conf
%{_mandir}/man1/bsmtp.1*
%{_mandir}/man8/bacula.8*
%{_mandir}/man8/btraceback.8*
%dir %attr(750, bacula, bacula) %{_localstatedir}/log/bacula
%dir %attr(750, bacula, bacula) %{_localstatedir}/spool/bacula

%files client
%defattr(-,root,root,-)
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/bacula/bacula-fd.conf
%config(noreplace) %{_sysconfdir}/sysconfig/bacula-fd
%{_sbindir}/bacula-fd
%{_libdir}/bacula/bpipe-fd.so
%if 0%{?fedora} || 0%{?rhel} > 6
%{_unitdir}/bacula-fd.service
%else
%{_initrddir}/bacula-fd
%endif
%{_mandir}/man8/bacula-fd.8*

%files console
%defattr(-,root,root,-)
%attr(640,root,bacula) %config(noreplace) %{_sysconfdir}/bacula/bconsole.conf
%{_sbindir}/bconsole
%{_mandir}/man8/bconsole.8*

%if 0%{?fedora} || 0%{?rhel} >= 6
%files console-bat
%defattr(-,root,root,-)
%doc %{_datadir}/doc/bacula-console-bat-%{version}/*
%config %{_sysconfdir}/security/console.apps/bat
%config %{_sysconfdir}/pam.d/bat
%attr(640,root,bacula) %config(noreplace) %{_sysconfdir}/bacula/bat.conf
%{_bindir}/bat
%{_sbindir}/bat
%{_mandir}/man1/bat.1.gz
%{_datadir}/applications/fedora-bacula-bat.desktop
%{_datadir}/pixmaps/bat_icon.png
%{_datadir}/pixmaps/bacula.png
%endif

%if ! 0%{?rhel}
%files console-wxwidgets
%defattr(-,root,root,-)
%config %{_sysconfdir}/security/console.apps/bwxconsole
%config %{_sysconfdir}/pam.d/bwxconsole
%attr(640,root,bacula) %config(noreplace) %{_sysconfdir}/bacula/bwxconsole.conf
%{_bindir}/bwxconsole
%{_sbindir}/bwxconsole
%{_mandir}/man1/bacula-bwxconsole.1*
%{_datadir}/applications/fedora-bacula-wxconsole.desktop
%{_datadir}/pixmaps/wxwin16x16.xpm
%endif

%files director-common
%defattr(-,root,root,-)
%doc bacula-%{version}/updatedb/
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/bacula/bacula-dir.conf
%config(noreplace) %{_sysconfdir}/sysconfig/bacula-dir
%config(noreplace) %{_sysconfdir}/bacula/query.sql
%config %{_sysconfdir}/logwatch/conf/logfiles/bacula.conf
%config %{_sysconfdir}/logwatch/conf/services/bacula.conf
%{_sysconfdir}/logwatch/scripts/services/bacula
%{_sysconfdir}/logwatch/scripts/shared/applybaculadate
%if 0%{?fedora} || 0%{?rhel} > 6
%{_unitdir}/bacula-dir.service
%else
%{_initrddir}/bacula-dir
%endif
%{_sbindir}/bregex
%{_sbindir}/bwild
%{_mandir}/man8/dbcheck.8*
%{_mandir}/man8/bacula-dir.8*
%{_libexecdir}/bacula/delete_catalog_backup
%{_libexecdir}/bacula/make_catalog_backup.pl

%files director-mysql
%defattr(-,root,root,-)
%{_sbindir}/bacula-dir.mysql
%{_sbindir}/dbcheck.mysql
%{_libexecdir}/bacula/create_mysql_database
%{_libexecdir}/bacula/drop_mysql_database
%{_libexecdir}/bacula/drop_mysql_tables
%{_libexecdir}/bacula/grant_mysql_privileges
%{_libexecdir}/bacula/make_mysql_tables
%{_libexecdir}/bacula/update_mysql_tables
%{_libexecdir}/bacula/create_bacula_database.mysql
%{_libexecdir}/bacula/drop_bacula_database.mysql
%{_libexecdir}/bacula/drop_bacula_tables.mysql
%{_libexecdir}/bacula/grant_bacula_privileges.mysql
%{_libexecdir}/bacula/make_bacula_tables.mysql
%{_libexecdir}/bacula/make_catalog_backup.mysql
%{_libexecdir}/bacula/update_bacula_tables.mysql
%{_libexecdir}/bacula/bacula_config.mysql

%files director-sqlite
%defattr(-,root,root,-)
%{_sbindir}/bacula-dir.sqlite
%{_sbindir}/dbcheck.sqlite
%{_libexecdir}/bacula/create_sqlite3_database
%{_libexecdir}/bacula/drop_sqlite3_database
%{_libexecdir}/bacula/drop_sqlite3_tables
%{_libexecdir}/bacula/grant_sqlite3_privileges
%{_libexecdir}/bacula/make_sqlite3_tables
%{_libexecdir}/bacula/update_sqlite3_tables
%{_libexecdir}/bacula/create_bacula_database.sqlite
%{_libexecdir}/bacula/drop_bacula_database.sqlite
%{_libexecdir}/bacula/drop_bacula_tables.sqlite
%{_libexecdir}/bacula/grant_bacula_privileges.sqlite
%{_libexecdir}/bacula/make_bacula_tables.sqlite
%{_libexecdir}/bacula/make_catalog_backup.sqlite
%{_libexecdir}/bacula/update_bacula_tables.sqlite
%{_libexecdir}/bacula/bacula_config.sqlite

%files director-postgresql
%defattr(-,root,root,-)
%{_sbindir}/bacula-dir.postgresql
%{_sbindir}/dbcheck.postgresql
%{_libexecdir}/bacula/create_postgresql_database
%{_libexecdir}/bacula/drop_postgresql_database
%{_libexecdir}/bacula/drop_postgresql_tables
%{_libexecdir}/bacula/grant_postgresql_privileges
%{_libexecdir}/bacula/make_postgresql_tables
%{_libexecdir}/bacula/update_postgresql_tables
%{_libexecdir}/bacula/create_bacula_database.postgresql
%{_libexecdir}/bacula/drop_bacula_database.postgresql
%{_libexecdir}/bacula/drop_bacula_tables.postgresql
%{_libexecdir}/bacula/grant_bacula_privileges.postgresql
%{_libexecdir}/bacula/make_bacula_tables.postgresql
%{_libexecdir}/bacula/make_catalog_backup.postgresql
%{_libexecdir}/bacula/update_bacula_tables.postgresql
%{_libexecdir}/bacula/bacula_config.postgresql

%files storage-common
%defattr(-,root,root,-)
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/bacula/bacula-sd.conf
%config(noreplace) %{_sysconfdir}/sysconfig/bacula-sd
%if 0%{?fedora} || 0%{?rhel} > 6
%{_unitdir}/bacula-sd.service
%else
%{_initrddir}/bacula-sd
%endif
%{_sbindir}/bacula-sd
%{_sbindir}/bextract
%{_sbindir}/bls
%{_libexecdir}/bacula/disk-changer
%{_libexecdir}/bacula/dvd-handler
%{_libexecdir}/bacula/mtx-changer
%{_mandir}/man8/bcopy.8*
%{_mandir}/man8/bextract.8*
%{_mandir}/man8/bls.8*
%{_mandir}/man8/bscan.8*
%{_mandir}/man8/btape.8*
%{_mandir}/man8/bacula-sd.8*

%files storage-mysql
%defattr(-,root,root,-)
%{_sbindir}/bcopy.mysql
%{_sbindir}/bscan.mysql
%{_sbindir}/btape.mysql

%files storage-sqlite
%defattr(-,root,root,-)
%{_sbindir}/bcopy.sqlite
%{_sbindir}/bscan.sqlite
%{_sbindir}/btape.sqlite

%files storage-postgresql
%defattr(-,root,root,-)
%{_sbindir}/bcopy.postgresql
%{_sbindir}/bscan.postgresql
%{_sbindir}/btape.postgresql

%files traymonitor
%defattr(-,root,root,-)
%attr(640,root,bacula) %config(noreplace) %{_sysconfdir}/bacula/tray-monitor.conf
%config %{_sysconfdir}/security/console.apps/bacula-tray-monitor
%config %{_sysconfdir}/pam.d/bacula-tray-monitor
%{_bindir}/bacula-tray-monitor
%{_sbindir}/bacula-tray-monitor
%{_mandir}/man1/bacula-tray-monitor.1*
%{_datadir}/applications/fedora-bacula-traymonitor.desktop
%{_datadir}/pixmaps/bacula-tray-monitor.xpm

%files devel
%defattr(-,root,root,-)
%{_includedir}/bacula
%{_libdir}/libbac.la
%{_libdir}/libbac.so
%{_libdir}/libbaccfg.la
%{_libdir}/libbaccfg.so
%{_libdir}/libbacfind.la
%{_libdir}/libbacfind.so
%{_libdir}/libbacpy.la
%{_libdir}/libbacpy.so
%{_libdir}/libbacsql.la


%files -n nagios-plugins-bacula
%defattr(-,root,root)
%{_libdir}/nagios/plugins/check_bacula


%changelog
* Wed Jan 09 2013 Simone Caronni <negativo17@gmail.com> - 5.0.3-35
- Move unversioned libraries into the devel package (#889244).

* Mon Sep 24 2012 Simone Caronni <negativo17@gmail.com> 5.0.3-34
- Updated SysV init scripts (sleep, useless code).
- Updated service files (documentation, required targets).
- Removed conditionals for EOL distributions.
- Remove user definition during prep so they are not used during the install phase (rhbz#852732).
- Enforce permissions in default config files.
- Spec file formatting fixes.
- Do not remove user on common subpackage uninstall.
- Remove useless docs.

* Tue Sep 18 2012 Lukáš Nykrýn <lnykryn@redhat.com> - 5.0.3-33
- Make dump_resource respect console ACL's (#857957)
- CVE-2012-4430

* Mon Jul 23 2012 Simone Caronni <negativo17@gmail.com> 5.0.3-32
- Updated sysconfig files.

* Thu Jul 19 2012 Simone Caronni <negativo17@gmail.com> 5.0.3-31
- Drop examples (rhbz#475469).

* Mon Jul 16 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-30
- Fix log path as in f17/rawhide builds (rhbz#837706).
- Add nss-lookup.target as required to service files (rhbz#838828).

* Mon Jul 02 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-29
- Remove leftover script.

* Wed Feb 01 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-28
- Add bat html docs so the help button works.

* Wed Feb 01 2012 Lukas Nykryn <lnykryn@redhat.com> - 5.0.3-27
- Remove dependency on fedora-usermgmt.

* Mon Jan 30 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-26
- Fix ldconfig/alternatives symlinks on removal of packages.

* Mon Jan 30 2012 Lukas Nykryn <lnykryn@redhat.com> - 5.0.3-25
- Remove dependency on WxGTK in RHEL.

* Fri Jan 27 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-24
- Correct license to AGPLv3.
- Split off libs in separate backends.
- Trim changelog for version <5.0.0.

* Thu Jan 26 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-23
- Add ldconfig after setting up symlinks for libbacsql variants.

* Wed Jan 25 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-22
- Fix for rhbz#784471.
- Add libbaccats.so symlink to alternatives, thanks pghmcfc.

* Tue Jan 24 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-21
- Fix postgresql libs dependency issue.

* Tue Jan 24 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-20
- Fix rhbz#728693 and rhbz#726147.
- Remove bacula-docs BuildRequires.
- Remove fedora-usermgmt dependency, static id 133 already defined as in:
  `cat /usr/share/doc/setup-2.8.36/uidgid | grep bacula`
  Upgrades still keep the old uid/gid.

* Wed Jan 11 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-19
- Add devel subpackage.
- Split off docs subpackage.

* Mon Jan 09 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-18
- Enable batch insert code.

* Mon Jan 02 2012 Simone Caronni <negativo17@gmail.com> - 5.0.3-17
- Revert to SySV init scripts as packaging policies forbid systemd
  migration if not changing Fedora release; thanks Lukáš.

* Fri Dec 23 2011 Simone Caronni <negativo17@gmail.com> - 5.0.3-16
- Add Nagios plugin.
- Add conditionals for RHEL building (initscripts, bat).
- Enable libtool, bpipe-fd.so plugin and remove dsolink patches.

* Fri Dec 23 2011 Simone Caronni <negativo17@gmail.com> - 5.0.3-15
- Spec file cleanup.
- Fix Buildrequires for RHEL.
- Enable POSIX.1e capabilities.
- Enable LZO compression.
- Enable readline support and tab completion in bconsole.
- Remove SQLite 2 support for RHEL 4.
- Add HTML docs.
- Change SQL query file patch.
- Add back sysconf files and remove redundant user/group in systemd
  service files.
- Move build of common parts around to reduce build time and to prepare
  for nagios-plugins and conditionals for RHEL.

* Thu Dec 22 2011 Lukáš Nykrýn <lnykryn@redhat.com> - 5.0.3-14
- removed duplicity from logrotate file (#755970)

* Thu Nov 3 2011 Lukáš Nykrýn <lnykryn@redhat.com> - 5.0.3-13
- fixed creating of bacula MySQL tables and bump

* Fri Oct  9 2011 Lukáš Nykrýn <lnykryn@redhat.com> - 5.0.3-12
- fixed restart option in service files (#745529)
- fixed creating of bacula MySQL tables (#724894)

* Fri Sep  9 2011 Tom Callaway <spot@fedoraproject.org> - 5.0.3-11
- add missing scriptlets

* Thu Sep  8 2011 Tom Callaway <spot@fedoraproject.org> - 5.0.3-10 
- convert to systemd

* Wed Mar 23 2011 Dan Horák <dan@danny.cz> - 5.0.3-9
- rebuilt for mysql 5.5.10 (soname bump in libmysqlclient)

* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Mon Jan 03 2011 Jon Ciesla <limb@jcomserv.net> - 5.0.3-7
- Rebuild for MySQL 5.5, with patch.

* Fri Nov 26 2010 Jan Görig <jgorig@redhat.com> - 5.0.3-6
- Fixed previous fix of alternatives
- Changed initscript return value for non-configured service
- Director address is required in tray-monitor config now (#626490)

* Tue Nov 23 2010 Jan Görig <jgorig@redhat.com> - 5.0.3-5
- Fixed alternatives for dbcheck (#650224)
- Moved director log file to /var/log/bacula/
- Changed permission of bacula-dir.conf (RHEL #651786)
- SQLite database is created as bacula user

* Tue Oct 19 2010 Jan Görig <jgorig@redhat.com> - 5.0.3-4
- Fixed initscripts and changed default group of bacula-sd (#629697)
- Better warning for non-configured password (#556669)

* Wed Sep 29 2010 jkeating - 5.0.3-3
- Rebuilt for gcc bug 634757

* Thu Sep 23 2010 Jan Görig <jgorig@redhat.com> - 5.0.3-2
- fixed openssl patch, thanks to Enrico Scholz

* Tue Aug 10 2010 Jon Ciesla <limb@jcomserv.net> - 5.0.3-1
- New upstream.
- DSOlink fix for same.

* Fri Jul 30 2010 Jon Ciesla <limb@jcomserv.net> - 5.0.2-8
- Patched configure scripts for Python 2.7.

* Fri Jul 30 2010 Jon Ciesla <limb@jcomserv.net> - 5.0.2-7
- Rebuild against Python 2.7.

* Wed Jul 14 2010 Dan Horák <dan@danny.cz> - 5.0.2-6
- rebuilt against wxGTK-2.8.11-2

* Thu Jun 3 2010 Jan Görig <jgorig@redhat.com> 5.0.2-5
- removed no longer needed sysconfig subpackage (#593307]
- build with $RPM_OPT_FLAGS, show compiler commands in build log (#575425)
  fixed by Ville Skyttä
- dropped tcp_wrappers build conditional (#537250)
- fixed location of query.xml in config file (#556480)

* Wed Jun 2 2010 Jan Görig <jgorig@redhat.com> 5.0.2-4
- initscripts improvements
- fixed consolehelper settings and menu entries

* Tue Jun 01 2010 Jon Ciesla <limb@jcomserv.net - 5.0.2-3
- Corrected ssl patch, court. jgorig.

* Wed May 19 2010 Jon Ciesla <limb@jcomserv.net - 5.0.2-2
- Corrected bat build, BZ 593149.
- Corrected ssl patch.

* Thu Apr 29 2010 Jon Ciesla <limb@jcomserv.net - 5.0.2-1
- New upstream, 5.0.2.
- Updated openssl patch.

* Thu Feb 25 2010 Jon Ciesla <limb@jcomserv.net - 5.0.1-1
- New upstream, 5.0.1.

* Mon Jan 25 2010 Jon Ciesla <limb@jcomserv.net - 5.0.0-1
- New upstream, 5.0.0.