Commit eea8fdc2 authored by Andrew Price's avatar Andrew Price
Browse files

Simplify version numbering using git tags

As we're determined to use git for providing version numbers we might as
well do it the right way. Take all of the version information from git
describe. This assumes that at least one annotated tag exists in the
branch relating to a release. The tag will be created using

$ git tag -a -m "Version 2.18" 2.18

so git describe will give us versions like 2.18-123-gf00baa which has
better ordering properties than the current 2.18-gf00baa scheme, which
is important for package upgrades. When HEAD matches the tag exactly, it
will just give 2.18
parent de9c285b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ build:
	$(MAKE) -C src $@
	$(MAKE) -C po $@

ifeq ($(SVNVER),)
ifeq ($(GITVER),)
# These rules can only be called from inside an exported tree
install:
	install -d $(DESTDIR)$(libdir)/mw
@@ -19,7 +19,7 @@ install:
deb:
	cp -a debian-template debian
	dch --create --package mw3 -v $(VERSION) -c debian/changelog "Build mw3 $(VERSION) package"
	debuild -e VERSION_TWEAK=$(VERSION_TWEAK) -us -uc -b
	debuild -e VERSION=$(VERSION) -us -uc -b

tarball:
	tar zchvf ../$(MWVERSION).tar.gz -C .. $(MWVERSION)
@@ -35,7 +35,7 @@ export:
	rm -rf $(TMPDIR)/$(MWVERSION)
	git checkout-index -a -f --prefix=$(TMPDIR)/$(MWVERSION)/
	# Store the git hash so we know it in the exported directory
	echo $(VERSION_TWEAK) > $(TMPDIR)/$(MWVERSION)/mw.rev
	echo $(GITVER) > $(TMPDIR)/$(MWVERSION)/mw.rev

install tarball rpm: export
	$(MAKE) -C $(TMPDIR)/$(MWVERSION) $@
+7 −19
Original line number Diff line number Diff line
SHELL = /bin/bash

SVNVER = $(shell git describe --always )

VERSION_MAJOR = 2
VERSION_MINOR = 17

ifeq ($(VERSION_TWEAK),)
ifeq ($(SVNVER),)
# mw.rev is created after an export so we can rely on it to provide the git hash here
VERSION_TWEAK = $(shell cat $(SRCROOT)/mw.rev)
else
ifeq ($(SVNVER),0)
$(warning failed to get git revision. VERSION_TWEAK will be set to 0)
endif
VERSION_TWEAK = $(SVNVER)
endif
GITVER = $(shell git describe --always )
VERSION = $(GITVER)

ifeq ($(VERSION),)
# mw.rev is created after an export so we can rely on it to provide the version here
VERSION = $(shell cat $(SRCROOT)/mw.rev)
endif

VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
MWVERSION = mw3-$(VERSION)

prefix ?= /usr
@@ -58,9 +48,7 @@ endif
# info strings, do not edit.
DEFS:= -DBUILD_DATE=\"$(shell date +%Y%m%d)\"
DEFS+= -DBUILD_USER=\"$(shell whoami | awk -f $(DEPTH)capitalise.awk)\"
DEFS+= -DVER_MAJ=\"$(VERSION_MAJOR)\"
DEFS+= -DVER_MIN=\"$(VERSION_MINOR)\"
DEFS+= -DVER_TWK=\"$(VERSION_TWEAK)\"
DEFS+= -DVERSION=\"$(VERSION)\"
DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
DEFS+= -DLOGDIR=\"$(LOGDIR)\"
DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
+1 −4
Original line number Diff line number Diff line
@@ -76,10 +76,7 @@ static int ReadInitFile(const char *base, const char *filename)
		curl_easy_setopt(cl, CURLOPT_WRITEDATA, file);
		curl_easy_setopt(cl, CURLOPT_URL, filename);
		curl_easy_setopt(cl, CURLOPT_ERRORBUFFER, cerr);
		if (atoi(VER_TWK) > 0)
			curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN "." VER_TWK);
		else
			curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN);
		curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VERSION);
		if (curl_easy_perform(cl))
			fprintf(stderr, "Error loading %s: %s\n", filename, cerr);
		curl_easy_cleanup(cl);
+1 −4
Original line number Diff line number Diff line
@@ -795,10 +795,7 @@ static JSBool js_urlget(JSContext *cx, unsigned int argc, jsval *vp)
		curl_easy_setopt(cl, CURLOPT_WRITEDATA, answer);
		curl_easy_setopt(cl, CURLOPT_URL, url);
		curl_easy_setopt(cl, CURLOPT_ERRORBUFFER, cerr);
		if (atoi(VER_TWK) > 0)
			curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN "." VER_TWK);
		else
			curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VER_MAJ "." VER_MIN);
		curl_easy_setopt(cl, CURLOPT_USERAGENT, "Milliways III v" VERSION);
		if (curl_easy_perform(cl)) {
			snprintf(msg, MAXTEXTLENGTH-1, "JavaScript urlget failed %s: %s", url, cerr);
			js_warning(cx, msg);
+2 −5
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ extern Alias force_list;
extern Alias shutdown_list;
extern Alias eventin_list;

static char version[]="Milliways III - Release "VER_MAJ"."VER_MIN"."VER_TWK"\n";
static char version[]="Milliways III - Release "VERSION"\n";

/* global termcap usage variable */
int g_boTermCap = 0;
@@ -1882,10 +1882,7 @@ char *part_comm_mesg(const char *text, int status)

void c_version(CommandList *cm, int argc, const char **argv, char *args)
{
	if (atoi(VER_TWK) > 0)
	printf(_("Version %s.%s.%s\n"), VER_MAJ, VER_MIN, VER_TWK);
	else
	printf(_("Version %s.%s\n"), VER_MAJ, VER_MIN);
	printf(_("Version "VERSION"\n"));
	printf(_("Built by %s on %s\n"), BUILD_USER, __DATE__);
}

Loading