[Dbconfig-common-changes] [dbconfig-common] r265 - trunk/dpkg
Matt Brown
mattb-guest at costa.debian.org
Sat Jun 17 10:30:45 CEST 2006
Author: mattb-guest
Date: 2006-06-17 08:30:44 +0000 (Sat, 17 Jun 2006)
New Revision: 265
Modified:
trunk/dpkg/common
trunk/dpkg/config
trunk/dpkg/prerm
Log:
Merge the portions of the SQLite branch onto the trunk
Specifically this merges the bits that deal with conditionalising the use
of debconf templates that relate to authentication or remote hosts.
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-06-17 07:54:35 UTC (rev 264)
+++ trunk/dpkg/common 2006-06-17 08:30:44 UTC (rev 265)
@@ -42,6 +42,12 @@
# all dbtypes supported by dbconfig-common
dbc_all_supported_dbtypes="mysql pgsql"
+ # database types supporting authenticated access
+ dbc_authenticated_dbtypes="mysql pgsql"
+
+ # database types supporting remote access
+ dbc_remote_dbtypes="mysql pgsql"
+
###
### source the pre-existing config, if it exists
###
@@ -178,24 +184,28 @@
# set the dbtype
db_set $dbc_package/database-type "$dbc_dbtype"
- # set app user
- db_set $dbc_package/db/app-user "$dbc_dbuser"
+ # 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 remote server/port
- db_set $dbc_package/remote/host "$dbc_dbserver"
- db_set $dbc_package/remote/port "$dbc_dbport"
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ # set app user
+ db_set $dbc_package/db/app-user "$dbc_dbuser"
- # set the name of the database to be created
- db_set $dbc_package/db/dbname "$dbc_dbname"
+ # set the app user password
+ db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
- # 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 database administrator name
+ db_set $dbc_package/$dbc_dbtype/admin-user "$dbc_dbadmin"
+ fi
- # set the app user password
- db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ # set the remote server/port
+ db_set $dbc_package/remote/host "$dbc_dbserver"
+ db_set $dbc_package/remote/port "$dbc_dbport"
+ fi
- # set the database administrator name
- db_set $dbc_package/$dbc_dbtype/admin-user "$dbc_dbadmin"
+ # set the name of the database to be created
+ db_set $dbc_package/db/dbname "$dbc_dbname"
case $dbc_dbtype in
"pgsql")
@@ -245,25 +255,30 @@
db_get $dbc_package/dbconfig-upgrade && dbc_upgrade="$RET"
db_get $dbc_package/dbconfig-remove && dbc_remove="$RET"
- # get app user
- db_get $dbc_package/db/app-user && dbc_dbuser="$RET"
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ # get app user
+ db_get $dbc_package/db/app-user && dbc_dbuser="$RET"
- # get the app user password
- db_get $dbc_package/$dbc_dbtype/app-pass && dbc_dbpass="$RET"
+ # get the app user password
+ db_get $dbc_package/$dbc_dbtype/app-pass && dbc_dbpass="$RET"
- # get the db server/port
- db_get $dbc_package/remote/host && dbc_dbserver="$RET"
- db_get $dbc_package/remote/port && dbc_dbport="$RET"
+ # get the database administrator name
+ db_get $dbc_package/$dbc_dbtype/admin-user && dbc_dbadmin="$RET"
+ # get the database administrator pass
+ db_get $dbc_package/$dbc_dbtype/admin-pass && dbc_dbadmpass="$RET"
+ fi
+
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+
+ # get the db server/port
+ db_get $dbc_package/remote/host && dbc_dbserver="$RET"
+ db_get $dbc_package/remote/port && dbc_dbport="$RET"
+ fi
+
# get the name of the database to be created
db_get $dbc_package/db/dbname && dbc_dbname="$RET"
- # get the database administrator name
- db_get $dbc_package/$dbc_dbtype/admin-user && dbc_dbadmin="$RET"
-
- # get the database administrator pass
- db_get $dbc_package/$dbc_dbtype/admin-pass && dbc_dbadmpass="$RET"
-
# a few db-specific things
case $dbc_dbtype in
"pgsql")
@@ -666,12 +681,14 @@
##
dbc_postinst_cleanup(){
dbc_debug "dbc_postinst_cleanup() $@"
- if [ "$dbc_remember_admin_pass" != "true" ]; then
- dbc_forget_dbadmin_password
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ if [ "$dbc_remember_admin_pass" != "true" ]; then
+ dbc_forget_dbadmin_password
+ fi
+ if [ "$dbc_remember_app_pass" != "true" ]; then
+ dbc_forget_app_password
+ fi
fi
- if [ "$dbc_remember_app_pass" != "true" ]; then
- dbc_forget_app_password
- fi
}
##
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-06-17 07:54:35 UTC (rev 264)
+++ trunk/dpkg/config 2006-06-17 08:30:44 UTC (rev 265)
@@ -76,17 +76,27 @@
if [ "$dbc_load_include" ] && [ -f "$ifile" ]; then
db_input high $dbc_package/import-oldsettings || true
eval `dbconfig-load-include $dbc_load_include_args -f $iformat $ifile`
- for f in database-type $dbc_dbtype/method remote/host remote/newhost remote/port pgsql/authmethod-admin pgsql/authmethod-user $dbc_dbtype/admin-user db/app-user db/dbname; do
+ for f in database-type $dbc_dbtype/method db/dbname; do
db_fset $dbc_package/$f seen true || true
done
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ for f in pgsql/authmethod-admin pgsql/authmethod-user $dbc_dbtype/admin-user db/app-user; do
+ db_fset $dbc_package/$f seen true || true
+ done
+ db_set $dbc_package/db/app-user "$dbc_dbuser"
+ db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
+ db_set $dbc_package/password-confirm "$dbc_dbpass"
+ fi
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ for f in remote/host remote/newhost remote/port ; do
+ db_fset $dbc_package/$f seen true || true
+ done
+ db_set $dbc_package/remote/host "$dbc_dbserver"
+ db_set $dbc_package/remote/port "$dbc_dbport"
+ fi
db_set $dbc_package/database-type $dbc_dbtype
- db_set $dbc_package/db/app-user "$dbc_dbuser"
db_set $dbc_package/db/dbname "$dbc_dbname"
- db_set $dbc_package/remote/host "$dbc_dbserver"
- db_set $dbc_package/remote/port "$dbc_dbport"
- db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
- db_set $dbc_package/password-confirm "$dbc_dbpass"
fi
fi
@@ -134,8 +144,8 @@
dbc_config $@
fi
- # there's a bit more to do with client/server rdbms
- if [ "$dbc_dbtype" = "mysql" -o "$dbc_dbtype" = "pgsql" ]; then
+ # there's a bit more to do with rdbms that support authentication
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
# if these haven't been specified, use defaults
if [ ! "$dbc_dbadmin" ]; then
dbc_dbadmin="$dbc_default_admin";
@@ -143,112 +153,121 @@
if [ ! "$dbc_dbuser" ]; then
dbc_dbuser="$dbc_default_dbuser"
fi
- if [ ! "$dbc_dbname" ]; then
- dbc_dbname=`echo $dbc_package | tr -d +-.`;
- fi
fi
+ if [ ! "$dbc_dbname" ]; then
+ dbc_dbname=`echo $dbc_package | tr -d +-.`;
+ fi
+
# pre-seed any already defined values into debconf as defaults
+ db_set $dbc_package/db/dbname "$dbc_dbname"
if [ "$dbc_upgrade" ]; then
db_set $dbc_package/dbconfig-upgrade "$dbc_upgrade"
fi
if [ "$dbc_remove" ]; then
db_set $dbc_package/dbconfig-remove "$dbc_remove"
- fi
- if [ "$dbc_dbuser" ]; then
- db_set $dbc_package/db/app-user "$dbc_dbuser"
- fi
- if [ "$dbc_dbpass" ]; then
- db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
- db_fset $dbc_package/$dbc_dbtype/app-pass seen true
- db_set $dbc_package/app-password-confirm "$dbc_dbpass"
- db_fset $dbc_package/app-password-confirm seen true
- fi
- if [ "$dbc_dbname" ]; then
- db_set $dbc_package/db/dbname "$dbc_dbname"
- fi
- if [ "$dbc_dbserver" ]; then
- db_set $dbc_package/remote/host "$dbc_dbserver"
fi
- if [ "$dbc_dbport" ]; then
- db_set $dbc_package/remote/port "$dbc_dbport"
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ if [ "$dbc_dbuser" ]; then
+ db_set $dbc_package/db/app-user "$dbc_dbuser"
+ fi
+ if [ "$dbc_dbpass" ]; then
+ db_set $dbc_package/$dbc_dbtype/app-pass "$dbc_dbpass"
+ db_fset $dbc_package/$dbc_dbtype/app-pass seen true
+ db_set $dbc_package/app-password-confirm "$dbc_dbpass"
+ db_fset $dbc_package/app-password-confirm seen true
+ fi
+ if [ "$dbc_dbadmin" ]; then
+ db_set $dbc_package/$dbc_dbtype/admin-user "$dbc_dbadmin"
+ fi
fi
- if [ "$dbc_dbadmin" ]; then
- db_set $dbc_package/$dbc_dbtype/admin-user "$dbc_dbadmin"
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ if [ "$dbc_dbserver" ]; then
+ db_set $dbc_package/remote/host "$dbc_dbserver"
+ fi
+ if [ "$dbc_dbport" ]; then
+ db_set $dbc_package/remote/port "$dbc_dbport"
+ fi
+ if [ "$dbc_ssl" = "true" -a "$dbc_dbtype" = "pgsql" ]; then
+ db_set $dbc_package/pgsql/method "tcp/ip + ssl"
+ fi
+ db_input $dbc_remote_questions_priority $dbc_package/$dbc_dbtype/method || true
fi
- if [ "$dbc_ssl" = "true" -a "$dbc_dbtype" = "pgsql" ]; then
- db_set $dbc_package/pgsql/method "tcp/ip + ssl"
- fi
- db_input $dbc_remote_questions_priority $dbc_package/$dbc_dbtype/method || true
;;
# state 4 - do stuff based on the connection method
4)
db_get $dbc_package/$dbc_dbtype/method && dbc_method="$RET"
- # if package/method == tcp/ip or tcp/ip + ssl
- if [ "$dbc_method" != "unix socket" ]; then
- # look at the hosts used in any other dbconfig-using
- # package, and create a list of hosts.
- _preconf_list=` (
- for f in /etc/dbconfig-common/*.conf; do
- test -f $f || continue
- eval \`dbconfig-generate-include --dbserver=_s $f | grep -v '^#'\`
- [ "$_s" ] && echo $_s
- done
- ) | sort | uniq`
- # turn the list into a comma separated list if it exists
- # and then substitute it into the list of available hosts
- if [ "$_preconf_list" ]; then
- _preconf_list=`echo $_preconf_list | sed -e 's/ /, /g'`
- _preconf_list="new host, $_preconf_list"
- db_subst $dbc_package/remote/host hosts "$_preconf_list"
- # and then ask them for one
- db_input high $dbc_package/remote/host || true
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ # if package/method == tcp/ip or tcp/ip + ssl
+ if [ "$dbc_method" != "unix socket" ]; then
+ # look at the hosts used in any other dbconfig-using
+ # package, and create a list of hosts.
+ _preconf_list=` (
+ for f in /etc/dbconfig-common/*.conf; do
+ test -f $f || continue
+ eval \`dbconfig-generate-include --dbserver=_s $f | grep -v '^#'\`
+ [ "$_s" ] && echo $_s
+ done
+ ) | sort | uniq`
+ # turn the list into a comma separated list if it exists
+ # and then substitute it into the list of available hosts
+ if [ "$_preconf_list" ]; then
+ _preconf_list=`echo $_preconf_list | sed -e 's/ /, /g'`
+ _preconf_list="new host, $_preconf_list"
+ db_subst $dbc_package/remote/host hosts "$_preconf_list"
+ # and then ask them for one
+ db_input high $dbc_package/remote/host || true
+ fi
+ # but if it is unix socket, forget all the host stuff
+ else
+ db_reset $dbc_package/remote/host || true
+ db_reset $dbc_package/remote/newhost || true
+ db_reset $dbc_package/remote/port || true
fi
- # but if it is unix socket, forget all the host stuff
- else
- db_reset $dbc_package/remote/host || true
- db_reset $dbc_package/remote/newhost || true
- db_reset $dbc_package/remote/port || true
fi
;;
# state 5 - get host / port info if necessary
5)
- if [ "$dbc_method" != "unix socket" ]; then
- if [ "$_preconf_list" ]; then
- db_get $dbc_package/remote/host
- host=$RET
- fi
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ if [ "$dbc_method" != "unix socket" ]; then
+ if [ "$_preconf_list" ]; then
+ db_get $dbc_package/remote/host
+ host=$RET
+ fi
- # if they've chosen "new host" or the host list was empty
- if [ ! "$host" -o "$host" = "new host" ]; then
- # prompt them for a new hostname
- db_input high $dbc_package/remote/newhost || true
+ # if they've chosen "new host" or the host list was empty
+ if [ ! "$host" -o "$host" = "new host" ]; then
+ # prompt them for a new hostname
+ db_input high $dbc_package/remote/newhost || true
+ fi
fi
fi
;;
# state 6 - do stuff based on host/port selection
6)
- if [ "$dbc_method" != "unix socket" ]; then
- if [ ! "$host" -o "$host" = "new host" ]; then
- db_get $dbc_package/remote/newhost
- newhost="$RET"
+ if echo "$dbc_remote_dbtypes" | grep -q "$dbc_dbtype"; then
+ if [ "$dbc_method" != "unix socket" ]; then
+ if [ ! "$host" -o "$host" = "new host" ]; then
+ db_get $dbc_package/remote/newhost
+ newhost="$RET"
- # add the new host to the existing list of hosts
- db_metaget $dbc_package/remote/host choices
- oldhosts="$RET"
- db_subst $dbc_package/remote/host hosts "$oldhosts, $newhost"
- db_set $dbc_package/remote/host "$newhost"
- db_fset $dbc_package/remote/host seen true
- else
- # set the "newhost" to the selected host, because
- # the second time through the configure script we'll
- # need this set
- db_set $dbc_package/remote/newhost "$host"
+ # add the new host to the existing list of hosts
+ db_metaget $dbc_package/remote/host choices
+ oldhosts="$RET"
+ db_subst $dbc_package/remote/host hosts "$oldhosts, $newhost"
+ db_set $dbc_package/remote/host "$newhost"
+ db_fset $dbc_package/remote/host seen true
+ else
+ # set the "newhost" to the selected host, because
+ # the second time through the configure script we'll
+ # need this set
+ db_set $dbc_package/remote/newhost "$host"
+ fi
+
+ # on what port?
+ db_input $dbc_remote_questions_priority $dbc_package/remote/port || true
fi
-
- # on what port?
- db_input $dbc_remote_questions_priority $dbc_package/remote/port || true
fi
;;
# state 7 - pgsql specific auth stuff, part 1
@@ -277,15 +296,19 @@
;;
# state 9 - admin/app user/pass, dbname
9)
- # who's the admin user (is there any reason to even ask this?)
- # TODO: should there be a difference between the local and remote admin?
- db_input low $dbc_package/$dbc_dbtype/admin-user || true
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
- if [ "$need_adminpw" != "false" ]; then
- dbc_get_admin_pass
+ # who's the admin user (is there any reason to even ask this?)
+ # TODO: should there be a difference between the local and
+ # remote admin?
+ db_input low $dbc_package/$dbc_dbtype/admin-user || true
+ if [ "$need_adminpw" != "false" ]; then
+ dbc_get_admin_pass
+ fi
+ db_input low $dbc_package/db/app-user || true
+ dbc_get_app_pass
+
fi
- db_input low $dbc_package/db/app-user || true
- dbc_get_app_pass
# get the name of the database to use
db_input low $dbc_package/db/dbname || true
Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm 2006-06-17 07:54:35 UTC (rev 264)
+++ trunk/dpkg/prerm 2006-06-17 08:30:44 UTC (rev 265)
@@ -16,7 +16,11 @@
# and re-run config for db-specific settings
dbc_set_dbtype_defaults $dbc_dbtype
- need_admin_pw="yup"
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ need_admin_pw="yup"
+ else
+ need_admin_pw=""
+ fi
if [ "$dbc_command" = "remove" ]; then
###
More information about the Dbconfig-common-changes
mailing list