[Dbconfig-common-devel] dbconfig-common/dpkg postinst,1.9,1.10 prerm,1.6,1.7
seanius@haydn.debian.org
seanius@haydn.debian.org
Update of /cvsroot/dbconfig-common/dbconfig-common/dpkg
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv3094/dpkg
Modified Files:
postinst prerm
Log Message:
* use the return status of the execute sql/script functions, not the
value of dbc_status, which is not consistant and probably on its way
out. thanks to tobias for pointing this out.
* return 0, not exit 0 in dbc_go functions, as it will otherwise
halt the entire maintainer script.
Index: postinst
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/postinst,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- postinst 30 Apr 2005 17:33:25 -0000 1.9
+++ postinst 1 May 2005 00:17:12 -0000 1.10
@@ -45,7 +45,7 @@
###
### if they don't want our help, quit
###
- if [ "$dbc_install" != "true" ]; then exit 0; fi
+ if [ "$dbc_install" != "true" ]; then return 0; fi
# export the config file if it exists, for the scripts
if [ "$dbc_generate_include" ]; then
@@ -72,12 +72,11 @@
# sqlfile is the file to use for installing the database, this is
dbc_sqlfile=$dbc_share/data/$dbc_package/install/$dbc_dbtype
dbc_scriptfile=$dbc_share/scripts/$dbc_package/install/$dbc_dbtype
- if [ -f $dbc_sqlfile -a ! "$dbc_dbstatus" = "nothing" ]; then
+ if [ -f "$dbc_sqlfile" ]; then
$dbc_sqlfile_cmd $dbc_sqlfile || dbc_install_error "populating database"
fi
- if [ -f $dbc_scriptfile -a ! "$dbc_dbstatus" = "nothing" ]; then
- # temporarily ignore non-zero exit vals so we can handle them
+ if [ -f "$dbc_scriptfile" ]; then
if ! sh -c "$dbc_scriptfile $*"; then
dbc_error="$dbc_scriptfile exited with non-zero status"
dbc_install_error "populating database"
@@ -123,7 +122,7 @@
dbc_write_package_config
# and if they don't want our help, we'll go away
- if [ "$dbc_upgrade" != "true" ]; then exit 0; fi
+ if [ "$dbc_upgrade" != "true" ]; then return 0; fi
###
### perform a few sanity checks on the data
@@ -140,11 +139,7 @@
for _dbc_f in $_dbc_upgrades_pending; do
# execute the script
echo dbconfig-common: upgrading with $_dbc_f >&2
- $dbc_sqlfile_cmd $_dbc_f
- # check for errors
- if [ "$dbc_status" = "error" ]; then
- upgrade_error "processing $_dbc_f"
- fi
+ $dbc_sqlfile_cmd $_dbc_f || upgrade_error "processing $_dbc_f"
done
# likewise for any scripts
@@ -152,11 +147,7 @@
_dbc_newvers=`basename $_dbc_f`
# execute the script
echo dbconfig-common: upgrading with $_dbc_f >&2
- set +e
- sh -c "$_dbc_f $*"
- _dbc_retval=$?
- set -e
- if [ $_dbc_retval -ne 0 ]; then
+ if ! sh -c "$_dbc_f $*"; then
dbc_error="$_dbc_f exited with non-zero status"
upgrade_error "processing $_dbc_f"
fi
Index: prerm
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/prerm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- prerm 24 Apr 2005 22:38:50 -0000 1.6
+++ prerm 1 May 2005 00:17:12 -0000 1.7
@@ -23,7 +23,7 @@
dbc_remove="$RET"
if [ "$dbc_remove" != "true" ]; then
- exit 0;
+ return 0;
fi
###
@@ -82,10 +82,7 @@
echo dbconfig-common: dumping $dbc_dbtype database $dbc_dbname to $_dbc_dbfile >&2
$dbc_dump_cmd > $_dbc_dbfile
echo dbconfig-common: dropping $dbc_dbtype database $dbc_dbname >&2
- $dbc_dropdb_cmd
- if [ "$dbc_status" = "error" ]; then
- remove_error "error encountered dropping database:"
- fi
+ $dbc_dropdb_cmd || remove_error "dropping database"
echo dbconfig-common: revoking privileges for user $dbc_dbuser on $dbc_dbname > /dev/stderr
$dbc_dropuser_cmd