From 3972cf795ee8c4dc4914193f43d6a45f4cfed2fb Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 19 Sep 2010 03:44:10 -0700 Subject: [PATCH] Bug #338002 - Make _LazyVersion format portage.VERSION so that it is a valid version. --- pym/portage/__init__.py | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 3c8d5ce..34d7ec8 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -125,6 +125,7 @@ try: 'cpv_getkey@getCPFromCPV,endversion_keys,' + \ 'suffix_value@endversion,pkgcmp,pkgsplit,vercmp,ververify', 'portage.xpak', + 'time', ) try: @@ -541,12 +542,21 @@ if VERSION == 'HEAD': if VERSION is not self: return VERSION if os.path.isdir(os.path.join(PORTAGE_BASE_PATH, '.git')): - status, output = subprocess_getstatusoutput( - "cd %s ; git describe --tags" % \ - _shell_quote(PORTAGE_BASE_PATH)) + status, output = subprocess_getstatusoutput(( + "cd %s ; git describe --tags || exit $? ; " + \ + "[ -n \"`git diff-index --name-only --diff-filter=M HEAD`\" ] && echo modified ; " + \ + "exit 0") % _shell_quote(PORTAGE_BASE_PATH)) if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: - VERSION = output - return VERSION + output = output.split() + if output: + version_split = output[0].split('-') + if version_split: + VERSION = version_split[0].lstrip('v') + if len(version_split) > 1: + VERSION = "%s_p%s" %(VERSION, version_split[1]) + if output[-1] == 'modified': + VERSION = "%s_p%d" % (VERSION, time.time()) + return VERSION VERSION = 'HEAD' return VERSION VERSION = _LazyVersion() -- 1.7.1.1