[pkg-bacula-commits] [bacula] 01/03: Enhance the new debian scripts to also create the files for dbconfig-common to update older versions and database creation
Carsten Leonhardt
leo at moszumanska.debian.org
Fri Jul 15 15:41:25 UTC 2016
This is an automated email from the git hooks/post-receive script.
leo pushed a commit to branch master
in repository bacula.
commit 2972fbe4ac25b1929caa14a130a278c775c96549
Author: Carsten Leonhardt <leo at debian.org>
Date: Fri Jul 15 11:37:06 2016 +0200
Enhance the new debian scripts to also create the files for
dbconfig-common to update older versions and database creation
---
debian/rules | 10 +----
debian/scripts/extract-dbupgrade.awk | 50 +++++++++++++++++++--
debian/scripts/install-dbconfig-upgrade | 79 ++++++++++++++++++++++++++++++---
3 files changed, 120 insertions(+), 19 deletions(-)
diff --git a/debian/rules b/debian/rules
index 1081be6..2277126 100755
--- a/debian/rules
+++ b/debian/rules
@@ -117,14 +117,8 @@ override_dh_installinit-arch:
override_dh_install-arch:
dh_install -a
######### dbconfig-common stuff
- # Sometimes the latest release doesn't have a copy of the data in updatedb.
- # Manually install those. CHECK THIS FOR EACH NEW RELEASE!
- #
- # 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
- 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
+ # The script install-dbconfig-upgrade needs to be adapted when upstream changes the database format!
+ debian/scripts/install-dbconfig-upgrade # handles install of all upgrade/install scripts to db version 11 and greater
# 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
index d4a30a3..2034757 100755
--- a/debian/scripts/extract-dbupgrade.awk
+++ b/debian/scripts/extract-dbupgrade.awk
@@ -1,15 +1,53 @@
#!/usr/bin/awk -f
+# extract database creation/upgrade statements from the input file
+
# usage: call with "awk -v version=<target version> -f <this file>
+# if version is a number, it extracts the upgrade statements to upgrade *to* that version
+# if version=="ignore", it ignores the version and extracts the first END-OF-DATA block
+
# used by debian/scripts/install-dbconfig-upgrade
+
+# (C) 2016 Carsten Leonhardt <leo at debian.org>
+
+# License: expat
+
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
BEGIN {
version_found = 0
data_found = 0
- version--
- if ( version < 1 ) {
- print "error: please pass target version in variable 'version'"
- exit 1
+ if ( version == "ignore" ) {
+ # don't mind the version, just search for END-OF-DATA
+ version_found = 1
+ }
+ else {
+ # decrease version from target to source version
+ version--
+ if ( version < 1 ) {
+ print "error: please pass target version in variable 'version'"
+ exit 1
+ }
}
}
@@ -36,6 +74,10 @@ BEGIN {
}
END {
+ # don't print more messages if no suitable version was passed
+ if ( version < 1 ) {
+ exit 1
+ }
if ( !version_found ) {
print "error: target version not found"
exit 1
diff --git a/debian/scripts/install-dbconfig-upgrade b/debian/scripts/install-dbconfig-upgrade
index 752d14e..539c81b 100755
--- a/debian/scripts/install-dbconfig-upgrade
+++ b/debian/scripts/install-dbconfig-upgrade
@@ -1,12 +1,38 @@
#!/bin/sh
-# this script creates the files needed by dbc for database updates.
+# this script creates the files needed by dbc for database creation
+# and 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.
+
+# (C) 2016 Carsten Leonhardt <leo at debian.org>
+
+# License: expat
+
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
# first and last target database version covered by this script
-dbtarget=13
+dbtarget=11
lastdbversion=15
variants="mysql pgsql sqlite3"
@@ -14,14 +40,41 @@ variants="mysql pgsql sqlite3"
dbc="usr/share/dbconfig-common/data"
extractor="debian/scripts/extract-dbupgrade.awk"
+set_longdb() {
+ if [ $db = pgsql ] ; then
+ longdb=postgresql
+ else
+ longdb=$db
+ fi
+}
+
+# handle older db upgrades
+while [ $dbtarget -le 12 ]; do
+ for db in $variants; do
+ set_longdb
+
+ case $dbtarget in
+ 11) baculaversion="3.0.0"
+ sourcefile="updatedb/update_"$longdb"_tables_10_to_11"
+ ;;
+ 12) baculaversion="5.0.0"
+ sourcefile="updatedb/update_"$longdb"_tables_11_to_12"
+ ;;
+ esac
+
+ targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/upgrade/"$db"/"$baculaversion;
+
+ mkdir -p `dirname $targetfile`
+ awk -v version=ignore -f $extractor $sourcefile >> $targetfile
+ done
+
+ dbtarget=$((dbtarget + 1))
+done
+# handle newer db upgrades
while [ $dbtarget -le $lastdbversion ]; do
for db in $variants; do
- if [ $db = pgsql ] ; then
- longdb=postgresql
- else
- longdb=$db
- fi
+ set_longdb
case $dbtarget in
13) baculaversion="5.2.0"
@@ -38,8 +91,20 @@ while [ $dbtarget -le $lastdbversion ]; do
sourcefile="src/cats/update_"$longdb"_tables"
targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/upgrade/"$db"/"$baculaversion;
+ mkdir -p `dirname $targetfile`
awk -v version=$dbtarget -f $extractor $sourcefile >> $targetfile
done
dbtarget=$((dbtarget + 1))
done
+
+# handle db creation
+for db in $variants; do
+ set_longdb
+
+ sourcefile="src/cats/make_"$longdb"_tables"
+ targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/install/"$db;
+
+ mkdir -p `dirname $targetfile`
+ awk -v version=ignore -f $extractor $sourcefile >> $targetfile
+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