Add support to repoman for using layout.conf to control which repositories
authorZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 06:59:20 +0000 (06:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 06:59:20 +0000 (06:59 -0000)
are used to satisfy dependencies. Thanks to Alistair Bush <ali_bush@g.o>
for the initial patch. See the "QA Overlay Layout support" thread on the
gentoo-dev mailing list for more information:

http://archives.gentoo.org/gentoo-dev/msg_33c61550b4ed2b7b25dd5a4110e1ec81.xml
(trunk r13295)

svn path=/main/branches/2.1.6/; revision=13466

bin/repoman
pym/_emerge/__init__.py
pym/portage/dbapi/porttree.py

index 24cda2396b4a3f684b00410c791e13beab0f9655..adfe987ce26617ca186f6a76875ebe156cdd0d46 100755 (executable)
@@ -479,31 +479,35 @@ if options.mode == 'commit' and not options.pretend and not vcs:
        logging.info("Not in a version controlled repository; enabling pretend mode.")
        options.pretend = True
 
-os.environ["PORTDIR"] = portdir
-if portdir_overlay != portdir:
-       os.environ["PORTDIR_OVERLAY"] = portdir_overlay
-else:
-       os.environ["PORTDIR_OVERLAY"] = ""
+# Ensure that PORTDIR_OVERLAY contains the repository corresponding to $PWD.
+repoman_settings = portage.config(local_config=False)
+repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % \
+       (repoman_settings.get('PORTDIR_OVERLAY', ''), portdir_overlay)
+repoman_settings.backup_changes('PORTDIR_OVERLAY')
+
+root = '/'
+trees = {
+       root : {'porttree' : portage.portagetree(root, settings=repoman_settings)}
+}
+portdb = trees[root]['porttree'].dbapi
+
+# Constrain dependency resolution to the master(s)
+# that are specified in layout.conf.
+portdir_overlay = os.path.realpath(portdir_overlay)
+repo_info = portdb._repo_info[portdir_overlay]
+portdb.porttrees = list(repo_info.eclass_db.porttrees)
+portdir = portdb.porttrees[0]
 
 logging.info('Setting paths:')
-logging.info('PORTDIR = "' + os.environ['PORTDIR'] + '"')
-logging.info('PORTDIR_OVERLAY = "' + os.environ['PORTDIR_OVERLAY']+'"')
+logging.info('PORTDIR = "' + portdir + '"')
+logging.info('PORTDIR_OVERLAY = "%s"' % ' '.join(portdb.porttrees[1:]))
 
-# Now that PORTDIR_OVERLAY is properly overridden, create the portdb.
-repoman_settings = portage.config(local_config=False,
-       config_incrementals=portage.const.INCREMENTALS)
-trees = portage.create_trees()
-trees["/"]["porttree"].settings = repoman_settings
-portdb = trees["/"]["porttree"].dbapi
 portdb.mysettings = repoman_settings
-setconfig = load_default_config(repoman_settings, trees["/"])
-root_config = RootConfig(repoman_settings, trees["/"], setconfig)
+root_config = RootConfig(repoman_settings, trees[root], None)
 # We really only need to cache the metadata that's necessary for visibility
 # filtering. Anything else can be discarded to reduce memory consumption.
 portdb._aux_cache_keys.clear()
 portdb._aux_cache_keys.update(["EAPI", "KEYWORDS", "SLOT"])
-# dep_zapdeps looks at the vardbapi, but it shouldn't for repoman.
-del trees["/"]["vartree"]
 
 myreporoot = os.path.basename(portdir_overlay)
 myreporoot += mydir[len(portdir_overlay):]
@@ -543,24 +547,27 @@ except (IOError, OSError, ParseError), e:
        logging.exception("Couldn't read USE flags from use.desc")
        sys.exit(1)
 
-# retrieve a list of current licenses in portage
+# get lists of valid keywords and licenses
+kwlist = set(portage.grabfile(os.path.join(portdir, "profiles", "arch.list")))
 liclist = set(portage.listdir(os.path.join(portdir, "licenses")))
+
+if portdir_overlay != portdir:
+       for porttree in portdb.porttrees[1:]:
+               try:
+                       liclist.update(os.listdir(os.path.join(porttree, "licenses")))
+               except OSError:
+                       pass
+               kwlist.update(portage.grabfile(os.path.join(porttree,
+                       "profiles", "arch.list")))
+
 if not liclist:
        logging.fatal("Couldn't find licenses?")
        sys.exit(1)
-if portdir_overlay != portdir:
-       liclist.update(portage.listdir(os.path.join(portdir_overlay, "licenses")))
 
-# retrieve list of offical keywords
-kwlist = set(portage.grabfile(os.path.join(portdir, "profiles", "arch.list")))
 if not kwlist:
        logging.fatal("Couldn't read KEYWORDS from arch.list")
        sys.exit(1)
 
-if portdir_overlay != portdir:
-       kwlist.update(portage.grabfile(
-               os.path.join(portdir_overlay, "profiles", "arch.list")))
-
 scanlist=[]
 if repolevel==2:
        #we are inside a category directory
index e8f75c2a9db005324c8de2db09eb54e444014590..63b5cb9d958458bfdfd3762f485f143e57340ed4 100644 (file)
@@ -751,7 +751,10 @@ class RootConfig(object):
                self.iuse_implicit = tuple(sorted(settings._get_implicit_iuse()))
                self.root = self.settings["ROOT"]
                self.setconfig = setconfig
-               self.sets = self.setconfig.getSets()
+               if setconfig is None:
+                       self.sets = {}
+               else:
+                       self.sets = self.setconfig.getSets()
                self.visible_pkgs = PackageVirtualDbapi(self.settings)
 
 def create_world_atom(pkg, args_set, root_config):
index 29f1fe996d88ed79813cb296ba62d9610e7852c0..3cd8b2acbd56e7b865bfe58611d90336589081f2 100644 (file)
@@ -190,8 +190,14 @@ class portdbapi(dbapi):
                                                level=logging.ERROR, noiselevel=-1)
                                else:
                                        porttrees.append(master_path)
+
                        if not porttrees:
-                               porttrees.append(porttree_root)
+                               # Make PORTDIR the default master, but only if this
+                               # repo doesn't provide profiles.desc itself.
+                               profiles_desc = os.path.join(path, 'profiles', 'profiles.desc')
+                               if not os.path.exists(profiles_desc):
+                                       porttrees.append(porttree_root)
+
                        porttrees.append(path)
 
                        eclass_db = None
@@ -227,11 +233,15 @@ class portdbapi(dbapi):
                                        db_ro=db_ro)
                else:
                        for x in self.porttrees:
+                               if x in self.auxdb:
+                                       continue
                                # location, label, auxdbkeys
                                self.auxdb[x] = self.auxdbmodule(
                                        self.depcachedir, x, filtered_auxdbkeys, gid=portage_gid)
                if "metadata-transfer" not in self.mysettings.features:
                        for x in self.porttrees:
+                               if x in self._pregen_auxdb:
+                                       continue
                                if os.path.isdir(os.path.join(x, "metadata", "cache")):
                                        self._pregen_auxdb[x] = self.metadbmodule(
                                                x, "metadata/cache", filtered_auxdbkeys, readonly=True)