diff -uNr patch-o-matic-20021012.orig.runme24/runme patch-o-matic-20021012/runme --- patch-o-matic-20021012.orig.runme24/runme Thu Aug 8 09:42:03 2002 +++ patch-o-matic-20021012/runme Sun Oct 13 16:51:09 2002 @@ -52,7 +52,7 @@ dd if=/dev/urandom bs=32 count=1 2>/dev/null | od -x -w32 -A n | tr -d ' ' } -# Too many rejects from trying to patch Configure.help and Config.in. +# Too many rejects from trying to patch Configure.help/Config.help and Config.in. # So we use special format: First line specifies entry we want to # follow, and rest of file is pasted in under that. @@ -119,14 +119,19 @@ return 0 } -# Args: configure.help file, Documentation dir. +# Args: configure.help file, Documentation file to which to add it. apply_config_help_change() { + if [ "$2" = '/dev/null' ]; then + #return 0 #Use this one if you don't care that the config*.help file is not getting updated + return 1 #Fail + fi + BASEFILE=`basename $2` #Configure.help or Config.help PRIOR="`head -1 $1`" - LINE=`fgrep -x -n "$PRIOR" $2/Configure.help | cut -d: -f1 | head -1` + LINE=`fgrep -x -n "$PRIOR" $2 | cut -d: -f1 | head -1` if [ -z "$LINE" ] || [ "$LINE" -eq 0 ] then - echo Could not find place to slot in Configure.help entry >&2 + echo Could not find place to slot in $BASEFILE entry >&2 return 1 fi @@ -135,13 +140,13 @@ # Reverse "patch" NUMLINES1=`sed -n \$= $1` - NUMLINES2=`sed -n \$= $2/Configure.help` + NUMLINES2=`sed -n \$= $2` BEGIN=2 - LINES=`fgrep -nx "\`sed -n 2p $1\`" $2/Configure.help | cut -d: -f1` + LINES=`fgrep -nx "\`sed -n 2p $1\`" $2 | cut -d: -f1` if [ -z "$LINES" ] then - echo Configure.help text not found >&2 + echo $BASEFILE text not found >&2 return 1 fi @@ -152,7 +157,7 @@ TESTLINE=$BEGIN # Be paranoid and check for match on all lines while `let "$TESTLINE <= $NUMLINES1"`; do - NOMATCH=`awk "NR==$x + $TESTLINE - $BEGIN" $2/Configure.help|\ + NOMATCH=`awk "NR==$x + $TESTLINE - $BEGIN" $2|\ fgrep -xcv "\`sed -n -e ${TESTLINE}p $1\`"`; if [ $NOMATCH -ne 0 ]; then continue 2; fi @@ -165,42 +170,42 @@ done; # for if [ ! "$MATCHES" ]; then - echo Configure.help text not found >&2 + echo $BASEFILE text not found >&2 return 1 fi; for x in $MATCHES; do -# if (head -`expr $x - 1` $2/Configure.help && \ -# tail -n +`expr $x + $NUMLINES1` $2/Configure.help) > $2/Configure.help.tmp - if (awk "NR==1,NR==$x - 1" $2/Configure.help && \ - awk "NR==$x + $NUMLINES1,NR=0" $2/Configure.help) > $2/Configure.help.tmp +# if (head -`expr $x - 1` $2 && \ +# tail -n +`expr $x + $NUMLINES1` $2) > $2.tmp + if (awk "NR==1,NR==$x - 1" $2 && \ + awk "NR==$x + $NUMLINES1,NR=0" $2) > $2.tmp then - mv $2/Configure.help.tmp $2/Configure.help + mv $2.tmp $2 else - echo Could not update Configure.help >&2 - rm -f $2/Configure.help.tmp + echo Could not update $BASEFILE >&2 + rm -f $2.tmp return 1 fi done - echo " Configure.help updated" + echo " $BASEFILE updated" return 0 fi #Apply "Patch" - rm -f $2/Configure.help.tmp + rm -f $2.tmp # Use awk to force newline if last line of $1 has only spaces # Necessary to properly remove inserted text if patch is reversed - if (awk "NR==1,NR==$LINE-2" $2/Configure.help && awk "NR==2,NR==0" $1 && echo && \ - awk "NR==$LINE-1,NR==0" $2/Configure.help) > $2/Configure.help.tmp + if (awk "NR==1,NR==$LINE-2" $2 && awk "NR==2,NR==0" $1 && echo && \ + awk "NR==$LINE-1,NR==0" $2) > $2.tmp then - mv $2/Configure.help.tmp $2/Configure.help + mv $2.tmp $2 else - echo Could not slot in Configure.help entry >&2 - rm -f $2/Configure.help.tmp + echo Could not slot in $BASEFILE entry >&2 + rm -f $2.tmp return 1 fi - echo " Placed new Configure.help entry" + echo " Placed new $BASEFILE entry" return 0 } @@ -335,8 +340,19 @@ echo Testing patch $1... + if [ -f "$KTMPDIR/net/$2/netfilter/Config.help" ]; then + DOCUMENTATIONFILE="$KTMPDIR/net/$2/netfilter/Config.help" + elif [ -f "$KTMPDIR/Documentation/Configure.help" ]; then + DOCUMENTATIONFILE="$KTMPDIR/Documentation/Configure.help" + else + echo Warning - no help text file could be found in either >&2 + echo $KTMPDIR/net/$2/netfilter/Config.help >&2 + echo or $KTMPDIR/Documentation/Configure.help >&2 + DOCUMENTATIONFILE=/dev/null + fi + if apply_config_in_changes $1 $KTMPDIR/net/$2/netfilter && - apply_config_help_changes $1 $KTMPDIR/Documentation && + apply_config_help_changes $1 $DOCUMENTATIONFILE && apply_makefile_changes $1 $KTMPDIR/net/$2/netfilter && apply_conntrack_h_changes $1 $KTMPDIR/include/linux/netfilter_$2 then : @@ -461,7 +477,7 @@ fi fi apply_config_in_changes $1 $KERNEL_DIR/net/$2/netfilter/ - apply_config_help_changes $1 $KERNEL_DIR/Documentation/ + apply_config_help_changes $1 $DOCUMENTATIONFILE apply_makefile_changes $1 $KERNEL_DIR/net/$2/netfilter/ apply_conntrack_h_changes $1 $KERNEL_DIR/include/linux/netfilter_$2 }