commit: 89beddf2ccfb320bac1f8d5b2e5964bf4890ac78 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Thu May 30 19:34:06 2013 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> CommitDate: Thu Jan 1 05:58:07 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=89beddf2
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 | 11 +++++++---- catalyst/version.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/catalyst/main.py b/catalyst/main.py index 7fea4e7..ae0abae 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -14,7 +14,6 @@ import os.path __selfpath__ = os.path.abspath(os.path.dirname(__file__)) -from . import __version__ import catalyst.config import catalyst.util from catalyst.contents import ContentsMap, CONTENTS_DEFINITIONS @@ -22,6 +21,7 @@ from catalyst.defaults import confdefaults, option_messages from catalyst.hash_utils import HashMap, HASH_DEFINITIONS from catalyst.lock import LockInUse from catalyst.support import CatalystError, find_binary +from catalyst.version import get_version conf_values={} @@ -57,7 +57,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" @@ -169,8 +169,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) @@ -204,11 +204,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"): @@ -264,6 +265,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 0000000..03c77e4 --- /dev/null +++ b/catalyst/version.py @@ -0,0 +1,23 @@ +#!/usr/bin/python -OO + +# Maintained in full by: +# Catalyst Team <catal...@gentoo.org> +# Release Engineering Team <rel...@gentoo.org> +# Copyright: 2011 Brian Harring <ferri...@gmail.com> +# License: BSD/GPL2 +# Copied & edited by: Brian Dolbec <dol...@gentoo.org> + +'''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