Project 'arthur/mw' was moved to 'milliways/mw'. Please update any links and bookmarks that may still have the old path.
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
......@@ -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) $@
......
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)\"
......
......@@ -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);
......
......@@ -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);
......
......@@ -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__);
}
......
......@@ -2034,19 +2034,18 @@ void scr_user( struct code *pc, int fargc, char **fargv )
free(value);
free(what);
}
void scr_version( struct code *pc, int fargc, char **fargv )
{
char *what;
const char *version_str = "R "VER_MAJ" "VER_MIN;
if (pc->argc < 1) {
if (script_debug) printf("Error in %s at %s too few arguments.\n", pc->inst->name, pc->debug);
return;
}
what=eval_arg(pc->argv[0], fargc, fargv);
if (script_debug) printf(" - VERSION: Version string is '%s'", version_str);
var_str_force_2(what, version_str);
if (script_debug) printf(" - VERSION: Version string is '%s'", VERSION);
var_str_force_2(what, VERSION);
free(what);
}
......
......@@ -308,9 +308,7 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg)
json_t * j = json_init(NULL);
json_addint(j, "uptime", now - uptime);
AUTOFREE_BUFFER version = NULL;
asprintf(&version, "%s.%s.%s", VER_MAJ, VER_MIN, VER_TWK);
json_addstring(j, "version", version);
json_addstring(j, "version", VERSION);
ipcmsg_json_encode(msg, j);
msg_attach(msg, conn);
ipcmsg_destroy(msg);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment