From 6a9990b5a4d13d7628902b0dc067c74e782922de Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sun, 18 Nov 2018 19:45:46 +0000 Subject: Pipeline also installs TeX live and necessary packages Since the final product of the pipeline is a LaTeX-created PDF file, it was necessary to also have LaTeX within the pipeline. With this commit, TeX Live is also built as part of the configuration and all the necessary packages to build the PDF are also installed and mentioned in the paper along with their versions. --- configure | 7 +- paper.tex | 34 +++++---- reproduce/config/pipeline/dependency-texlive.mk | 14 ++++ reproduce/config/pipeline/dependency-versions.mk | 1 + reproduce/src/make/Top-Makefile | 25 ++++--- reproduce/src/make/dependencies-basic.mk | 11 +++ reproduce/src/make/dependencies.mk | 90 +++++++++++++++++++----- reproduce/src/make/initialize.mk | 6 +- reproduce/src/make/paper.mk | 6 -- tex/preamble-necessary.tex | 1 - 10 files changed, 143 insertions(+), 52 deletions(-) create mode 100644 reproduce/config/pipeline/dependency-texlive.mk diff --git a/configure b/configure index 5f21e04..0663e15 100755 --- a/configure +++ b/configure @@ -145,6 +145,7 @@ if [ -f $pconf ] || [ -f $glconf ]; then do read -p"Re-write existing configuration file(s) (y/n)? " userread done + userread=n # Set `rewriteconfig'. if [ $userread = "n" ]; then @@ -408,8 +409,8 @@ ln -s $(pwd)/reproduce/config/gnuastro .gnuastro # See if the C compiler can build static libraries # ------------------------------------------------ -oprog=$ddir/static-test -cprog=$ddir/static-test.c +oprog=$depdir/static-test +cprog=$depdir/static-test.c echo "#include " > $cprog echo "int main(void) {return 0;}" >> $cprog if [ x$CC = x ]; then CC=gcc; fi; @@ -452,7 +453,7 @@ fi # Inform the user that the build process is starting # ------------------------------------------------- -tsec=0 +tsec=10 cat < /dev/null || [ x$(pdf-build-final) = x ]; then + echo + echo "-----" + echo "The processing has COMPLETED SUCCESSFULLY! But we won't be" + echo "building the final LaTeX-built PDF." + 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'." + echo + exit 1 + fi # Merge all the TeX macros that are prepared for building the PDF. @cat $(mtexdir)/*.tex > $@ diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk index 45a4192..dcc0b59 100644 --- a/reproduce/src/make/dependencies-basic.mk +++ b/reproduce/src/make/dependencies-basic.mk @@ -92,6 +92,7 @@ tarballs = $(foreach t, bash-$(bash-version).tar.gz \ lzip-$(lzip-version).tar.gz \ make-$(make-version).tar.lz \ tar-$(tar-version).tar.gz \ + which-$(which-version).tar.gz \ xz-$(xz-version).tar.gz \ zlib-$(zlib-version).tar.gz \ , $(tdir)/$(t) ) @@ -111,6 +112,7 @@ $(tarballs): $(tdir)/%: elif [ $$n = lzip ]; then w=http://download.savannah.gnu.org/releases/lzip; \ elif [ $$n = make ]; then w=http://akhlaghi.org/src; \ elif [ $$n = tar ]; then w=http://ftp.gnu.org/gnu/tar; \ + elif [ $$n = which ]; then w=http://ftp.gnu.org/gnu/which; \ elif [ $$n = xz ]; then w=http://tukaani.org/xz; \ elif [ $$n = zlib ]; then w=http://www.zlib.net; \ else \ @@ -218,6 +220,14 @@ $(ibdir)/tar: $(tdir)/tar-$(tar-version).tar.gz \ +# GNU Which: +$(ibdir)/which: $(tdir)/which-$(which-version).tar.gz + $(call gbuild,$(subst $(tdir)/,,$<), which-$(which-version), static) + + + + + # GNU Make: Unfortunately it needs dynamic linking in two instances: when # loading objects (dynamically linked libraries), or when using the # `getpwnam' function (for tilde expansion). The first can be disabled with @@ -233,6 +243,7 @@ $(ibdir)/make: $(tdir)/make-$(make-version).tar.lz \ # GNU Bash $(ibdir)/bash: $(tdir)/bash-$(bash-version).tar.gz \ + $(ibdir)/which \ $(ibdir)/make ifeq ($(static_build),yes) $(call gbuild,$(subst $(tdir)/,,$<), bash-$(bash-version), , \ diff --git a/reproduce/src/make/dependencies.mk b/reproduce/src/make/dependencies.mk index 70b0a9e..fe5fb19 100644 --- a/reproduce/src/make/dependencies.mk +++ b/reproduce/src/make/dependencies.mk @@ -32,6 +32,7 @@ # Top level environment include reproduce/config/pipeline/LOCAL.mk include reproduce/src/make/dependencies-build-rules.mk +include reproduce/config/pipeline/dependency-texlive.mk include reproduce/config/pipeline/dependency-versions.mk ddir = $(BDIR)/dependencies @@ -42,7 +43,7 @@ ildir = $(BDIR)/dependencies/installed/lib # Define the top-level programs to build (installed in `.local/bin', so for # Coreutils, only one of its executables is enough). -top-level-programs = ls gawk gs grep libtool sed git tex astnoisechisel +top-level-programs = ls gawk gs grep libtool sed git latex astnoisechisel all: $(foreach p, $(top-level-programs), $(ibdir)/$(p)) # Other basic environment settings. @@ -226,7 +227,7 @@ $(ibdir)/gs: $(tdir)/ghostscript-$(ghostscript-version).tar.gz \ $(call gbuild,$(subst $(tdir)/,,$<), ghostscript-$(ghostscript-version)) $(ibdir)/git: $(tdir)/git-$(git-version).tar.xz \ - $(ibdir)/ls + $(ibdir)/ls $(call gbuild,$(subst $(tdir)/,,$<), git-$(git-version), static) $(ibdir)/astnoisechisel: $(tdir)/gnuastro-$(gnuastro-version).tar.lz \ @@ -242,21 +243,74 @@ $(ibdir)/astnoisechisel: $(tdir)/gnuastro-$(gnuastro-version).tar.lz \ static, --enable-static=yes --enable-shared=no, -j8, \ make check -j8) -$(ibdir)/tex: - - # First we'll download the tarball. Note that since the most recent - # installer is downloaded by day, the installer's version is hard - # to configure at this stage. - #wget -O$(tdir)/install-tl-unx.tar.gz \ - # http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz +$(ibdir)/latex: reproduce/config/pipeline/dependency-texlive.mk - # Unpack, enter the directory and run the installer. + # We'll need the current directory later down. topdir=$$(pwd) - cd $(ddir) - 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-* + + # 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 \ + 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-* + + # 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)/ + rm $@ + cp $(idir)/texlive/20*/bin/*/latex $@ + else + echo "Not able to download TeX Live installer" > $@ + fi + 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 + + # 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. + # + # tlmgr info XXXXXX.sty + tlmgr install $(texlive-packages) + + # Make a symbolic link of all the TeX Live executables in the bin + # directory so we don't have to modify `PATH'. + ln -fs $(idir)/texlive/20*/bin/*/* $(ibdir)/ + + # Get all the necessary versions. + tv=$(ddir)/texlive-versions.tex + texlive=$$(pdflatex --version | awk 'NR==1' | sed 's/.*(\(.*\))/\1/' \ + | awk '{print $$NF}'); + echo "\newcommand{\\texliveversion}{$$texlive}" > $$tv + + # 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 + fi diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk index 943efdd..9639c79 100644 --- a/reproduce/src/make/initialize.mk +++ b/reproduce/src/make/initialize.mk @@ -72,10 +72,10 @@ curdir := $(shell echo $$(pwd)) .ONESHELL: .SHELLFLAGS = -ec SHELL := .local/bin/bash +PATH := $(curdir)/.local/bin LD_LIBRARY_PATH := $(curdir)/.local/lib LDFLAGS := -L$(curdir)/.local/lib CPPFLAGS := -I$(curdir)/.local/include -PATH := $(curdir)/.local/bin:$(shell ls -d $$(pwd)/.local/texlive/2018/bin/*) @@ -208,6 +208,7 @@ $(mtexdir)/initialize.tex: | $(mtexdir) $(call pvcheck, make, $(make-version), GNU Make, makeversion) $(call pvcheck, sed, $(sed-version), GNU SED, sedversion) $(call pvcheck, tar, $(tar-version), GNU Tar, tarversion) + $(call pvcheck, which, $(which-version), GNU Which, whichversion) $(call pvcheck, xz, $(xz-version), XZ Utils, xzversion) # Bzip2 prints its version in standard error, not standard output! @@ -233,3 +234,6 @@ $(mtexdir)/initialize.tex: | $(mtexdir) $(call lvcheck, wcslib/wcsconfig.h, $(wcslib-version), WCSLIB, \ wcslibversion) $(call lvcheck, zlib.h, $(zlib-version), zlib, zlibversion) + + # TeX versions + cat $(BDIR)/dependencies/texlive-versions.tex >> $@ diff --git a/reproduce/src/make/paper.mk b/reproduce/src/make/paper.mk index aec29c7..79d7722 100644 --- a/reproduce/src/make/paper.mk +++ b/reproduce/src/make/paper.mk @@ -38,9 +38,6 @@ $(texbdir)/paper.bbl: tex/references.tex \ | $(tikzdir) $(texbdir) tex/pipeline.tex - # To find LaTeX (which currently isn't internally installed). - #PATH=$(sys-path) - # We'll run LaTeX first to generate the `.bcf' file (necessary for # `biber') and then run `biber' to generate the `.bbl' file. p=$$(pwd); @@ -64,9 +61,6 @@ $(texbdir)/paper.bbl: tex/references.tex \ paper.pdf: tex/pipeline.tex paper.tex $(texbdir)/paper.bbl \ | $(tikzdir) $(texbdir) - # To find LaTeX (which currently isn't internally installed). - #PATH=$(sys-path) - # Go into the top TeX build directory and make the paper. p=$$(pwd) export TEXINPUTS=$$p:$$TEXINPUTS diff --git a/tex/preamble-necessary.tex b/tex/preamble-necessary.tex index 329352a..bef5a2f 100644 --- a/tex/preamble-necessary.tex +++ b/tex/preamble-necessary.tex @@ -11,7 +11,6 @@ % Macros for to help in typing, remove them if you don't need them, but % this can help as a demo on how you can simply writing of commonly used % words that need special formatting (like software names). -\newcommand{\gnu}[1]{{\small GNU} #1} \newcommand{\snsign}{{\small S}/{\small N}} \newcommand{\originsoft}{\textsf{ORIGIN}} \newcommand{\sextractor}{\textsf{SE\-xtractor}} -- cgit v1.2.1