Skip to content
Commits on Source (2)
  • Andrew Price's avatar
    Simplify version numbering using git tags · 9325a02d
    Andrew Price authored
    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.17" 2.17 fb1be771
    
    so git describe will give us versions like 2.17-123-gf00baa which has
    better ordering properties than the current 2.17-gf00baa scheme, which
    is important for package upgrades. When HEAD matches the tag exactly, it
    will just give 2.17
    9325a02d
  • Andrew Price's avatar
......@@ -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 --dirty)
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 | sed 's/^./\u&/')\"
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)\"
......
......@@ -66,10 +66,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);
......
......@@ -780,10 +780,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);
......
......@@ -51,7 +51,7 @@
#include "who.h"
#include "alias.h"
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;
......@@ -1858,10 +1858,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__);
}
......
......@@ -2032,15 +2032,14 @@ void scr_user( struct code *pc, int fargc, char **fargv )
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);
}
......
......@@ -311,9 +311,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 char *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);
......