1 |
commit: 89beddf2ccfb320bac1f8d5b2e5964bf4890ac78 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 30 19:34:06 2013 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 1 05:58:07 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=89beddf2 |
7 |
|
8 |
Migrate version to use snakeoil's format_version() to append git commit info. |
9 |
|
10 |
This will make tagging releases easy as well as providing better debug info while running live versions of the software. |
11 |
|
12 |
--- |
13 |
catalyst/main.py | 11 +++++++---- |
14 |
catalyst/version.py | 23 +++++++++++++++++++++++ |
15 |
2 files changed, 30 insertions(+), 4 deletions(-) |
16 |
|
17 |
diff --git a/catalyst/main.py b/catalyst/main.py |
18 |
index 7fea4e7..ae0abae 100644 |
19 |
--- a/catalyst/main.py |
20 |
+++ b/catalyst/main.py |
21 |
@@ -14,7 +14,6 @@ import os.path |
22 |
__selfpath__ = os.path.abspath(os.path.dirname(__file__)) |
23 |
|
24 |
|
25 |
-from . import __version__ |
26 |
import catalyst.config |
27 |
import catalyst.util |
28 |
from catalyst.contents import ContentsMap, CONTENTS_DEFINITIONS |
29 |
@@ -22,6 +21,7 @@ from catalyst.defaults import confdefaults, option_messages |
30 |
from catalyst.hash_utils import HashMap, HASH_DEFINITIONS |
31 |
from catalyst.lock import LockInUse |
32 |
from catalyst.support import CatalystError, find_binary |
33 |
+from catalyst.version import get_version |
34 |
|
35 |
|
36 |
conf_values={} |
37 |
@@ -57,7 +57,7 @@ catalyst -f stage1-specfile.spec |
38 |
|
39 |
|
40 |
def version(): |
41 |
- print "Catalyst, version "+__version__ |
42 |
+ print get_version() |
43 |
print "Copyright 2003-2008 Gentoo Foundation" |
44 |
print "Copyright 2008-2012 various authors" |
45 |
print "Distributed under the GNU General Public License version 2.1\n" |
46 |
@@ -169,8 +169,8 @@ def build_target(addlargs): |
47 |
|
48 |
def main(): |
49 |
|
50 |
- version() |
51 |
if os.getuid() != 0: |
52 |
+ version() |
53 |
# catalyst cannot be run as a normal user due to chroots, mounts, etc |
54 |
print "!!! catalyst: This script requires root privileges to operate" |
55 |
sys.exit(2) |
56 |
@@ -204,11 +204,12 @@ def main(): |
57 |
run = False |
58 |
for o, a in opts: |
59 |
if o in ("-h", "--help"): |
60 |
+ version() |
61 |
usage() |
62 |
sys.exit(1) |
63 |
|
64 |
if o in ("-V", "--version"): |
65 |
- print "Catalyst version "+__version__ |
66 |
+ print get_version() |
67 |
sys.exit(1) |
68 |
|
69 |
if o in ("-d", "--debug"): |
70 |
@@ -264,6 +265,8 @@ def main(): |
71 |
usage() |
72 |
sys.exit(2) |
73 |
|
74 |
+ # made it this far so start by outputting our version info |
75 |
+ version() |
76 |
# import configuration file and import our main module using those settings |
77 |
parse_config(myconfig) |
78 |
|
79 |
|
80 |
diff --git a/catalyst/version.py b/catalyst/version.py |
81 |
new file mode 100644 |
82 |
index 0000000..03c77e4 |
83 |
--- /dev/null |
84 |
+++ b/catalyst/version.py |
85 |
@@ -0,0 +1,23 @@ |
86 |
+#!/usr/bin/python -OO |
87 |
+ |
88 |
+# Maintained in full by: |
89 |
+# Catalyst Team <catalyst@g.o> |
90 |
+# Release Engineering Team <releng@g.o> |
91 |
+# Copyright: 2011 Brian Harring <ferringb@×××××.com> |
92 |
+# License: BSD/GPL2 |
93 |
+# Copied & edited by: Brian Dolbec <dolsen@g.o> |
94 |
+ |
95 |
+'''Version information and/or git version information |
96 |
+''' |
97 |
+ |
98 |
+from snakeoil.version import format_version |
99 |
+ |
100 |
+__version__="rewrite-git" |
101 |
+_ver = None |
102 |
+ |
103 |
+def get_version(): |
104 |
+ """Return: a string describing our version.""" |
105 |
+ global _ver |
106 |
+ if _ver is None: |
107 |
+ _ver = format_version('catalyst',__file__, __version__) |
108 |
+ return _ver |