Blob Blame History Raw
From 216934c3f4884999206715db3499fc0162e1d65c Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Tue, 30 May 2017 17:52:04 +1000
Subject: [PATCH] build: preserve release version across autoreconf

Administrators building from a release tarball can safely run
autoreconf without the source tree forgetting its version (or
worse, scavenging an unrelated version string from some git
repository in an ancestor directory).
---
 Makefile.am          | 6 +++++-
 tools/git-version.sh | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 9a4fa49be..e37822aac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,7 +116,8 @@ noinst_HEADERS =
 noinst_LTLIBRARIES =
 noinst_PROGRAMS =
 EXTRA_DIST = \
-	$(wildcard tools/vzic/*)
+	$(wildcard tools/vzic/*) \
+	VERSION
 
 if COM_ERR
 COMPILE_ET_DEP = com_err/et/compile_et
@@ -1910,6 +1911,9 @@ dist-hook:
 	find $(top_distdir) -type f -name .sphinx-build.stamp -delete
 	rm -rf $(top_distdir)/$(SPHINX_CACHE)
 
+VERSION: tools/git-version.sh
+	$(AM_V_GEN)$< > $@.NEW && mv $@.NEW $@
+
 install-data-hook:
 if CMULOCAL
 	$(INSTALL) -m 644 $(top_srcdir)/depot/depot.conf $(DESTDIR)/
diff --git a/tools/git-version.sh b/tools/git-version.sh
index 66563c162..c728769db 100755
--- a/tools/git-version.sh
+++ b/tools/git-version.sh
@@ -41,6 +41,10 @@
 # OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
+# if we've come from a release package, ignore git entirely
+test -s VERSION &&
+    exec head -1 VERSION
+
 # first try: based on annotated git tags (real releases)
 version=$(git describe --dirty=-dirty 2>/dev/null)
 test -n "$version" &&