[Dbconfig-common-changes] [dbconfig-common] r238 - in trunk: debian
dpkg
Sean Finney
seanius at costa.debian.org
Tue May 30 23:15:59 CEST 2006
Author: seanius
Date: 2006-05-30 21:15:59 +0000 (Tue, 30 May 2006)
New Revision: 238
Modified:
trunk/debian/changelog
trunk/dpkg/common
trunk/dpkg/config
trunk/dpkg/postinst
trunk/dpkg/postrm
trunk/dpkg/prerm
Log:
bug fixes etc
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/debian/changelog 2006-05-30 21:15:59 UTC (rev 238)
@@ -7,15 +7,17 @@
(closes: #366761).
* andrew mcmillan found a spelling error, so i ran aspell over all
the documentation :)
- * provide a new hint option dbc_default_authmethod_user for the packager
+ * provide a new hint option dbc_authmethod_user for the packager
to provide the "sane default" for how the application's database
user should authenticate for pgsql applications (closes: #368219).
+ we'll soon provide a better (automagic) detection, but it shouldn't
+ break things if you start using this feature before then.
* extra sanity check for a glob that might not expand in some circumstances,
from matt brown (closes: #368714).
* more code consolidation, configfile-vs-debconf fixes, removal of some
obsolete code/templates.
- -- sean finney <seanius at debian.org> Wed, 24 May 2006 18:21:06 +0200
+ -- sean finney <seanius at debian.org> Tue, 30 May 2006 23:15:35 +0200
dbconfig-common (1.8.13) unstable; urgency=low
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/dpkg/common 2006-05-30 21:15:59 UTC (rev 238)
@@ -19,7 +19,6 @@
dbc_command="$2"
dbc_oldversion="$3"
-
if ! _dbc_sanity_check package command; then
dbc_install_error "determining package or command";
fi
@@ -49,15 +48,16 @@
if [ -f $dbc_globalconfig ]; then
. $dbc_globalconfig
fi
- # and the package config
- dbc_read_package_config
+ dbc_set_dbtype_defaults $dbc_dbtype
+}
+
+dbc_set_dbtype_defaults(){
+ dbc_debug "dbc_set_dbtype_defaults() $@"
+
# if dbtype isn't set, but dbc_hardcoded_dbtype is set, set dbtype to that
if [ "$dbc_hardcoded_dbtype" ]; then
dbc_dbtype="$dbc_hardcoded_dbtype"
- # likewise for dbc_prompted_dbtype (result from debconf not yet written to disk)
- elif [ "$dbc_prompted_dbtype" ]; then
- dbc_dbtype="$dbc_prompted_dbtype"
fi
###
@@ -101,6 +101,7 @@
dbc_register_templates="$dbc_standard_templates $dbc_mysql_templates $dbc_pgsql_templates"
;;
esac
+
}
@@ -128,6 +129,11 @@
dbc_read_package_config(){
dbc_debug "dbc_read_package_config() $@"
_dbc_sanity_check package packageconfig || dbc_install_error
+
+ # first we set some defaults, which will be overridden by the config
+ dbc_install=true
+ dbc_upgrade=true
+
if [ -f $dbc_packageconfig ]; then
. $dbc_packageconfig
fi
@@ -148,15 +154,9 @@
### the "Debconf is Not a Registry" dilemma.
###
dbc_preseed_package_debconf(){
- dbc_debug "dbc_preseed_package_config() $@"
- _dbc_sanity_check package packageconfig || dbc_install_error
+ dbc_debug "dbc_preseed_package_debconf() $@"
+ _dbc_sanity_check package || dbc_install_error
- # if the package configuration does not exist then there is
- # nothing to preseed.
- if [ ! -f "$dbc_packageconfig" ]; then
- return 0
- fi
-
# set whether they want our help
db_set $dbc_package/dbconfig-install "$dbc_install"
db_set $dbc_package/dbconfig-upgrade "$dbc_upgrade"
@@ -168,9 +168,6 @@
# set app user
db_set $dbc_package/db/app-user "$dbc_dbuser"
- # set the app user password
- db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
-
# set the remote server/port
db_set $dbc_package/remote/host "$dbc_dbserver"
db_set $dbc_package/remote/port "$dbc_dbport"
@@ -178,10 +175,15 @@
# set the name of the database to be created
db_set $dbc_package/db/dbname "$dbc_dbname"
+ # a few db-specific things, don't preseed them if we don't know the dbtype yet
+ if [ ! "$dbc_dbtype" ]; then return 0 ; fi
+
+ # set the app user password
+ db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
+
# set the database administrator name
db_set $dbc_package/$dbc_dbtype/admin-user "$dbc_dbadmin"
- # a few db-specific things
case $dbc_dbtype in
"pgsql")
# get the psql authentication method
@@ -216,9 +218,11 @@
_dbc_sanity_check package || dbc_install_error
# gracefully fetch this to support multi-dbtype packages
- db_get $dbc_package/database-type && dbc_prompted_dbtype="$RET"
+ if [ "$dbc_dbtypes" ]; then
+ db_get $dbc_package/database-type && dbc_dbtype="$RET"
+ fi
# dbconfig needs to be reloaded at this point for multi-dbtype apps
- dbc_config $@
+ dbc_set_dbtype_defaults $dbc_dbtype
# just to make sure...
_dbc_sanity_check dbtype || dbc_install_error
@@ -267,7 +271,7 @@
### dump package configuration to a config file
###
dbc_write_package_config(){
- local iformat ofile warn tfile
+ local iformat ofile tfile
dbc_debug "dbc_write_package_config() $@"
_dbc_sanity_check packageconfig || dbc_install_error
echo "dbconfig-common: writing config to $dbc_packageconfig" >&2
@@ -275,16 +279,9 @@
tfile=`mktemp -t dbconfig-package-config.XXXXXX`
# a quick check if this is a multi-dbtype app
- if [ "$dbc_prompted_dbtype" ]; then
- dbc_chosen_dbtype=$dbc_prompted_dbtype;
- elif [ "$dbc_hardcoded_dbtype" ]; then
- dbc_chosen_dbtype="$dbc_hardcoded_dbtype"
- warn="yes"
+ if [ "$dbc_hardcoded_dbtype" ]; then
+ dbc_dbtype="$dbc_hardcoded_dbtype"
fi
- # yes, the single quotes here are intentional
- if [ "$dbc_chosen_dbtype" = '${database_type}' ]; then
- dbc_chosen_dbtype=""
- fi
# and a check for ssl
if [ "$dbc_method" = "tcp/ip + ssl" ]; then
dbc_ssl="true"
@@ -313,7 +310,7 @@
# type to use when a package supports multiple database types.
# don't change this value unless you know for certain that this
# package supports multiple database types
-dbc_dbtype="$dbc_chosen_dbtype"
+dbc_dbtype="$dbc_dbtype"
# dbc_dbuser: database user
# the name of the user who we will use to connect to the database.
@@ -665,51 +662,48 @@
}
##
-## determine whether a db is supported by a package and installed on the system
+## determine whether a db is supported by a package
##
-dbc_detect_dbtype(){
+dbc_detect_supported_dbtype(){
local query_dbtype
- dbc_debug "dbc_detect_dbtype() $@"
+ dbc_debug "dbc_detect_supported_dbtype() $@"
query_dbtype=$1
- dbc_dbtype_supported="no"
- dbc_dbtype_installed="no"
# see if the package says it's supported
- if echo $dbc_dbconfig_dbtypes | grep -qE "(^|,[[:space:]]*)$query_dbtype(\$|,)"; then
- dbc_dbtype_supported="yes"
+ if echo $dbc_dbtypes | grep -qE "(^|,[[:space:]]*)$query_dbtype(\$|,)"; then
+ return 0
fi
+ return 1
+}
+##
+## determine whether a db is installed on the system
+##
+dbc_detect_installed_dbtype(){
+ local query_dbtype testfile
+ dbc_debug "dbc_detect_installed_dbtype() $@"
+ query_dbtype=$1
+
# see if the dbtype is already installed. this is not 100% accurate
- if [ "$dbc_dbtype_supported" = "yes" ]; then
- case $query_dbtype in
- "mysql")
- if [ -f /usr/bin/mysql ]; then
- dbc_dbtype_installed="yes"
- fi
- ;;
- "pgsql")
- if [ -f /usr/bin/psql ]; then
- dbc_dbtype_installed="yes"
- fi
- ;;
- "")
- ;;
- esac
- fi
+ case $query_dbtype in
+ "mysql") testfile='/usr/bin/mysql'
+ ;;
+ "pgsql") testfile='/usr/bin/psql'
+ ;;
+ "")
+ ;;
+ esac
+
+ [ "$testfile" ] && test -f $testfile && return 0
+ return 1
}
###
### register all the necessary debconf templates
###
dbc_register_debconf(){
- local f local authmethod_user
+ local f local
dbc_debug "dbc_register_debconf() $@"
- if [ "$dbc_default_authmethod_user" = "password" ]; then
- authmethod_user="password"
- else
- authmethod_user="ident"
- fi
-
for f in $dbc_register_templates; do
# perform some basic customizing substitutions
db_register dbconfig-common/$f $dbc_package/$f
@@ -718,4 +712,7 @@
db_subst $dbc_package/$f dbvendor $dbc_dbvendor
fi
done
+ if [ "$dbc_dbtypes" ]; then
+ db_subst $dbc_package/database-type database_types $dbc_dbtypes
+ fi
}
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/dpkg/config 2006-05-30 21:15:59 UTC (rev 238)
@@ -12,7 +12,7 @@
db_capb backup
# only do this on install/reconfigure
- if [ "$dbc_command" != "configure" -a "$dbc_command" != "reconfigure" ];
+ if [ "$dbc_command" != "configure" ] && [ "$dbc_command" != "reconfigure" ];
then
return 0
fi
@@ -23,6 +23,7 @@
dbc_register_debconf
# make sure debconf is up to date with on-disk configuration
+ dbc_read_package_config
dbc_preseed_package_debconf
# and start our beautiful state-machine
@@ -31,7 +32,7 @@
case "$STATE" in
# state 1 - ask if they want our help at all
1)
- db_input medium $dbc_package/dbconfig-install || true
+ db_input high $dbc_package/dbconfig-install || true
;;
# state 2 - check to see if they do.
# - see if this is an upgrade newly supporting dbc
@@ -81,61 +82,43 @@
##
## start multidb section
##
-
- # check to see if there's a dbtype answer already in debconf
- db_get $dbc_package/database-type && dbc_prompted_dbtype="$RET"
-
# if the dbtype is hardcoded (using config.mysql, etc), use that
if [ "$dbc_hardcoded_dbtype" ]; then
dbc_dbtype=$dbc_hardcoded_dbtype
- # if dbc_dbtype is set (from above or in conf), don't bother
- elif [ "$dbc_dbtype" ]; then
- true
- # else see if they've already told us what to use, use that
- elif [ "$dbc_prompted_dbtype" ]; then
- dbc_dbtype=$dbc_prompted_dbtype
- fi
-
- # if the package supports multiple dbtypes, help them pick one
- if [ "$dbc_dbtypes" ]; then
+ # else if the package supports multiple dbtypes, help them pick one
+ elif [ "$dbc_dbtypes" ]; then
# loop through all available dbtypes
for db in $dbc_all_supported_dbtypes; do
- # check to see $db is supported
- dbc_detect_dbtype $db
# if we're already happy, we're already done
if [ "$happy" ]; then
true
- # else, if it's installed and unpacked, we're happy
- elif [ "$dbc_dbtype_installed" = "yes" ]; then
- default_dbtype=$db
- happy="yes"
- # else if it's supported and there's nothing better...
- elif [ "$dbc_dbtype_supported" = "yes" ]; then
- if [ ! "$default_dbtype" ]; then
- default_dbtype=$db
+ # else, if it's supported, installed and unpacked, we're happy
+ elif dbc_detect_supported_dbtype $db; then
+ # if it's installed, we're happy
+ if dbc_detect_installed_dbtype $db; then
+ happy="yes"
fi
+ # but in any case it's be the default even if not happy
+ default_dbtype=$db
fi
# otherwise, there's no default yet, which is okay
done
# now that we're done with that, actually do the debconf stuff
- db_subst $dbc_package/database-type database_types "$dbc_dbtypes"
- # if dbc_dbtype is already set (from conf file) then
- # use that as a default, otherwise use our best guess
- if [ "$dbc_dbtype" ]; then
- default_dbtype="$dbc_dbtype"
+ # if dbc_dbtype isn't already set (from conf file) then
+ # use the default as our best guess
+ if [ ! "$dbc_dbtype" ]; then
+ dbc_dbtype="$default_dbtype"
fi
- db_set $dbc_package/database-type "$default_dbtype"
+ db_set $dbc_package/database-type "$dbc_dbtype"
db_input high $dbc_package/database-type || true
fi
;;
# state 3 - multidb support part 2, pre-seeding, get conn. method
3)
if [ "$dbc_dbtypes" ]; then
- db_get $dbc_package/database-type
- dbc_prompted_dbtype="$RET"
-
+ db_get $dbc_package/database-type && dbc_dbtype="$RET"
# now that we have a dbtype, reload common to set other defaults
dbc_config $@
fi
Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/dpkg/postinst 2006-05-30 21:15:59 UTC (rev 238)
@@ -2,24 +2,24 @@
### load up common variables and functions
###
dbc_go(){
- local prev_dbc_upgrade importing_from_non_dbc upgrading f tsubstfile upgrades_pending dumpfile _dbc_asuser
+ local prev_dbc_upgrade importing_from_non_dbc upgrading reconfiguring f tsubstfile upgrades_pending dumpfile _dbc_asuser
. /usr/share/dbconfig-common/dpkg/common
dbc_debug "(postinst) dbc_go() $@"
-
dbc_config $@
- # read in debconf responses (which are seeded from the config)
- dbc_read_package_debconf $@
- # and write them to file.
- dbc_write_package_config
- # finally, read in the configuration from this file
- dbc_read_package_config
###
### begin main code execution
###
- if [ "$dbc_command" = "configure" -o "$dbc_command" = "reconfigure" ];
+ if [ "$dbc_command" = "configure" ] || [ "$dbc_command" = "reconfigure" ];
then
+ # read in debconf responses (which are seeded from the config)
+ dbc_read_package_debconf
+ # and write them to file.
+ dbc_write_package_config
+ # finally, re-read in the configuration from this file
+ dbc_read_package_config
+
###
### if they don't want our help, quit
###
@@ -36,9 +36,9 @@
# find out if we're upgrading/reinstalling
if [ "$dbc_oldversion" ]; then
# read that little crumb left in config if we're reconfiguring
- db_get $dbc_package/internal/reconfiguring
+ db_get $dbc_package/internal/reconfiguring && reconfiguring="$RET"
# if not, we're definitely upgrading
- if [ "$RET" = "false" ]; then
+ if [ "$reconfiguring" = "false" ]; then
upgrading="yes"
fi
# and set it back to false
@@ -116,7 +116,7 @@
fi
fi
- # end install/reconfigure section
+ # end install/reconfigure section
if [ "$importing_from_non_dbc" ]; then
if ! $dbc_checkuser_command; then
@@ -125,7 +125,7 @@
fi
fi
- # begin upgrade section
+ # begin upgrade section
if [ "$upgrading" ]; then
@@ -133,19 +133,14 @@
# if there are any upgrades to be applied
if [ "$upgrades_pending" ]; then
-
# ask if they want our help in the process at all
prev_dbc_upgrade="$dbc_upgrade"
+ db_set $dbc_package/dbconfig-upgrade $dbc_upgrade
db_fset $dbc_package/dbconfig-upgrade seen false
db_input high $dbc_package/dbconfig-upgrade || true
db_go || true
db_get $dbc_package/dbconfig-upgrade && dbc_upgrade="$RET"
- # if their answer has changed, synchronize config to disk
- if [ "$prev_dbc_upgrade" != "$dbc_upgrade" ]; then
- dbc_write_package_config
- fi
-
# and if they don't want our help, we'll go away
if [ "$dbc_upgrade" != "true" ]; then return 0; fi
Modified: trunk/dpkg/postrm
===================================================================
--- trunk/dpkg/postrm 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/dpkg/postrm 2006-05-30 21:15:59 UTC (rev 238)
@@ -6,7 +6,10 @@
dbc_debug "(postrm) dbc_go() $@"
dbc_config $@
- if [ "$dbc_command" = "purge" ]; then
+ if [ "$dbc_command" = "upgrade" ]; then
+ dbc_read_package_config
+ dbc_preseed_package_debconf
+ elif [ "$dbc_command" = "purge" ]; then
# remove the dbc configuration file
rm -f /etc/dbconfig-common/$dbc_package.conf || true
ucf -p "/etc/dbconfig-common/$dbc_package.conf" || true
Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm 2006-05-30 12:35:37 UTC (rev 237)
+++ trunk/dpkg/prerm 2006-05-30 21:15:59 UTC (rev 238)
@@ -13,6 +13,8 @@
### get all the settings we need
###
dbc_read_package_config
+ # and re-run config for db-specific settings
+ dbc_set_dbtype_defaults $dbc_dbtype
need_admin_pw="yup"
@@ -59,7 +61,7 @@
if [ ! -f $dumpfile ]; then
dbc_remove_error "creating temporary file for database dump"
fi
- dbc_logline "dbconfig-common: dumping $dbc_dbtype database $dbc_dbname to $_dbc_dbfile"
+ dbc_logline "dbconfig-common: dumping $dbc_dbtype database $dbc_dbname to $dumpfile"
$dbc_dump_cmd > $dumpfile || dbc_remove_error "dumping database"
dbc_logline "dbconfig-common: dropping $dbc_dbtype database $dbc_dbname"
$dbc_dropdb_cmd || dbc_remove_error "dropping database"
More information about the Dbconfig-common-changes
mailing list