%define db_backend mysql
%endif
%if %{sqlite}
-%define db_backend sqlite
+%define db_backend sqlite3
%endif
%if %{postgresql}
%define db_backend postgresql
# so fix for broken rh
%define broken_rh 0
%if %{rhel5} || %{centos5} || %{sl5} || %{fc5} || %{fc6} || %{fc7}
-%define broken_rh 1"
+%define broken_rh 1
%endif
%if %{bat} && ! %{broken_rh}
BuildRequires: qt-devel >= 4.2
This build requires PostgreSQL to be installed separately as the catalog database.
%endif
%if %{sqlite}
-This build incorporates sqlite as the catalog database, statically compiled.
+This build incorporates sqlite3 as the catalog database, statically compiled.
%endif
%if %{python}
This build includes python scripting support.
cwd=${PWD}
cd %{depkgs}
%if %{sqlite}
-make sqlite
+make sqlite3
%endif
%if ! %{client_only}
make mtx
# patches for the bundled sqlite scripts
# 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_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 the create_sqlite_database script for installation bindir
-# not necessary after 1.39.26 no longer references sqlite binary
#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 the make_catalog_backup script for installation bindir
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_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 the bacula-dir init script to remove sqlite service
%if %{sqlite} && %{su9}
--with-mysql \
%endif
%if %{sqlite}
- --with-sqlite=${cwd}/%{depkgs}/sqlite \
+ --with-sqlite3=${cwd}/%{depkgs}/sqlite3 \
%endif
%if %{postgresql}
--with-postgresql \
# install sqlite
%if %{sqlite}
-cp -p %{depkgs}/sqlite/sqlite $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite
-cp -p %{depkgs}/sqlite/sqlite.h $RPM_BUILD_ROOT%{sqlite_bindir}/sqlite.h
-cp -p %{depkgs}/sqlite/libsqlite.a $RPM_BUILD_ROOT%{sqlite_bindir}/libsqlite.a
+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
%if %{sqlite}
%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
-%{sqlite_bindir}/libsqlite.a
-%{sqlite_bindir}/sqlite.h
-%{sqlite_bindir}/sqlite
+%attr(-, root, %{daemon_group}) %{script_dir}/create_sqlite3_database
+%attr(-, root, %{daemon_group}) %{script_dir}/drop_sqlite3_database
+%attr(-, root, %{daemon_group}) %{script_dir}/grant_sqlite3_privileges
+%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
%if %{postgresql}
%if %{sqlite}
%pre sqlite
-# test for bacula database older than version 9
+# are we upgrading from sqlite to sqlite3?
if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite ];then
- DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
+ 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 "%{sqlite_bindir}/sqlite3 $* bacula.db < %{working_dir}/bacula_backup.sql"
+ exit 1
+fi
+# test for bacula database older than version 9 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`
%endif
%if %{postgresql}
%if %{sqlite}
# test for an existing database
if [ -s %{working_dir}/bacula.db ]; then
- DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
+ DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite3 2>/dev/null %{working_dir}/bacula.db | tail -n 1`
# check to see if we need to upgrade a 1.38 or lower database
if [ "$DB_VER" -lt "10" ] && [ "$DB_VER" -ge "9" ]; then
echo "This release requires an upgrade to your bacula database."
echo "Backing up your current database..."
- echo ".dump" | %{sqlite_bindir}/sqlite %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2
+ echo ".dump" | %{sqlite_bindir}/sqlite3 %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2
echo "Upgrading bacula database ..."
- %{script_dir}/update_sqlite_tables
+ %{script_dir}/update_sqlite3_tables
echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2"
fi
else
# create the database and tables
echo "Hmm, doesn't look like you have an existing database."
echo "Creating SQLite database..."
- %{script_dir}/create_sqlite_database
+ %{script_dir}/create_sqlite3_database
chown %{director_daemon_user}.%{daemon_group} %{working_dir}/bacula.db
echo "Creating the SQLite tables..."
- %{script_dir}/make_sqlite_tables
+ %{script_dir}/make_sqlite3_tables
fi
%endif
%endif
%changelog
+* Sat Nov 17 2007 D. Scott Barninger <barninger@fairfieldcomputers.com>
+- switch to sqlite3
* Sun Nov 11 2007 D. Scott Barninger <barninger@fairfieldcomputers.com>
- add new files required by rescue makefile
* Sat Nov 10 2007 D. Scott Barninger <barninger@fairfieldcomputers.com>