summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-03-27 14:35:11 -0700
committerZac Medico <zmedico@gentoo.org>2010-03-27 14:35:11 -0700
commit4f8e75b71f149b1aa0411051fe06a836f6f07cd3 (patch)
tree15075ed9be0a1d8c5f949a55b0d488715a42416f /pym
parent54f2e2bbf03175577429dd83e64e72aabff10acf (diff)
downloadportage-4f8e75b71f149b1aa0411051fe06a836f6f07cd3.tar.gz
portage-4f8e75b71f149b1aa0411051fe06a836f6f07cd3.tar.bz2
portage-4f8e75b71f149b1aa0411051fe06a836f6f07cd3.zip
If portage.VERSION == HEAD then use a proxy to lazily call git describe --tags
if it's accessed.
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/actions.py3
-rw-r--r--pym/portage/__init__.py17
2 files changed, 19 insertions, 1 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 954123a76..4fb08e3ad 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2477,7 +2477,8 @@ def getportageversion(portdir, target_root, profile, chost, vardb):
gccver = getgccversion(chost)
unameout=platform.release()+" "+platform.machine()
- return "Portage " + portage.VERSION +" ("+profilever+", "+gccver+", "+libcver+", "+unameout+")"
+ return "Portage %s (%s, %s, %s, %s)" % \
+ (portage.VERSION, profilever, gccver, libcver, unameout)
def git_sync_timestamps(settings, portdir):
"""
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 44402edd4..e1de04635 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -553,6 +553,23 @@ def create_trees(config_root=None, target_root=None, trees=None):
binarytree, myroot, mysettings["PKGDIR"], settings=mysettings)
return trees
+if VERSION == 'HEAD':
+ class _LazyVersion(proxy.objectproxy.ObjectProxy):
+ def _get_target(self):
+ global VERSION
+ 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))
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
+ VERSION = output
+ return VERSION
+ VERSION = 'HEAD'
+ return VERSION
+ VERSION = _LazyVersion()
+
class _LegacyGlobalProxy(proxy.objectproxy.ObjectProxy):
__slots__ = ('_name',)