From ac96a9d9bc8a5a23cdd7a1b1bff3e6e2ac863cb9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 11 Jun 2010 16:27:29 +0200 Subject: [PATCH] Add BDB_VERSION for scripts + prepare update 11 to 12 + automate BDB_VERSION checking --- bacula/autoconf/configure.in | 47 +++++----- bacula/src/cats/cats.h | 17 +--- bacula/src/cats/make_ingres_tables.in | 2 +- bacula/src/cats/make_mysql_tables.in | 2 +- bacula/src/cats/make_postgresql_tables.in | 2 +- bacula/src/cats/make_sqlite3_tables.in | 2 +- bacula/src/cats/update_mysql_tables.in | 21 +++-- bacula/src/cats/update_postgresql_tables.in | 23 +++-- bacula/src/cats/update_sqlite3_tables.in | 23 +++-- .../updatedb/update_mysql_tables_11_to_12.in | 76 +++++++++++++++ .../update_postgresql_tables_11_to_12.in | 93 +++++++++++++++++++ .../update_sqlite3_tables_11_to_12.in | 77 +++++++++++++++ 12 files changed, 328 insertions(+), 57 deletions(-) create mode 100644 bacula/updatedb/update_mysql_tables_11_to_12.in create mode 100644 bacula/updatedb/update_postgresql_tables_11_to_12.in create mode 100644 bacula/updatedb/update_sqlite3_tables_11_to_12.in diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 3df9416ee2..90adfaed7d 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -36,11 +36,13 @@ BACULA=${BACULA:-Bacula} VERSION=`sed -n -e 's/^.*VERSION.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h` DATE=`sed -n -e 's/^.*[ \t]*BDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h` LSMDATE=`sed -n -e 's/^.*LSMDATE.*"\(.*\)"$/\1/p' ${srcdir}/src/version.h` +BDB_VERSION=`sed -n -e 's/^.*BDB_VERSION \(.*\)$/\1/p' ${srcdir}/src/cats/cats.h` AC_SUBST(VERSION)dnl AC_SUBST(DATE)dnl AC_SUBST(LSMDATE)dnl AC_SUBST(BACULA)dnl AC_SUBST(post_host)dnl +AC_SUBST(BDB_VERSION)dnl dnl src/lib dnl can be overwritten by specific values from version.h @@ -2432,10 +2434,10 @@ if test x$support_afs = xyes -o x$support_afs = xauto; then dnl if test x$with_afsdir = x; then for root in /usr /usr/local; do - if test -d ${root}/include/afs/ ; then - with_afsdir=${root} - break - fi + if test -d ${root}/include/afs/ ; then + with_afsdir=${root} + break + fi done fi @@ -2455,13 +2457,13 @@ if test x$support_afs = xyes -o x$support_afs = xauto; then do for arch_type in .a .so do - A=`test -f ${dir}/libsys${arch_type} && nm ${dir}/libsys${arch_type} | grep pioctl` - pkg=$? - if test $pkg = 0; then - have_afs=yes - AFS_LIBS="-L${dir} -lsys -lrx -llwp ${dir}/util.a" - break - fi + A=`test -f ${dir}/libsys${arch_type} && nm ${dir}/libsys${arch_type} | grep pioctl` + pkg=$? + if test $pkg = 0; then + have_afs=yes + AFS_LIBS="-L${dir} -lsys -lrx -llwp ${dir}/util.a" + break + fi done done @@ -2471,7 +2473,7 @@ if test x$support_afs = xyes -o x$support_afs = xauto; then else if test $have_afs = yes; then AC_DEFINE([HAVE_AFS],1,[Defines if your system has AFS support]) - AC_DEFINE([HAVE_AFS_ACL],1,[Andrew FileSystem ACL support]) + AC_DEFINE([HAVE_AFS_ACL],1,[Andrew FileSystem ACL support]) fi fi fi @@ -2505,18 +2507,18 @@ if test x$support_acl = xyes -o x$support_acl = xauto; then AC_CHECK_LIB(acl, acl_get_file, [ have_acl=yes; - if test $have_afs = yes; then - dnl - dnl Because of possible naming conflict with AFS libacl make sure we use the one in /usr/lib64 or /usr/lib !!! - dnl + if test $have_afs = yes; then + dnl + dnl Because of possible naming conflict with AFS libacl make sure we use the one in /usr/lib64 or /usr/lib !!! + dnl if test -d /usr/lib64/; then FDLIBS="-L/usr/lib64 -lacl $FDLIBS" - else + else FDLIBS="-L/usr/lib -lacl $FDLIBS" - fi - else + fi + else FDLIBS="-lacl $FDLIBS" - fi + fi ], [ AC_CHECK_LIB(pacl, acl_get_file, [ @@ -3166,6 +3168,9 @@ AC_OUTPUT([autoconf/Make.common \ updatedb/update_mysql_tables_10_to_11 \ updatedb/update_sqlite3_tables_10_to_11 \ updatedb/update_postgresql_tables_10_to_11 \ + updatedb/update_mysql_tables_11_to_12 \ + updatedb/update_sqlite3_tables_11_to_12 \ + updatedb/update_postgresql_tables_11_to_12 \ examples/nagios/check_bacula/Makefile \ $PFILES ], [ ] @@ -3343,7 +3348,7 @@ Configuration on `date`: build-dird: ${build_dird} build-stored: ${build_stored} Plugin support: ${have_plugins} - AFS support: ${have_afs} + AFS support: ${have_afs} ACL support: ${have_acl} XATTR support: ${have_xattr} Python support: ${support_python} ${PYTHON_LIBS} diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index a33650ba69..8908fbae95 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -85,12 +85,14 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **); #ifdef __SQL_C +/* Current database version number for all drivers */ +#define BDB_VERSION 13 + + #if defined(BUILDING_CATS) #ifdef HAVE_SQLITE #error "SQLite2 is now deprecated, use SQLite3 instead." -#define BDB_VERSION 12 - #include /* Define opaque structure for sqlite */ @@ -210,9 +212,6 @@ extern const char* my_sqlite_batch_fill_path_query; #ifdef HAVE_SQLITE3 - -#define BDB_VERSION 12 - #include /* Define opaque structure for sqlite */ @@ -338,8 +337,6 @@ extern const char* my_sqlite_batch_fill_path_query; #ifdef HAVE_MYSQL -#define BDB_VERSION 12 - #include /* @@ -423,8 +420,6 @@ extern int my_mysql_insert_autokey_record(B_DB *mdb, const char *query, const ch #ifdef HAVE_POSTGRESQL -#define BDB_VERSION 12 - #include /* TEMP: the following is taken from select OID, typname from pg_type; */ @@ -540,8 +535,6 @@ extern const char* my_pg_batch_fill_path_query; #include "myingres.h" -#define BDB_VERSION 12 - /* TEMP: the following is taken from $(II_SYSTEM)/ingres/files/eqsqlda.h IISQ_ types */ #define IS_NUM(x) ((x) == 10 || (x) == 30 || (x) == 31) #define IS_NOT_NULL(x) ((x) == 1) @@ -649,8 +642,6 @@ extern const char* my_ingres_batch_fill_path_query; #ifdef HAVE_DBI -#define BDB_VERSION 12 - #include #ifdef HAVE_BATCH_FILE_INSERT diff --git a/bacula/src/cats/make_ingres_tables.in b/bacula/src/cats/make_ingres_tables.in index 3dd62447ca..a3bc72506d 100755 --- a/bacula/src/cats/make_ingres_tables.in +++ b/bacula/src/cats/make_ingres_tables.in @@ -491,7 +491,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES ('i', 'Doing batch insert file records',15); -INSERT INTO Version (VersionId) VALUES (12); +INSERT INTO Version (VersionId) VALUES (@BDB_VERSION@); -- Make sure we have appropriate permissions \g diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index c030341893..7fc01b3126 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -423,7 +423,7 @@ CREATE TABLE Version ( ); -- Initialize Version -INSERT INTO Version (VersionId) VALUES (12); +INSERT INTO Version (VersionId) VALUES (@BDB_VERSION@); END-OF-DATA then diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index fd831d3774..aa28815a54 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -444,7 +444,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES ('i', 'Doing batch insert file records',15); -INSERT INTO Version (VersionId) VALUES (12); +INSERT INTO Version (VersionId) VALUES (@BDB_VERSION@); -- Make sure we have appropriate permissions diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index 3205b6a013..4585d05acb 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -434,7 +434,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES -- Initialize Version -INSERT INTO Version (VersionId) VALUES (12); +INSERT INTO Version (VersionId) VALUES (@BDB_VERSION@); PRAGMA default_cache_size = 100000; diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index 2f8534798d..b2f6270e31 100644 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -1,17 +1,26 @@ #!/bin/sh # -# Shell script to update MySQL tables from Bacula Enterprise 2.6 to 4.0 or -# Standard version 3.0 to 5.0 +# Shell script to update MySQL Community version 3.0.x to 5.0.x # echo " " echo "This script will update a Bacula MySQL database from version 11 to 12" -echo " which is needed to convert from Bacula Enterprise 2.6 to 4.0 or " -echo " Standard version 3.0 to 5.0" +echo " which is needed to convert from Bacula Community version 3.0.x to 5.0.x" echo " " bindir=@SQL_BINDIR@ PATH="$bindir:$PATH" db_name=@db_name@ +mysql ${db_name} -e "select VersionId from Version\G" >/tmp/$$ +DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$` +if [ $DBVERSION != 11 ] ; then + echo " " + echo "The existing database is version $DBVERSION !!" + echo "This script can only update an existing version 11 database to version 12." + echo "Error. Cannot upgrade this database." + echo " " + exit 1 +fi + if mysql $* -f </tmp/$$ +DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$` +if [ $DBVERSION != 11 ] ; then + echo " " + echo "The existing database is version $DBVERSION !!" + echo "This script can only update an existing version 11 database to version 12." + echo "Error. Cannot upgrade this database." + echo " " + exit 1 +fi + +if mysql $* -f <