Bind all manifest access through repoconfigs
authorBrian Harring <ferringb@gmail.com>
Thu, 1 Sep 2011 00:29:58 +0000 (17:29 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 12 Sep 2011 21:23:10 +0000 (14:23 -0700)
This enables controling the behaviour (creation and validation) per
repo, and while mildly ugly, refactors in the right direction.

bin/ebuild
bin/repoman
pym/_emerge/EbuildFetcher.py
pym/_emerge/search.py
pym/portage/dbapi/porttree.py
pym/portage/package/ebuild/digestcheck.py
pym/portage/package/ebuild/digestgen.py
pym/portage/package/ebuild/doebuild.py
pym/portage/package/ebuild/fetch.py
pym/portage/repository/config.py

index db7e5e3857c4663be3034cc77b8ef0d8a1211216..92105bbbd988ddd2a4ebae2b70a40cca58ab601d 100755 (executable)
@@ -200,8 +200,9 @@ def discard_digests(myebuild, mysettings, mydbapi):
                portage._doebuild_manifest_exempt_depend += 1
                pkgdir = os.path.dirname(myebuild)
                fetchlist_dict = portage.FetchlistDict(pkgdir, mysettings, mydbapi)
-               from portage.manifest import Manifest
-               mf = Manifest(pkgdir, mysettings["DISTDIR"],
+               mf = mysettings.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir)))
+               mf = mf.load_manifest(pkgdir, mysettings["DISTDIR"],
                        fetchlist_dict=fetchlist_dict, manifest1_compat=False)
                mf.create(requiredDistfiles=None,
                        assumeDistHashesSometimes=True, assumeDistHashesAlways=True)
index b40d2d18c63d0f993a5871df048ebd3b4c700fd3..3462f939de034b69adacca8085fc138f557c55c6 100755 (executable)
@@ -1104,7 +1104,9 @@ for x in scanlist:
                        portage._doebuild_manifest_exempt_depend += 1
                        try:
                                distdir = repoman_settings['DISTDIR']
-                               mf = portage.manifest.Manifest(checkdir, distdir,
+                               mf = repoman_settings.repositories.get_repo_for_location(
+                                       os.path.dirname(os.path.dirname(checkdir)))
+                               mf = mf.load_manifest(checkdir, distdir,
                                        fetchlist_dict=fetchlist_dict)
                                mf.create(requiredDistfiles=None,
                                        assumeDistHashesAlways=True)
@@ -1314,7 +1316,9 @@ for x in scanlist:
                                raise
                        continue
 
-       mf = Manifest(checkdir, repoman_settings["DISTDIR"])
+       mf = repoman_settings.repositories.get_repo_for_location(
+               os.path.dirname(os.path.dirname(checkdir)))
+       mf = mf.load_manifest(checkdir, repoman_settings["DISTDIR"])
        mydigests=mf.getTypeDigests("DIST")
 
        fetchlist_dict = portage.FetchlistDict(checkdir, repoman_settings, portdb)
index feb68d07255f9d269863bba394ec75bdd6d46517..4389f840827309a92df04e6687f0d632850dd534 100644 (file)
@@ -206,8 +206,10 @@ class EbuildFetcher(SpawnProcess):
        def _get_digests(self):
                if self._digests is not None:
                        return self._digests
-               self._digests = portage.Manifest(os.path.dirname(
-                       self._get_ebuild_path()), None).getTypeDigests("DIST")
+               pkgdir = os.path.dirname(self._get_ebuild_path())
+               mf = self.pkg.root_config.settings.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir)))
+               self._digests = mf.load_manifest(pkgdir, None).getTypeDigests("DIST")
                return self._digests
 
        def _get_uri_map(self):
index 096b384126e5cb3ac8036b541f6cddc02044447e..4a4183d099326186c23f13dc5d90cef068b366ce 100644 (file)
@@ -317,7 +317,9 @@ class search(object):
                                                        installed=False, metadata=metadata,
                                                        root_config=self.root_config, type_name="ebuild")
                                                pkgdir = os.path.dirname(myebuild)
-                                               mf = Manifest(
+                                               mf = self.settings.repositories.get_repo_for_location(
+                                                       os.path.dirname(os.path.dirname(pkgdir)))
+                                               mf = mf.load_manifest(
                                                        pkgdir, self.settings["DISTDIR"])
                                                try:
                                                        uri_map = _parse_uri_map(mycpv, metadata,
index ac972c43389c972d6af24d4b0b3ebc61a4e6dbbd..bfff0264762c5863fbb2e4195ee5417f5942b330 100644 (file)
@@ -597,7 +597,9 @@ class portdbapi(dbapi):
                if myebuild is None:
                        raise AssertionError(_("ebuild not found for '%s'") % mypkg)
                pkgdir = os.path.dirname(myebuild)
-               mf = Manifest(pkgdir, self.settings["DISTDIR"])
+               mf = self.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir))).load_manifest(
+                               pkgdir, self.settings["DISTDIR"])
                checksums = mf.getDigests()
                if not checksums:
                        if debug: 
@@ -665,7 +667,9 @@ class portdbapi(dbapi):
                if myebuild is None:
                        raise AssertionError(_("ebuild not found for '%s'") % mypkg)
                pkgdir = os.path.dirname(myebuild)
-               mf = Manifest(pkgdir, self.settings["DISTDIR"])
+               mf = self.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir)))
+               mf = mf.load_manifest(pkgdir, self.settings["DISTDIR"])
                mysums = mf.getDigests()
 
                failures = {}
index 1e34b14966421d29492200d5d637f61b04b856a2..d18430160176c2f60258487e78cea9219c5bc2d7 100644 (file)
@@ -41,7 +41,9 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None):
                else:
                        return 1
        if mf is None:
-               mf = Manifest(pkgdir, mysettings["DISTDIR"])
+               mf = mysettings.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir)))
+               mf = mf.load_manifest(pkgdir, mysettings["DISTDIR"])
        manifest_empty = True
        for d in mf.fhashdict.values():
                if d:
index eb7210e182ca4927d76ace58cce91ea01175ff65..605151263dae70faf2fbbf2c9a3f11d5991d784c 100644 (file)
@@ -53,7 +53,8 @@ def digestgen(myarchives=None, mysettings=None, myportdb=None):
                                return 0
                mytree = os.path.dirname(os.path.dirname(mysettings["O"]))
                manifest1_compat = False
-               mf = Manifest(mysettings["O"], mysettings["DISTDIR"],
+               mf = mysettings.repositories.get_repo_for_location(mytree)
+               mf = mf.load_manifest(mysettings["O"], mysettings["DISTDIR"],
                        fetchlist_dict=fetchlist_dict, manifest1_compat=manifest1_compat)
                # Don't require all hashes since that can trigger excessive
                # fetches when sufficient digests already exist.  To ease transition
index eef1d329fd1bd340762c14e58a90cf41d2fd6517..51b2dbcfe49230b100a8c0e44801caad84b35d8a 100644 (file)
@@ -508,7 +508,9 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                out.eerror(_("Manifest not found for '%s'") % (myebuild,))
                                _doebuild_broken_ebuilds.add(myebuild)
                                return 1
-                       mf = Manifest(pkgdir, mysettings["DISTDIR"])
+                       mf = mysettings.repositories.get_repo_for_location(
+                               os.path.dirname(os.path.dirname(pkgdir)))
+                       mf = mf.load_manifest(pkgdir, mysettings["DISTDIR"])
 
                else:
                        mf = _doebuild_manifest_cache
index 5cbbf8708d36a4d87cfaf05292fe06eeca1f9dac..11c4c0147f2503062951f09ed6144127eeb443a8 100644 (file)
@@ -356,7 +356,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
                allow_missing_digests = True
        pkgdir = mysettings.get("O")
        if digests is None and not (pkgdir is None or skip_manifest):
-               mydigests = Manifest(
+               mydigests = mysettings.repositories.get_repo_for_location(
+                       os.path.dirname(os.path.dirname(pkgdir))).load_manifest(
                        pkgdir, mysettings["DISTDIR"]).getTypeDigests("DIST")
        elif digests is None or skip_manifest:
                # no digests because fetch was not called for a specific package
index 020297ce95c3863ab87a02be560439ef4a270613..9e308a8dcd1da966d1d796d8a8d100cdaf48ad44 100644 (file)
@@ -21,6 +21,7 @@ from portage.util import normalize_path, writemsg, writemsg_level, shlex_split
 from portage.localization import _
 from portage import _unicode_encode
 from portage import _encodings
+from portage import manifest
 
 _repo_name_sub_re = re.compile(r'[^\w-]')
 
@@ -41,7 +42,7 @@ class RepoConfig(object):
        """Stores config of one repository"""
 
        __slots__ = ['aliases', 'eclass_overrides', 'eclass_locations', 'location', 'user_location', 'masters', 'main_repo',
-               'missing_repo_name', 'name', 'priority', 'sync', 'format']
+               'missing_repo_name', 'name', 'priority', 'sync', 'format', 'load_manifest']
 
        def __init__(self, name, repo_opts):
                """Build a RepoConfig with options in repo_opts
@@ -110,6 +111,7 @@ class RepoConfig(object):
                        missing = False
                self.name = name
                self.missing_repo_name = missing
+               self.load_manifest = manifest.Manifest
 
        def update(self, new_repo):
                """Update repository with options in another RepoConfig"""
@@ -496,6 +498,9 @@ class RepoConfigLoader(object):
                        return None
                return self.treemap[repo_name]
 
+       def get_repo_for_location(self, location):
+               return self.prepos[self.get_name_for_location(location)]
+
        def __getitem__(self, repo_name):
                return self.prepos[repo_name]