diff options
author | Boud Roukema <boud@cosmo.torun.pl> | 2020-07-20 18:31:43 +0200 |
---|---|---|
committer | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2020-07-20 21:43:45 +0100 |
commit | 2ed8a2d60bc991ad06411b2aab43989a64a59a2d (patch) | |
tree | 39b9fcc92fda1f8b3240be529c87a60d9d2eecb7 | |
parent | c18c170b7f31b4cb1499dfbc0a0d13e54de1df89 (diff) |
make dist: only archive files that are under version control
Until this commit, the '$(project-package-contents)' rules in
'reproduce/analysis/make/initialize.mk' included a line to provide all
contents, recursively, of the directory 'reproduce/' in the package for
further distribution.
This could potentially lead to the distribution of private working files
that are used during development and not intended for general distribution.
With this commit, only those files in 'reproduce/' and 'tex/src' that are
under version control are copied to the temporary directory (that is later
used for creating an archive). With this change, the archiving commands
actually became more clean (we don't have to manually remove 'LOCAL.conf'
or other temporary files). Extensive comments have also been added above
each step to clarify each step's purpose and method.
-rw-r--r-- | reproduce/analysis/make/initialize.mk | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/reproduce/analysis/make/initialize.mk b/reproduce/analysis/make/initialize.mk index 29cd2dc..211c1c0 100644 --- a/reproduce/analysis/make/initialize.mk +++ b/reproduce/analysis/make/initialize.mk @@ -298,32 +298,46 @@ $(project-package-contents): paper.pdf | $(texdir) sed -e's|\\newcommand{\\makepdf}{}|%\\newcommand{\\makepdf}{}|' \ paper.tex > $$dir/paper.tex - # Build the top-level directories. - mkdir $$dir/reproduce $$dir/tex $$dir/tex/tikz $$dir/tex/build - - # Copy all the necessary `reproduce' and `tex' contents. + # Copy ONLY the version-controlled files in 'reproduce' and + # 'tex/src'. This is important because files like 'LOCAL.conf' (in + # 'reproduce/software/config') should not be archived, they contain + # information about the host computer and are irrelevant for + # others. Also some project authors may have temporary files here + # that are not under version control and thus shouldn't be archived + # (although this is bad practice, but that is up to the user). + # + # To keep the sub-directory structure, we are packaging the files + # with Tar, piping it, and unpacking it in the archive + # directory. So afterwards we need to come back to the current + # directory. + tar -c -f - $$(git ls-files reproduce tex/src) \ + | (cd $$dir ; tar -x -f -) + cd $(curdir) + + # Build the other two subdirectories of 'tex/' that we need in the + # archive (in the actual project, these are symbolic links to the + # build directory). + mkdir $$dir/tex/tikz $$dir/tex/build + + # Copy the 'tex/build' directory into the archive (excluding the + # temporary archive directory that we are now copying to). We will + # be using Bash's extended globbing ('extglob') for excluding this + # directory. shopt -s extglob - cp -r tex/src $$dir/tex/src - cp -r reproduce/* $$dir/reproduce cp -r tex/build/!($(project-package-name)) $$dir/tex/build + # Clean up the $(texdir)/build* directories in the archive (when + # building in a group structure, there will be `build-user1', + # `build-user2' and etc). These are just temporary LaTeX build + # files and don't have any relevant/hand-written files in them. + rm -rf $$dir/tex/build/build* + # If the project has any PDFs in its 'tex/tikz' directory (TiKZ or # PGFPlots was used to generate them), copy them too. if ls tex/tikz/*.pdf &> /dev/null; then cp tex/tikz/*.pdf $$dir/tex/tikz fi - # Clean up un-necessary/local files: 1) the $(texdir)/build* - # directories (when building in a group structure, there will be - # `build-user1', `build-user2' and etc), are just temporary LaTeX - # build files and don't have any relevant/hand-written files in - # them. 2) The `LOCAL.conf' and `gnuastro-local.conf' files just - # have this machine's local settings and are irrelevant for anyone - # else. - rm -rf $$dir/tex/build/build* - rm $$dir/reproduce/software/config/LOCAL.conf - rm $$dir/reproduce/analysis/config/gnuastro/gnuastro-local.conf - # When submitting to places like arXiv, they will just run LaTeX # once and won't run `biber'. So we need to also keep the `.bbl' # file into the distributing tarball. However, BibLaTeX is |