diff options
author | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2018-11-20 19:31:12 +0000 |
---|---|---|
committer | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2018-11-20 20:16:29 +0000 |
commit | 11d5e76a7f89abe6da0b7c2b948f97f5c1cdc508 (patch) | |
tree | 36675b4cfe15d8ae36ac3e715b3090e7c2298b8a | |
parent | 1edf44917b4d28eba7d7344616b2ed3b43e29168 (diff) |
Configure script passes if TeX Live was not finalized
When there is a problem in creating the final TeX Live installation, the
previous version of the pipeline would not understand and just finish! We
would later have problems in building the paper.
So the following series of steps were taken: to keep the recipes in a
shorter and easier to understand way, the steps to install TeX Live are now
one rule (that produce `.local/bin/texlive-ready-tlmgr' when its
successful), and the steps to install the necessary packages are in another
rule (that produce `.local/bin/texlive-ready' when its successful).
When control comes back inside configure, if `.local/bin/texlive-ready'
isn't there (something failed during the TeX Live installation, or building
packages), then the whole TeX Live installation directory
(`.local/texlive') will be deleted along with the two output files. This
will help ensure that future steps can check the availablility of a working
TeX Live in the pipeline.
-rwxr-xr-x | configure | 86 | ||||
-rw-r--r-- | reproduce/src/make/Top-Makefile | 33 | ||||
-rw-r--r-- | reproduce/src/make/dependencies.mk | 122 | ||||
-rw-r--r-- | reproduce/src/make/paper.mk | 43 |
4 files changed, 181 insertions, 103 deletions
@@ -182,7 +182,6 @@ if [ $rewritepconfig = yes ]; then else cat <<EOF - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -194,7 +193,6 @@ the system. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - EOF downloader="no-downloader-found" fi; @@ -482,7 +480,7 @@ fi # Build Basic dependencies # ------------------------ make -f reproduce/src/make/dependencies-basic.mk \ - static_build=$static_build #-j8 + static_build=$static_build -j8 @@ -497,37 +495,83 @@ make -f reproduce/src/make/dependencies-basic.mk \ # to build them in this script. But after this, we can rely on Makefiles. numthreads=$($instdir/bin/nproc) ./.local/bin/make -f reproduce/src/make/dependencies.mk \ - static_build=$static_build #-j$numthreads + static_build=$static_build -j$numthreads -# Print a final notice -# -------------------- +# Make sure TeX Live installed successfully +# ----------------------------------------- # -# The configuration is now complete, we can inform the user on the next -# step(s) to take. -echo -echo "----------------" -echo "The reproduction pipeline and its environment are SUCCESSFULLY configured." -echo -echo "Please run the following command to start." -echo "(Replace '8' with the number of CPU threads)" -echo -echo " ./.local/bin/make -j8" -echo -echo "To change the configuration later, please re-run './configure'," -echo "DO NOT manually edit the relevant files." -echo +# TeX Live is managed over the internet, so if there isn't any, or it +# suddenly gets cut, it can't be built. However, when TeX Live isn't +# installed, the pipeline and can do all its processing independent of +# it. It will just stop at the stage when all the processing is complete +# and it is only necessary to build the PDF. So we don't want to stop the +# pipeline if its not present. +if ! [ -f $instdir/bin/texlive-ready ]; then + $instdir/bin/texlive-ready-tlmgr + rm -rf $instdir/texlive + cat <<EOF + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TeX Live couldn't be installed during the configuration (probably because +there was no internet). TeX Live is only necessary in making the final PDF +(which is only done after all the analysis has been complete). It is not +used at all during the analysis. + +Therefore, if you don't need the final PDF, and just want to do the +analysis, you can safely ignore this warning and continue. +If you later have internet access and would like to add TeX live to your +pipeline, please delete the respective files, then re-run configure as +shown below. Within configure, answer 'n' (for "no") when asked to re-write +the configuration files. + rm .local/bin/texlive-ready-* + ./configure + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +EOF +fi -# Final target: the Makefile + + +# Final step: the Makefile # -------------------------- # # To see why this is the last step of the configuration, see above (when we # delete the top-level Makefile at the start of this script). ln -s $(pwd)/reproduce/src/make/Top-Makefile Makefile + + + + + +# Final notice +# ------------ +# +# The configuration is now complete, we can inform the user on the next +# step(s) to take. +cat <<EOF + +---------------- +The reproduction pipeline and its environment are configured with no errors. + +Please run the following command to start. +(Replace '8' with the number of CPU threads) + + ./.local/bin/make -j8 + +To change the configuration later, please re-run './configure', +DO NOT manually edit the relevant files. + +EOF diff --git a/reproduce/src/make/Top-Makefile b/reproduce/src/make/Top-Makefile index abd0f45..4c547be 100644 --- a/reproduce/src/make/Top-Makefile +++ b/reproduce/src/make/Top-Makefile @@ -93,19 +93,30 @@ tex/pipeline.tex: $(foreach f, initialize \ , $(mtexdir)/$(f).tex) # If no PDF is requested, or if LaTeX isn't available, don't - # continue to building LaTeX. - @if ! latex --version &> /dev/null || [ x$(pdf-build-final) = x ]; then + # continue to building the final PDF. Otherwise, merge all the TeX + # macros into one for building the PDF. + @if [ -f .local/bin/pdflatex ] && [ x"$(pdf-build-final)" != x ]; then + cat $(mtexdir)/*.tex > $@ + else echo echo "-----" - echo "The processing has COMPLETED SUCCESSFULLY! But we won't be" - echo "building the final LaTeX-built PDF." + echo "The processing has COMPLETED SUCCESSFULLY! But the final " + echo "LaTeX-built PDF paper will not be built." echo - echo "To do so, make sure you have LaTeX within the pipeline and" - echo "give a value to the 'pdf-build-final' variable. It is defined" - echo "in 'reproduce/config/pipeline/pdf-build.mk'." + if [ x$(more-on-building-pdf) = x1 ]; then + echo "To do so, make sure you have LaTeX within the pipeline (you" + echo "can check by running './.local/bin/latex --version'), _AND_" + echo "make sure that the 'pdf-build-final' variable has a value." + echo "'pdf-build-final' is defined in: " + echo "'reproduce/config/pipeline/pdf-build.mk'." + echo + echo "If you don't have LaTeX within the pipeline, please re-run" + echo "'./configure' when you have internet access. To speed it up," + echo "you can keep the previous configuration files (answer 'n'" + echo "when it asks about re-writing previous configuration files)." + else + echo "For more, run './.local/bin/make more-on-building-pdf=1'" + fi echo - exit 1 + echo "" > $@ fi - - # Merge all the TeX macros that are prepared for building the PDF. - @cat $(mtexdir)/*.tex > $@ diff --git a/reproduce/src/make/dependencies.mk b/reproduce/src/make/dependencies.mk index 768bafb..455a3b8 100644 --- a/reproduce/src/make/dependencies.mk +++ b/reproduce/src/make/dependencies.mk @@ -270,56 +270,70 @@ endif # Since we want to avoid complicating the PATH, we are putting a symbolic -# link of all the TeX Live executables in $(ibdir). Therefore, since the -# symbolic link is hard to track for Make (as a target), we'll make a -# simple ASCII file called `texlive-ready' when it is complete and use that -# as a target. -$(ibdir)/texlive-ready: reproduce/config/pipeline/dependency-texlive.mk - - # We'll need the current directory later down. - topdir=$$(pwd) - - # First, if necessary, we'll download the tarball. Note that since - # a new version of the installer is created every day, the - # installer's version is hard to configure at this stage and is - # mostly irrelevant. - if $(ibdir)/tlmgr --version &> /dev/null; then - echo "TeX Live manager ('tlmgr') is already installed." - else - if wget -O$(tdir)/install-tl-unx.tar.gz \ +# link of all the TeX Live executables in $(ibdir). But symbolic links are +# hard to track for Make (as a target). So we'll make a simple ASCII file +# called `texlive-ready' when it is complete and use that as a target. +$(ibdir)/texlive-ready-tlmgr: reproduce/config/pipeline/texlive.conf + + # To work with TeX live installation, we'll need the internet. + if ping -c1 ctan.org; then + # Download the TeX Live installation tarball. + $(DOWNLOADER) $(tdir)/install-tl-unx.tar.gz \ http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz - then - # Unpack, enter the directory, and do a basic installation. - cd $(ddir) - rm -rf install-tl-* - tar xf $(tdir)/install-tl-unx.tar.gz - cd install-tl-* - sed -e's|@installdir[@]|$(idir)|g' -e's|@topdir[@]|'"$$topdir"'|g' \ - $$topdir/reproduce/config/pipeline/texlive.conf > texlive.conf - ./install-tl --profile=texlive.conf - cd .. - rm -rf install-tl-* $(tdir)/install-tl-unx.tar.gz - - # Put a symbolic link of the TeX Live executables in - # `ibdir'. For `latex' do a copy, because it is the target of - # this rule and it won't cause problems. - ln -fs $(idir)/texlive/20*/bin/*/* $(ibdir)/ - fi + + # Unpack, enter the directory, and install based on the given + # configuration (prerequisite of this rule). + topdir=$$(pwd) + cd $(ddir) + rm -rf install-tl-* + tar xf $(tdir)/install-tl-unx.tar.gz + cd install-tl-* + sed -e's|@installdir[@]|$(idir)|g' -e's|@topdir[@]|'"$$topdir"'|g' \ + $$topdir/$< > texlive.conf + ./install-tl --profile=texlive.conf + + # Put a symbolic link of the TeX Live executables in `ibdir'. The + # main problem is that the year and build system (for example + # `x86_64-linux') are also in the directory names, making it hard + # to be generic. We are using wildcards here, but only in this + # Makefile, not in any other. + ln -fs $(idir)/texlive/20*/bin/*/* $(ibdir)/ + + # Clean up and build the final target. + cd .. && rm -rf install-tl-* $(tdir)/install-tl-unx.tar.gz + echo "TeX Live is ready." > $@ fi - # In scenarios like having no internet on the first run, its - # possible to get to this point without actually having `tlmgr' - # ready for usage. Since the pipeline can still do its processing - # without building the final PDF, we don't want to stop the build. - if $(ibdir)/tlmgr --version &> /dev/null; then + + + + +# To keep things modular and simple, we'll break up the installation of TeX +# Live itself (only very basic TeX and LaTeX) and the installation of its +# necessary packages into two packages. +$(ibdir)/texlive-ready: reproduce/config/pipeline/dependency-texlive.mk \ + $(ibdir)/texlive-ready-tlmgr + + # To work with TeX live installation, we'll need the internet. + res=$(cat $(ibdir)/texlive-ready-tlmgr) + if ping -c1 ctan.org \ + && [ -f $(ibdir)/texlive-ready-tlmgr ] \ + && [ x$$res != x"NOT" ]; then + # The current directory is necessary later. + topdir=$$(pwd) # Install all the extra necessary packages. If LaTeX complains - # about not finding a package, simply run the following command - # to find which package its in, then add it to the - # `texlive-packages' variable. + # about not finding a command/file/what-ever/XXXXXX, simply run + # the following command to find which package its in, then add it + # to the `texlive-packages' variable of the first prerequisite. + # + # ./.local/bin/tlmgr info XXXXXX # - # tlmgr info XXXXXX.sty + # We are putting a notice, because if there is no internet, + # `tlmgr' just hangs waiting. + echo; echo; echo "Downloading necessary TeX packages..."; echo; tlmgr install $(texlive-packages) + echo "returned: $$?"; echo; echo; # Make a symbolic link of all the TeX Live executables in the bin # directory so we don't have to modify `PATH'. @@ -333,16 +347,14 @@ $(ibdir)/texlive-ready: reproduce/config/pipeline/dependency-texlive.mk # LaTeX Package versions. tlmgr info $(texlive-packages) --only-installed | awk \ - '$$1=="package:" {version=0; \ - if($$NF=="tex-gyre") name="texgyre"; \ - else name=$$NF} \ - $$1=="cat-version:" {version=$$NF} \ - $$1=="cat-date:" {if(version==0) version=$$2; \ - printf("\\newcommand{\\tex%sversion}{%s}\n",\ - name, version)}' >> $$tv + '$$1=="package:" {version=0; \ + if($$NF=="tex-gyre") name="texgyre"; \ + else name=$$NF} \ + $$1=="cat-version:" {version=$$NF} \ + $$1=="cat-date:" {if(version==0) version=$$2; \ + printf("\\newcommand{\\tex%sversion}{%s}\n", \ + name, version)}' >> $$tv + + # Write the target if TeX live was actually installed. + echo "TeX Live's packages are also ready." > $@ fi - - # Write the target if TeX live was actually installed. - if [ -f $(idir)/texlive/20*/bin/*/latex ]; then - echo "TeX Live is installed." > $@ - fi; diff --git a/reproduce/src/make/paper.mk b/reproduce/src/make/paper.mk index 79d7722..d50c59a 100644 --- a/reproduce/src/make/paper.mk +++ b/reproduce/src/make/paper.mk @@ -37,14 +37,19 @@ # PDF. $(texbdir)/paper.bbl: tex/references.tex \ | $(tikzdir) $(texbdir) tex/pipeline.tex + # If `tex/pipeline.tex' is empty, then the PDF must not be built. + @macros=$$(cat tex/pipeline.tex) + if [ x"$$macros" != x ]; then - # We'll run LaTeX first to generate the `.bcf' file (necessary for - # `biber') and then run `biber' to generate the `.bbl' file. - p=$$(pwd); - export TEXINPUTS=$$p:$$TEXINPUTS; - cd $(texbdir); - pdflatex -shell-escape -halt-on-error $$p/paper.tex; - biber paper + # We'll run LaTeX first to generate the `.bcf' file (necessary + # for `biber') and then run `biber' to generate the `.bbl' file. + p=$$(pwd); + export TEXINPUTS=$$p:$$TEXINPUTS; + cd $(texbdir); + pdflatex -shell-escape -halt-on-error $$p/paper.tex; + biber paper + + fi @@ -61,13 +66,19 @@ $(texbdir)/paper.bbl: tex/references.tex \ paper.pdf: tex/pipeline.tex paper.tex $(texbdir)/paper.bbl \ | $(tikzdir) $(texbdir) - # Go into the top TeX build directory and make the paper. - p=$$(pwd) - export TEXINPUTS=$$p:$$TEXINPUTS - cd $(texbdir) - pdflatex -shell-escape -halt-on-error $$p/paper.tex + # If `tex/pipeline.tex' is empty, then the PDF must not be built. + @macros=$$(cat tex/pipeline.tex) + if [ x"$$macros" != x ]; then + + # Go into the top TeX build directory and make the paper. + p=$$(pwd) + export TEXINPUTS=$$p:$$TEXINPUTS + cd $(texbdir) + pdflatex -shell-escape -halt-on-error $$p/paper.tex + + # Come back to the top pipeline directory and copy the built PDF + # file here. + cd $$p + cp $(texbdir)/$@ $@ - # Come back to the top pipeline directory and copy the built PDF - # file here. - cd $$p - cp $(texbdir)/$@ $@ + fi |