Attached you will find a small patch to runme, to allow runme to be 
used in batch mode, not asking for user input unless it has to.

I use this for applying netfilter patches in automated kernel builds, 
and have it drop back on the normal runme prompt when it needs 
attention.

It also changes the newly added "reverse" option to "--reverse" to 
syntactially separate it from suite names, and updated the usage to 
cover both options.

Regards
Henrik
Index: runme
===================================================================
RCS file: /cvsroot/netfilter/userspace/patch-o-matic/runme,v
retrieving revision 1.19
diff -u -w -r1.19 runme
--- runme	19 Feb 2002 09:16:19 -0000	1.19
+++ runme	19 Feb 2002 15:43:12 -0000
@@ -399,6 +400,9 @@
         CURRENT=`expr $CURRENT + 1`
         if [ $CURRENT -gt $# ];
         then
+    if [ $BATCH ]; then
+	return
+    fi
     printheader "$PROCESSED"
     ANSWER=""
     while [ ! $ANSWER ]
@@ -489,6 +493,16 @@
 		echo The $SUITE/$BASE ${PROTO:+$PROTO } patch:
 		if [ -f $THIS_PATCH.help ]; then while read LINE; do echo "   $LINE"; done < $THIS_PATCH.help; fi
 		ANSWER=""
+		if [ $BATCH ]; then
+		    if test_patch $THIS_PATCH ${PROTO:-"ipv4"}
+		    then
+			apply_patch $THIS_PATCH ${PROTO:-"ipv4"}
+			PROCESSED="$PROCESSED $SUITE/$BASE${PROTO:+-$PROTO}"
+			ANSWER=Y
+		    else
+			echo TEST FAILED: patch NOT `modesense 2`.
+		    fi
+		fi
 		while [ "$ANSWER" = "" ]
 		do
 		    echo "-----------------------------------------------------------------"
@@ -589,9 +603,16 @@
     exit 1
 fi 
 
+# Check to see if we are running in batch mode
+BATCH=
+if [ "$1" = "--batch" ]; then
+    BATCH=1
+    shift
+fi
+
 # Check to see if we are applying or reversing patches
 MODE=
-if [ $1 = reverse ]; then
+if [ "$1" = "--reverse" ]; then
     shift
     MODE=UN
 fi
@@ -608,8 +629,12 @@
 	PATCHES=$1
 else
     echo
-    echo "Usage: $0 [reverse] suite|suite/patch-file"
+    echo "Usage: $0 [--batch] [--reverse] suite|suite/patch-file"
+    echo
+    echo "  --batch	batch mode, automatically applying patches"
+    echo "  --reverse	back out the selected patches"
     echo
+
     echo Possible patch-o-matic suites:
     echo
     for x in */SUITE; do

Reply via email to