aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2015-02-05 19:35:12 -0800
committerZac Medico <zmedico@gentoo.org>2015-03-04 13:32:07 -0800
commit328dd4712f88cbb8ef390ae9eb471afa1ef781d7 (patch)
treebf16e99c89b73589031f0df6a0e5907865b48245 /pym/portage/emaint/modules/binhost/binhost.py
parentbinpkg-multi-instance 2 of 7 (diff)
downloadportage-328dd4712f88cbb8ef390ae9eb471afa1ef781d7.tar.gz
portage-328dd4712f88cbb8ef390ae9eb471afa1ef781d7.tar.bz2
portage-328dd4712f88cbb8ef390ae9eb471afa1ef781d7.zip
binpkg-multi-instance 3 of 7
FEATURES=binpkg-multi-instance causes an integer build-id to be associated with each binary package instance. Inclusion of the build-id in the file name of the binary package file makes it possible to store an arbitrary number of binary packages built from the same ebuild. Having multiple instances is useful for a number of purposes, such as retaining builds that were built with different USE flags or linked against different versions of libraries. The location of any particular package within PKGDIR can be expressed as follows: ${PKGDIR}/${CATEGORY}/${PN}/${PF}-${BUILD_ID}.xpak The build-id starts at 1 for the first build of a particular ebuild, and is incremented by 1 for each new build. It is possible to share a writable PKGDIR over NFS, and locking ensures that each package added to PKGDIR will have a unique build-id. It is not necessary to migrate an existing PKGDIR to the new layout, since portage is capable of working with a mixed PKGDIR layout, where packages using the old layout are allowed to remain in place. The new PKGDIR layout is backward-compatible with binhost clients running older portage, since the file format is identical, the per-package PATH attribute in the 'Packages' index directs them to download the file from the correct URI, and they automatically use BUILD_TIME metadata to select the latest builds. There is currently no automated way to prune old builds from PKGDIR, although it is possible to remove packages manually, and then run 'emaint --fix binhost' to update the ${PKGDIR}/Packages index. Support for FEATURES=binpkg-multi-instance is planned for eclean-pkg. X-Gentoo-Bug: 150031 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=150031
Diffstat (limited to 'pym/portage/emaint/modules/binhost/binhost.py')
-rw-r--r--pym/portage/emaint/modules/binhost/binhost.py47
1 files changed, 31 insertions, 16 deletions
diff --git a/pym/portage/emaint/modules/binhost/binhost.py b/pym/portage/emaint/modules/binhost/binhost.py
index 1138a8c7e..cf1213e94 100644
--- a/pym/portage/emaint/modules/binhost/binhost.py
+++ b/pym/portage/emaint/modules/binhost/binhost.py
@@ -7,6 +7,7 @@ import stat
import portage
from portage import os
from portage.util import writemsg
+from portage.versions import _pkg_str
import sys
@@ -38,7 +39,7 @@ class BinhostHandler(object):
if size is None:
return True
- mtime = data.get("MTIME")
+ mtime = data.get("_mtime_")
if mtime is None:
return True
@@ -90,6 +91,7 @@ class BinhostHandler(object):
def fix(self, **kwargs):
onProgress = kwargs.get('onProgress', None)
bintree = self._bintree
+ _instance_key = bintree.dbapi._instance_key
cpv_all = self._bintree.dbapi.cpv_all()
cpv_all.sort()
missing = []
@@ -98,16 +100,21 @@ class BinhostHandler(object):
onProgress(maxval, 0)
pkgindex = self._pkgindex
missing = []
+ stale = []
metadata = {}
for d in pkgindex.packages:
- metadata[d["CPV"]] = d
-
- for i, cpv in enumerate(cpv_all):
- d = metadata.get(cpv)
+ cpv = _pkg_str(d["CPV"], metadata=d,
+ settings=bintree.settings)
+ d["CPV"] = cpv
+ metadata[_instance_key(cpv)] = d
+ if not bintree.dbapi.cpv_exists(cpv):
+ stale.append(cpv)
+
+ for cpv in cpv_all:
+ d = metadata.get(_instance_key(cpv))
if not d or self._need_update(cpv, d):
missing.append(cpv)
- stale = set(metadata).difference(cpv_all)
if missing or stale:
from portage import locks
pkgindex_lock = locks.lockfile(
@@ -121,31 +128,39 @@ class BinhostHandler(object):
pkgindex = bintree._load_pkgindex()
self._pkgindex = pkgindex
+ # Recount stale/missing packages, with lock held.
+ missing = []
+ stale = []
metadata = {}
for d in pkgindex.packages:
- metadata[d["CPV"]] = d
-
- # Recount missing packages, with lock held.
- del missing[:]
- for i, cpv in enumerate(cpv_all):
- d = metadata.get(cpv)
+ cpv = _pkg_str(d["CPV"], metadata=d,
+ settings=bintree.settings)
+ d["CPV"] = cpv
+ metadata[_instance_key(cpv)] = d
+ if not bintree.dbapi.cpv_exists(cpv):
+ stale.append(cpv)
+
+ for cpv in cpv_all:
+ d = metadata.get(_instance_key(cpv))
if not d or self._need_update(cpv, d):
missing.append(cpv)
maxval = len(missing)
for i, cpv in enumerate(missing):
+ d = bintree._pkgindex_entry(cpv)
try:
- metadata[cpv] = bintree._pkgindex_entry(cpv)
+ bintree._eval_use_flags(cpv, d)
except portage.exception.InvalidDependString:
writemsg("!!! Invalid binary package: '%s'\n" % \
bintree.getname(cpv), noiselevel=-1)
+ else:
+ metadata[_instance_key(cpv)] = d
if onProgress:
onProgress(maxval, i+1)
- for cpv in set(metadata).difference(
- self._bintree.dbapi.cpv_all()):
- del metadata[cpv]
+ for cpv in stale:
+ del metadata[_instance_key(cpv)]
# We've updated the pkgindex, so set it to
# repopulate when necessary.