$NetBSD: patch-ab,v 1.1.1.1 2001/10/21 22:50:01 mjl Exp $

--- gensysinfo.orig	Mon Jul 16 01:04:59 2001
+++ gensysinfo	Mon Oct 22 00:41:55 2001
@@ -2,5 +2,8 @@
 #
+# Copyright (c) 2001 Andrey Simonenko
+#
 # Generate information about system and generate IP Filter
 # version number by parsing /usr/include/netinet/ipl.h or
-# /usr/src/sys/netinet/ipl.h file.
+# /usr/src/sys/netinet/ipl.h file, or output of
+# the "/sbin/ipf -V" command.
 #
@@ -14,2 +17,4 @@
 
+IPF=/sbin/ipf
+
 IPL_H=/usr/include/netinet/ipl.h
@@ -17,10 +22,2 @@
 
-if [ ! -f ${IPL_H} -a ! -f ${IPL_H_SRC} ]; then
-	${ECHO}
-	${ECHO} ">> Can't find file ${IPL_H} or ${IPL_H_SRC}."
-	${ECHO} ">> Is IP Filter installed on this system?"
-	${ECHO}
-	exit 1
-fi
-
 if [ ! -f ${IPL_H} ]; then
@@ -30,9 +27,26 @@
 ${ECHO} "** Generating information about system"
-SYSTEM="`${UNAME} -m`--`${UNAME} -s` `${UNAME} -r`"
+SYSTEM="`${UNAME} -s`/`${UNAME} -m` `${UNAME} -r`"
 ${ECHO} "  -- Your system: ${SYSTEM}"
 
-${ECHO} "** Parsing file ${IPL_H}"
-IPF_VERSION_ORIG=`${SED} -n '/^#[ 	]*define[	 ][	 ]*IPL_VERSION[	 ][	 ]*.*\".*v\([[:digit:]][[:digit:]]*\(\.[[:digit:]][[:digit:]]*\)*\).*\".*$/s//\1/p' ${IPL_H}`
+# if [ ! -f ${IPL_H} -a ! -f ${IPL_H_SRC} ]; then
+# 	${ECHO}
+# 	${ECHO} ">> Can't find ${IPL_H}"
+# 	${ECHO} ">> and ${IPL_H_SRC} file."
+# 	${ECHO}
+if [ ! -f ${IPF} -o ! -x ${IPF} ]; then
+	${ECHO} ">> Can't find ${IPF}, or it is not executable."
+	${ECHO} ">> Is IP Filter installed on this system?"
+	${ECHO}
+	exit 1
+fi
+	${ECHO} "** Parsing output of \"${IPF} -V\" command"
+IPF_VERSION_ORIG=`${IPF} -V 2>&1 | ${SED} -n -e 's/^.*IP[ 	]*Filter.*v\([[:digit:]][[:digit:]]*\(\.[[:digit:]][[:digit:]]*\)*\).*$/\1/p' | ${SED} -e '1q'`
+# else
+# ${ECHO} "** Parsing file ${IPL_H}"
+# IPF_VERSION_ORIG=`${SED} -n -e 's/^#[ 	]*define[	 ][	 ]*IPL_VERSION[	 ][	 ]*.*\".*v\([[:digit:]][[:digit:]]*\(\.[[:digit:]][[:digit:]]*\)*\).*\".*$/\1/p' ${IPL_H}`
+# fi
+
 IPF_VERSION_GEN=`${ECHO} ${IPF_VERSION_ORIG} | ${AWK} '
-	BEGIN { FS="." }
+	BEGIN { FS="."
+		err = 0 }
 	NF == 0 { err = 2 }
@@ -48,3 +62,3 @@
 	${ECHO}
-	${ECHO} ">> Don't know how to convert IP Filter version ${IPF_VERSION_ORIG} to single decimal number"
+	${ECHO} ">> Don't know how to convert IP Filter version ${IPF_VERSION_ORIG} to single decimal number."
 	${ECHO}
@@ -54,3 +68,4 @@
 	${ECHO}
-	${ECHO} ">> Can't find IP Filter version number in ${IPL_H}"
+	${ECHO} ">> Found IP Filter version number \"${IPF_VERSION_ORIG}\" doesn't look like version number."
+	${ECHO} ">> Can't determine IP Filter version number."
 	${ECHO}
