[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

base-config/lib prep-menu,NONE,1.1 show-menu,NONE,1.1



Update of /cvs/debian-boot/base-config/lib
In directory gluck:/tmp/cvs-serv6908/lib

Added Files:
	prep-menu show-menu 
Log Message:
more 2.0 changes


--- NEW FILE: prep-menu ---
#!/bin/sh -e
# This helper program is run by base-config before displaying the main
# menu. It populates the base-config/main-menu's choices list with the menu
# choices, and generates a menu-mapping file that can be used to translate
# back from the menu items to the programs to run.

. /usr/share/debconf/confmodule

# Get an ordered list of the menu items.
get_menu_items () {
	(
		for i in $(find menu -type f -perm -700 -printf '%f\n '); do
			if [ "$NEW" ] || grep -q '^Only-New: false' menu/$i.mnu; then
				echo $(grep ^Order: menu/$i.mnu | cut -f 2 -d ' ') $i
			fi
		done
	) | sort -n | cut -d ' ' -f 2
}

CHOICES=""
for item in $(get_menu_items); do
	db_metaget base-config/menu/$item description || RET="$item"
	echo "$RET:$item" >> menu-mapping
	if [ -z "$CHOICES" ]; then
		CHOICES="$RET"
		# Mark first menu item as default to get things going.
		db_set base-config/main-menu "$RET"
	else
		CHOICES="$CHOICES, $RET"
	fi
done

db_subst base-config/main-menu CHOICES "$CHOICES"

--- NEW FILE: show-menu ---
#!/bin/sh -e
# This helper program displays the base-config menu. If the selected item
# can also run under debconf, it runs it directly (this is fastest).
# Otherwise, it echos it to file descriptor 5, for base-config to read and
# run it outside of debconf. To indicate that the main menu should no
# longer be shown, it will exit without echoing anything to that file
# descriptor.

. /usr/share/debconf/confmodule

ADVANCE=$1
NEW=$2

db_capb backup

while :; do
	# Title might get reset, so set it each time.
	db_settitle base-config/title
	
	if [ "$ADVANCE" = 1 ]; then
		# Advance default to the next menu item.
		db_get base-config/main-menu
		NEXT=$(grep -A 1 "$RET:" menu-mapping | cut -d : -f 1 | tail -n 1)
		if [ ! -z "$NEXT" ]; then
			db_set base-config/main-menu $NEXT
		fi
	fi
	ADVANCE=1
	
	db_fset base-config/main-menu seen false
	if db_input medium base-config/main-menu; then
		# back all the way out is the same as exiting base-config
		# however, note that I only go if the question will be
		# shown. Else debconf's auto-backup code could emulate a
		# backup based on a prior backup within a menu item.
		db_go || exit 30
	fi
	
	db_get base-config/main-menu
	menu_item=$(grep "^$RET:" menu-mapping | cut -d : -f 2)
	
	if grep -q '^Debconf: true' menu/$menu_item.mnu; then
		# Run menu item inside debconf.
		if ! ./menu/$menu_item $NEW 5>/dev/null; then
			ADVANCE=0
			# Drop priority to make sure the menu is displayed
			# since a menu item is failing.
			db_get debconf/priority
			if [ "$RET" = high ] || [ "$RET" = critical ]; then
				db_set debconf/priority medium
			fi
		else
			if grep -q 'Exit-Menu: true' menu/$menu_item.mnu; then
				# This menu item finished the install, so
				# exit the menu.
				exit 0
			fi
		fi
	else
		# The menu item cannot run inside debconf, so pass it back
		# to base-config on the special communication fd.
		echo $menu_item >&5
		exit 0
	fi
done



Reply to: