[Dbconfig-common-devel] dbconfig-common/dpkg common, 1.31, 1.32 config, 1.21, 1.22 postinst, 1.16, 1.17 preinst, 1.4, 1.5

seanius at haydn.debian.org seanius at haydn.debian.org
Wed Aug 24 23:37:17 UTC 2005


Update of /cvsroot/dbconfig-common/dbconfig-common/dpkg
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv5282/dpkg

Modified Files:
	common config postinst preinst 
Log Message:
note that the second of these is not yet fully tested, so no release
just yet.  

    - add support for 'template' output format in dbc_generate_include.
    - dbc no longer provides preinst hooks, as we can't promise
      dbconfig-common will be there without pre-depends.  turns out
      there was a more graceful way to handle what we wanted to do
      in there anyway.  also updated example packages accordingly.
      thanks to Miguel (as well as Marc 'HE' Brockschmidt)
      for finding this (closes: #323620).



Index: common
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/common,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- common	18 May 2005 20:19:37 -0000	1.31
+++ common	24 Aug 2005 23:37:12 -0000	1.32
@@ -50,10 +50,6 @@
 	# and the package config
 	dbc_read_package_config
 
-	###
-	### dbtype-specific variable section
-	###
-
 	# 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"
@@ -62,6 +58,10 @@
 		dbc_dbtype="$dbc_prompted_dbtype"
 	fi
 
+	###
+	### dbtype-specific variable section
+	###
+
 	# now set some variables based on the dbtype
 	case $dbc_dbtype in
 	mysql)
@@ -130,6 +130,70 @@
 }
 
 ###
+### this function is responsible for setting all debconf values based
+### on the contents of on-system config files, so that we can avoid
+### the "Debconf is Not a Registry" dilemma.
+###
+dbc_preseed_package_debconf(){
+	_dbc_sanity_check package packageconfig || 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"
+	db_set $dbc_package/dbconfig-remove "$dbc_remove"
+
+	# set the dbtype
+	db_set $dbc_package/database-type "$dbc_dbtype"
+
+	# 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"
+
+	# set the name of the database to be created
+	db_set $dbc_package/db/dbname "$dbc_dbname"
+
+	# 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
+		db_set $dbc_package/pgsql/authmethod-admin "$dbc_authmethod_admin"
+		db_set $dbc_package/pgsql/authmethod-user "$dbc_authmethod_user"
+
+		# ident based auth doesn't need a password
+		if [ "$dbc_authmethod_admin" != "ident" ]; then
+			# set the database administrator pass
+			db_set $dbc_package/pgsql/admin-pass "$dbc_dbadmpass"
+		fi
+		if [ "$dbc_authmethod_user" != "ident" ]; then
+			# set the database user pass
+			db_set $dbc_package/pgsql/app-pass "$dbc_dbpass"
+		fi
+
+		# set whether or not they want to force SSL
+		if [ "$dbc_ssl" = "true" ]; then
+			db_set $dbc_package/pgsql/method "tcp/ip + ssl"
+		fi
+	;;
+	esac
+}
+
+
+###
 ### this function is responsible for reading in everything 
 ### with respect to the package's configuration and dbconfig-common.  
 ###

Index: config
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/config,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- config	21 May 2005 16:23:35 -0000	1.21
+++ config	24 Aug 2005 23:37:12 -0000	1.22
@@ -19,7 +19,11 @@
 	## register all the dbconfig-common questions
 	##
 	dbc_register_debconf
+	
+	# make sure debconf is up to date with on-disk configuration
+	dbc_preseed_package_debconf
 
+	# and start our beautiful state-machine
 	STATE=1
 	while true; do
 	case "$STATE" in

Index: postinst
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/postinst,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- postinst	31 Jul 2005 10:26:39 -0000	1.16
+++ postinst	24 Aug 2005 23:37:12 -0000	1.17
@@ -2,10 +2,12 @@
 ### load up common variables and functions
 ###
 dbc_go(){
+	local prev_dbc_upgrade
 	. /usr/share/dbconfig-common/dpkg/common
 	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
 
 	###
@@ -14,16 +16,9 @@
 	if [ "$dbc_command" = "configure" -o "$dbc_command" = "reconfigure" ]; 
 	then
 		###
-		### get all the debconf settings we need
+		### if they don't want our help, quit
 		###
-
-		# do they want our help at all?  if so we'll quit after writing the cfg
-		db_get $dbc_package/dbconfig-install && dbc_install="$RET"
-		# we need to remember this, so synchronize this to disk before anything
-		dbc_write_package_config
-
-		# read in admin input from debconf
-		dbc_read_package_debconf $@
+		if [ "$dbc_install" != "true" ]; then return 0; fi
 
 		###
 		### perform a few sanity checks on the data
@@ -38,15 +33,6 @@
 			dbc_dballow=`hostname`
 		fi
 
-		# synchronize info to disk
-		dbc_write_package_config
-		
-
-		###
-		### if they don't want our help, quit
-		###
-		if [ "$dbc_install" != "true" ]; then return 0; fi
-
 		# export the config file if it exists, for the scripts
 		if [ "$dbc_generate_include" ]; then
 			# strip the leading format string for convenience
@@ -145,15 +131,16 @@
 			if [ "$_dbc_upgrades_pending" -o "$_dbc_scriptupgrades_pending" -o "$_dbc_upgrades_pending_adm" ]; then
 
 				# ask if they want our help in the process at all
-				db_set $dbc_package/dbconfig-upgrade "$dbc_upgrade"
+				prev_dbc_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"
+				db_get $dbc_package/dbconfig-upgrade && dbc_upgrade="$RET"
 
-				# synchronize config to disk, so we can remember this
-				dbc_write_package_config
+				# 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

Index: preinst
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/preinst,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- preinst	7 Feb 2005 14:17:03 -0000	1.4
+++ preinst	24 Aug 2005 23:37:12 -0000	1.5
@@ -1,21 +1,10 @@
 ###
 ### what happens in this script:
 ###
-### the debconf settings aquired in the previous config run
-### are written out to the package configuration file.  this
-### way when the config script is re-run before postinst it
-### doesn't overwrite debconf variables that may have changed from
-### the first config run.  otherwise the contents of the configuration
-### file will never be changed.
+### nothing.  unfortunately we can't reliably be run out of a package's
+### postinst script without pre-dependencies, and we don't really need
+### to anyway.
 ###	
 dbc_go(){
-	. /usr/share/dbconfig-common/dpkg/common
-	dbc_config $@
-
-	case $dbc_command in
-	"upgrade"|"install")
-		dbc_read_package_debconf $@
-		dbc_write_package_config
-	;;
-	esac
+	echo "W: use of dbc preinst hooks is now unnecesary and deprecated" >&2
 }




More information about the Dbconfig-common-devel mailing list