binarytree: tweak deprecated constructor param
[portage.git] / pym / portage / dbapi / bintree.py
index a2fd5eabe08237f0e982a84bcd279501998706d9..890e8e10b14f1296aa520b4dd9cc59be860d5f42 100644 (file)
@@ -72,9 +72,10 @@ class bindbapi(fakedbapi):
                self.cpdict={}
                # Selectively cache metadata in order to optimize dep matching.
                self._aux_cache_keys = set(
-                       ["BUILD_TIME", "CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS",
+                       ["BUILD_TIME", "CHOST", "DEPEND", "EAPI",
+                       "HDEPEND", "IUSE", "KEYWORDS",
                        "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE",
-                       "RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "DEFINED_PHASES",
+                       "RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "DEFINED_PHASES"
                        ])
                self._aux_cache_slot_dict = slot_dict_class(self._aux_cache_keys)
                self._aux_cache = {}
@@ -257,7 +258,7 @@ def _pkgindex_cpv_map_latest_build(pkgindex):
 
 class binarytree(object):
        "this tree scans for a list of all packages available in PKGDIR"
-       def __init__(self, _unused=None, pkgdir=None,
+       def __init__(self, _unused=DeprecationWarning, pkgdir=None,
                virtual=DeprecationWarning, settings=None):
 
                if pkgdir is None:
@@ -266,11 +267,11 @@ class binarytree(object):
                if settings is None:
                        raise TypeError("settings parameter is required")
 
-               if _unused is not None and _unused != settings['ROOT']:
-                       warnings.warn("The root parameter of the "
+               if _unused is not DeprecationWarning:
+                       warnings.warn("The first parameter of the "
                                "portage.dbapi.bintree.binarytree"
-                               " constructor is now unused. Use "
-                               "settings['ROOT'] instead.",
+                               " constructor is now unused. Instead "
+                               "settings['ROOT'] is used.",
                                DeprecationWarning, stacklevel=2)
 
                if virtual is not DeprecationWarning:
@@ -302,12 +303,12 @@ class binarytree(object):
                        self._pkgindex_keys.update(["CPV", "MTIME", "SIZE"])
                        self._pkgindex_aux_keys = \
                                ["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION", "EAPI",
-                               "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES",
+                               "HDEPEND", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES",
                                "PROVIDE", "RDEPEND", "repository", "SLOT", "USE", "DEFINED_PHASES",
                                "BASE_URI"]
                        self._pkgindex_aux_keys = list(self._pkgindex_aux_keys)
                        self._pkgindex_use_evaluated_keys = \
-                               ("LICENSE", "RDEPEND", "DEPEND",
+                               ("DEPEND", "HDEPEND", "LICENSE", "RDEPEND",
                                "PDEPEND", "PROPERTIES", "PROVIDE")
                        self._pkgindex_header_keys = set([
                                "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
@@ -316,8 +317,10 @@ class binarytree(object):
                                "GENTOO_MIRRORS", "INSTALL_MASK", "SYNC", "USE"])
                        self._pkgindex_default_pkg_data = {
                                "BUILD_TIME"         : "",
+                               "DEFINED_PHASES"     : "",
                                "DEPEND"  : "",
                                "EAPI"    : "0",
+                               "HDEPEND" : "",
                                "IUSE"    : "",
                                "KEYWORDS": "",
                                "LICENSE" : "",
@@ -329,7 +332,6 @@ class binarytree(object):
                                "RESTRICT": "",
                                "SLOT"    : "0",
                                "USE"     : "",
-                               "DEFINED_PHASES" : "",
                        }
                        self._pkgindex_inherited_keys = ["CHOST", "repository"]
 
@@ -423,7 +425,7 @@ class binarytree(object):
                        moves += 1
                        mytbz2 = portage.xpak.tbz2(tbz2path)
                        mydata = mytbz2.get_data()
-                       updated_items = update_dbentries([mylist], mydata, eapi=mycpv.eapi)
+                       updated_items = update_dbentries([mylist], mydata, parent=mycpv)
                        mydata.update(updated_items)
                        mydata[b'PF'] = \
                                _unicode_encode(mynewpkg + "\n",
@@ -1017,75 +1019,7 @@ class binarytree(object):
                                        # Local package instances override remote instances.
                                        for cpv in metadata:
                                                self._remotepkgs.pop(cpv, None)
-                               continue
-                       try:
-                               chunk_size = long(self.settings["PORTAGE_BINHOST_CHUNKSIZE"])
-                               if chunk_size < 8:
-                                       chunk_size = 8
-                       except (ValueError, KeyError):
-                               chunk_size = 3000
-                       writemsg_stdout("\n")
-                       writemsg_stdout(
-                               colorize("GOOD", _("Fetching bininfo from ")) + \
-                               _hide_url_passwd(base_url) + "\n")
-                       remotepkgs = portage.getbinpkg.dir_get_metadata(
-                               base_url, chunk_size=chunk_size)
-
-                       for mypkg, remote_metadata in remotepkgs.items():
-                               mycat = remote_metadata.get("CATEGORY")
-                               if mycat is None:
-                                       #old-style or corrupt package
-                                       writemsg(_("!!! Invalid remote binary package: %s\n") % mypkg,
-                                               noiselevel=-1)
-                                       continue
-                               mycat = mycat.strip()
-                               try:
-                                       fullpkg = _pkg_str(mycat+"/"+mypkg[:-5])
-                               except InvalidData:
-                                       writemsg(_("!!! Invalid remote binary package: %s\n") % mypkg,
-                                               noiselevel=-1)
-                                       continue
-
-                               if fullpkg in metadata:
-                                       # When using this old protocol, comparison with the remote
-                                       # package isn't supported, so the local package is always
-                                       # preferred even if getbinpkgsonly is enabled.
-                                       continue
-
-                               if not self.dbapi._category_re.match(mycat):
-                                       writemsg(_("!!! Remote binary package has an " \
-                                               "unrecognized category: '%s'\n") % fullpkg,
-                                               noiselevel=-1)
-                                       writemsg(_("!!! '%s' has a category that is not" \
-                                               " listed in %setc/portage/categories\n") % \
-                                               (fullpkg, self.settings["PORTAGE_CONFIGROOT"]),
-                                               noiselevel=-1)
-                                       continue
-                               mykey = portage.cpv_getkey(fullpkg)
-                               try:
-                                       # invalid tbz2's can hurt things.
-                                       self.dbapi.cpv_inject(fullpkg)
-                                       for k, v in remote_metadata.items():
-                                               remote_metadata[k] = v.strip()
-                                       remote_metadata["BASE_URI"] = base_url
-
-                                       # Eliminate metadata values with names that digestCheck
-                                       # uses, since they are not valid when using the old
-                                       # protocol. Typically this is needed for SIZE metadata
-                                       # which corresponds to the size of the unpacked files
-                                       # rather than the binpkg file size, triggering digest
-                                       # verification failures as reported in bug #303211.
-                                       remote_metadata.pop('SIZE', None)
-                                       for k in portage.checksum.hashfunc_map:
-                                               remote_metadata.pop(k, None)
-
-                                       self._remotepkgs[fullpkg] = remote_metadata
-                               except SystemExit as e:
-                                       raise
-                               except:
-                                       writemsg(_("!!! Failed to inject remote binary package: %s\n") % fullpkg,
-                                               noiselevel=-1)
-                                       continue
+
                self.populated=1
 
        def inject(self, cpv, filename=None):
@@ -1465,7 +1399,8 @@ class binarytree(object):
 
                hash_filter = _hash_filter(
                        self.settings.get("PORTAGE_CHECKSUM_FILTER", ""))
-               digests = _apply_hash_filter(digests, hash_filter)
+               if not hash_filter.transparent:
+                       digests = _apply_hash_filter(digests, hash_filter)
                eout = EOutput()
                eout.quiet = self.settings.get("PORTAGE_QUIET") == "1"
                ok, st = _check_distfile(pkg_path, digests, eout, show_errors=0)
@@ -1481,9 +1416,7 @@ class binarytree(object):
                "Get a slot for a catpkg; assume it exists."
                myslot = ""
                try:
-                       myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0]
-               except SystemExit as e:
-                       raise
-               except Exception as e:
+                       myslot = self.dbapi._pkg_str(mycatpkg, None).slot
+               except KeyError:
                        pass
                return myslot