[pkg-bacula-commits] [bacula] 01/01: created new scripts to cope with new database update scripts
Carsten Leonhardt
leo at moszumanska.debian.org
Fri May 20 15:31:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
leo pushed a commit to branch experimental
in repository bacula.
commit f2d5dc97118b95bfd46471b2be79d27e795b4a7b
Author: Carsten Leonhardt <leo at debian.org>
Date: Fri May 20 17:30:55 2016 +0200
created new scripts to cope with new database update scripts
---
debian/TODO | 4 ---
debian/changelog | 1 +
debian/rules | 4 +--
debian/scripts/extract-dbupgrade.awk | 47 +++++++++++++++++++++++++++
debian/scripts/install-dbconfig-upgrade | 56 +++++++++++++++++++++++++++++++++
5 files changed, 106 insertions(+), 6 deletions(-)
diff --git a/debian/TODO b/debian/TODO
index f20ebbb..3861ae3 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -1,7 +1,3 @@
-Important:
-
- * Database upgrades for 7.2.x
-
Normal:
* Unify bacula-sd-(pgsql|mysql|sqlite3) into bacula-sd-tools, they
diff --git a/debian/changelog b/debian/changelog
index 62a7171..414f4be 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,7 @@ bacula (7.4.0+dfsg-1) experimental; urgency=low
packages if needed
* Update Standards-Version to 3.9.8. No changes required.
* bacula-director-pgsql no longer suggests postgresql-doc
+ * created new scripts to cope with new database update scripts
--
diff --git a/debian/rules b/debian/rules
index cb1d47e..43bd63d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -123,8 +123,8 @@ override_dh_install-arch:
# lenny -> squeeze is 10 -> 12
$(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db) 3.0.0 11)) # 3.0.0 upgrade 10 to 11
$(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db) 5.0.0 12)) # 5.0.0 upgrade 11 to 12
- $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db) 5.2.0)) # 5.2.0 upgrade 12 to 14
- $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db)))
+ debian/scripts/install-dbconfig-upgrade # handles install of all upgrade scripts to db version 13 and greater
+ $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db))) # new installs
# fix database type in some scripts
$(foreach db,$(VARIANTS),sed -i \
-e "s/XX_DB_XX/$(db)/" \
diff --git a/debian/scripts/extract-dbupgrade.awk b/debian/scripts/extract-dbupgrade.awk
new file mode 100755
index 0000000..d4a30a3
--- /dev/null
+++ b/debian/scripts/extract-dbupgrade.awk
@@ -0,0 +1,47 @@
+#!/usr/bin/awk -f
+
+# usage: call with "awk -v version=<target version> -f <this file>
+# used by debian/scripts/install-dbconfig-upgrade
+
+BEGIN {
+ version_found = 0
+ data_found = 0
+ version--
+ if ( version < 1 ) {
+ print "error: please pass target version in variable 'version'"
+ exit 1
+ }
+}
+
+{
+ # skip to version check for the desired version
+ if ( !version_found && !data_found && ($0 ~ "DBVERSION.* +(-eq|=) " version " ") ) {
+ version_found = 1
+ next
+ }
+ # skip to beginning of data block (marked by "<<END-OF-DATA")
+ if ( version_found && !data_found && ($0 ~ "<<END-OF-DATA$") ) {
+ data_found = 1
+ next
+ }
+ # exit if end of data block is reached
+ if ( version_found && data_found && ($0 ~ "^END-OF-DATA$") )
+ exit
+ # skip "USE ${db_name};" line, found in mysql files but handled by dbconfig
+ if ( $0 ~ "^USE \\${db_name};" )
+ next
+ # otherwise print the data line
+ if ( version_found && data_found )
+ print $0
+}
+
+END {
+ if ( !version_found ) {
+ print "error: target version not found"
+ exit 1
+ }
+ if ( !data_found ) {
+ print "error: data block not found for target version"
+ exit 1
+ }
+}
diff --git a/debian/scripts/install-dbconfig-upgrade b/debian/scripts/install-dbconfig-upgrade
new file mode 100755
index 0000000..9d920a1
--- /dev/null
+++ b/debian/scripts/install-dbconfig-upgrade
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# this script creates the files needed by dbc for database updates.
+
+# this script needs to be augmented whenever there is a new database update,
+# in particular "lastdbversion" and the case statements need to be reviewed.
+
+# first and last target database version covered by this script
+dbtarget=13
+lastdbversion=15
+
+variants="mysql pgsql sqlite3"
+
+dbc="usr/share/dbconfig-common/data"
+extractor="debian/scripts/extract-dbupgrade.awk"
+
+
+while [ $dbtarget -le $lastdbversion ]; do
+ for db in $variants; do
+ if [ $db = pgsql ] ; then
+ longdb=postgresql
+ else
+ longdb=$db
+ fi
+
+ case $dbtarget in
+ 13) baculaversion="5.2.0"
+ ;;
+ 14) baculaversion="5.2.0"
+ ;;
+ 15) baculaversion="7.2.0"
+ ;;
+ *) echo "$0: Unknown database target version"
+ exit 1
+ ;;
+ esac
+
+ sourcefile="updatedb/update_"$longdb"_tables"
+ targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/upgrade/"$db"/"$baculaversion;
+
+ awk -v version=$dbtarget -f $extractor $sourcefile >> $targetfile
+
+ # special handling for pgsql, there's extra code at the end of
+ # the upgrade script that we use for updates to version 15
+ # - sh compatible improvements welcome :-)
+ if [ $db = pgsql ]; then
+ if [ $dbtarget -eq 15 ]; then
+ # the double awk invocation tries to make extra sure we get the correct instructions
+ awk '/For all versions, we need to create the Index on Media/ , /^END-OF-DATA$/' $sourcefile | awk '/set client_min_messages/, /CREATE INDEX media_storageid_idx ON Media/' >> $targetfile
+ fi
+ fi
+
+ done
+
+ dbtarget=$((dbtarget + 1))
+done
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git
More information about the pkg-bacula-commits
mailing list