[SM-Commit] PERFORCE change 77667 by Karsten Behrmann for review

Perforce Review Daemon p4review at smee.org
Wed Apr 12 17:05:03 EDT 2006


Change 77667 by karsten_behrmann at karsten_behrmann-karsten on 2006/04/12 22:03:17

	some more hackery on the net-tools spell

Affected files ...

... //sgl/grimoires/devel/net/net-tools/BUILD#4 edit
... //sgl/grimoires/devel/net/net-tools/CONFIGURE#4 edit
... //sgl/grimoires/devel/net/net-tools/generate-options.sh#1 add
... //sgl/grimoires/devel/net/net-tools/options/AFASH#2 delete
... //sgl/grimoires/devel/net/net-tools/options/AFAX25#2 delete
... //sgl/grimoires/devel/net/net-tools/options/AFECONET#2 delete
... //sgl/grimoires/devel/net/net-tools/options/AFNETROM#2 delete
... //sgl/grimoires/devel/net/net-tools/options/AFROSE#2 delete
... //sgl/grimoires/devel/net/net-tools/options/AFX25#2 delete
... //sgl/grimoires/devel/net/net-tools/options/APPLETALK#2 delete
... //sgl/grimoires/devel/net/net-tools/options/ARCNET#2 delete
... //sgl/grimoires/devel/net/net-tools/options/CISCO#2 delete
... //sgl/grimoires/devel/net/net-tools/options/ETHERNET#2 delete
... //sgl/grimoires/devel/net/net-tools/options/FDDI#2 delete
... //sgl/grimoires/devel/net/net-tools/options/FRAME#2 delete
... //sgl/grimoires/devel/net/net-tools/options/GETTEXT#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFASH#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFATALK#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFAX25#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFDECnet#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFECONET#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFINET#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFINET6#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFIPX#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFNETROM#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFROSE#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFUNIX#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_AFX25#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_FW_MASQUERADE#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWARC#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWASH#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWAX25#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWEC#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWETHER#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWFDDI#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWFR#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWHDLCLAPB#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWHIPPI#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWIRDA#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWNETROM#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWPPP#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWROSE#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWSIT#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWSLIP#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWSTRIP#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWTR#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWTUNNEL#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_HWX25#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_IP_TOOLS#1 add
... //sgl/grimoires/devel/net/net-tools/options/HAVE_MII#1 add
... //sgl/grimoires/devel/net/net-tools/options/HIPPI#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWASH#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWAX25#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWECONET#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWNETROM#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWROSE#2 delete
... //sgl/grimoires/devel/net/net-tools/options/HWX25#2 delete
... //sgl/grimoires/devel/net/net-tools/options/I18N#1 add
... //sgl/grimoires/devel/net/net-tools/options/INET#2 delete
... //sgl/grimoires/devel/net/net-tools/options/INET6#2 delete
... //sgl/grimoires/devel/net/net-tools/options/IPIP#2 delete
... //sgl/grimoires/devel/net/net-tools/options/IPMASQ#2 delete
... //sgl/grimoires/devel/net/net-tools/options/IPTOOLS#2 delete
... //sgl/grimoires/devel/net/net-tools/options/IRDA#2 delete
... //sgl/grimoires/devel/net/net-tools/options/MII#2 delete
... //sgl/grimoires/devel/net/net-tools/options/NOVELL#2 delete
... //sgl/grimoires/devel/net/net-tools/options/PPP#2 delete
... //sgl/grimoires/devel/net/net-tools/options/SIT#2 delete
... //sgl/grimoires/devel/net/net-tools/options/SLIP#2 delete
... //sgl/grimoires/devel/net/net-tools/options/STRIP#2 delete
... //sgl/grimoires/devel/net/net-tools/options/TOKEN#2 delete
... //sgl/grimoires/devel/net/net-tools/options/UNIX#2 delete

Differences ...

==== //sgl/grimoires/devel/net/net-tools/BUILD#4 (xtext) ====

@@ -1,9 +1,32 @@
+#!/bin/bash
+
+# Let's not use the configure.sh bundled with this. It's no good for us.
+# NOTE: This function needs changing when confug.in changes significantly.
+# SUBNOTE: That isn't likely to happen.
+my_configure() {
+  local VARNAME DEFAULT VALUE
+  while read VARNAME DEFAULT ;do
+  # We should not be needing the default here, but well...
+    VALUE=${!VARNAME}
+    if [[ ${VALUE:-$DEFAULT} == y ]] ;then
+      echo "#define $VARNAME 1" >&3
+      echo "$VARNAME=1" >&4
+    else
+      echo "#define $VARNAME 0" >&3
+      echo "$VARNAME=0" >&4
+    fi
+  done < <(sed -n "s/^bool '[^']*' //p" config.in) \
+    3>config.h 4>config.make
+  echo "configure script insane. We cheated." >config.status
+}
+
 echo  -e\n  $CONFIG_OPTS  >  smgl_config_opts                &&
 patch  -p1  <  $SCRIPT_DIRECTORY/gcc-3.4.patch               &&
 patch  -p1  <  $SCRIPT_DIRECTORY/x25_address-fix.patch       &&
 patch  -p1  <  $SCRIPT_DIRECTORY/double-free-nameif.patch    &&
 sedit  '382,391s/$/\\n\\/'  mii-tool.c                       &&
-./configure.sh  config.in  <  smgl_config_opts               &&
+my_configure                                                 &&
 make_single                                                  &&
 make  COPTS="-D_GNU_SOURCE -Wall $CFLAGS"  LOPTS="$LDFLAGS"
 
+

==== //sgl/grimoires/devel/net/net-tools/CONFIGURE#4 (xtext) ====

@@ -1,141 +1,90 @@
+#!/bin/bash
 # net-tools CONFIGURE script
 #
 # Created 2006-03-22 by Matthew Clark <MatthewClark at SourceMage.org>
 #
 
-option_list() {
+make_option_list() {
   # Return a dialog-friendly list of modules and attributes
-  for NAME in $OPTIONLIST
-  do
-    source $OPTIONDIR/$NAME
-    echo $NAME
-    echo $QUESTION
-    echo $STATUS
-  done
-}
+  OPTS=()
+  local i=0
+  local FILE QUESTION STATUS
 
-option_config() {
-
-  while true
-  do
-    OUTPUT=$( $DIALOG --title "$TITLE" --nocancel \
-    --checklist "Select which features you'd like supported. If you don't know what these are, then just press OK to build all features." \
-    0 0 0 \
-    $(option_list) )
-
-    RETVAL=$?
-    if [ $RETVAL == 0 ]
-    then
-      FIRSTFIELD=$( echo $OUTPUT | cut -d' ' -f1 )
-      REST=$( echo $OUTPUT | cut -d' ' -f2- )
-
-      # OK was pressed
-      # OUTPUT now contains the list of modules to build
-      output_option_config
-      break
+  for FILE in $OPTIONDIR/* ;do
+    source $FILE
+    OPTS[i++]=${FILE##*/} # strip everything before (including) the last /
+    OPTS[i++]=$QUESTION
+    if [[ $STATUS == "y" ]] ;then
+      OPTS[i++]=on
     else
-      # CANCEL was pressed
-      break
+      OPTS[i++]=off
     fi
   done
 }
 
 output_option_config() {
-  # Function to output the configuration info to $SPELL_CONFIG
+  # Function to save the config info.
 
-  # First we need to strip the quotes out of $OUTPUT
-  OUTPUT=$( echo $OUTPUT | sed -e 's/\"//g' )
+  # Iterate through all the options.
+  # This relies on the fact that the options are in the same
+  # order here as they are in $* ($OUTPUT). They are.
 
-  # Iterate through all the options. TARGET is the
-  # first unmatched option in the list of options
-  # to enable. NAME is the name of the target option
+  local OPTION NAME
 
-  local TARGET=$( echo $OUTPUT | cut -d' ' -f1 )
-  if [ "${TARGET:0:1}" != "m" ]
-  then
-    TARGET=${TARGET:1}
-  fi
-  local NAME
-
-  for OPTION in $OPTIONLIST
+  for OPTION in $OPTIONDIR/*
   do
-    if [ "$TARGET" = "" ] || [ "$TARGET" != "$OPTION" ]
-    then
-      # Disable this option
-      echo "$NAME=n" >> $SPELL_CONFIG
+    NAME=${OPTION##*/}
+    if [ "$NAME" == "$1" ] ;then
+      # it's in the list of enabled options
+      config_set_option $NAME y
+      shift #move on to the next option
     else
-      # Enable this option
-      echo "$NAME=y" >> $SPELL_CONFIG
+      config_set_option $NAME n
     fi
   done
 }
 
+option_config_menu() {
+  local OPTS TITLE OUTPUT
+
+  make_option_list
+  TITLE="net-conf option selection"
 
-# Perform the configuration
-if ! grep -q 'CONFIGURED=y' $SPELL_CONFIG; then
-  local oldIFS=$IFS
-  export IFS="
-"
+  OUTPUT=$( $DIALOGPROG --title "$TITLE" --backtitle "$TITLE" \
+            --nocancel --stdout --single-quoted --checklist   \
+            "Select which features you'd like supported.
+            If you don't know what these are, then just press OK
+            to build all features."                              \
+            0 0 0 "${OPTS[@]}" ) &&
 
-  TITLE="net-conf option selection"
-  OPTIONDIR="$SCRIPT_DIRECTORY/options"
-  OPTIONLIST=`ls $OPTIONDIR`
-  DIALOG="dialog
---backtitle
-net-conf option selection
---stdout"
+  # OUTPUT now contains the list of modules to build
+  # Yes, we don't quote $OUTPUT. We want each module as a seperate arg
+  output_option_config $OUTPUT
 
-  if query "Would you like to selection options from the menu? (N will build all options)" n
-  then
+  # When either of those fail we return failure
+  # and fall back to option_config_list
+}
 
-    option_config
-    CONFIG_OPTS=$SPELL_CONFIG
+option_config_list() {
+  local FILE QUESTION STATUS NAME
 
-  else
+  for FILE in $OPTIONDIR/* ;do
+    source $FILE
+    NAME=${FILE##*/}
+    config_query $NAME "$QUESTION" $STATUS
+  done
+}
 
-    CONFIG_OPTS="
-    GETTEXT=y\n\
-    UNIX=y\n\
-    INET=y\n\
-    INET6=y\n\
-    NOVELL=y\n\
-    APPLETALK=y\n\
-    AFAX25=y\n\
-    AFNETROM=y\n\
-    AFROSE=y\n\
-    AFX25=y\n\
-    AFECONET=y\n\
-    AFASH=y\n\
-    ETHERNET=y\n\
-    ARCNET=y\n\
-    SLIP=y\n\
-    PPP=y\n\
-    IPIP=y\n\
-    STRIP=y\n\
-    TOKEN=y\n\
-    HWAX25=y\n\
-    HWROSE=y\n\
-    HWNETROM=y\n\
-    HWX25=y\n\
-    FRAME=y\n\
-    SIT=y\n\
-    FDDI=y\n\
-    HIPPI=y\n\
-    HWASH=y\n\
-    CISCO=y\n\
-    IRDA=y\n\
-    HWECONET=y\n\
-    IPMASQ=y\n\
-    IPTOOLS=y\n\
-    DECNET=n\n\
-    MII=y\n"
 
-  fi
+# Perform the configuration
+OPTIONDIR="$SCRIPT_DIRECTORY/options"
 
-  # we're gonna disable decnet support without asking -- it's broke 
-  persistent_add DECNET
-  echo 'DECNET=n\nCONFIGURED=y' >> $SPELL_CONFIG
+# I cheat. I'm not really re-using this answer,
+# but it makes for a neat way to skip the prompt on later non-reconf casts.
 
-  IFS=$oldIFS
+config_query NETTOOLS_CONFIG_GUI \
+  "Would you like to use a dialog menu to select options? (recommended)" n &&
+option_config_menu ||
+option_config_list
 
-fi
+config_set_option NETTOOLS_CONFIG_GUI n



More information about the SM-Commit mailing list