[Webapps-common-discuss] webapps-common/dpkg common, 1.9, 1.10 config, 1.6, 1.7

seanius at haydn.debian.org seanius at haydn.debian.org
Wed Apr 5 07:30:05 UTC 2006


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

Modified Files:
	common config 
Log Message:
another nice chunkawork.  the debconf/config-script process is getting
closer to how the final process should look, though more work needs to
be done to implement the configuration all the way through.


Index: common
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/common,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- common	1 Apr 2006 17:53:40 -0000	1.9
+++ common	5 Apr 2006 07:30:00 -0000	1.10
@@ -40,7 +40,7 @@
 
 	# standard templates provided by webapps-common, which will have copies
 	# registered with the package in question.
-	wc_standard_templates="webapps_install httpd/website_subdirectory httpd/select_httpd install_error httpd/virtualhost httpd/virtualhost_new"
+	wc_standard_templates="webapps_install httpd/install_type httpd/website_subdirectory httpd/select_httpd install_error httpd/virtualhost httpd/virtualhost_single httpd/virtualhost_new"
 	wc_register_templates=$wc_standard_templates
 
 	###
@@ -206,36 +206,6 @@
 #	done
 #}
 
-
-
-###
-### wc_select_httpds:
-###	choose the servers for the app
-wc_select_httpds(){
-	local h instd_httpds chosen_httpds oldchoices debconf_dest
-	_wc_debug "wc_select_httpds() $@"
-
-	if [ "$1" ]; then
-		debconf_dest="$wc_package/vhosts/$1"
-	else
-		debconf_dest="$wc_package"
-	fi
-
-	# create a list of installed httpds
-	instd_httpds=`_wc_list_create \`wc_httpd_installed\``
-	# get a list of previously offered choices of installed httpds
-	db_metaget $debconf_dest/httpd/select_httpd choices && oldchoices="$RET"
-
-	# if the old list was empty or does not match the current list, we need
-	# to ask for the new selection.
-	if [ ! "$oldchoices" -o "$instd_httpds" != "$oldchoices" ]; then
-		db_subst $debconf_dest/httpd/select_httpd httpds $instd_httpds
-		db_input medium  $debconf_dest/httpd/select_httpd || true
-
-		#wc_httpd_apache_include "$wc_package_confdir/apache.conf" "$wc_package" $chosen_httpds
-	fi
-}
-
 ###
 ### this function is responsible for reading in everything 
 ### with respect to the package's configuration and webapps-common.  
@@ -244,7 +214,6 @@
 	_wc_debug "wc_read_package_debconf() $@"
 	_wc_sanity_check package || wc_install_error
 	db_get $wc_package/httpd/website_subdirectory && wc_website_subdirectory="$RET"
-	db_get $wc_package/httpd/virtualhost && wc_website_virtualhost="$RET"
 }
 
 ##
@@ -346,18 +315,22 @@
 		debconf_dest="$wc_package/vhosts/$vhost_id"
 	fi
 
-	for f in $wc_register_templates; do
-		# perform some basic customizing substitutions
-		if ! db_get "$debconf_dest/$f/httpd/website_subdirectory"; then
+	if ! db_get "$debconf_dest/$f/httpd/website_subdirectory"; then
+		for f in $wc_register_templates; do
 			db_register "webapps-common/$f" "$debconf_dest/$f"
-		fi
+		done
+		# perform some basic customizing substitutions
 		db_subst "$debconf_dest/$f" pkg "$wc_package"
 		if [ "$vhost_id" ]; then
 			db_subst "$debconf_dest/$f" vhost "$vhost_id"
 		fi
-	done
-	# set some default values
-	db_set "$debconf_dest/httpd/website_subdirectory" "$wc_package"
+	fi
+
+	# set some default values if this is a first-time installation
+	if [ ! "$wc_oldversion" ]; then
+		db_set "$debconf_dest/httpd/website_subdirectory" "$wc_package"
+		db_set "$debconf_dest/httpd/select_httpd" "`wc_httpd_installed`"
+	fi
 }
 
 ###
@@ -425,6 +398,7 @@
 	# and of course add the new vhost option
 	vhosts=`_wc_list_add "[new vhost]" "$vhosts"`
 	db_subst $wc_package/httpd/virtualhost vhosts "$vhosts"
+	db_subst $wc_package/httpd/virtualhost_single vhosts "$vhosts"
 }
 
 

Index: config
===================================================================
RCS file: /cvsroot/webapps-common/webapps-common/dpkg/config,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- config	1 Apr 2006 16:32:21 -0000	1.6
+++ config	5 Apr 2006 07:30:00 -0000	1.7
@@ -2,7 +2,7 @@
 # sean finney <seanius at debian.org>
 
 wc_go(){
-	local donewithvhosts vhost_name vhost_new vhost_list v
+	local installtype donewithvhosts vhosts_selected vhost_list v
 	. /usr/share/webapps-common/dpkg/common
 	_wc_debug "(config) wc_go() $@"
 	wc_config $@
@@ -19,11 +19,8 @@
 	# preseed debconf values from configuration files
 	wc_preseed_debconf
 
-	# state 1 - ask if they want our help at all
+	# state 100 - ask if they want our help at all
 	db_input medium $wc_package/webapps_install || true
-
-
-	# state 2 - check to see if they do
 	db_go || true
 	db_get $wc_package/webapps_install
 	_wc_debug webapps_install: $RET
@@ -31,65 +28,127 @@
 		return 0;
 	fi
 
-	# state 3 - choose vhosts
-	while [ ! "$donewithvhosts" ]; do
+	# state 200 - get how we're going to be installed
+	db_input medium $wc_package/httpd/install_type || true
+	db_go || true
+	db_get $wc_package/httpd/install_type && installtype="$RET"
+	_wc_debug install-type: $installtype
 
-		# state 3.1, fetch the current list of vhost choices. 
-		# if the list is empty, add the default "[new vhost]" entry
-		db_metaget $wc_package/httpd/virtualhost choices && vhost_list=$RET
-		if [ ! "$vhost_list" ]; then
-			vhost_list="[new vhost]"
+	# state 300 - if we're doing vhosts, choose vhosts
+	while wc_config_select_more_vhosts "$installtype"; do true; done
+
+	# state 400 - ask for the httpds/site directory for each instance
+	#	- if we're doing directory style install, then configure the
+	#	  the global instance
+	if [ "$installtype" = "directory" ]; then
+		wc_config_instance
+	#	- otherwise configure each virtualhost instance
+	else
+		db_get $wc_package/httpd/virtualhost && vhosts_selected=$RET
+		for v in `_wc_list_explode "$vhosts_selected"`; do
+			wc_config_instance "$v"
+		done
+	fi
+
+	# let's stop here for now.
+	db_go || true
+}
+
+# select some set of vhosts.  return non-zero when the user is done
+# selecting hosts (or has chosen to quit maybe)
+wc_config_select_more_vhosts(){
+	local instype vhost_question vhost_list vhost_new vhost_name vhosts_selected
+	_wc_debug "wc_config_select_more_vhosts $@"
+
+	instype="$1"
+	case "$instype" in
+	"directory")
+		return 1;
+		;;
+	"virtualhost + directory")
+		vhost_question="httpd/virtualhost_single"
+		;;
+	"multiple instances")
+		vhost_question="httpd/virtualhost"
+		;;
+	esac
+
+	# fetch the current list of vhost choices. 
+	# if the list is empty, add the default "[new vhost]" entry
+	db_metaget $wc_package/httpd/virtualhost choices && vhost_list=$RET
+	if [ ! "$vhost_list" ]; then
+		vhost_list="[new vhost]"
+		db_subst $wc_package/httpd/virtualhost vhosts "$vhost_list"
+		db_subst $wc_package/httpd/virtualhost_single vhosts "$vhost_list"
+	fi
+
+	# ask, and fetch what they entered
+	db_input high "$wc_package/$vhost_question" || true
+	db_go || true
+	db_get "$wc_package/$vhost_question" && vhosts_selected=$RET
+	_wc_debug vhosts_selected: $RET
+
+	# if '[new vhost]' was in the list of selected vhosts, then we
+	# have to fetch info about this new virtualhost
+	if _wc_list_is_member "$vhosts_selected" '\[new vhost\]'; then
+		# fetch the new virtualhost setting
+		db_input high $wc_package/httpd/virtualhost_new || true
+		db_go || true
+		db_get $wc_package/httpd/virtualhost_new && vhost_new=$RET
+
+		# if they provide a name
+		if [ "$vhost_new" ]; then
+			# add it to the original list prompted in the question
+			vhost_list=`_wc_list_add "$vhost_list" "$vhost_new"`
+			# add it to the list of selected vhosts
+			vhosts_selected=`_wc_list_add "$vhosts_selected" "$vhost_new"`
+			# remove mention of '[new vhost]' being selected
+			vhosts_selected=`_wc_list_remove "$vhosts_selected" "\[new vhost\]"`
+			# update the list of available vhosts in the debconf question
 			db_subst $wc_package/httpd/virtualhost vhosts "$vhost_list"
+			db_subst $wc_package/httpd/virtualhost_single vhosts "$vhost_list"
+			# update the value of the answer
+			db_set $wc_package/httpd/virtualhost $vhosts_selected
+			db_set $wc_package/httpd/virtualhost_single $vhosts_selected
+			# reset the value of virtualhost_new in case it's asked again
+			db_set $wc_package/httpd/virtualhost_new ""
+			# copy over all the answers into a subtree just for this package
+			wc_register_debconf "$vhost_new"
 		fi
+		# at this point it's possible that they want to enter more
+		# vhosts, so we're not done yet
+		return 0
+	else
+		# if they're done entering new vhosts, we're done with this part
+		return 1
+	fi
+}
 
-		# state 3.2 - ask.
-		db_input high $wc_package/httpd/virtualhost || true
+###
+###	choose the servers and directory for a particular instance
+###
+wc_config_instance(){
+	local instd_httpds oldchoices debconf_dest
+	_wc_debug "wc_config_instance() $@"
 
-		# state 3.3 - fetch what they entered 
-		db_go || true
-		db_get $wc_package/httpd/virtualhost && vhosts_selected=$RET
-		_wc_debug vhosts_selected: $RET
+	if [ "$1" ]; then
+		debconf_dest="$wc_package/vhosts/$1"
+	else
+		debconf_dest="$wc_package"
+	fi
 
-		# state 3.4 - if '[new vhost]' was in the list of selected
-		# vhosts, then we have to fetch info about this new virtualhost
-		if _wc_list_is_member "$vhosts_selected" '\[new vhost\]'; then
-			# fetch the new virtualhost setting
-			db_input high $wc_package/httpd/virtualhost_new || true
-			db_go || true
-			db_get $wc_package/httpd/virtualhost_new && vhost_new=$RET
+	db_input medium $debconf_dest/httpd/website_subdirectory || true
 
-			# if they provide a name
-			if [ "$vhost_new" ]; then
-				# add it to the original list prompted in the question
-				vhost_list=`_wc_list_add "$vhost_list" "$vhost_new"`
-				# add it to the list of selected vhosts
-				vhosts_selected=`_wc_list_add "$vhosts_selected" "$vhost_new"`
-				# remove mention of '[new vhost]' being selected
-				vhosts_selected=`_wc_list_remove "$vhosts_selected" "\[new vhost\]"`
-				# update the list of available vhosts in the debconf question
-				db_subst $wc_package/httpd/virtualhost vhosts "$vhost_list"
-				# update the value of the answer
-				db_set $wc_package/httpd/virtualhost $vhosts_selected
-				# reset the value of virtualhost_new in case it's asked again
-				db_set $wc_package/httpd/virtualhost_new ""
-				# copy over all the answers into a subtree just for this package
-				wc_register_debconf "$vhost_new"
-			fi
-			# at this point it's possible that they want to enter more
-			# vhosts, so we're not done yet
-		else
-			# if they're done entering new vhosts, we're done with this part
-			donewithvhosts="true"
-		fi
-	done
+	# create a list of installed httpds
+	instd_httpds=`_wc_list_create \`wc_httpd_installed\``
+	# get a list of previously offered choices of installed httpds
+	db_metaget $debconf_dest/httpd/select_httpd choices && oldchoices="$RET"
 
-	# state 4 - ask for the httpds/site directory for each virtualhost
-	for v in `_wc_list_explode "$vhosts_selected"`; do
-		db_input medium $wc_package/vhosts/$v/httpd/website_subdirectory || true
-		wc_select_httpds "$v"
-		db_input medium $wc_package/vhosts/$v/httpd/select_httpd || true
-	done
+	# if the old list was empty or does not match the current list, we need
+	# to update the list of available choices
+	if [ ! "$oldchoices" -o "$instd_httpds" != "$oldchoices" ]; then
+		db_subst $debconf_dest/httpd/select_httpd httpds $instd_httpds
+	fi
 
-	# let's stop here for now.
-	db_go || true
+	db_input high $debconf_dest/httpd/select_httpd || true
 }




More information about the Webapps-common-discuss mailing list