# Conditional build:
%bcond_without console_wx # wx-console program
%bcond_without gnome # gnome-console program
-%bcond_without sqlite # use sqlite
+%bcond_with sqlite # use sqlite
%bcond_without bat # bat Qt4 GUI
-%bcond_with mysql # use mysql
+%bcond_without mysql # use mysql
%bcond_with pgsql # use PostgreSQL
%bcond_with python
%bcond_with rescue
%bcond_with sqlite3_sync_off # makes sqlite3 backend much faster, but less reliable
%if %{with sqlite}
%define _database sqlite
+%undefine with_mysql
+%undefine with_pgsql
%endif
%if %{with sqlite3}
%define _database sqlite3
Summary: Bacula - The Network Backup Solution
Summary(pl.UTF-8): Bacula - rozwiązanie do wykonywania kopii zapasowych po sieci
Name: bacula
-Version: 2.2.5
-Release: 1
+Version: 2.2.6
+Release: 4
Epoch: 0
License: extended GPL v2
Group: Networking/Utilities
Source0: http://dl.sourceforge.net/bacula/%{name}-%{version}.tar.gz
-# Source0-md5: 175a796b96c28fc28cbedb1dc881826f
+# Source0-md5: fe964931ab3fc538a8884204d23e8a5a
Source1: http://dl.sourceforge.net/bacula/%{name}-docs-%{version}.tar.bz2
-# Source1-md5: 578e4221afd009d711f1430e392823d6
+# Source1-md5: a251dc0b5a2c8250b43e2ae372526de2
Source2: http://dl.sourceforge.net/bacula/%{name}-rescue-%{version}.tar.gz
-# Source2-md5: 266e3e814482c2c33e071607cb25d38f
+# Source2-md5: 51bc4b1e5d60593cb9f9aa80d31ad8e4
Source10: %{name}-dir.init
Source11: %{name}-fd.init
Source12: %{name}-sd.init
Source14: %{name}-dir.sysconfig
Source15: %{name}-fd.sysconfig
Source16: %{name}-sd.sysconfig
-Patch100: http://dl.sourceforge.net/bacula/2.2.5-deamon.patch
-Patch101: http://dl.sourceforge.net/bacula/2.2.5-lastwritten.patch
-Patch102: http://dl.sourceforge.net/bacula/2.2.5-nextvol.patch
-Patch103: http://dl.sourceforge.net/bacula/2.2.5-postgresql-errors.patch
-Patch104: http://dl.sourceforge.net/bacula/2.2.5-tray-monitor.patch
Patch0: %{name}-dvd-handler_path.patch
Patch1: %{name}-link.patch
-Patch2: %{name}-compile.patch
-Patch3: %{name}-wx28.patch
-Patch4: %{name}-sqlite3_init_query.patch
+Patch2: %{name}-mysql.patch
+Patch3: %{name}-tinfo-readline.patch
+Patch4: %{name}-branding.patch
+Patch5: %{name}-conf.patch
+Patch10: 2.2.6-add.patch
+Patch11: 2.2.6-dvdwrite_trialfix.patch
+Patch12: 2.2.6-queued-msg.patch
+Patch13: 2.2.6-backup-restore-socket.patch
+Patch14: 2.2.6-mac-build.patch
+Patch15: 2.2.6-status.patch
+
URL: http://www.bacula.org/
BuildRequires: acl-static
BuildRequires: automake
BuildRequires: python-static
%endif
%if %{with bat}
+BuildRequires: qt4-build
BuildRequires: qt4-qmake
BuildRequires: qwt-devel >= 5.0.2-2
BuildRequires: QtCore-devel
%prep
%setup -q -a 1
-%patch100 -p0
-%patch101 -p0
-%patch102 -p0
-%patch103 -p0
-%patch104 -p0
%patch0 -p1
%patch1 -p1
-#%patch2 -p1
-#%patch3 -p1
-#%patch4 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+
+%patch10 -p0
+%patch11 -p0
+%patch12 -p0
+%patch13 -p0
+%patch14 -p0
+%patch15 -p0
tar -xf %{SOURCE2} && ln -s bacula-rescue-* rescue
-sed -i -e 's#wx-config#wx-gtk2-unicode-config#g' configure*
-sed -i -e 's#-lreadline -lhistory -ltermcap#-lreadline -lhistory#g' configure*
+
sed -i -e 's#bindir=.*#bindir=%{_bindir}#g' \
src/cats/create_* src/cats/delete_* src/cats/drop_* \
src/cats/grant_* src/cats/make_* src/cats/update_*
%build
cp -f %{_datadir}/automake/config.sub autoconf
+cd autoconf && %{__aclocal} -I bacula-macros -I gettext-macros && cd ..
+%{__autoconf} --prepend-include=$(pwd)/autoconf autoconf/configure.in > configure
+
CPPFLAGS="-I/usr/include/ncurses -I%{_includedir}/readline"
+WXCONFIG=%{_bindir}/wx-gtk2-unicode-config \
%configure \
--with-scriptdir=%{_libexecdir}/%{name} \
--%{!?with_gnome:dis}%{?with_gnome:en}able-gnome \
--with-smtp-host=localhost \
--with-pid-dir=/var/run \
--with-subsys-dir=/var/lock/subsys \
+ --enable-batch-insert \
--with-%{_database} \
%{?with_sqlite3_sync_off:--enable-extra-sqlite3-init="pragma synchronous=0;"} \
--with-dir-password="#FAKE-dir-password#" \
install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,logrotate.d,pam.d,sysconfig}
install -d $RPM_BUILD_ROOT%{_sysconfdir}/rescue
-install -d $RPM_BUILD_ROOT{%{_pixmapsdir},%{_desktopdir},%{_mandir},%{_bindir}}
+install -d $RPM_BUILD_ROOT{%{_pixmapsdir},%{_desktopdir},%{_mandir},%{_bindir},/var/log/bacula}
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
install rescue/linux/floppy/sfdisk.bz2 $RPM_BUILD_ROOT%{_sysconfdir}/rescue
%endif
+touch $RPM_BUILD_ROOT/var/log/bacula/log
+
# install the updatedb scripts
install updatedb/update_sqlite* $RPM_BUILD_ROOT%{_libexecdir}/%{name}
%post dir
umask 077
+
+# XXX: Most of this upgrade procedure is safe for sqlite only. Other databases would require knowledge
+# about currently used version so we can't easily support these :(
+
+%if %{with sqlite} || %{with sqlite3}
[ -s %{_localstatedir}/bacula.db ] && \
DB_VER=`echo "select * from Version;" | \
%{_bindir}/sqlite%{?with_sqlite3:3} %{_localstatedir}/bacula.db | tail -n 1 2>/dev/null`
+
if [ -z "$DB_VER" ]; then
# grant privileges and create tables
%{_libexecdir}/%{name}/grant_bacula_privileges > dev/null
%{_libexecdir}/%{name}/create_bacula_database > dev/null
%{_libexecdir}/%{name}/make_bacula_tables > dev/null
-elif [ "$DB_VER" -lt "9" ]; then
+else
echo "Backing up bacula tables"
echo ".dump" | sqlite%{?with_sqlite3:3} %{_localstatedir}/bacula.db | bzip2 > %{_localstatedir}/bacula_backup.sql.bz2
- echo "Upgrading bacula tables"
- %if %{with sqlite3}
- type=sqlite3
- if [ "$DB_VER" -lt "9" ]; then
- %{_libexecdir}/%{name}/update_${type}_tables_8_to_9
- fi
- %endif
- %if %{with sqlite}
- type=sqlite
- if [ "$DB_VER" -lt "9" ]; then
- if [ "$DB_VER" -lt "8" ]; then
- if [ "$DB_VER" -lt "7" ]; then
- if [ "$DB_VER" -lt "6" ]; then
- if [ "$DB_VER" -lt "5" ]; then
- %{_libexecdir}/%{name}/update_${type}_tables_4_to_5
- fi
- %{_libexecdir}/%{name}/update_${type}_tables_5_to_6
- fi
- %{_libexecdir}/%{name}/update_${type}_tables_6_to_7
- fi
- %{_libexecdir}/%{name}/update_${type}_tables_7_to_8
- fi
- %{_libexecdir}/%{name}/update_${type}_tables_8_to_9
+
+ db_type="%{_database}"
+
+ next_ver=$(($DB_VER + 1))
+ # support up to version 30; increase this if needed
+ for ver in $(seq $next_ver 30); do
+ prev_ver=$(($ver - 1))
+
+ if [ -x %{_libexecdir}/%{name}/update_${type}_tables_${prev_ver}_to_${ver} ]; then
+ echo "Upgrading bacula database: db=${db_type} from ${prev_ver} to ${ver}..."
+ %{_libexecdir}/%{name}/update_${type}_tables_${prev_ver}_to_${ver}
fi
- %endif
+ done
+
%{_libexecdir}/%{name}/update_bacula_tables
echo "If bacula works correctly you can remove the backup file %{_localstatedir}/bacula_backup.sql.bz2"
fi
chown -R bacula:bacula %{_localstatedir}
chmod -R u+rX,go-rwx %{_localstatedir}/*
+%endif
echo "Updating Bacula passwords and names..."
cd /etc/bacula
%{_libexecdir}/%{name}/btraceback.dbx
%{_libexecdir}/%{name}/btraceback.gdb
%attr(770,root,bacula) %dir %{_localstatedir}
+%attr(750,bacula,logs) %dir /var/log/bacula
+%attr(640,bacula,logs) %ghost /var/log/bacula/log
%files dir
%defattr(644,root,root,755)
%doc ChangeLog CheckList ReleaseNotes kernstodo LICENSE
#%doc examples %{name}-docs-%{version}/manual/{*.pdf,bacula}
-%attr(600,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/bacula-dir.conf
+%attr(640,root,bacula) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/bacula-dir.conf
%ghost %{_sysconfdir}/.pw.sed
%attr(640,root,root) %config(noreplace) /etc/logrotate.d/bacula-dir
%attr(754,root,root) /etc/rc.d/init.d/bacula-dir
%files sd
%defattr(644,root,root,755)
%doc LICENSE
-%dir %{_sysconfdir}
%attr(600,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/bacula-sd.conf
%attr(754,root,root) /etc/rc.d/init.d/bacula-sd
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/bacula-sd