Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2012 18:43:54 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241701 - in head/usr.sbin/bsdconfig: . include share
Message-ID:  <201210181843.q9IIhs6N099621@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Thu Oct 18 18:43:54 2012
New Revision: 241701
URL: http://svn.freebsd.org/changeset/base/241701

Log:
  More-accurately replicate the help system from sysinstall(8). However, also
  improve upon the system by giving the user a "Help" button instead of requiring
  the user to press F1.
  
  NOTE: In FreeBSD-9 and higher, dialog(1) does not support the F1 hook, so the
        mechanism for providing help to the user had to be changed to a button.
  
  This now means we can resurrect *.hlp files from usr.sbin/sysinstall/help/ as-
  is and reusing them as-needed in bsdconfig (holding to the goal of losing as
  little functionality from sysinstall as possible).
  
  Reviewed by:	adrian (co-mentor)
  Approved by:	adrian (co-mentor)

Added:
  head/usr.sbin/bsdconfig/include/bsdconfig.hlp   (contents, props changed)
Modified:
  head/usr.sbin/bsdconfig/bsdconfig
  head/usr.sbin/bsdconfig/include/Makefile
  head/usr.sbin/bsdconfig/include/messages.subr
  head/usr.sbin/bsdconfig/share/common.subr

Modified: head/usr.sbin/bsdconfig/bsdconfig
==============================================================================
--- head/usr.sbin/bsdconfig/bsdconfig	Thu Oct 18 17:09:45 2012	(r241700)
+++ head/usr.sbin/bsdconfig/bsdconfig	Thu Oct 18 18:43:54 2012	(r241701)
@@ -37,6 +37,7 @@ f_include $BSDCFG_SHARE/strings.subr
 
 BSDCFG_LIBE="/usr/libexec/bsdconfig"
 f_include_lang $BSDCFG_LIBE/include/messages.subr
+f_include_help $BSDCFG_LIBE/include/bsdconfig.hlp
 
 ############################################################ FUNCTIONS
 
@@ -185,6 +186,8 @@ dialog_menu_main()
 		--item-help                             \
 		--ok-label \"\$msg_ok\"                 \
 		--cancel-label \"\$msg_exit_bsdconfig\" \
+		--help-button                           \
+	${USE_XDIALOG:+--help \"\$( f_include_help )\"} \
 		--menu \"\$prompt\" $size $menu_list    \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
@@ -286,8 +289,6 @@ if [ "$1" ]; then
 	exec $cmd ${USE_XDIALOG:+-X} "$@" || exit 1
 fi
 
-[ -f "$HOME/.bsdconfigrc" ] || f_dialog_msgbox "$msg_help_text"
-
 #
 # Launch application main menu
 #
@@ -297,7 +298,13 @@ while :; do
 	mtag=$( f_dialog_menutag )
 	f_dprintf "retval=$retval mtag=[$mtag]"
 
-	[ $retval -eq 0 ] || f_die
+	if [ $retval -eq 2 ]; then
+		# The Help button was pressed
+		f_show_msg "%s" "$( f_include_help )"
+		continue
+	elif [ $retval -ne 0 ]; then
+		f_die
+	fi
 
 	case "$mtag" in
 	X) # Exit

Modified: head/usr.sbin/bsdconfig/include/Makefile
==============================================================================
--- head/usr.sbin/bsdconfig/include/Makefile	Thu Oct 18 17:09:45 2012	(r241700)
+++ head/usr.sbin/bsdconfig/include/Makefile	Thu Oct 18 18:43:54 2012	(r241701)
@@ -3,7 +3,7 @@
 NO_OBJ=
 
 FILESDIR=	${LIBEXECDIR}/bsdconfig/include
-FILES=		messages.subr
+FILES=		bsdconfig.hlp messages.subr
 
 beforeinstall:
 	mkdir -p ${DESTDIR}${FILESDIR}

Added: head/usr.sbin/bsdconfig/include/bsdconfig.hlp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.sbin/bsdconfig/include/bsdconfig.hlp	Thu Oct 18 18:43:54 2012	(r241701)
@@ -0,0 +1,12 @@
+This menu allows you to configure your system after the installation
+process is complete.  At the minimum, you should probably set the root
+password and the system time zone.
+
+For extra goodies like bash, emacs, firefox, etc., you should look at
+the Packages item in this menu.
+
+For setting the timezone after the system is installed, use the 'Time
+Zone' item in this menu.
+
+For more information on the overall general system configuration, see
+the /etc/rc.conf and /etc/defaults/rc.conf files.

Modified: head/usr.sbin/bsdconfig/include/messages.subr
==============================================================================
--- head/usr.sbin/bsdconfig/include/messages.subr	Thu Oct 18 17:09:45 2012	(r241700)
+++ head/usr.sbin/bsdconfig/include/messages.subr	Thu Oct 18 18:43:54 2012	(r241701)
@@ -38,7 +38,6 @@ msg_created_path="Created %s"
 msg_directory_not_found="%s: Directory not found."
 msg_exit="Exit"
 msg_exit_bsdconfig="Exit bsdconfig"
-msg_help_text="This menu allows you to configure your system after the installation\nprocess is complete.  At the minimum, you should probably set the root\npassword and the system time zone.\n\nFor extra goodies like bash, emacs, firefox, etc., you should look at the\n'Packages' item in this menu.\n\nFor setting the timezone after the system is installed, use the 'Time\nZone' item in this menu.\n\nFor more information on the overall general system configuration, see the\n/etc/rc.conf and /etc/defaults/rc.conf files. (Note: to inhibit displaying\nof this message, create an empty file: \$HOME/.bsdconfigrc or copy it from\n/usr/share/examples/bsdconfig/bsdconfigrc)"
 msg_main_menu="Main Menu"
 msg_menu_text="If you've already installed FreeBSD, you may use\nthis menu to customize it somewhat to suit your\nparticular configuration.  Most importantly, you\ncan use the Packages utility to load extra '3rd\nparty' software not provided in the base\ndistributions."
 msg_must_be_root_to_execute="%s: must be root to execute"

Modified: head/usr.sbin/bsdconfig/share/common.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/common.subr	Thu Oct 18 17:09:45 2012	(r241700)
+++ head/usr.sbin/bsdconfig/share/common.subr	Thu Oct 18 18:43:54 2012	(r241701)
@@ -179,6 +179,44 @@ f_include_lang()
 	fi
 }
 
+# f_include_help [$file]
+#
+# When given an argument, cache the contents of a language help-file (to later
+# be retrieved by executing again without arguments).
+#
+# Automatically takes $LANG and $LC_ALL into consideration when reading $file
+# (suffix ".$LC_ALL" or ".$LANG" will automatically be added prior to loading
+# the language help-file).
+#
+# No error is produced if (a) a language has been requested (by setting either
+# $LANG or $LC_ALL in the environment) and (b) the language help-file does not
+# exist -- in which case we will fall back to loading $file without-suffix.
+#
+# If the language help-file does not exist, an error is cached in place of the
+# help-file contents.
+#
+# When called without arguments, the cached value (if any) is produced. Each
+# time this function is called, the cache is overwritten with the newly loaded
+# contents.
+#
+f_include_help()
+{
+	local file="$1"
+
+	if [ "$file" ]; then
+		local lang="${LANG:-$LC_ALL}"
+
+		f_dprintf "lang=[$lang]"
+		if [ -f "$file.$lang" ]; then
+			setvar HELP_$$ "$( cat "$file.$lang" 2>&1 )"
+		else
+			setvar HELP_$$ "$( cat "$file" 2>&1 )"
+		fi
+	else
+		eval echo \"\$HELP_$$\"
+	fi
+}
+
 # f_usage $file [ $key1 $value1 ... ]
 #
 # Display USAGE file with optional pre-processor macro definitions. The first



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210181843.q9IIhs6N099621>