summaryrefslogtreecommitdiffstats
path: root/pym/portage/getbinpkg.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-05-22 11:16:50 +0000
committerZac Medico <zmedico@gentoo.org>2007-05-22 11:16:50 +0000
commitf45516f92d9cfa12736783ec62273e78f3805120 (patch)
tree890bb30d207fbf16d1746db58166bf65360b2352 /pym/portage/getbinpkg.py
parent29fd2e335caa465372eb35a1b65ecdf9a37f83a6 (diff)
downloadportage-f45516f92d9cfa12736783ec62273e78f3805120.tar.gz
portage-f45516f92d9cfa12736783ec62273e78f3805120.tar.bz2
portage-f45516f92d9cfa12736783ec62273e78f3805120.zip
Cache xpak metadata in ${PKGDIR}/Packages in order to minimize disk load when binarytree.populate() is called. This does not do all the keys that genpkgindex does but it will copy metadata from the existing Packages file if it appears valid. The binarytree.populate() code is performance critical, so the MD5 will certainly have to be done elsewhere (like just after a package is built).
svn path=/main/trunk/; revision=6569
Diffstat (limited to 'pym/portage/getbinpkg.py')
-rw-r--r--pym/portage/getbinpkg.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index b0d5ca9eb..070b036b5 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -570,3 +570,23 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
conn.close()
return metadata[baseurl]["data"]
+
+def readpkgindex(pkgfile):
+ d = {}
+ for line in pkgfile:
+ line = line.rstrip("\n")
+ if not line:
+ break
+ line = line.split(":", 1)
+ if not len(line) == 2:
+ continue
+ k, v = line
+ if v:
+ v = v[1:]
+ d[k] = v
+ return d
+
+def writepkgindex(pkgfile, items):
+ for k, v in items:
+ pkgfile.write("%s: %s\n" % (k, v))
+ pkgfile.write("\n")