diff options
Diffstat (limited to 'usr.sbin')
-rwxr-xr-x | usr.sbin/bsdconfig/bsdconfig | 74 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/share/common.subr | 16 |
2 files changed, 87 insertions, 3 deletions
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig index b637961..57d9928 100755 --- a/usr.sbin/bsdconfig/bsdconfig +++ b/usr.sbin/bsdconfig/bsdconfig @@ -57,6 +57,13 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr BSDCONFIG_HELPFILE=$BSDCFG_LIBE/include/bsdconfig.hlp USAGE_HELPFILE=$BSDCFG_LIBE/include/usage.hlp +############################################################ CONFIGURATION + +# +# Alternate `local' libexec directory for add-on modules (e.g., from ports) +# +BSDCFG_LOCAL_LIBE="/usr/local/libexec/bsdconfig" + ############################################################ FUNCTIONS # usage @@ -83,6 +90,27 @@ usage() }' */$index | sort ) + local alt_cmd_list # Calculated below (if $BSDCFG_LOCAL_LIBE exists) + if f_quietly cd $BSDCFG_LOCAL_LIBE; then + # No need to preserve CWD (headed toward exit) + + # Test for language-specific indices + f_quietly ls */"$index.${LANG:-$LC_ALL}" && + index="$index.${LANG:-$LC_ALL}" + + alt_cmd_list=$( + awk '/^menu_selection="/ { + sub(/\|.*/, "") + sub(/^menu_selection="/, "") + print + }' */$index 2> /dev/null | sort + ) + + # Conflate lists, removing duplicates + cmd_list=$( printf "%s\n%s\n" \ + "$cmd_list" "$alt_cmd_list" | sort -u ) + fi + # # Determine the longest command-length (in characters) # @@ -167,6 +195,9 @@ dialog_menu_main() local defaultitem= # Calculated below local hline= + # + # Pick up the base modules (directories named `[0-9][0-9][0-9].*') + # local menuitem menu_title menu_help menu_selection index=2 for menuitem in $( cd $BSDCFG_LIBE && ls -d [0-9][0-9][0-9].* ); do [ $index -lt ${#DIALOG_MENU_TAGS} ] || break @@ -190,6 +221,49 @@ dialog_menu_main() index=$(( $index + 1 )) done + # + # Process the `local' libexec sources. + # + # Whereas modules in $BSDCFG_LIBE must be named [0-9][0-9][0-9].* + # modules in $BSDCFG_LOCAL_LIBE should NOT be named this way (making it + # more practical for port-maintainers). + # + # This also has the fortunate side-effect of making the de-duplication + # effort rather simple (because so-called `base' modules must be named + # differently than add-on modules). + # + local separator_added= + for menuitem in $( cd "$BSDCFG_LOCAL_LIBE" 2> /dev/null && ls -d * ) + do + [ $index -lt ${#DIALOG_MENU_TAGS} ] || break + + # Skip the module if it looks like a `base' module + case "$menuitem" in [0-9][0-9][0-9].*) continue;; esac + + menu_program= menu_title= menu_help= + f_include_lang $BSDCFG_LOCAL_LIBE/$menuitem/INDEX || continue + [ "$menu_program" ] || continue + + if [ ! "$separator_added" ]; then + menu_list="$menu_list '-' '-' ''" + separator_added=1 + fi + + case "$menu_program" in + /*) : already fully qualified ;; + *) menu_program="$BSDCFG_LOCAL_LIBE/$menuitem/$menu_program" + esac + + tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 ) + setvar "menu_program$tag" "$menu_program" + + f_shell_escape "$menu_title" menu_title + f_shell_escape "$menu_help" menu_help + menu_list="$menu_list '$tag' '$menu_title' '$menu_help'" + + index=$(( $index + 1 )) + done + local height width rows eval f_dialog_menu_with_help_size height width rows \ \"\$title\" \ diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr index 32d6aba..6c0400a 100644 --- a/usr.sbin/bsdconfig/share/common.subr +++ b/usr.sbin/bsdconfig/share/common.subr @@ -531,12 +531,22 @@ f_index_file() if [ "$lang" ]; then awk -v keyword="$keyword" "$f_index_file_awk" \ - $BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX.$lang && - return + $BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX.$lang && return # No match, fall-thru to non-i18n sources fi awk -v keyword="$keyword" "$f_index_file_awk" \ - $BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX + $BSDCFG_LIBE${BSDCFG_LIBE:+/}*/INDEX && return + + # No match? Fall-thru to `local' libexec sources (add-on modules) + + [ "$BSDCFG_LOCAL_LIBE" ] || return $FAILURE + if [ "$lang" ]; then + awk -v keyword="$keyword" "$f_index_file_awk" \ + $BSDCFG_LOCAL_LIBE/*/INDEX.$lang && return + # No match, fall-thru to non-i18n sources + fi + awk -v keyword="$keyword" "$f_index_file_awk" \ + $BSDCFG_LOCAL_LIBE/*/INDEX } # f_index_menusel_keyword $indexfile $pgm |