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

Matt Helsley matthltc at us.ibm.com
Tue Aug 4 21:42:28 PDT 2009


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

Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
Cc: Linux Containers <containers at lists.linux-foundation.org>
---
 rewrite-cr-header.sh |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/rewrite-cr-header.sh b/rewrite-cr-header.sh
index 63a2e88..bb334b8 100755
--- a/rewrite-cr-header.sh
+++ b/rewrite-cr-header.sh
@@ -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
 
 (
-- 
1.5.6.3


_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list