aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedram Ashofteh Ardakani <pedramardakani@pm.me>2020-06-25 13:33:36 +0430
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2020-06-25 23:25:51 +0100
commit5c3f2c4e38bec20616e4cf6ac568298a614df040 (patch)
tree8abb6b1ac69470bf7c830c326d7b5a5b235c86ce
parent4785b459b8c31ae11b8974724ccbf2723e001d75 (diff)
Check if there is enough available in selected build directory
Until now, Maneage would accept the given build directory, regardless of the free memory available there. This could cause confusing situations for new users who don't know about the minimum storage requirement. With this commit, after all other checks on the given build directory are completed, the configure script will check the available space and warns the user if there is less than almost 5GB free space available in the build directory (with a 5 second delay). It won't cause a crash because some projects may require roughly smaller than this space (the default only needs roughly 2GB). But we also don't want the host's partition to get too close to being full, causing them problems elsewhere. We can change the behavior as desired in future commits.
-rwxr-xr-xreproduce/software/shell/configure.sh47
1 files changed, 45 insertions, 2 deletions
diff --git a/reproduce/software/shell/configure.sh b/reproduce/software/shell/configure.sh
index 68009a2..6694e17 100755
--- a/reproduce/software/shell/configure.sh
+++ b/reproduce/software/shell/configure.sh
@@ -153,6 +153,38 @@ check_permission ()
+# Check if there is enough free space available in the build directory
+# --------------------------------------------------------------------
+#
+# Use this function to check if there is enough free space in a
+# directory. It is meant to be passed to the 'if' statement in the
+# shell. So if there is enough space, it returns 0 (which translates to
+# TRUE), otherwise, the funcion returns 1 (which translates to FALSE).
+#
+# Expects to be called with two arguments, the first is the threshold and
+# the second is the desired directory. The 'df' function checks the given
+# path to see where it is mounted on, and how much free space there is on
+# that partition (in units of 1024 bytes).
+#
+# synopsis:
+# $ free_space_warning <acceptable_threshold> <path-to-check>
+#
+# example:
+# To check if there is 5MB of space available in /path/to/check
+# call the command with arguments as shown below:
+# $ free_space_warning 5000 /path/to/check/free/space
+free_space_warning()
+{
+ fs_threshold=$1
+ fs_destpath=$2
+ return $(df $fs_destpath \
+ | awk 'FNR==2 {if($4>'$fs_threshold') print 1; \
+ else print 0; }')
+}
+
+
+
+
# Check for C/C++ compilers
# -------------------------
@@ -729,14 +761,14 @@ EOF
bdir=$(absolute_dir $build_dir)
rm -rf $build_dir/$junkname
else
- echo " ** Can't write in '$build_dir'"; echo
+ echo " ** Can't write in '$build_dir'";
fi
else
if mkdir $build_dir 2> /dev/null; then
instring="the newly created"
bdir=$(absolute_dir $build_dir)
else
- echo " ** Can't create '$build_dir'"; echo
+ echo " ** Can't create '$build_dir'";
fi
fi
@@ -759,8 +791,19 @@ EOF
# file permissions.
if ! [ x"$bdir" = x ]; then
if ! $(check_permission $bdir); then
+ # Unable to handle permissions well
bdir=
echo " ** File permissions can't be modified in this directory"
+ else
+ # Able to handle permissions, now check for 5GB free space
+ # in the given partition (note that the number is in units
+ # of 1024 bytes). If this is not the case, print a warning.
+ if $(free_space_warning 5000000 $bdir); then
+ echo " !! LESS THAN 5GB FREE SPACE IN: $bdir"
+ echo " !! We recommend choosing another partition."
+ echo " !! Build will continue in 5 seconds..."
+ sleep 5
+ fi
fi
fi