From: Brian Dolbec Date: Thu, 30 May 2013 19:34:06 +0000 (-0700) Subject: Migrate version to use snakeoil's format_version() to append git commit info. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b8ce8e8cdcae5e40712f7972a46e5ff04cfcb95d;p=catalyst.git 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. --- diff --git a/catalyst/main.py b/catalyst/main.py index a838cbde..26e0c8b3 100644 --- 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" @@ -174,8 +173,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) @@ -213,11 +212,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"): @@ -273,6 +273,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