aboutsummaryrefslogtreecommitdiff
path: root/reproduce/software/shell/configure.sh
diff options
context:
space:
mode:
authorMohammad Akhlaghi <mohammad@akhlaghi.org>2020-06-27 23:49:36 +0100
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2020-06-27 23:49:36 +0100
commit3d7d8cedfe0698e895949027906ce5ca996aad17 (patch)
tree108627d6dcb039ad340e75b1b14081524cc5a3df /reproduce/software/shell/configure.sh
parent57f922480d62a826b3e6030c81b85b412794fd4c (diff)
parentc151eddbcc5f4208b40dc3037a8ae8adb0ff9173 (diff)
Imported recent work in master, minor conflict fixed in paper.mk
Only two conflicts came up in the newly added comments of 'paper.mk' in the Maneage branch. It happened because in this project we don't use 'pdflatex', but 'latex' alone.
Diffstat (limited to 'reproduce/software/shell/configure.sh')
-rwxr-xr-xreproduce/software/shell/configure.sh139
1 files changed, 114 insertions, 25 deletions
diff --git a/reproduce/software/shell/configure.sh b/reproduce/software/shell/configure.sh
index b2e3979..38dcf7f 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
@@ -1113,7 +1156,7 @@ ln -s $instdir .local
ln -s $texdir tex/build
ln -s $tikzdir tex/tikz
# --------- Delete for no Gnuastro ---------
-ln -s $topdir/reproduce/software/config/gnuastro .gnuastro
+ln -s $topdir/reproduce/analysis/config/gnuastro .gnuastro
# ------------------------------------------
@@ -1250,6 +1293,48 @@ fi
+# Find Zenodo URL for software downloading
+# ----------------------------------------
+#
+# All free-software source tarballs that are potentially used in Maneage
+# are also archived in Zenodo with a certain concept-DOI. A concept-DOI is
+# a Zenodo terminology, meaning a fixed DOI of the project (that can have
+# many sub-DOIs for different versions). By default, the concept-DOI points
+# to the most recently uploaded version. However, the concept-DOI itself is
+# not directly usable for downloading files. The concept-DOI will just take
+# us to the top webpage of the most recent version of the upload.
+#
+# The problem is that as more software are added (as new Zenodo versions),
+# the most recent Zenodo-URL that the concept-DOI points to, also
+# changes. The most reliable solution was found to be the tiny script below
+# which will download the DOI-resolved webpage, and extract the Zenodo-URL
+# of the most recent version from there (using the 'coreutils' tarball as
+# an example, the directory part of the URL for all the other software are
+# the same).
+user_backup_urls=""
+zenodocheck=.build/software/zenodo-check.html
+if $downloader $zenodocheck https://doi.org/10.5281/zenodo.3883409; then
+ zenodourl=$(sed -n -e'/coreutils/p' $zenodocheck \
+ | sed -n -e'/http/p' \
+ | tr ' ' '\n' \
+ | grep http \
+ | sed -e 's/href="//' -e 's|/coreutils| |' \
+ | awk 'NR==1{print $1}')
+else
+ zenodourl=""
+fi
+rm -f $zenodocheck
+
+# Add the Zenodo URL to the user's given back software URLs. Since the user
+# can specify 'user_backup_urls' (not yet implemented as an option in
+# './project'), we'll give preference to their specified servers, then add
+# the Zenodo URL afterwards.
+user_backup_urls="$user_backup_urls $zenodourl"
+
+
+
+
+
# Build core tools for project
# ----------------------------
#
@@ -1258,7 +1343,7 @@ fi
# (minimal Bash-like shell) and Flock (to lock files and enable serial
# download).
./reproduce/software/shell/pre-make-build.sh \
- "$bdir" "$ddir" "$downloader"
+ "$bdir" "$ddir" "$downloader" "$user_backup_urls"
@@ -1272,6 +1357,7 @@ fi
# tools, but we have to be very portable (and use minimal features in all).
echo; echo "Building necessary software (if necessary)..."
.local/bin/make -k -f reproduce/software/make/basic.mk \
+ user_backup_urls="$user_backup_urls" \
sys_library_path=$sys_library_path \
rpath_command=$rpath_command \
static_build=$static_build \
@@ -1293,20 +1379,22 @@ echo; echo "Building necessary software (if necessary)..."
# script. Bash and Make were the tools we need to run Makefiles, so we had
# to build them in this script. But after this, we can rely on Makefiles.
if [ $jobs = 0 ]; then
- numthreads=$($instdir/bin/nproc --all)
+ numthreads=$(.local/bin/nproc --all)
else
numthreads=$jobs
fi
.local/bin/env -i HOME=$bdir \
- .local/bin/make -k -f reproduce/software/make/high-level.mk \
- sys_library_path=$sys_library_path \
- rpath_command=$rpath_command \
- static_build=$static_build \
- numthreads=$numthreads \
- on_mac_os=$on_mac_os \
- sys_cpath=$sys_cpath \
- host_cc=$host_cc \
- -j$numthreads
+ .local/bin/make -k -f reproduce/software/make/high-level.mk \
+ user_backup_urls="$user_backup_urls" \
+ sys_library_path=$sys_library_path \
+ rpath_command=$rpath_command \
+ all_highlevel=$all_highlevel \
+ static_build=$static_build \
+ numthreads=$numthreads \
+ on_mac_os=$on_mac_os \
+ sys_cpath=$sys_cpath \
+ host_cc=$host_cc \
+ -j$numthreads
@@ -1400,26 +1488,27 @@ prepare_name_version ()
fi
}
+# Import the context/sentences for placing between the list of software
+# names during their acknowledgment.
+. $cdir/software_acknowledge_context.sh
+
# Report the different software in separate contexts (separating Python and
# TeX packages from the C/C++ programs and libraries).
proglibs=$(prepare_name_version $verdir/proglib/*)
pymodules=$(prepare_name_version $verdir/python/*)
texpkg=$(prepare_name_version $verdir/tex/texlive)
-# Write them as one paragraph for LaTeX.
+# Acknowledge these software packages in a LaTeX paragraph.
pkgver=$mtexdir/dependencies.tex
-.local/bin/echo "This research was done with the following free" > $pkgver
-.local/bin/echo "software programs and libraries: $proglibs." >> $pkgver
+
+# Add the text to the ${pkgver} file.
+.local/bin/echo "$thank_software_introduce " > $pkgver
+.local/bin/echo "$thank_progs_libs $proglibs. " >> $pkgver
if [ x"$pymodules" != x ]; then
- .local/bin/echo "Within Python, the following modules" >> $pkgver
- echo "were used: $pymodules." >> $pkgver
+ .local/bin/echo "$thank_python $pymodules. " >> $pkgver
fi
-.local/bin/echo "The \LaTeX{} source of the paper was compiled" >> $pkgver
-.local/bin/echo "to make the PDF using the following packages:" >> $pkgver
-.local/bin/echo "$texpkg. We are very grateful to all their" >> $pkgver
-.local/bin/echo "creators for freely providing this necessary" >> $pkgver
-.local/bin/echo "infrastructure. This research (and many " >> $pkgver
-.local/bin/echo "others) would not be possible without them." >> $pkgver
+.local/bin/echo "$thank_latex $texpkg. " >> $pkgver
+.local/bin/echo "$thank_software_conclude" >> $pkgver
# Prepare the BibTeX entries for the used software (if there are any).
hasentry=0