Package: dbconfig-common
Version: 1.8.45
Severity: wishlist
Tags: patch
Sometimes, I feel more flexibility is needed concerning:
- the order of execution of scripts/data
- the order of execution of elements therein
I.e. for now it is hardcoded that scripts are run first and then data
snippets are applied. What if I need to do the inverse?
Furthermure, for an upgrade to one version I can only specify one file
that would have to contain all the snippets. I'd opt for a conf.d-style
approach.
For the first wish, I wouldn't know right know how to fix.
For the second wish I am attaching an idea of a patch for the script files.
Oh maybe one could even generalize this $(find) to go over all the files
in the data/scripts directories, sort them and then execute/apply them
one after the other in whatever order they occur. That would solve both
problems and one could even
- apply data
- run a script
- apply more data
- run more scripts
- ...
(Might be less transparent though.)
Regards,
JM
--- /usr/share/dbconfig-common/dpkg/postinst.orig 2010-03-19
03:45:42.000000000 +0000
+++ /usr/share/dbconfig-common/dpkg/postinst 2010-03-19 03:57:09.000000000
+0000
@@ -282,19 +282,19 @@
vers="$1"
sqlfile="$dbc_share/data/$dbc_basepackage/upgrade/$dbc_dbtype/$vers"
admsqlfile="$dbc_share/data/$dbc_basepackage/upgrade-dbadmin/$dbc_dbtype/$vers"
-
scriptfile="$dbc_share/scripts/$dbc_basepackage/upgrade/$dbc_dbtype/$vers"
+ scriptfilepath="$dbc_share/scripts/$dbc_basepackage/upgrade/$dbc_dbtype"
# now go through script updates
- if [ -f "$scriptfile" ]; then
- dbc_logline "applying upgrade script for $dbc_oldversion ->
$vers"
+ for scriptfile in $(find "$scriptfilepath" -name "$vers*" -type f |
sort); do
+ dbc_logline "applying upgrade script for $dbc_oldversion ->
$vers: ${scriptfile#$scriptfilepath/}"
# XXX $*
if ! sh -c "$scriptfile $*"; then
dbc_error="$scriptfile exited with non-zero status"
dbc_upgrade_error "processing $scriptfile"
[ "$dbc_tried_again" ] && return 0
fi
- fi
+ done
_dbc_asuser=""
if [ -f "$admsqlfile" ]; then