From a82eee8b28e1aaf6bd59aad63709037ae2363752 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Thu, 30 May 2013 12:34:06 -0700 Subject: [PATCH] Migrate version to use snakeoil's format_version() to append git commit info. This will make tagging releases easy as well as providing better debug info while running live versions of the software. --- catalyst/main.py | 12 +++++++----- catalyst/version.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 catalyst/version.py diff --git a/catalyst/main.py b/catalyst/main.py index 3e9cb7e9..9ca33ece 100755 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -23,10 +23,9 @@ from catalyst.defaults import hash_definitions, confdefaults, option_messages from hash_utils import HashMap from defaults import contents_definitions from contents import ContentsMap - +from catalyst.version import get_version __maintainer__="Catalyst " -__version__="rewrite-git" conf_values={} @@ -60,7 +59,7 @@ catalyst -f stage1-specfile.spec def version(): - print "Catalyst, version "+__version__ + print get_version() print "Copyright 2003-2008 Gentoo Foundation" print "Copyright 2008-2012 various authors" print "Distributed under the GNU General Public License version 2.1\n" @@ -172,8 +171,8 @@ def build_target(addlargs): def main(): - version() if os.getuid() != 0: + version() # catalyst cannot be run as a normal user due to chroots, mounts, etc print "!!! catalyst: This script requires root privileges to operate" sys.exit(2) @@ -207,11 +206,12 @@ def main(): run = False for o, a in opts: if o in ("-h", "--help"): + version() usage() sys.exit(1) if o in ("-V", "--version"): - print "Catalyst version "+__version__ + print get_version() sys.exit(1) if o in ("-d", "--debug"): @@ -267,6 +267,8 @@ def main(): usage() sys.exit(2) + # made it this far so start by outputting our version info + version() # import configuration file and import our main module using those settings parse_config(myconfig) diff --git a/catalyst/version.py b/catalyst/version.py new file mode 100644 index 00000000..03c77e40 --- /dev/null +++ b/catalyst/version.py @@ -0,0 +1,23 @@ +#!/usr/bin/python -OO + +# Maintained in full by: +# Catalyst Team +# Release Engineering Team +# Copyright: 2011 Brian Harring +# License: BSD/GPL2 +# Copied & edited by: Brian Dolbec + +'''Version information and/or git version information +''' + +from snakeoil.version import format_version + +__version__="rewrite-git" +_ver = None + +def get_version(): + """Return: a string describing our version.""" + global _ver + if _ver is None: + _ver = format_version('catalyst',__file__, __version__) + return _ver -- 2.26.2