From c7ff75a5f0633d21860a91060a6c3a4fb64660b2 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Fri, 12 Apr 2019 01:01:02 +0100 Subject: Configure script dealing properly with empty software directories Until now, we hadn't actually tested the case where a whole software directory (Python modules in particular) is empty. So the configure script finished with some errors in this case. With this commit, this step of the configure script was modified to deal with such cases cleanly. Also, in `initialize.mk', I added a `-f' to the symbolic link command, so it doesn't complain if the file link already exists. --- configure | 54 +++++++++++++++++++++++++--------------- reproduce/src/make/initialize.mk | 2 +- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/configure b/configure index 7a97d93..6760d0b 100755 --- a/configure +++ b/configure @@ -654,7 +654,7 @@ itidir=$verdir/tex if ! [ -d $itidir ]; then mkdir $itidir; fi texdir=$bdir/tex -if ! [ -d $texdir ]; then mkdir $texdir; fi +if ! [ -d $texdir ]; then mkdir $texdir; ln -s $texdir tex/pipeline; fi mtexdir=$texdir/macros if ! [ -d $mtexdir ]; then mkdir $mtexdir; fi @@ -1019,25 +1019,40 @@ fi -# Put all the names and versions in a human-readable format in LaTeX. +# Put all the names and versions in a human-readable paragraph. function prepare_name_version() { - # Total number of tools to report. - num=$(.local/bin/cat "$@" | .local/bin/wc -l) - - # Put them all in one paragraph. - .local/bin/cat "$@" \ - | .local/bin/sort \ - | .local/bin/awk 'NF>0 { \ - c++; \ - if(c==1) \ - { \ - if('$num'==1) printf("%s", $0); \ - else printf("%s", $0); \ - } \ - else if(c=='$num') printf(" and %s\n", $0); \ - else printf(", %s", $0) \ - }' + # First see if the (possible) `*' in the input arguments corresponds to + # anything. Note that some of the given directories may be empty (no + # software installed). + hasfiles=0 + for f in $@; do + if [ -f $f ]; then hasfiles=1; break; fi; + done + + # If there are any files, merge all the names in a paragraph. + if [ $hasfiles = 1 ]; then + + # Count how many names there are. This is necessary to identify the + # last element. + num=$(.local/bin/cat $@ \ + | .local/bin/sed '/^\s*$/d' \ + | .local/bin/wc -l) + + # Put them all in one paragraph. + .local/bin/cat $@ \ + | .local/bin/sort \ + | .local/bin/awk 'NF>0 { \ + c++; \ + if(c==1) \ + { \ + if('$num'==1) printf("%s", $0); \ + else printf("%s", $0); \ + } \ + else if(c=='$num') printf(" and %s\n", $0); \ + else printf(", %s", $0) \ + }' + fi } # Report the different software in separate contexts (separating Python and @@ -1050,8 +1065,7 @@ texpkg=$(prepare_name_version $verdir/tex/texlive) 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 -npython=$(.local/bin/ls $verdir/python/* | .local/bin/wc -l) -if [ $npython != 0 ]; then +if [ x$pymodules != x ]; then .local/bin/echo "Within Python, the following modules" >> $pkgver echo "were used: $pymodules." >> $pkgver fi diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk index 3c272d8..286e64e 100644 --- a/reproduce/src/make/initialize.mk +++ b/reproduce/src/make/initialize.mk @@ -162,7 +162,7 @@ export MPI_PYTHON3_SITEARCH := .SUFFIXES: $(lockdir): | $(BDIR); mkdir $@ $(texbdir): | $(texdir); mkdir $@ -$(tikzdir): | $(texbdir); mkdir $@ && ln -s $(tikzdir) tex/tikz +$(tikzdir): | $(texbdir); mkdir $@ && ln -fs $@ tex/tikz -- cgit v1.2.1