diff options
author | Rob Austein <sra@hactrn.net> | 2013-06-10 18:48:46 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-06-10 18:48:46 +0000 |
commit | 176c13d5e71db72e237e399f6402a63475b4fead (patch) | |
tree | 84b46887808cb571e6aa4a58fe6b8beb051aacec | |
parent | 4ad57ffa7bb69eb725da56ec5c4f9dcbdf95c8c8 (diff) |
rpki.version hack and rpkic command to display it.
See #543.
svn path=/trunk/; revision=5384
-rw-r--r-- | Makefile.in | 9 | ||||
-rw-r--r-- | buildtools/make-version.py | 51 | ||||
-rw-r--r-- | rpkid/rpki/rpkic.py | 14 |
3 files changed, 73 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in index 508d6973..1247ff0d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,7 @@ # $Id$ +PYTHON = @PYTHON@ + abs_top_builddir = @abs_top_builddir@ SUBDIRS = @TOP_LEVEL_SUBDIRS@ @@ -8,6 +10,8 @@ default: all test:: all +all:: VERSION + all install clean test distclean deinstall uninstall:: @for i in ${SUBDIRS}; do echo "Making $@ in $$i"; (cd $$i && ${MAKE} $@); done @@ -21,3 +25,8 @@ distclean clean:: distclean:: rm -rf Makefile config.log config.status + +VERSION: .FORCE + ${PYTHON} buildtools/make-version.py + +.FORCE: diff --git a/buildtools/make-version.py b/buildtools/make-version.py new file mode 100644 index 00000000..9f6eb39f --- /dev/null +++ b/buildtools/make-version.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# $Id$ + +# Copyright (C) 2013 Internet Systems Consortium ("ISC") +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# Kludge to extract Subversion revision number from environment at +# build time, if possible, using it to construct the software version +# number that one of our users so desperately wants us to have. This +# is a bit tricky because we want this to be automatic (hence use of +# Subversion revision number, which isn't really intended for this +# purpose), want it to work whether installing from binary package or +# subversion checkout or frozen tarball, and need to be careful both +# to update it whenever the revision changes and not to stomp on it +# when the subversion revision number isn't available. +# +# I did say this was a kludge. + +import subprocess + +try: + v = subprocess.Popen(("svnversion", "-c"), stdout = subprocess.PIPE).communicate()[0] +except: + v = "Unknown" + +if any(s in v for s in ("Unversioned", "Uncommitted", "Unknown")): + v = "Unknown" +else: + v = "0." + v.strip().split(":")[-1].translate(None, "SMP") + +try: + old = open("VERSION", "r").read().strip() +except: + old = None + +if old is None or v != old: + with open("VERSION", "w") as f: + f.write(v + "\n") + with open("rpkid/rpki/version.py", "w") as f: + f.write("VERSION = \"%s\"\n" % v) diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py index 8085db43..377b6474 100644 --- a/rpkid/rpki/rpkic.py +++ b/rpkid/rpki/rpkic.py @@ -17,7 +17,7 @@ integration with the Django-based GUI interface. $Id$ -Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2013 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -54,6 +54,7 @@ import rpki.exceptions import rpki.left_right import rpki.x509 import rpki.async +import rpki.version from rpki.cli import Cmd, BadCommandSyntax @@ -743,3 +744,14 @@ class main(Cmd): raise BadCommandSyntax("This command takes no arguments") self.zoo.clear_all_sql_cms_replay_protection() + + + def do_version(self, arg): + """ + Show current software version number. + """ + + if arg: + raise BadCommandSyntax("This command takes no arguments") + + print rpki.version.VERSION |