[Dbconfig-common-devel] dbconfig-common/dpkg common,1.7,1.8 config,1.7,1.8

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-serv1678/dpkg

Modified Files:
	common config 
Log Message:
the overall featureset is now more or less complete.  what's left to
do is some documentation and testing/bug hunting.  then comes the
experimental upload...


Index: common
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/common,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- common	23 Feb 2005 05:39:59 -0000	1.7
+++ common	25 Feb 2005 05:57:04 -0000	1.8
@@ -192,7 +192,7 @@
 ### dump package configuration to a config file
 ###
 dbc_write_package_config(){
-	local iformat ofile
+	local iformat ofile warn
 	_dbc_sanity_check packageconfig || dbc_install_error
 	echo "dbconfig-common: writing config to $dbc_packageconfig" >&2
 
@@ -200,7 +200,8 @@
 	if [ "$dbc_prompted_dbtype" ]; then
 		dbc_chosen_dbtype=$dbc_prompted_dbtype; 
 	elif [ "$dbc_hardcoded_dbtype" ]; then
-		dbc_chosen_dbtype=""
+		dbc_chosen_dbtype="$dbc_hardcoded_dbtype"
+		warn="yes"
 	fi
 	# yes, the single quotes here are intentional
 	if [ "$dbc_chosen_dbtype" = '${database_type}' ]; then
@@ -232,8 +233,8 @@
 # dbc_dbtype: type of underlying database to use
 #	this exists primarily to let dbconfig-common know what database
 #	type to use when a package supports multiple database types.  if this
-#	option is blank, you probably want to leave it that way because your
-#	package may not support other database types at all.
+#	don't change this value unless you know for certain that this
+#	package supports multiple database types
 dbc_dbtype="$dbc_chosen_dbtype"
 
 # dbc_dbuser: database user

Index: config
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/config,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- config	23 Feb 2005 05:39:59 -0000	1.7
+++ config	25 Feb 2005 05:57:04 -0000	1.8
@@ -3,7 +3,7 @@
 ###
 
 dbc_go(){
-	local db happy default_dbtype host newhost port oldhosts authmethod_user authmethod_admin do_config need_adminpw need_userpw
+	local db happy default_dbtype host newhost port oldhosts authmethod_user authmethod_admin do_config need_adminpw need_userpw f _preconf_list _s _t
 	. /usr/share/dbconfig-common/dpkg/common
 	dbc_config $@
 
@@ -36,17 +36,6 @@
 		fi
 
 		###
-		### pre-configured choices selection section
-		###
-		# local _dsn
-		# for f in /etc/dbconfig-common/*.conf; do
-		#	eval `dbconfig-generate-include -D _dsn $f | grep -v'^#'`
-		# 	add selection to set of choices
-		# done
-		# prompt for a pre-selected server, if at least one was found
-		# if they choose one, use it, else continue
-
-		###
 		### multi dbtype support section
 		###
 		# check to see if there's an answer in debconf
@@ -146,39 +135,53 @@
 		db_get $dbc_package/$dbc_dbtype/method && dbc_method="$RET"
 
 		# if package/method == tcp/ip or tcp/ip + ssl
-		if [ "$dbc_connection_method" != "unix socket" ]; then
-			# if no hosts have ever been selected, 
-			# this would be set to '${hosts}' (literally)
-			db_metaget $dbc_package/$dbc_dbtype/host hosts
-			if [ ! "$RET" ]; then
-				db_subst $dbc_package/$dbc_dbtype/host hosts "new host"
+		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
+				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
+			# and then ask them for one
+			if [ "$_preconf_list" ]; then
+				_preconf_list=`echo $_preconf_list | sed -e 's/ /, /g'`
+				_preconf_list="new host, $_preconf_list"
+				db_subst $dbc_package/$dbc_dbtype/host hosts "$_preconf_list"
+				# choose from a list of remote hosts 
+				db_input high $dbc_package/$dbc_dbtype/host || true
+				db_go || true
+				db_get $dbc_package/$dbc_dbtype/host 
+				host=$RET
 			fi
 
-			# choose from a list of remote hosts (if the list exists)
-			db_input high $dbc_package/$dbc_dbtype/host || true
-			db_go || true
-			db_get $dbc_package/$dbc_dbtype/host 
-			host=$RET
-
 			# if they've chosen "new host" or the host list was empty
-			if [ "$host" = "new host" ]; then
+			if [ ! "$host" -o "$host" = "new host" ]; then
 				# prompt them for a new hostname
 				db_input high $dbc_package/$dbc_dbtype/newhost || true
 				db_go || true
 				db_get $dbc_package/$dbc_dbtype/newhost 
 				newhost="$RET"
 
-				# prompt them for a new hostname
+				# on what port?
 				db_input low $dbc_package/$dbc_dbtype/port || true
 				db_go || true
 				db_get $dbc_package/$dbc_dbtype/port 
 				port=$RET
 
-				# get the existing list of hosts
+				# add the new host to the existing list of hosts
 				db_metaget $dbc_package/$dbc_dbtype/host choices
 				oldhosts="$RET"
 				db_subst $dbc_package/$dbc_dbtype/host hosts "$oldhosts, $newhost"
 				db_set $dbc_package/$dbc_dbtype/host "$newhost"
+			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/$dbc_dbtype/newhost "$host"
 			fi
 		fi