From f908cddb505b81533861196c4713378e63dac1fa Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Wed, 31 Aug 2011 17:29:58 -0700 Subject: [PATCH] Bind all manifest access through repoconfigs This enables controling the behaviour (creation and validation) per repo, and while mildly ugly, refactors in the right direction. --- bin/ebuild | 5 +++-- bin/repoman | 8 ++++++-- pym/_emerge/EbuildFetcher.py | 6 ++++-- pym/_emerge/search.py | 4 +++- pym/portage/dbapi/porttree.py | 8 ++++++-- pym/portage/package/ebuild/digestcheck.py | 4 +++- pym/portage/package/ebuild/digestgen.py | 3 ++- pym/portage/package/ebuild/doebuild.py | 4 +++- pym/portage/package/ebuild/fetch.py | 3 ++- pym/portage/repository/config.py | 7 ++++++- 10 files changed, 38 insertions(+), 14 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index db7e5e385..92105bbbd 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -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) diff --git a/bin/repoman b/bin/repoman index b40d2d18c..3462f939d 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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) diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index feb68d072..4389f8408 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -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): diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py index 096b38412..4a4183d09 100644 --- a/pym/_emerge/search.py +++ b/pym/_emerge/search.py @@ -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, diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index ac972c433..bfff02647 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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 = {} diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py index 1e34b1496..d18430160 100644 --- a/pym/portage/package/ebuild/digestcheck.py +++ b/pym/portage/package/ebuild/digestcheck.py @@ -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: diff --git a/pym/portage/package/ebuild/digestgen.py b/pym/portage/package/ebuild/digestgen.py index eb7210e18..605151263 100644 --- a/pym/portage/package/ebuild/digestgen.py +++ b/pym/portage/package/ebuild/digestgen.py @@ -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 diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index eef1d329f..51b2dbcfe 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -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 diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 5cbbf8708..11c4c0147 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -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 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 020297ce9..9e308a8dc 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -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] -- 2.26.2