diff options
-rw-r--r-- | pym/portage/dbapi/bintree.py | 25 | ||||
-rw-r--r-- | pym/portage/getbinpkg.py | 19 |
2 files changed, 28 insertions, 16 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 629788544..88ad06603 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -152,6 +152,13 @@ class binarytree(object): self._pkgindex_header_keys = set(["ACCEPT_KEYWORDS", "CBUILD", "CHOST", "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "FEATURES", "GENTOO_MIRRORS", "INSTALL_MASK", "SYNC", "USE"]) + self._pkgindex_default_pkg_data = { + "EAPI" : "0", + "IUSE" : "", + "PROVIDE" : "", + "SLOT" : "0", + "USE" : "" + } def move_ent(self, mylist): if not self.populated: @@ -360,7 +367,8 @@ class binarytree(object): dirs.remove("All") dirs.sort() dirs.insert(0, "All") - pkgindex = portage.getbinpkg.PackageIndex() + pkgindex = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) pf_index = None try: f = open(self._pkgindex_file) @@ -373,7 +381,8 @@ class binarytree(object): f.close() del f if not self._pkgindex_version_supported(pkgindex): - pkgindex = portage.getbinpkg.PackageIndex() + pkgindex = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) header = pkgindex.header metadata = pkgindex.packages update_pkgindex = False @@ -556,7 +565,8 @@ class binarytree(object): urldata = urlparse(base_url) pkgindex_file = os.path.join(CACHE_PATH, "binhost", urldata[1] + urldata[2], "Packages") - pkgindex = portage.getbinpkg.PackageIndex() + pkgindex = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) try: f = open(pkgindex_file) try: @@ -568,7 +578,8 @@ class binarytree(object): raise local_timestamp = pkgindex.header.get("TIMESTAMP", None) import urllib, urlparse - rmt_idx = portage.getbinpkg.PackageIndex() + rmt_idx = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) try: f = urllib.urlopen(urlparse.urljoin(base_url, "Packages")) try: @@ -711,7 +722,8 @@ 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() + pkgindex = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) try: f = open(self._pkgindex_file) except EnvironmentError: @@ -723,7 +735,8 @@ class binarytree(object): f.close() del f if not self._pkgindex_version_supported(pkgindex): - pkgindex = portage.getbinpkg.PackageIndex() + pkgindex = portage.getbinpkg.PackageIndex( + default_pkg_data=self._pkgindex_default_pkg_data) d = digests d["CPV"] = cpv d["SLOT"] = slot diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index a248e378b..108161c02 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -664,7 +664,8 @@ def writepkgindex(pkgfile, items): class PackageIndex(object): - def __init__(self): + def __init__(self, default_pkg_data=None): + self._default_pkg_data = default_pkg_data self.header = {} self.packages = {} self.modified = True @@ -685,11 +686,9 @@ class PackageIndex(object): mycpv = d.get("CPV") if not mycpv: continue - d.setdefault("EAPI", "0") - d.setdefault("IUSE", "") - d.setdefault("PROVIDE", "") - d.setdefault("SLOT", "0") - d.setdefault("USE", "") + 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) self.packages[mycpv] = d @@ -708,10 +707,10 @@ class PackageIndex(object): metadata = self.packages[cpv].copy() if metadata.get("CHOST") == header_chost: del metadata["CHOST"] - if metadata.get("EAPI") == "0": - del metadata["EAPI"] - if metadata.get("SLOT") == "0": - del metadata["SLOT"] + if self._default_pkg_data: + for k, v in self._default_pkg_data.iteritems(): + if metadata.get(k) == v: + metadata.pop(k, None) keys = metadata.keys() keys.sort() writepkgindex(pkgfile, |