Skip to contentSkip to conversation

cr_tests: Replace KERNELSRC envvar with a required commandline option

PATCH In review Matt Helsley 1 participant 1 message Aug 5, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 cr_tests: Replace KERNELSRC envvar with a required commandline option

Replace KERNELSRC environment variable with an explicit commandline option which sets the variable in the rewrite-cr-header.sh script.

Cc Linux Containers <containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
---
 rewrite-cr-header.sh |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
rewrite-cr-header.sh +31 -2
index 63a2e88..bb334b8 100755
@@ -6,11 +6,40 @@
 # Sanitize checkpoint/restart kernel headers for userspace.
 #
 
-KERNELSRC=../oren
+function usage()
+{
+	echo "Usage: $0 [-h|--help] -s|--kernel-src=DIR"
+}
+
+OPTIONS=`getopt -o s:o:h --long kernel-src:,output:,help -- "$@"`
+eval set -- "${OPTIONS}"
+while true ; do
+	case "$1" in
+	-s|--kernel-src)
+		KERNELSRC="$2"
+		shift 2 ;;
+	-h|--help)
+		usage
+		exit 0 ;;
+	--)
+		shift
+		break ;;
+	*)
+		echo "Unknown option: $1"
+		shift
+		echo "Unparsed options: $@"
+		usage 1>&2
+		exit 2 ;;
+	esac
+done
+
+if [ -z "${KERNELSRC}" -o '!' -d "${KERNELSRC}" ]; then
+	usage 1>&2
+	exit 2
+fi
 
 ################################################################################
 
-[ -z "${KERNELSRC}" ] && exit -1
 mv cr.h cr.h.bak || exit -1
 
 (
Signature · 1 line
1.5.6.3