2.1.81: Split Configure.help into separate files(w/ patch)

Adam Heath (adam@brainiac.egr.msu.edu)
Sun, 25 Jan 1998 07:45:47 -0500 (EST)


Very often, when patches come in, and they attempt to update
Configure.help, clashes/rejects arise. This patch, when run on a virgin
system, splits Configure.help, and creates several files in
Documentation/config/<config-var-name>. I have also modified the
nescessary config scripts to use the new scripts/help to get at the
documentation. Now, whenever a new feature is added, all that has to be
done is to create a new file in the above directory. This patch can also
speed of the documentation system, as, once Configure.help is split, it no
longer needs to be grep'ed, sed'ed, etc.

Also, the patch can rebuild Configure.help from the individual files.
However, the resulting output will not be in the same order as before.
As an added bonus(this is untested), you can have the same help for
multiple CONFIG options. Just create a file .links.<some-name>, and the
links will be created automatically. The links will survive a
Configure.help rebuild.

The format of the Documentation/config/* files has, as the first line, the
one line discription from Configure.help, then the long description.

diff -ruN 2.1.81-pure/Makefile 2.1.81/Makefile
--- 2.1.81-pure/Makefile Fri Jan 23 22:58:21 1998
+++ 2.1.81/Makefile Sun Jan 25 06:40:38 1998
@@ -210,20 +210,24 @@
fi

oldconfig: symlinks scripts/split-include
+ scripts/help split
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config

xconfig: symlinks scripts/split-include
+ scripts/help split
$(MAKE) -C scripts kconfig.tk
wish -f scripts/kconfig.tk
scripts/split-include include/linux/autoconf.h include/config

menuconfig: include/linux/version.h symlinks scripts/split-include
+ scripts/help split
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config

config: symlinks scripts/split-include
+ scripts/help split
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
scripts/split-include include/linux/autoconf.h include/config

diff -ruN 2.1.81-pure/scripts/Configure 2.1.81/scripts/Configure
--- 2.1.81-pure/scripts/Configure Mon Jun 16 19:36:02 1997
+++ 2.1.81/scripts/Configure Sun Jan 25 05:17:30 1998
@@ -83,28 +83,12 @@
# help variable
#
function help () {
- if [ -f Documentation/Configure.help ]
+ text=`scripts/help extract $1`
+ if [ -z "$text" ]
then
- #first escape regexp special characters in the argument:
- var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')
- #now pick out the right help text:
- text=$(sed -n "/^$var[ ]*\$/,\${
- /^$var[ ]*\$/b
- /^#.*/b
- /^[ ]*\$/q
- p
- }" Documentation/Configure.help)
- if [ -z "$text" ]
- then
- echo; echo " Sorry, no help available for this option yet.";echo
- else
- (echo; echo "$text"; echo) | ${PAGER:-more}
- fi
+ echo; echo " Sorry, no help available for this option yet.";echo
else
- echo;
- echo " Can't access the file Documentation/Configure.help which"
- echo " should contain the help texts."
- echo
+ (echo; echo "$text"; echo) | ${PAGER:-more}
fi
}

diff -ruN 2.1.81-pure/scripts/Menuconfig 2.1.81/scripts/Menuconfig
--- 2.1.81-pure/scripts/Menuconfig Fri Jan 23 22:58:27 1998
+++ 2.1.81/scripts/Menuconfig Sun Jan 25 07:32:36 1998
@@ -259,49 +259,11 @@

} # END load_functions()

-
-
-
-
-#
-# Extract available help for an option from Configure.help
-# and send it to standard output.
-#
-# Most of this function was borrowed from the original kernel
-# Configure script.
-#
-function extract_help () {
- if [ -f Documentation/Configure.help ]
- then
- #first escape regexp special characters in the argument:
- var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g')
- #now pick out the right help text:
- text=$(sed -n "/^$var[ ]*\$/,\${
- /^$var[ ]*\$/d
- /^#.*/d
- /^[ ]*\$/q
- s/^ //
- p
- }" Documentation/Configure.help)
-
- if [ -z "$text" ]
- then
- echo "There is no help available for this kernel option."
- return 1
- else
- echo "$text"
- fi
- else
- echo "There is no help available for this kernel option."
- return 1
- fi
-}
-
#
# Activate a help dialog.
#
function help () {
- if extract_help $1 >help.out
+ if scripts/help extract $1 >help.out
then
$DIALOG --backtitle "$backtitle" --title "$2"\
--textbox help.out $ROWS $COLS
diff -ruN 2.1.81-pure/scripts/header.tk 2.1.81/scripts/header.tk
--- 2.1.81-pure/scripts/header.tk Mon Jan 5 04:41:01 1998
+++ 2.1.81/scripts/header.tk Sun Jan 25 05:34:30 1998
@@ -350,45 +350,21 @@
catch {destroy $w}
toplevel $w -class Dialog

- set filefound 0
set found 0
set lineno 0

- if { [file readable Documentation/Configure.help] == 1} then {
- set filefound 1
- set message [exec sed -n "
- /^$var\[ \]*\$/,\${
- /^$var\[ \]*\$/c\\
-${var}:\\
-
- /^#.*/d
- /^\[ \]*\$/bL
- H
- }
- d
- :L x
- s/\\n //
- s/\\n / /g
- p
- q
- " Documentation/Configure.help]
- set found [expr [string length "$message"] > 0]
- }
+ set message [exec scripts/help "extract $var "]
+ set found [expr [string length "$message"] > 0]

frame $w.f1

if { $found == 0 } then {
- if { $filefound == 0 } then {
- message $w.f1.m -width 750 -aspect 300 -relief flat -text \
- "No help available - unable to open file Documentation/Configure.help. This file should have come with your kernel."
- } else {
message $w.f1.m -width 400 -aspect 300 -relief flat -text \
"No help available for $var"
- }
label $w.f1.bm -bitmap error
wm title $w "RTFM"
} else {
- message $w.f1.m -width 400 -aspect 300 -text $message \
+ message $w.f1.m -width 600 -aspect 300 -text $message \
-relief flat
label $w.f1.bm -bitmap info
wm title $w "Configuration help"
diff -ruN 2.1.81-pure/scripts/help 2.1.81/scripts/help
--- 2.1.81-pure/scripts/help Wed Dec 31 19:00:00 1969
+++ 2.1.81/scripts/help Sun Jan 25 06:37:24 1998
@@ -0,0 +1,148 @@
+#!/bin/sh
+progname=$0
+helpb=Documentation
+helpd=$helpb/config
+mf=$helpb/Configure.help
+nohlp="There is no help available for the option."
+[ ! -d $helpd ] && mkdir $helpd
+
+need_exit=
+trap set_need_exit SIGINT
+
+debug=
+function debug () {
+ [ ! -z "$debug" ] && eval '$*'
+}
+function set_var () {
+ eval $1=$2
+}
+function msg () {
+ eval echo '$*' 1>&2
+}
+function set_need_exit () {
+ if [ ! "$need_exit" ];then
+ need_exit=1
+ msg -n '(Please wait, finishing...)'
+ fi
+}
+function split () {
+ if [ -f $mf ]; then
+ mode=0
+ msg -n Splitting $mf ""
+ (cat $mf;echo)|
+ while read;do
+ case $mode in
+ 0)
+ case "$REPLY" in
+ CONFIG*)
+ set_var var '$REPLY'
+ set_var ofile $helpd/$var
+ debug msg Help for $var now resides in $ofile
+ echo $lastl > $ofile
+ mode=1;;
+ *) debug msg "$REPLY";;
+ esac;;
+ 1)
+ if [ ! -z "$REPLY" ];then
+ echo "$REPLY" >> $ofile
+ else
+ mode=0
+ onel=
+ msg -n .
+ [ "$need_exit" ] && break;
+ fi;;
+ esac
+ lastl="$REPLY"
+ done
+ msg done.
+ if [ -z "$need_exit" ];then
+ msg Removing $mf
+ rm $mf
+ fi
+ fi
+}
+function make_link () {
+ if [ -f $1 ];then
+ (cat $1;echo)|
+ while read link orig;do
+ [ -f "$link" ] && rm -f $link
+ ln -s $helpd/$orig $helpd/$link
+ done
+ fi
+}
+function make_links () {
+ for a in $helpd/.links.*;do
+ make_link $a
+ done
+}
+function extract () {
+ file=$helpd/$1
+ if [ -f $file ];then
+ mode=0
+ declare -i count
+ set_var count `wc -l $file`
+ count=$count-1
+ tail -n $count $file
+ else
+ echo $nohlp
+ fi
+}
+function extract_oneliner () {
+ file=$helpd/$1
+ if [ -f $file ];then
+ head --lines=1 $file
+ else
+ echo
+ fi
+}
+function make_link_file () {
+ for file in .links.*;do
+ [ -e "$file" ] && rm $file
+ done
+ find $helpd -type l -printf "%P %l\n" >> $helpd/.links.master
+}
+function combine () {
+ make_link_file
+ [ -e $mf ] && rm -f $mf
+ msg -n Building $mf ""
+ for file in `cd $helpd;ls *`;do
+ case $file in
+ .links.*)
+ rm $helpd/$file
+ ;;
+ *)
+ onel=`extract_oneliner $file`
+ (echo $onel;echo $file;extract $file;echo) >> $mf
+ rm $helpd/$file
+ echo -n .
+ [ "$need_exit" ] && break;
+ ;;
+ esac
+ done
+ msg done.
+}
+function usage () {
+ cat <<EOF
+Usage: $progname command arg
+
+ Where command is the following:
+
+ split Split $mf into $helpd
+ make_link <file> Read file, and make links
+ make_links Read all link files, and make links
+ extract <var> Get help on var
+ combine Build $mf from $helpd
+
+EOF
+}
+[ -e $mf ] && split
+[ "$need_exit" ] && exit;
+case $1 in
+ *split*|*make_link*|*make_links*|*extract*|*extract_oneliner*|*combine*)
+ eval $*;;
+ *)
+ echo Unknown option!
+ echo cmdline: $*
+ usage;;
+esac
+