diff options
-rw-r--r-- | pym/portage/dbapi/bintree.py | 24 | ||||
-rw-r--r-- | pym/portage/getbinpkg.py | 19 |
2 files changed, 24 insertions, 19 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 88ad06603..2b23cc763 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -159,6 +159,7 @@ class binarytree(object): "SLOT" : "0", "USE" : "" } + self._pkgindex_inherited_keys = ["CHOST"] def move_ent(self, mylist): if not self.populated: @@ -367,8 +368,7 @@ class binarytree(object): 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) @@ -381,8 +381,7 @@ class binarytree(object): 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 @@ -565,8 +564,7 @@ class binarytree(object): 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: @@ -578,8 +576,7 @@ class binarytree(object): 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: @@ -722,8 +719,7 @@ class binarytree(object): 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: @@ -735,8 +731,7 @@ class binarytree(object): 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 @@ -769,6 +764,11 @@ class binarytree(object): 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 diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 108161c02..290bf76c5 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -664,8 +664,9 @@ def writepkgindex(pkgfile, items): 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 @@ -678,7 +679,6 @@ class PackageIndex(object): self.header.update(readpkgindex(pkgfile)) def readBody(self, pkgfile): - header_chost = self.header.get("CHOST") while True: d = readpkgindex(pkgfile) if not d: @@ -689,8 +689,11 @@ class PackageIndex(object): 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): @@ -702,11 +705,13 @@ class PackageIndex(object): 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: |