From e19c7d38f00fe3612a8c499f8ac4c965f52cb86b Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Tue, 5 Feb 2019 23:31:27 +0000 Subject: Ability to package project into tarball or zip file With this commit, it is now possible to package the project into a tarball or zip file, ready to be distributed to collaborators who only want to modify the final paper (and not do the analysis technicalities), or for uploading to sites like arXiv, or online LaTeX sharing pages. --- .file-metadata | Bin 3666 -> 3666 bytes .gitignore | 4 + paper.tex | 11 +-- reproduce/config/pipeline/dependency-versions.mk | 2 + reproduce/src/make/dependencies.mk | 43 ++++++++--- reproduce/src/make/initialize.mk | 92 ++++++++++++++++++++--- reproduce/src/make/paper.mk | 6 ++ tex/preamble-pgfplots.tex | 2 +- 8 files changed, 134 insertions(+), 26 deletions(-) diff --git a/.file-metadata b/.file-metadata index b5d861e..7ce229a 100644 Binary files a/.file-metadata and b/.file-metadata differ diff --git a/.gitignore b/.gitignore index b1e82ef..6338a5b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,12 +4,16 @@ *.log *.pdf *.out +*.zip .nfs* mmap_* +*.tar.gz *.auxlock +.tex .local Makefile +tex/tikz .gnuastro .texlive* LOCAL_tmp.mk diff --git a/paper.tex b/paper.tex index 5961270..19c202d 100644 --- a/paper.tex +++ b/paper.tex @@ -215,11 +215,12 @@ Scientific Library (GSL) \gslversion, GNU Tar \tarversion, GNU Wget \ghostscriptversion, Libbsd \libbsdversion, Libgit2 \libgitwoversion, Libjpeg \libjpegversion, Libtiff \libtiffversion, Metastore (forked) \metastoreversion, OpenSSL \opensslversion, Pkg-config \pkgconfigversion, -WCSLIB \wcslibversion, XZ Utils \xzversion, and ZLib \zlibversion. The -final paper was produced with \TeX{} Live \texliveversion, using the -following packages: \TeX{} \textexversion, EC \texecversion, NewTX -\texnewtxversion, Fontaxes \texfontaxesversion, Keyval, \texxkeyvalversion, -Etoolbox \texetoolboxversion, Xcolor \texxcolorversion, Setspace +Unzip \unzipversion, WCSLIB \wcslibversion, XZ Utils \xzversion, Zip +\zipversion, and ZLib \zlibversion. The final paper was produced with +\TeX{} Live \texliveversion, using the following packages: \TeX{} +\textexversion, EC \texecversion, NewTX \texnewtxversion, Fontaxes +\texfontaxesversion, Keyval, \texxkeyvalversion, Etoolbox +\texetoolboxversion, Xcolor \texxcolorversion, Setspace \texsetspaceversion, Caption \texcaptionversion, Footmisc \texfootmiscversion, Datetime \texdatetimeversion, Fmtcount \texfmtcountversion, Titlesec \textitlesecversion, Preprint diff --git a/reproduce/config/pipeline/dependency-versions.mk b/reproduce/config/pipeline/dependency-versions.mk index 3e588f1..41a4cf9 100644 --- a/reproduce/config/pipeline/dependency-versions.mk +++ b/reproduce/config/pipeline/dependency-versions.mk @@ -32,9 +32,11 @@ pkgconfig-version = 0.29.2 readline-version = 8.0 sed-version = 4.7 tar-version = 1.31 +unzip-version = 6.0 wget-version = 1.20.1 which-version = 2.21 xz-version = 5.2.4 +zip-version = 3.0 # Libraries cfitsio-version = 3.45 diff --git a/reproduce/src/make/dependencies.mk b/reproduce/src/make/dependencies.mk index 4610226..80a787e 100644 --- a/reproduce/src/make/dependencies.mk +++ b/reproduce/src/make/dependencies.mk @@ -43,7 +43,7 @@ ildir = $(BDIR)/dependencies/installed/lib ilidir = $(BDIR)/dependencies/installed/lib/built # Define the top-level programs to build (installed in `.local/bin'). -top-level-programs = astnoisechisel metastore flock +top-level-programs = astnoisechisel metastore flock zip unzip all: $(ddir)/texlive-versions.tex \ $(foreach p, $(top-level-programs), $(ibdir)/$(p)) @@ -90,19 +90,21 @@ export LDFLAGS := $(rpath_command) -L$(ildir) tarballs = $(foreach t, cfitsio-$(cfitsio-version).tar.gz \ cmake-$(cmake-version).tar.gz \ curl-$(curl-version).tar.gz \ - flock-$(flock-version).tar.xz \ - ghostscript-$(ghostscript-version).tar.gz \ - git-$(git-version).tar.xz \ - gnuastro-$(gnuastro-version).tar.lz \ - gsl-$(gsl-version).tar.gz \ + flock-$(flock-version).tar.xz \ + ghostscript-$(ghostscript-version).tar.gz \ + git-$(git-version).tar.xz \ + gnuastro-$(gnuastro-version).tar.lz \ + gsl-$(gsl-version).tar.gz \ install-tl-unx.tar.gz \ - jpegsrc.$(libjpeg-version).tar.gz \ - libbsd-$(libbsd-version).tar.xz \ + jpegsrc.$(libjpeg-version).tar.gz \ + libbsd-$(libbsd-version).tar.xz \ libtool-$(libtool-version).tar.xz \ libgit2-$(libgit2-version).tar.gz \ metastore-$(metastore-version).tar.gz \ + unzip-$(unzip-version).tar.gz \ tiff-$(libtiff-version).tar.gz \ - wcslib-$(wcslib-version).tar.bz2 \ + zip-$(zip-version).tar.gz \ + wcslib-$(wcslib-version).tar.bz2 \ , $(tdir)/$(t) ) $(tarballs): $(tdir)/%: if [ -f $(DEPENDENCIES-DIR)/$* ]; then @@ -140,7 +142,13 @@ $(tarballs): $(tdir)/%: w=https://github.com/libgit2/libgit2/archive/v$(libgit2-version).tar.gz elif [ $$n = metastore ]; then w=http://akhlaghi.org/src elif [ $$n = tiff ]; then w=https://download.osgeo.org/libtiff + elif [ $$n = unzip ]; then w=ftp://ftp.info-zip.org/pub/infozip/src + mergenames=0; v=$$(echo $(unzip-version) | sed -e's/\.//') + w=ftp://ftp.info-zip.org/pub/infozip/src/unzip$$v.tgz elif [ $$n = wcslib ]; then w=ftp://ftp.atnf.csiro.au/pub/software/wcslib + elif [ $$n = zip ]; then + mergenames=0; v=$$(echo $(zip-version) | sed -e's/\.//') + w=ftp://ftp.info-zip.org/pub/infozip/src/zip$$v.tgz else echo; echo; echo; echo "'$$n' not recognized as a dependency name to download." @@ -438,6 +446,23 @@ endif $$staticopts, -j$(numthreads), \ make check -j$(numthreads)) +$(ibdir)/unzip: $(tdir)/unzip-$(unzip-version).tar.gz + v=$$(echo $(unzip-version) | sed -e's/\.//') + $(call gbuild, $<, unzip$$v, static,, \ + -f unix/Makefile generic_gcc \ + CFLAGS="-DBIG_MEM -DMMAP",,pwd, \ + -f unix/Makefile \ + BINDIR=$(ibdir) MANDIR=$(idir)/man/man1 ) + +$(ibdir)/zip: $(tdir)/zip-$(zip-version).tar.gz + v=$$(echo $(zip-version) | sed -e's/\.//') + $(call gbuild, $<, zip$$v, static,, \ + -f unix/Makefile generic_gcc \ + CFLAGS="-DBIG_MEM -DMMAP",,pwd, \ + -f unix/Makefile \ + BINDIR=$(ibdir) MANDIR=$(idir)/man/man1 ) + + diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk index 57565b9..b3180e3 100644 --- a/reproduce/src/make/initialize.mk +++ b/reproduce/src/make/initialize.mk @@ -158,10 +158,15 @@ $(mtexdir) $(texbdir): | $(texdir); mkdir $@ # we want to ensure that the file is always built in every run: it contains # the pipeline version which may change between two separate runs, even # when no file actually differs. -.PHONY: all clean distclean clean-mmap $(mtexdir)/initialize.tex +packagebasename := $(shell echo paper-$$(git describe --dirty --always)) +packagecontents = $(texdir)/$(packagebasename) +.PHONY: all clean distclean clean-mmap tarball zip $(packagecontents) \ + $(mtexdir)/initialize.tex + # --------- Delete for no Gnuastro --------- clean-mmap:; rm -f reproduce/config/gnuastro/mmap* # ------------------------------------------ + clean: clean-mmap # Delete the top-level PDF file. rm -f *.pdf @@ -173,6 +178,7 @@ clean: clean-mmap # are using afterwards. shopt -s extglob rm -rf $(BDIR)/!(dependencies) + distclean: clean # We'll be deleting the built environent programs and just need the # `rm' program. So for this recipe, we'll use the host system's @@ -185,13 +191,75 @@ distclean: clean +# Packaging rules +# --------------- +# +# With the rules in this section, you can package the project in a state +# that is ready for building the final PDF with LaTeX. This is useful for +# collaborators who only want to contribute to the text of your project, +# without having to worry about the technicalities of the analysis. +$(packagecontents): | $(texdir) + + # Set up the output directory, delete it if it exists and remake it + # to fill with new contents. + dir=$(texdir)/$(packagebasename) + rm -rf $$dir + mkdir $$dir + + # Copy the top-level contents into it. + cp configure COPYING for-group README.md README-hacking.md $$dir/ + + # Since the tarball is mainly intended for high-level building of + # the PDF with LaTeX, we'll comment the `makepdf' LaTeX macro in + # the paper. + sed -e's|\\newcommand{\\makepdf}{}|%\\newcommand{\\makepdf}{}|' \ + paper.tex > $$dir/paper.tex + + # Copy all the `reproduce' contents except for the `build' symbolic + # link. + shopt -s extglob + mkdir $$dir/reproduce $$dir/tex $$dir/tex/tikz + cp tex/*.tex $$dir/tex + cp -r reproduce/!(build) $$dir/reproduce + cp tex/tikz/*.pdf $$dir/tex/tikz + + # PIPELINE SPECIFIC: add or remove any of the copied files above, + # specific to your pipeline here. + + # Clean all temporary files. + cd $(texdir) + find $(packagebasename) -name \*~ -delete + +# Package into `.tar.gz'. +tarball: $(packagecontents) + curdir=$$(pwd) + cd $(texdir) + tar -cf $(packagebasename).tar $(packagebasename) + gzip -f --best $(packagebasename).tar + cd $$curdir + mv $(texdir)/$(packagebasename).tar.gz ./ + +# Package into `.zip'. +zip: $(packagecontents) + curdir=$$(pwd) + cd $(texdir) + zip -q -r $(packagebasename).zip $(packagebasename) + cd $$curdir + mv $(texdir)/$(packagebasename).zip ./ + + + + + # Check the version of programs which write their version # ------------------------------------------------------- pvcheck = prog="$(strip $(1))"; \ ver="$(strip $(2))"; \ name="$(strip $(3))"; \ macro="$(strip $(4))"; \ - v=$$($$prog --version | awk '/'$$ver'/{print "y"; exit 0}'); \ + verop="$(strip $(5))"; \ + if [ "x$$verop" = x ]; then V="--version"; else V=$$verop; fi; \ + v=$$($$prog $$V | awk '/'$$ver'/{print "y"; exit 0}'); \ if [ x$$v != xy ]; then \ echo; echo "PIPELINE ERROR: Not running $$name $$ver"; echo; \ exit 1; \ @@ -228,7 +296,12 @@ $(mtexdir)/initialize.tex: | $(mtexdir) echo "\newcommand{\pipelineversion}{$$v}" > $@ @echo "\newcommand{\bdir}{$(BDIR)}" >> $@ - # Versions of programs (same order as 'dependency-versions.mk'). + # Versions of programs (same order as 'dependency-versions.mk'), + # ordered alphabetically (by their executable name). + # --------- Delete for no Gnuastro --------- + $(call pvcheck, astnoisechisel, $(gnuastro-version), Gnuastro, \ + gnuastroversion) + # ------------------------------------------ $(call pvcheck, awk, $(gawk-version), GNU AWK, gawkversion) $(call pvcheck, bash, $(bash-version), GNU Bash, bashversion) $(call pvcheck, cmake, $(cmake-version), CMake, cmakeversion) @@ -237,12 +310,12 @@ $(mtexdir)/initialize.tex: | $(mtexdir) diffutilsversion) $(call pvcheck, find, $(findutils-version), GNU Findutils, \ findutilsversion) - $(call pvcheck, gs, $(ghostscript-version), GPL Ghostscript, \ - ghostscriptversion) $(call pvcheck, git, $(git-version), Git, gitversion) - $(call pvcheck, grep, $(grep-version), GNU Grep, grepversion) $(call pvcheck, glibtool, $(libtool-version), GNU Libtool, \ libtoolversion) + $(call pvcheck, grep, $(grep-version), GNU Grep, grepversion) + $(call pvcheck, gs, $(ghostscript-version), GPL Ghostscript, \ + ghostscriptversion) $(call pvcheck, gzip, $(gzip-version), GNU Gzip, gzipversion) $(call pvcheck, ls, $(coreutils-version), GNU Coreutils, \ coreutilsversion) @@ -254,14 +327,11 @@ $(mtexdir)/initialize.tex: | $(mtexdir) pkgconfigversion) $(call pvcheck, sed, $(sed-version), GNU SED, sedversion) $(call pvcheck, tar, $(tar-version), GNU Tar, tarversion) + $(call pvcheck, unzip, $(unzip-version), Unzip, unzipversion, -v) $(call pvcheck, wget, $(wget-version), GNU Wget, wgetversion) $(call pvcheck, which, $(which-version), GNU Which, whichversion) $(call pvcheck, xz, $(xz-version), XZ Utils, xzversion) - - # --------- Delete for no Gnuastro --------- - $(call pvcheck, astnoisechisel, $(gnuastro-version), Gnuastro, \ - gnuastroversion) - # ------------------------------------------ + $(call pvcheck, zip, $(zip-version), Zip, zipversion, -v) # Bzip2 prints its version in standard error, not standard output! echo "" | bzip2 --version &> $@_bzip2_ver; diff --git a/reproduce/src/make/paper.mk b/reproduce/src/make/paper.mk index 17d59bf..aea6c60 100644 --- a/reproduce/src/make/paper.mk +++ b/reproduce/src/make/paper.mk @@ -126,6 +126,12 @@ paper.pdf: tex/pipeline.tex paper.tex $(texbdir)/paper.bbl \ @macros=$$(cat tex/pipeline.tex) if [ x"$$macros" != x ]; then + # If it doesn't exist, make the `tex/tikz' symbolic link + # directory. This is necessary for situations when we just want + # TeX to use built figures instead of actually building the + # figures. + if [ ! -e tex/tikz ]; then ln -s $(tikzdir) tex/tikz; fi + # Go into the top TeX build directory and make the paper. p=$$(pwd) export TEXINPUTS=$$p:$$TEXINPUTS diff --git a/tex/preamble-pgfplots.tex b/tex/preamble-pgfplots.tex index 17ca7b5..26b98d6 100644 --- a/tex/preamble-pgfplots.tex +++ b/tex/preamble-pgfplots.tex @@ -71,7 +71,7 @@ \tikzsetnextfilename{#1}% \input{tex/#1.tex}% \else - \includegraphics[width=\linewidth]{\bdir/tex/build/tikz/#1.pdf} + \includegraphics[width=\linewidth]{tex/tikz/#1.pdf} \fi } -- cgit v1.2.1