[tz] [PROPOSED PATCH 3/3] Use more-accurate release numbers

Paul Eggert eggert at cs.ucla.edu
Tue Sep 6 04:24:40 UTC 2016


This largely affects just the release process, not the generated
tarballs.
* NEWS: Document this.
* Makefile (VERSION): Now 'unknown', since it is overrridden.
(SOURCES): Add 'version'.
(VERSION_DEPS): New macro.
(version): New rule.
(version.h, tzselect): Use 'version' file, instead of $(VERSION).
(maintainer-clean): Remove 'version'.
(set-timestamps.out): Set the timestamp of 'version'.
(tarballs, signatures): Set VERSION to it before doing the real work.
(tarballs_version, signatures_version): New rules, with the old
definiens of 'tarballs' and 'signatures'.
(tzdb-$(VERSION).tar.lz): Simplify by using ENCHILADA.
---
 Makefile | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
 NEWS     | 25 ++++++++++++++++++-------
 2 files changed, 63 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 9692a1d..79b4cdb 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,8 @@
 # Package name for the code distribution.
 PACKAGE=	tzcode
 
-# Version numbers of the code and data distributions.
-VERSION=	2016f
+# Version number for the distribution, overridden in the 'tarballs' rule below.
+VERSION=	unknown
 
 # Email address for bug reports.
 BUGEMAIL=	tz at iana.org
@@ -356,7 +356,7 @@ HEADERS=	tzfile.h private.h
 NONLIBSRCS=	zic.c zdump.c
 NEWUCBSRCS=	date.c strftime.c
 SOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
-			tzselect.ksh workman.sh
+			tzselect.ksh version workman.sh
 MANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
 			tzfile.5 tzselect.8 zic.8 zdump.8
 MANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
@@ -385,6 +385,26 @@ TZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
 			private.h tzfile.h zdump.c zic.c
 ENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS)
 
+# Consult these files when deciding whether to rebuild the 'version' file.
+# This list is not the same as the output of 'git ls-files', since
+# .gitignore is not distributed.
+VERSION_DEPS= \
+		CONTRIBUTING LICENSE Makefile NEWS README Theory \
+		africa antarctica asctime.c asia australasia \
+		backward backzone \
+		checklinks.awk checktab.awk \
+		date.1 date.c difftime.c \
+		etcetera europe factory iso3166.tab \
+		leap-seconds.list leapseconds.awk localtime.c \
+		newctime.3 newstrftime.3 newtzset.3 northamerica \
+		pacificnew private.h \
+		southamerica strftime.c systemv \
+		time2posix.3 tz-art.htm tz-how-to.html tz-link.htm \
+		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
+		workman.sh yearistype.sh \
+		zdump.8 zdump.c zic.8 zic.c \
+		zone.tab zone1970.tab zoneinfo2tdf.pl
+
 # And for the benefit of csh users on systems that assume the user
 # shell should be used to handle commands in Makefiles. . .
 
@@ -413,9 +433,16 @@ INSTALL:	ALL install date.1
 		cp date $(DESTDIR)$(BINDIR)/.
 		cp -f date.1 $(DESTDIR)$(MANDIR)/man1/.
 
-version.h:
+version:	$(VERSION_DEPS)
+		{ V=$$(git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
+				--abbrev=7 --dirty) || \
+		  V=$(VERSION); } && \
+		printf '%s\n' "$$V" >$@
+
+version.h:	version
 		(echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
-		 echo 'static char const TZVERSION[]="$(VERSION)";' && \
+		 printf 'static char const TZVERSION[]="%s";\n' \
+		   "$$(cat version)" && \
 		 echo 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";') >$@
 
 zdump:		$(TZDOBJS)
@@ -510,15 +537,15 @@ libtz.a:	$(LIBOBJS)
 date:		$(DATEOBJS)
 		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
 
-tzselect:	tzselect.ksh
+tzselect:	tzselect.ksh version
 		sed \
 			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
 			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
 			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
 			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
 			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
-			-e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \
-			<$? >$@
+			-e 's|\(TZVERSION\)=.*|\1='"$$(cat version)"'|' \
+			<$@.ksh >$@
 		chmod +x $@
 
 check:		check_character_set check_white_space check_links check_sorted \
@@ -573,7 +600,7 @@ clean:		clean_misc
 maintainer-clean: clean
 		@echo 'This command is intended for maintainers to use; it'
 		@echo 'deletes files that may need special tools to rebuild.'
-		rm -f leapseconds $(MANTXTS) $(TZS) *.asc *.tar.*
+		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
 
 names:
 		@echo $(ENCHILADA)
@@ -621,6 +648,7 @@ set-timestamps.out: $(ENCHILADA)
 		    exit; \
 		done
 		touch -cmr $$(ls -t $(TZS_DEPS) | sed 1q) $(TZS)
+		touch -cmr $$(ls -t $(VERSION_DEPS) | sed 1q) version
 		touch $@
 
 # The zics below ensure that each data file can stand on its own.
@@ -672,7 +700,10 @@ check_time_t_alternatives:
 		done
 		rm -fr time_t.dir
 
-tarballs:	tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz \
+tarballs signatures: version
+		$(MAKE) VERSION="$$(cat version)" $@_version
+
+tarballs_version: tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz \
 		tzdb-$(VERSION).tar.lz
 
 tzcode$(VERSION).tar.gz: set-timestamps.out
@@ -689,13 +720,12 @@ tzdata$(VERSION).tar.gz: set-timestamps.out
 tzdb-$(VERSION).tar.lz: set-timestamps.out
 		rm -fr tzdb-$(VERSION)
 		mkdir tzdb-$(VERSION)
-		ln $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) \
-		  tzdb-$(VERSION)
+		ln $(ENCHILADA) tzdb-$(VERSION)
 		touch -cmr $$(ls -t tzdb-$(VERSION)/* | sed 1q) tzdb-$(VERSION)
 		LC_ALL=C && export LC_ALL && \
 		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 > $@
 
-signatures:	tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \
+signatures_version: tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \
 		tzdb-$(VERSION).tar.lz.asc
 
 tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
@@ -736,5 +766,6 @@ zic.o:		private.h tzfile.h version.h
 .PHONY: clean clean_misc force_tzs
 .PHONY: install install_data maintainer-clean names
 .PHONY: posix_only posix_packrat posix_right
-.PHONY: public right_only right_posix signatures tarballs typecheck
+.PHONY: public right_only right_posix signatures signatures_version
+.PHONY: tarballs tarballs_version typecheck
 .PHONY: zonenames zones
diff --git a/NEWS b/NEWS
index 6cbdbd7..f5a0b13 100644
--- a/NEWS
+++ b/NEWS
@@ -63,13 +63,24 @@ Unreleased, experimental changes
 
   Changes to build procedure
 
-    An experimental distribution format is available in the tarball
-    tzdb-VERSION.tar.lz with signature file tzdb-VERSION.tar.lz.asc.
-    It unpacks to a top-level directory containing the code and data
-    of the traditional two-tarball format, along with extra data that
-    may be useful.  The traditional format will continue to be
-    distributed.  (Thanks to Antonio Diaz Diaz, Oscar van Vlijmen, and
-    many others for comments about the experimental format.)
+    An experimental distribution format is available, in addition
+    to the traditional format which will continue to be distributed.
+    The new format is a tarball tzdb-VERSION.tar.lz with signature
+    file tzdb-VERSION.tar.lz.asc.  It unpacks to a top-level directory
+    tzdb-VERSION containing the code and data of the traditional
+    two-tarball format, along with extra data that may be useful.
+    (Thanks to Antonio Diaz Diaz, Oscar van Vlijmen, and many others
+    for comments about the experimental format.)
+
+    The release version number is now more accurate in the usual case
+    where releases are built from a Git repository.  For example, if
+    23 commits and some working-file changes have been made since
+    release 2016g, the version number is now something like
+    '2016g-23-g50556e3-dirty' instead of the misleading '2016g'.
+    Official releases uses the same version number format as before,
+    e.g., '2016g'.  To support the more-accurate version number, its
+    specification has moved from a line in the Makefile to a new
+    source file 'version'.
 
     The experimental distribution contains a file to2050.tzs that
     contains what should be the output of 'zdump -i -c 2050' on
-- 
2.7.4




More information about the tz mailing list