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 <[email protected]>
Cc: Linux Containers <[email protected]>
---
 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
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Devel mailing list
[email protected]
https://openvz.org/mailman/listinfo/devel

Reply via email to