[PATCH modular 7/8] config: add user input checking for *DIR environment variables
Gaetan Nadon
memsize at videotron.ca
Thu Dec 16 18:31:49 PST 2010
Check that the supplied path is a full patch name and not a relative
path name.
Autoconf configure srcipt does the same check:
error: expected an absolute directory name for --libdir: lib
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
build.sh | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/build.sh b/build.sh
index 659450e..ae1adf0 100755
--- a/build.sh
+++ b/build.sh
@@ -980,6 +980,21 @@ usage() {
envoptions
}
+# Ensure the named variable value contains a full path name
+# arguments:
+# $1 - the variable value (the path to examin)
+# $2 - the name of the variable
+# returns:
+# returns nothing or exit on error with message
+check_full_path () {
+ if [ X"`expr substr $1 1 1`" != X/ ]; then
+ echo "The path \"$1\" supplied by \"$2\" must be a full path name"
+ echo ""
+ usage
+ exit 1
+ fi
+}
+
HAVE_ARCH="`uname -i`"
DIR_ARCH=""
DIR_CONFIG="."
@@ -1178,35 +1193,43 @@ if [ X"${PREFIX}" = X ] && [ X"$LISTONLY" = X ]; then
exit 1
fi
+check_full_path $PREFIX PREFIX
+
# Set the default value for EPREFIX
if [ X"$EPREFIX_SET" = X ]; then
EPREFIX=$PREFIX
fi
+check_full_path $EPREFIX EPREFIX
# Set the default value for BINDIR
if [ X"$BINDIR_SET" = X ]; then
BINDIR=$EPREFIX/bin
fi
+check_full_path $BINDIR BINDIR
# Set the default value for DATAROOTDIR
if [ X"$DATAROOTDIR_SET" = X ]; then
DATAROOTDIR=$PREFIX/share
fi
+check_full_path $DATAROOTDIR DATAROOTDIR
# Set the default value for DATADIR
if [ X"$DATADIR_SET" = X ]; then
DATADIR=$DATAROOTDIR
fi
+check_full_path $DATADIR DATADIR
# Set the default value for LIBDIR
if [ X"$LIBDIR_SET" = X ]; then
LIBDIR=$EPREFIX/lib
fi
+check_full_path $LIBDIR LIBDIR
# Set the default value for LOCALSTATEDIR
if [ X"$LIBDIR_SET" = X ]; then
LOCALSTATEDIR=$PREFIX/var
fi
+check_full_path $LOCALSTATEDIR LOCALSTATEDIR
HOST_OS=`uname -s`
export HOST_OS
--
1.6.0.4
More information about the xorg-devel
mailing list