"SLOT" : "0",
"USE" : ""
}
+ self._pkgindex_inherited_keys = ["CHOST"]
def move_ent(self, mylist):
if not self.populated:
dirs.remove("All")
dirs.sort()
dirs.insert(0, "All")
- pkgindex = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ pkgindex = self._new_pkgindex()
pf_index = None
try:
f = open(self._pkgindex_file)
f.close()
del f
if not self._pkgindex_version_supported(pkgindex):
- pkgindex = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ pkgindex = self._new_pkgindex()
header = pkgindex.header
metadata = pkgindex.packages
update_pkgindex = False
urldata = urlparse(base_url)
pkgindex_file = os.path.join(CACHE_PATH, "binhost",
urldata[1] + urldata[2], "Packages")
- pkgindex = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ pkgindex = self._new_pkgindex()
try:
f = open(pkgindex_file)
try:
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
import urllib, urlparse
- rmt_idx = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ rmt_idx = self._new_pkgindex()
try:
f = urllib.urlopen(urlparse.urljoin(base_url, "Packages"))
try:
if self._all_directory and \
self.getname(cpv).split(os.path.sep)[-2] == "All":
self._create_symlink(cpv)
- pkgindex = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ pkgindex = self._new_pkgindex()
try:
f = open(self._pkgindex_file)
except EnvironmentError:
f.close()
del f
if not self._pkgindex_version_supported(pkgindex):
- pkgindex = portage.getbinpkg.PackageIndex(
- default_pkg_data=self._pkgindex_default_pkg_data)
+ pkgindex = self._new_pkgindex()
d = digests
d["CPV"] = cpv
d["SLOT"] = slot
if pkgindex_lock:
unlockfile(pkgindex_lock)
+ def _new_pkgindex(self):
+ return portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data,
+ inherited_keys=self._pkgindex_inherited_keys)
+
def _update_pkgindex_header(self, header):
portdir = normalize_path(os.path.realpath(self.settings["PORTDIR"]))
profiles_base = os.path.join(portdir, "profiles") + os.path.sep
class PackageIndex(object):
- def __init__(self, default_pkg_data=None):
+ def __init__(self, default_pkg_data=None, inherited_keys=None):
self._default_pkg_data = default_pkg_data
+ self._inherited_keys = inherited_keys
self.header = {}
self.packages = {}
self.modified = True
self.header.update(readpkgindex(pkgfile))
def readBody(self, pkgfile):
- header_chost = self.header.get("CHOST")
while True:
d = readpkgindex(pkgfile)
if not d:
if self._default_pkg_data:
for k, v in self._default_pkg_data.iteritems():
d.setdefault(k, v)
- if header_chost:
- d.setdefault("CHOST", header_chost)
+ if self._inherited_keys:
+ for k in self._inherited_keys:
+ v = self.header.get(k)
+ if v is not None:
+ d.setdefault(k, v)
self.packages[mycpv] = d
def write(self, pkgfile):
keys = self.header.keys()
keys.sort()
writepkgindex(pkgfile, [(k, self.header[k]) for k in keys])
- header_chost = self.header.get("CHOST")
for cpv in cpv_all:
metadata = self.packages[cpv].copy()
- if metadata.get("CHOST") == header_chost:
- del metadata["CHOST"]
+ if self._inherited_keys:
+ for k in self._inherited_keys:
+ v = self.header.get(k)
+ if v is not None and v == metadata.get(k):
+ del metadata[k]
if self._default_pkg_data:
for k, v in self._default_pkg_data.iteritems():
if metadata.get(k) == v: