aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Akhlaghi <mohammad@akhlaghi.org>2019-09-16 14:46:46 +0100
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2019-09-16 14:57:04 +0100
commite8a05d4c9a03d28e6a962b37c967f31ee93a7183 (patch)
tree0e107cdb11162ed44bda02ea00b738947f020677
parent5ab5ad03b5a3b48619987033bf3bedb333bfa9b1 (diff)
Configure script won't allow build directory to be under source
Users that are not familiar with the file structure of the project may specify the current directory (to-level source directory) as their build-directory. This will cause a crash right after answering the questions, where `rm' will complain about `tex/build' not being deleted because it exists as a directory. To avoid such confusing situtations, the configure script now checks if the build directory is actually a sub-directory of the source. If it is, it will complain with a short message and abort. Also, a `CAUTION' statment has been put in the initial description, right ontop of the question. This bug was reported Carlos Allende Prieto and David Valls-Gabaud.
-rw-r--r--.file-metadatabin6250 -> 6250 bytes
-rwxr-xr-xreproduce/software/bash/configure.sh32
2 files changed, 28 insertions, 4 deletions
diff --git a/.file-metadata b/.file-metadata
index b779b19..07d4ceb 100644
--- a/.file-metadata
+++ b/.file-metadata
Binary files differ
diff --git a/reproduce/software/bash/configure.sh b/reproduce/software/bash/configure.sh
index 14268d9..5c46496 100755
--- a/reproduce/software/bash/configure.sh
+++ b/reproduce/software/bash/configure.sh
@@ -230,8 +230,14 @@ during this configuration. It can help encourage you to set the actual
build directory in a very different address from this one (one that can be
deleted and has large volume), while having easy access to it from here.
+--- CAUTION ---
+Do not choose any directory under the top source directory (this
+directory). The build directory cannot be a subdirectory of the source.
+---------------
+
EOF
bdir=
+ currentdir=$(pwd)
junkname=pure-junk-974adfkj38
while [ x$bdir == x ]
do
@@ -243,18 +249,36 @@ EOF
# If it exists, see if we can write in it. If not, try making it.
if [ -d $build_dir ]; then
if mkdir $build_dir/$junkname 2> /dev/null; then
+ instring="the already existing"
bdir=$(absolute_dir $build_dir)
- echo " -- Build directory: '$bdir'"
rm -rf $build_dir/$junkname
else
- echo " -- Can't write in '$build_dir'"
+ echo " -- Can't write in '$build_dir'"; echo
fi
else
if mkdir $build_dir 2> /dev/null; then
+ instring="the newly created"
bdir=$(absolute_dir $build_dir)
- echo " -- Build directory set to (the newly created): '$bdir'"
else
- echo " -- Can't create '$build_dir'"
+ echo " -- Can't create '$build_dir'"; echo
+ fi
+ fi
+
+ # Make sure the given directory is not a subdirectory of the
+ # source directory.
+ if ! [ x"$bdir" = x ]; then
+ if [[ $bdir == $currentdir* ]]; then
+
+ # If it was newly created, it will be empty, so delete it.
+ if ! [ "$(ls -A $bdir)" ]; then rm --dir $bdir; fi
+
+ # Inform the user that this is not acceptable and reset `bdir'.
+ bdir=
+ echo " -- The build-directory cannot be under the source-directory."
+ echo " Please specify another build-directory that is outside of the source."
+ echo ""
+ else
+ echo " -- Build directory set to ($instring): '$bdir'"
fi
fi