shithub: puzzles

Download patch

ref: 2ebbdbf2a567c73d75af4f0e04f4f42bfe6d3530
parent: bc930a121466e0e33b46ff01db0153f5cfb79054
author: Simon Tatham <anakin@pobox.com>
date: Wed Sep 24 06:33:21 EDT 2014

Remove dependencies on Subversion.

I'm going through all my projects and reworking them to avoid
depending on the monotonic integer-valued source control revision
identifier provided by Subversion, so I can migrate everything to git
without my builds and versioning breaking.

Puzzles's version number is now of the form YYYYMMDD.vvvvvv, where
vvvvvv is some string of source control information (currently still
the SVN-style "rNNNNN", but free to change in future). The date
provides monotonicity between my official automated builds, and the
second component is the one I'll be most interested in when people
send bug reports.

[originally from svn r10263]

--- a/Buildscr
+++ b/Buildscr
@@ -3,10 +3,17 @@
 
 module puzzles
 
+set Version $(!builddate).$(vcsid)
+
 # Start by substituting the right version number in configure.ac.
-in puzzles do perl -i~ -pe 's/rNNNN/r$(revision)/' configure.ac
+in puzzles do perl -i~ -pe 's/6.66/$(Version)/' configure.ac
 in puzzles do rm configure.ac~
 
+# And put it into the documentation as a versionid.
+# use perl to avoid inconsistent behaviour of echo '\v'
+in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> puzzles.but
+in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> devel.but
+
 # First build some local binaries, to run the icon build.
 in puzzles do perl mkfiles.pl -U
 in puzzles do make
@@ -28,7 +35,7 @@
 # Build the OS X .dmg archive.
 delegate osx
   in puzzles do make -f Makefile.osx clean
-  in puzzles do make -f Makefile.osx release VER=-DREVISION=$(revision)
+  in puzzles do make -f Makefile.osx release VER=-DVER=$(Version)
   return puzzles/Puzzles.dmg
 enddelegate
 
@@ -36,7 +43,7 @@
 in puzzles do make -f Makefile.doc clean
 in puzzles do make -f Makefile.doc chm
 in puzzles do make -f Makefile.doc # build help file for installer
-in puzzles do perl winiss.pl $(revision) gamedesc.txt > puzzles.iss
+in puzzles do perl winiss.pl $(Version) gamedesc.txt > puzzles.iss
 delegate windows
   # Ignore the poorly controlled return value from HHC, and instead
   # just test that the output file was generated.
@@ -43,7 +50,7 @@
   in puzzles do hhc puzzles.hhp; test -f puzzles.chm
   # FIXME: Cygwin alternative?
   in puzzles do cmd /c 'vcvars32 & nmake -f Makefile.vc clean'
-  in puzzles do cmd /c 'vcvars32 & nmake -f Makefile.vc VER=-DREVISION=$(revision)'
+  in puzzles do cmd /c 'vcvars32 & nmake -f Makefile.vc VER=-DVER=$(Version)'
   # Build installer.
   in puzzles do iscc puzzles.iss
   return puzzles/puzzles.chm
@@ -76,7 +83,7 @@
 #in puzzles do perl wceinf.pl gamedesc.txt > puzzles.inf
 #delegate windows
 #  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce clean'
-#  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce VER=-DREVISION=$(revision)'
+#  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce VER=-DVER=$(Version)'
 #  # Nasty piece of sh here which saves the return code from cabwiz,
 #  # outputs its errors and/or warnings, and then propagates the
 #  # return code back to bob. If only cabwiz could output to
@@ -107,7 +114,7 @@
 
 # Create the source archive. (That writes the archive into the
 # _parent_ directory, so be careful when we deliver it.)
-in puzzles do ./makedist.sh $(revision)
+in puzzles do ./makedist.sh $(Version)
 
 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl -i~ -pe 'print "!srcdir unfinished/\n" if /!srcdir icons/' Recipe
 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do ln -s unfinished/group.R .
@@ -115,7 +122,7 @@
 
 # Build the Java applets.
 delegate nestedvm
-  in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DREVISION=$(revision)
+  in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version)
   return puzzles/*.jar
 enddelegate
 
@@ -134,7 +141,7 @@
 in puzzles do echo "AddType application/octet-stream .hlp" >> .htaccess
 in puzzles do echo "AddType application/octet-stream .cnt" >> .htaccess
 in . do set -- puzzles*.tar.gz; echo RedirectMatch temp '(.*/)'puzzles.tar.gz '$$1'"$$1" >> puzzles/.htaccess
-in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.exe '$$1'puzzles-r$(revision)-installer.exe >> .htaccess
+in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.exe '$$1'puzzles-$(Version)-installer.exe >> .htaccess
 
 # Phew, we're done. Deliver everything!
 deliver puzzles/icons/*-web.png $@
@@ -147,7 +154,7 @@
 deliver puzzles/puzzles.hlp $@
 deliver puzzles/puzzles.cnt $@
 deliver puzzles/puzzles.zip $@
-deliver puzzles/Output/setup.exe puzzles-r$(revision)-installer.exe
+deliver puzzles/Output/setup.exe puzzles-$(Version)-installer.exe
 deliver puzzles/*.jar java/$@
 deliver puzzles/js/*.js js/$@
 deliver puzzles/html/*.html html/$@
--- a/Recipe
+++ b/Recipe
@@ -118,8 +118,6 @@
 version2.def: FORCE
 	if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
 		cat version.def > version2.def.new; \
-	elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
-		echo "-DREVISION=`svnversion .`" >version2.def.new; \
 	else \
 		echo "$(VER)" >version2.def.new; \
 	fi && \
@@ -136,7 +134,7 @@
 # backtick expression. We also force rebuilding via a -D option that
 # makes version.o include empty.h, which we construct ourselves and
 # touch whenever any source file is updated.
-!cflags am version $(VER) -DINCLUDE_EMPTY_H `if test -z "$(VER)" && (cd $(srcdir) && test -f manifest && md5sum -c manifest >/dev/null 2>&1); then cat $(srcdir)/version.def; elif test -z "$(VER)" && test -d $(srcdir)/.svn && svnversion $(srcdir) >/dev/null 2>&1; then echo "-DREVISION=\`svnversion $(srcdir)\`"; else echo "$(VER)"; fi`
+!cflags am version -DINCLUDE_EMPTY_H `if test -z "$(VER)" && (cd $(srcdir) && test -f manifest && md5sum -c manifest >/dev/null 2>&1); then cat $(srcdir)/version.def; else echo "$(VER)"; fi`
 !begin am
 BUILT_SOURCES = empty.h
 CLEANFILES = empty.h
@@ -156,8 +154,6 @@
 version2.def: FORCE
 	if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
 		cat version.def > version2.def.new; \
-	elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
-		echo "-DREVISION=`svnversion .`" >version2.def.new; \
 	else \
 		echo "$(VER)" >version2.def.new; \
 	fi && \
@@ -180,8 +176,6 @@
 version2.def: FORCE
 	if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
 		cat version.def > version2.def.new; \
-	elif test -z "$(VER)" && test -d .svn && svnversion . >/dev/null 2>&1; then \
-		echo "-DREVISION=`svnversion .`" >version2.def.new; \
 	else \
 		echo "$(VER)" >version2.def.new; \
 	fi && \
--- a/chm.but
+++ b/chm.but
@@ -19,5 +19,3 @@
 \cfg{html-body-end}{}
 
 \cfg{html-head-end}{<link rel="stylesheet" type="text/css" href="chm.css">}
-
-\versionid $Id$
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 dnl Configure script for the Unix GTK build of puzzles.
 
-AC_INIT([puzzles], rNNNN, [anakin@pobox.com])
+AC_INIT([puzzles], [6.66], [anakin@pobox.com])
 AC_CONFIG_SRCDIR([midend.c])
 AM_INIT_AUTOMAKE([foreign])
 AC_PROG_CC
--- a/makedist.sh
+++ b/makedist.sh
@@ -2,27 +2,15 @@
 
 # Build a Unix source distribution from the Puzzles SVN area.
 #
-# Pass a numeric argument to have the archive tagged as that SVN
-# revision. Otherwise, the script will work it out itself by
-# calling `svnversion', or failing that it will not version-tag the
+# Pass a version number argument to have the archive tagged with that
+# version number. Otherwise, the script will not version-tag the
 # archive at all.
 
-case "$#" in
-  0)
-    # Ignore errors; if we can't get a version, we'll have a blank
-    # string.
-    rev=`svnversion . 2>/dev/null`
-    if test "x$rev" = "xexported"; then rev=; fi
-    ;;
-  *)
-    case "$1" in *[!0-9M]*) echo "Malformed revision number '$1'">&2;exit 1;;esac
-    rev="$1"
-    ;;
-esac
+version="$1"
 
-if test "x$rev" != "x"; then
-  arcsuffix="-r$rev"
-  ver="-DREVISION=$rev"
+if test "x$version" != "x"; then
+  arcsuffix="-$version"
+  ver="-DVER=$version"
 else
   arcsuffix=
   ver=
@@ -45,7 +33,8 @@
   HACKING puzzles.txt puzzles.hlp puzzles.cnt puzzles.chm \
   icons/Makefile icons/*.{sav,pl,sh} icons/win16pal.xpm \
   icons/*.png icons/*.ico icons/*.rc icons/*.c \
-  configure.ac mkauto.sh aclocal.m4 configure depcomp install-sh missing; do
+  configure.ac mkauto.sh aclocal.m4 \
+  configure depcomp install-sh missing compile; do
   case $i in
     */*) ln -s ../../../$i tmp.$$/puzzles$arcsuffix/$i;;
     *)   ln -s ../../$i tmp.$$/puzzles$arcsuffix/$i;;
--- a/puzzles.but
+++ b/puzzles.but
@@ -36,8 +36,6 @@
 
 \cfg{html-local-head}{<meta name="AppleTitle" content="Puzzles Help">}
 
-\versionid $Id$
-
 \C{intro} Introduction
 
 I wrote this collection because I thought there should be more small
--- a/version.c
+++ b/version.c
@@ -21,9 +21,9 @@
 # include "empty.h"
 #endif
 
-#if defined REVISION
+#if defined VER
 
-char ver[] = "Revision: r" STR(REVISION);
+char ver[] = "Version: " STR(VER);
 
 #else
 
--- a/winiss.pl
+++ b/winiss.pl
@@ -6,15 +6,27 @@
 
 # Usage:
 #
-#   $ ./winiss.pl 1234 gamedesc.txt > puzzles.iss
+#   $ ./winiss.pl 20140922.sdfsdf gamedesc.txt > puzzles.iss
 #
-# where `1234' is the revision number which will be encoded in the
-# installer's version indicators.
+# where the first argument is the version number which will be encoded
+# in the installer's version indicators. The first component of that
+# version number will be expected to be a YYYYMMDD-format date.
 
 use warnings;
+use Time::Local;
 
-$rev = shift @ARGV;
-($revclean=$rev) =~ s/M$//;
+$ver = shift @ARGV;
+
+# Parse the date out of $ver, and convert it into an integer number of
+# days since an arbitrary epoch. This number is used for the Windows
+# version resource (which wants a monotonic 16-bit integer). The epoch
+# is chosen so that the first build using this date-based mechanism
+# has a higher number than the last build in which that number was
+# derived from a Subversion revision.
+die "bad date format" if $ver !~ /^(\d{4})(\d{2})(\d{2})/;
+$date = timegm(0,0,0,$3,$2-1,$1);
+$integer_date = int($date / 86400) - 6000;
+
 $desc = shift @ARGV;
 open DESC, "<", $desc;
 while (<DESC>) {
@@ -31,10 +43,10 @@
 print ''."\n";
 print '[Setup]'."\n";
 print 'AppName=Simon Tatham\'s Portable Puzzle Collection'."\n";
-print 'AppVerName=Puzzles revision '.$rev."\n";
-print 'VersionInfoTextVersion=Revision '.$rev."\n";
-print 'AppVersion=r'.$rev."\n";
-print 'VersionInfoVersion=0.0.'.$revclean.'.0'."\n";
+print 'AppVerName=Puzzles version '.$ver."\n";
+print 'VersionInfoTextVersion=Version '.$ver."\n";
+print 'AppVersion=r'.$ver."\n";
+print 'VersionInfoVersion=0.0.'.$integer_date.'.0'."\n";
 print 'AppPublisher=Simon Tatham'."\n";
 print 'AppPublisherURL=http://www.chiark.greenend.org.uk/~sgtatham/puzzles/'."\n";
 print 'DefaultDirName={pf}\Simon Tatham\'s Portable Puzzle Collection'."\n";