From 080d9176fa3fc281cf7974b8431a6c5f3be62dab Mon Sep 17 00:00:00 2001
From: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Date: Tue, 13 Nov 2018 14:09:13 +0000
Subject: Version of programs checked on each run of pipeline

The version of all programs is now checked in
`reproduce/make/src/initialize.mk' and the pipeline won't complete if any
of the program versions change from those listed in
`reproduce/config/pipeline/dependency-versions.mk'.

Since the pipeline is systematically checking all program versions, we
don't need Gnuastro's `--onlyversion' option any more. So it (and all
references to it) have been removed.
---
 README.md                                        | 12 ++-----
 reproduce/config/gnuastro/gnuastro.conf          |  5 +--
 reproduce/config/pipeline/dependency-versions.mk | 12 ++++---
 reproduce/src/make/initialize.mk                 | 41 ++++++++++++++++++------
 4 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index 4e4af70..83b4265 100644
--- a/README.md
+++ b/README.md
@@ -466,15 +466,9 @@ advanced in later stages of your work.
  - **Gnuastro**: GNU Astronomy Utilities (Gnuastro) is currently a
      dependency of the pipeline which will be built and used. The main
      reason for this is to demonstrate how critically important it is to
-     version your software. If you do want to use Gnuastro in your
-     pipeline, be sure to un-comment the `onlyversion` option in
-     `reproduce/config/gnuastro/gnuastro.conf` file and set it to your
-     version of Gnuastro. This will force you to keep the pipeline in match
-     with the version of Gnuastro you are using all the time and also allow
-     commits to be exactly reproducible also (for example if you update to
-     a new version of Gnuastro during your research project). If you will
-     be using Gnuastro, you can also remove the "marks" (comments) put in
-     the relevant files of the list below to make them more readable.
+     version your software. If you will be using Gnuastro, you can also
+     remove the "marks" (comments) put in the relevant files of the list
+     below to make them more readable.
 
    - Delete marked part(s) in `configure`.
    - Delete marked parts in `reproduce/src/make/initialize.mk`.
diff --git a/reproduce/config/gnuastro/gnuastro.conf b/reproduce/config/gnuastro/gnuastro.conf
index ce8d990..561df9f 100644
--- a/reproduce/config/gnuastro/gnuastro.conf
+++ b/reproduce/config/gnuastro/gnuastro.conf
@@ -4,9 +4,7 @@
 # IMPORTANT NOTE FOR THE REPRODUCTION PIPELINE: The `lastconfig'
 # option is very important here, because we don't want any of
 # Gnuastro's programs to go into an un-controlled environment (user or
-# system wide configuration files). Uncomment the `onlyversion' option
-# when the paper/pipeline is ready to be published and set the value
-# of X.X accordingly.
+# system wide configuration files).
 #
 # The rest of this configuration file in this template reproduction
 # pipeline is taken from the default Gnuastro configuration from its
@@ -14,7 +12,6 @@
 
 # Reproduction pipeline (`config' has to be before `lastconfig').
  config           .gnuastro/gnuastro-local.conf
-#onlyversion      X.X
  lastconfig       1
 
 # Input:
diff --git a/reproduce/config/pipeline/dependency-versions.mk b/reproduce/config/pipeline/dependency-versions.mk
index dac56b1..bf19dc1 100644
--- a/reproduce/config/pipeline/dependency-versions.mk
+++ b/reproduce/config/pipeline/dependency-versions.mk
@@ -1,20 +1,24 @@
 # Versions of the various dependnecies
+
+# Programs
 bash-version        = 4.4.18
-cfitsio-version     = 3450
 cmake-version       = 3.12.4
 coreutils-version   = 8.30
-curl-version        = 7.62.0
 gawk-version        = 4.2.1
 ghostscript-version = 9.25
 git-version         = 2.19.1
 gnuastro-version    = 0.7.60-4c9eb
 grep-version        = 3.1
+make-version        = 4.2.90
+sed-version         = 4.5
+
+# Libraries
+cfitsio-version     = 3450
+curl-version        = 7.62.0
 gsl-version         = 2.5
 libjpeg-version     = v9b
 libgit2-version     = 0.26.0
 libtiff-version     = 4.0.10
 libtool-version     = 2.4.6
-make-version        = 4.2.90
-sed-version         = 4.5
 wcslib-version      = 6.2
 zlib-version        = 1.2.11
diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk
index c5f8620..b8d71c6 100644
--- a/reproduce/src/make/initialize.mk
+++ b/reproduce/src/make/initialize.mk
@@ -145,6 +145,22 @@ distclean: clean
 
 
 
+# Check the version of programs which write their version
+# -------------------------------------------------------
+vercheck = prog="$(strip $(1))";                                          \
+	   ver="$(strip $(2))";                                           \
+	   name="$(strip $(3))";                                          \
+	   macro="$(strip $(4))";                                         \
+	   v=$$($$prog --version | awk '/'$$ver'/{print "y"}');           \
+	   if [ x$$v != xy ]; then                                        \
+	     echo; echo "PIPELINE ERROR: Not running $$name $$ver"; echo; \
+	     exit 1;                                                      \
+	   fi;                                                            \
+	   echo "\newcommand{\\$$macro}{$$ver}" >> $@
+
+
+
+
 # Pipeline initialization results
 # -------------------------------
 #
@@ -154,15 +170,22 @@ distclean: clean
 # actually exists, it is also aded as a `.PHONY' target above.
 $(mtexdir)/initialize.tex: | $(mtexdir)
 
-        # Version of the pipeline.
+        # Version of the pipeline and build directory (for LaTeX inputs).
 	@v=$$(git describe --dirty --always);
 	echo "\newcommand{\pipelineversion}{$$v}"  > $@
-
-# --------- Delete for no Gnuastro ---------
-        # Version of Gnuastro.
-	@v=$$(astnoisechisel --version | awk 'NR==1{print $$NF}');
-	echo "\newcommand{\gnuastroversion}{$$v}" >> $@
-# ------------------------------------------
-
-        # Location of the build directory (for LaTeX inputs).
 	@echo "\newcommand{\bdir}{$(BDIR)}"       >> $@
+
+        # Versions of programs (same order as `dependency-versions.mk').
+	$(call vercheck, bash, $(bash-version), GNU Bash, bashversion)
+	$(call vercheck, cmake, $(cmake-version), CMake, cmakeversion)
+	$(call vercheck, ls, $(coreutils-version), GNU Coreutils,       \
+                         coreutilsversion)
+	$(call vercheck, awk, $(gawk-version), GNU AWK, gawkversion)
+	$(call vercheck, gs, $(ghostscript-version), GPL Ghostscript,   \
+	                 ghostscriptversion)
+	$(call vercheck, git, $(git-version), Git, gitversion)
+	$(call vercheck, astnoisechisel, $(gnuastro-version), Gnuastro, \
+                         gnuastroversion)
+	$(call vercheck, grep, $(grep-version), GNU Grep, grepversion)
+	$(call vercheck, make, $(make-version), GNU Make, makeversion)
+	$(call vercheck, sed, $(sed-version), GNU SED, sedversion)
-- 
cgit v1.2.1