Use EROOT instead of ROOT for keys everywhere.
authorZac Medico <zmedico@gentoo.org>
Tue, 25 Oct 2011 08:59:39 +0000 (01:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 25 Oct 2011 08:59:39 +0000 (01:59 -0700)
It makes more sense to use EROOT instead of ROOT for keys in mappings
like portage.db, since it allows for multiple prefixes to exist
simultaneously within the same map without having a key collision.
This affects all portageq commands which take a <root> parameter, since
that parameter now corresponds to EROOT instead of ROOT. None of this
makes any difference for non-prefix users, since EROOT and ROOT are
identical when EPREFIX is empty.

26 files changed:
bin/ebuild
bin/emaint
bin/glsa-check
bin/portageq
bin/quickpkg
bin/regenworld
pym/_emerge/BlockerDB.py
pym/_emerge/Package.py
pym/_emerge/RootConfig.py
pym/_emerge/Scheduler.py
pym/_emerge/actions.py
pym/_emerge/depgraph.py
pym/_emerge/main.py
pym/_emerge/unmerge.py
pym/portage/__init__.py
pym/portage/_global_updates.py
pym/portage/_legacy_globals.py
pym/portage/dbapi/vartree.py
pym/portage/news.py
pym/portage/package/ebuild/doebuild.py
pym/portage/tests/ebuild/test_config.py
pym/portage/tests/ebuild/test_doebuild_spawn.py
pym/portage/tests/emerge/test_simple.py
pym/portage/tests/repoman/test_simple.py
pym/portage/tests/resolver/ResolverPlayground.py
pym/portage/util/env_update.py

index 771ccb51c3e558479fb48477c4d2e0cae5b2249a..82f0ff99002c3f49b1ddeb7e16241bb8f80d3238 100755 (executable)
@@ -260,14 +260,14 @@ if "merge" in pargs and "noauto" in tmpsettings.features:
 
 try:
        metadata = dict(zip(Package.metadata_keys,
-               portage.db[portage.settings["ROOT"]][mytree].dbapi.aux_get(
+               portage.db[portage.settings['EROOT']][mytree].dbapi.aux_get(
                cpv, Package.metadata_keys, myrepo=myrepo)))
 except KeyError:
        # aux_get failure, message should have been shown on stderr.
        sys.exit(1)
 
 root_config = RootConfig(portage.settings,
-       portage.db[portage.settings["ROOT"]], None)
+       portage.db[portage.settings['EROOT']], None)
 
 pkg = Package(built=(pkg_type != "ebuild"), cpv=cpv,
        installed=(pkg_type=="installed"),
index fdd01ed559e18f51e621838146e2cbe360c82994..ea26e5548ee83cf768e5acbc4b40050f545309ca 100755 (executable)
@@ -40,15 +40,15 @@ class WorldHandler(object):
                self.okay = []
                from portage._sets import load_default_config
                setconfig = load_default_config(portage.settings,
-                       portage.db[portage.settings["ROOT"]])
+                       portage.db[portage.settings['EROOT']])
                self._sets = setconfig.getSets()
 
        def _check_world(self, onProgress):
                categories = set(portage.settings.categories)
-               myroot = portage.settings["ROOT"]
-               self.world_file = os.path.join(portage.settings["EROOT"], portage.const.WORLD_FILE)
+               eroot = portage.settings['EROOT']
+               self.world_file = os.path.join(eroot, portage.const.WORLD_FILE)
                self.found = os.access(self.world_file, os.R_OK)
-               vardb = portage.db[myroot]["vartree"].dbapi
+               vardb = portage.db[eroot]["vartree"].dbapi
 
                from portage._sets import SETPREFIX
                sets = self._sets
@@ -120,8 +120,8 @@ class BinhostHandler(object):
        name = staticmethod(name)
 
        def __init__(self):
-               myroot = portage.settings["ROOT"]
-               self._bintree = portage.db[myroot]["bintree"]
+               eroot = portage.settings['EROOT']
+               self._bintree = portage.db[eroot]["bintree"]
                self._bintree.populate()
                self._pkgindex_file = self._bintree._pkgindex_file
                self._pkgindex = self._bintree._load_pkgindex()
@@ -403,8 +403,8 @@ class MoveInstalled(MoveHandler):
                return "moveinst"
        name = staticmethod(name)
        def __init__(self):
-               myroot = portage.settings["ROOT"]
-               MoveHandler.__init__(self, portage.db[myroot]["vartree"], portage.db[myroot]["porttree"])
+               eroot = portage.settings['EROOT']
+               MoveHandler.__init__(self, portage.db[eroot]["vartree"], portage.db[eroot]["porttree"])
 
 class MoveBinary(MoveHandler):
 
@@ -414,8 +414,8 @@ class MoveBinary(MoveHandler):
                return "movebin"
        name = staticmethod(name)
        def __init__(self):
-               myroot = portage.settings["ROOT"]
-               MoveHandler.__init__(self, portage.db[myroot]["bintree"], portage.db[myroot]["porttree"])
+               eroot = portage.settings['EROOT']
+               MoveHandler.__init__(self, portage.db[eroot]["bintree"], portage.db[eroot]['porttree'])
 
 class VdbKeyHandler(object):
        def name():
index 2f2d55523d9fabe6954f788dbd25ae2527d3e502..a840c3206452d6eea8b57e59ae0b4b9340005b08 100755 (executable)
@@ -103,8 +103,9 @@ elif mode == "list" and not params:
 # delay this for speed increase
 from portage.glsa import *
 
-vardb = portage.db[portage.settings["ROOT"]]["vartree"].dbapi
-portdb = portage.db["/"]["porttree"].dbapi
+eroot = portage.settings['EROOT']
+vardb = portage.db[eroot]["vartree"].dbapi
+portdb = portage.db[eroot]["porttree"].dbapi
 
 # build glsa lists
 completelist = get_glsa_list(portage.settings)
index eaeca60d941d5012ea0ae47fe9704b68c8e17595..02f19040ce84e67a95b04e0543200af8d13d5a4e 100755 (executable)
@@ -185,7 +185,7 @@ def metadata(argv):
                print("ERROR: insufficient parameters!", file=sys.stderr)
                sys.exit(2)
 
-       root, pkgtype, pkgspec = argv[0:3]
+       eroot, pkgtype, pkgspec = argv[0:3]
        metakeys = argv[3:]
        type_map = {
                "ebuild":"porttree",
@@ -195,10 +195,8 @@ def metadata(argv):
                print("Unrecognized package type: '%s'" % pkgtype, file=sys.stderr)
                sys.exit(1)
        trees = portage.db
-       if os.path.realpath(root) == os.path.realpath(portage.settings["ROOT"]):
-               root = portage.settings["ROOT"] # contains the normalized $ROOT
        try:
-                       values = trees[root][type_map[pkgtype]].dbapi.aux_get(
+                       values = trees[eroot][type_map[pkgtype]].dbapi.aux_get(
                                pkgspec, metakeys)
                        writemsg_stdout(''.join('%s\n' % x for x in values), noiselevel=-1)
        except KeyError:
@@ -250,9 +248,9 @@ def owners(argv):
                return 2
 
        from portage import catsplit, dblink
-       settings = portage.settings
-       root = settings["ROOT"]
-       vardb = portage.db[root]["vartree"].dbapi
+       eroot = argv[0]
+       vardb = portage.db[eroot]["vartree"].dbapi
+       root = portage.settings['ROOT']
 
        cwd = None
        try:
@@ -451,7 +449,8 @@ def best_visible(argv):
                        noiselevel=-1)
                return 2
 
-       db = portage.db[portage.settings["ROOT"]][type_map[pkgtype]].dbapi
+       eroot = argv[0]
+       db = portage.db[eroot][type_map[pkgtype]].dbapi
 
        try:
                atom = portage.dep_expand(atom, mydb=db, settings=portage.settings)
@@ -461,7 +460,7 @@ def best_visible(argv):
                return 2
 
        root_config = RootConfig(portage.settings,
-               portage.db[portage.settings["ROOT"]], None)
+               portage.db[eroot], None)
 
        if hasattr(db, "xmatch"):
                cpv_list = db.xmatch("match-all-cpv-only", atom)
@@ -839,7 +838,13 @@ def main():
                        sys.stderr.write("Run portageq with --help for info\n")
                        sys.stderr.flush()
                        sys.exit(os.EX_USAGE)
-               os.environ["ROOT"] = sys.argv[2]
+               eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX")
+               eroot = portage.util.normalize_path(sys.argv[2])
+               if eprefix:
+                       root = eroot[:1-len(eprefix)]
+               else:
+                       root = eroot
+               os.environ["ROOT"] = root
 
        args = sys.argv[2:]
        if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
@@ -848,7 +853,7 @@ def main():
 
        try:
                if uses_root:
-                       args[0] = portage.settings["ROOT"]
+                       args[0] = portage.settings['EROOT']
                retval = function(args)
                if retval:
                        sys.exit(retval)
index ced2468886f8b1bddfb5a602bf29cb204bd30854..d908c03469e38528b6a1624709b1b9316043732e 100755 (executable)
@@ -31,8 +31,9 @@ from portage._sets import load_default_config, SETPREFIX
 
 def quickpkg_atom(options, infos, arg, eout):
        settings = portage.settings
-       root = portage.settings["ROOT"]
-       trees = portage.db[root]
+       root = portage.settings['ROOT']
+       eroot = portage.settings['EROOT']
+       trees = portage.db[eroot]
        vartree = trees["vartree"]
        vardb = vartree.dbapi
        bintree = trees["bintree"]
@@ -65,10 +66,7 @@ def quickpkg_atom(options, infos, arg, eout):
        for cpv in matches:
                excluded_config_files = []
                bintree.prevent_collision(cpv)
-               cat, pkg = portage.catsplit(cpv)
-               dblnk = dblink(cat, pkg, root,
-                       vartree.settings, treetype="vartree",
-                       vartree=vartree)
+               dblnk = vardb._dblink(cpv)
                have_lock = False
                try:
                        dblnk.lockdb()
@@ -101,7 +99,7 @@ def quickpkg_atom(options, infos, arg, eout):
                        contents = dblnk.getcontents()
                        protect = None
                        if not include_config:
-                               confprot = ConfigProtect(root,
+                               confprot = ConfigProtect(eroot,
                                        shlex_split(settings.get("CONFIG_PROTECT", "")),
                                        shlex_split(settings.get("CONFIG_PROTECT_MASK", "")))
                                def protect(filename):
@@ -161,8 +159,8 @@ def quickpkg_atom(options, infos, arg, eout):
                infos["missing"].append(arg)
 
 def quickpkg_set(options, infos, arg, eout):
-       root = portage.settings["ROOT"]
-       trees = portage.db[root]
+       eroot = portage.settings['EROOT']
+       trees = portage.db[eroot]
        vartree = trees["vartree"]
 
        settings = vartree.settings
@@ -189,8 +187,8 @@ def quickpkg_set(options, infos, arg, eout):
 
 
 def quickpkg_extended_atom(options, infos, atom, eout):
-       root = portage.settings["ROOT"]
-       trees = portage.db[root]
+       eroot = portage.settings['EROOT']
+       trees = portage.db[eroot]
        vartree = trees["vartree"]
        vardb = vartree.dbapi
 
@@ -222,8 +220,8 @@ def quickpkg_extended_atom(options, infos, atom, eout):
 
 
 def quickpkg_main(options, args, eout):
-       root = portage.settings["ROOT"]
-       trees = portage.db[root]
+       eroot = portage.settings['EROOT']
+       trees = portage.db[eroot]
        bintree = trees["bintree"]
 
        try:
index 6b5af4ca547e7f885ec1fcb34ee2b8fefb5b0e89..3199fdf907f83c774b3e1114e089441a5daae317 100755 (executable)
@@ -47,7 +47,6 @@ def isunwanted(pkgline):
                __uniqlist__.append(pkgline)
                return True
 
-root = portage.settings['ROOT']
 eroot = portage.settings['EROOT']
 world_file = os.path.join(eroot, portage.WORLD_FILE)
 
@@ -78,7 +77,7 @@ for mykey in syslist:
        # drop the asterix
        mykey = mykey[1:]
        #print("candidate:",mykey)
-       mylist = portage.db[root]["vartree"].dbapi.match(mykey)
+       mylist = portage.db[eroot]["vartree"].dbapi.match(mykey)
        if mylist:
                mykey=portage.cpv_getkey(mylist[0])
                if mykey not in realsyslist:
@@ -87,7 +86,7 @@ for mykey in syslist:
 for mykey in biglist:
        #print("checking:",mykey)
        try:
-               mylist = portage.db[root]["vartree"].dbapi.match(mykey)
+               mylist = portage.db[eroot]["vartree"].dbapi.match(mykey)
        except (portage.exception.InvalidAtom, KeyError):
                if "--debug" in sys.argv:
                        print("* ignoring broken log entry for %s (likely injected)" % mykey)
index 0033665e3c8ce001a9dc52228b411bc4a57da391..459affdb0161b0ebbda036621fba8063c9bdfa67 100644 (file)
@@ -25,7 +25,7 @@ class BlockerDB(object):
                self._dep_check_trees = None
                self._fake_vartree = fake_vartree
                self._dep_check_trees = {
-                       self._vartree.settings["ROOT"] : {
+                       self._vartree.settings["EROOT"] : {
                                "porttree"    :  fake_vartree,
                                "vartree"     :  fake_vartree,
                }}
@@ -36,7 +36,7 @@ class BlockerDB(object):
                new_pkg is planned to be installed. This ignores build-time
                blockers, since new_pkg is assumed to be built already.
                """
-               blocker_cache = BlockerCache(self._vartree.settings["ROOT"],
+               blocker_cache = BlockerCache(None,
                        self._vartree.dbapi)
                dep_keys = ["RDEPEND", "PDEPEND"]
                settings = self._vartree.settings
index 9f1be122d1bc9a49b68b7dd50e8cac1f5229f583..f87d5931289df0eff67c1f47af5816c620452cbf 100644 (file)
@@ -361,15 +361,15 @@ class Package(Task):
                        % (portage.output.colorize(cpv_color, self.cpv + _repo_separator + self.repo) , self.type_name)
 
                if self.type_name == "installed":
-                       if self.root != "/":
-                               s += " in '%s'" % self.root
+                       if self.root_config.settings['ROOT'] != "/":
+                               s += " in '%s'" % self.root_config.settings['ROOT']
                        if self.operation == "uninstall":
                                s += " scheduled for uninstall"
                else:
                        if self.operation == "merge":
                                s += " scheduled for merge"
-                               if self.root != "/":
-                                       s += " to '%s'" % self.root
+                               if self.root_config.settings['ROOT'] != "/":
+                                       s += " to '%s'" % self.root_config.settings['ROOT']
                s += ")"
                return s
 
index d84f108891ddb5f85d2e9038c59d8e6f5fa2f5ff..bb0d7682ad7c23ad7c3a02c48ffd6d66efbe4f4b 100644 (file)
@@ -19,7 +19,7 @@ class RootConfig(object):
        def __init__(self, settings, trees, setconfig):
                self.trees = trees
                self.settings = settings
-               self.root = self.settings["ROOT"]
+               self.root = self.settings['EROOT']
                self.setconfig = setconfig
                if setconfig is None:
                        self.sets = {}
index 3221b86204bc2778690b2ec57d9fd61b959d57b9..bc85a0d261831079f043cae2f19a62873a73a784 100644 (file)
@@ -151,7 +151,7 @@ class Scheduler(PollScheduler):
                                DeprecationWarning, stacklevel=2)
 
                self.settings = settings
-               self.target_root = settings["ROOT"]
+               self.target_root = settings["EROOT"]
                self.trees = trees
                self.myopts = myopts
                self._spinner = spinner
@@ -207,10 +207,7 @@ class Scheduler(PollScheduler):
                if max_jobs is None:
                        max_jobs = 1
                self._set_max_jobs(max_jobs)
-
-               # The root where the currently running
-               # portage instance is installed.
-               self._running_root = trees["/"]["root_config"]
+               self._running_root = trees[trees._running_eroot]["root_config"]
                self.edebug = 0
                if settings.get("PORTAGE_DEBUG", "") == "1":
                        self.edebug = 1
@@ -970,7 +967,7 @@ class Scheduler(PollScheduler):
 
                                portage.package.ebuild.doebuild.doebuild_environment(ebuild_path,
                                        "pretend", settings=settings,
-                                       db=self.trees[settings["ROOT"]][tree].dbapi)
+                                       db=self.trees[settings['EROOT']][tree].dbapi)
                                prepare_build_dirs(root_config.root, settings, cleanup=0)
 
                                vardb = root_config.trees['vartree'].dbapi
@@ -1563,7 +1560,7 @@ class Scheduler(PollScheduler):
                return temp_settings
 
        def _deallocate_config(self, settings):
-               self._config_pool[settings["ROOT"]].append(settings)
+               self._config_pool[settings['EROOT']].append(settings)
 
        def _main_loop(self):
 
index edc0afdb1ce7a627520f9f262ea413840bba0268..5485d755cb19c972785cd6285febb9f2915d5028 100644 (file)
@@ -292,7 +292,7 @@ def action_build(settings, trees, mtimedb,
                        success, mydepgraph, favorites = backtrack_depgraph(
                                settings, trees, myopts, myparams, myaction, myfiles, spinner)
                except portage.exception.PackageSetNotFound as e:
-                       root_config = trees[settings["ROOT"]]["root_config"]
+                       root_config = trees[settings['EROOT']]['root_config']
                        display_missing_pkg_set(root_config, e.value)
                        return 1
 
@@ -330,7 +330,7 @@ def action_build(settings, trees, mtimedb,
                                        mergecount += 1
 
                        if mergecount==0:
-                               sets = trees[settings["ROOT"]]["root_config"].sets
+                               sets = trees[settings['EROOT']]['root_config'].sets
                                world_candidates = None
                                if "selective" in myparams and \
                                        not oneshot and favorites:
@@ -440,7 +440,7 @@ def action_build(settings, trees, mtimedb,
                if retval == os.EX_OK and not (buildpkgonly or fetchonly or pretend):
                        if "yes" == settings.get("AUTOCLEAN"):
                                portage.writemsg_stdout(">>> Auto-cleaning packages...\n")
-                               unmerge(trees[settings["ROOT"]]["root_config"],
+                               unmerge(trees[settings['EROOT']]['root_config'],
                                        myopts, "clean", [],
                                        ldpath_mtimes, autoclean=1)
                        else:
@@ -463,7 +463,7 @@ def action_config(settings, trees, myopts, myfiles):
                sys.exit(1)
        print()
        try:
-               pkgs = trees[settings["ROOT"]]["vartree"].dbapi.match(myfiles[0])
+               pkgs = trees[settings['EROOT']]['vartree'].dbapi.match(myfiles[0])
        except portage.exception.AmbiguousPackageName as e:
                # Multiple matches thrown from cpv_expand
                pkgs = e.args[0]
@@ -501,17 +501,16 @@ def action_config(settings, trees, myopts, myfiles):
        else:
                print("Configuring pkg...")
        print()
-       ebuildpath = trees[settings["ROOT"]]["vartree"].dbapi.findname(pkg)
+       ebuildpath = trees[settings['EROOT']]['vartree'].dbapi.findname(pkg)
        mysettings = portage.config(clone=settings)
-       vardb = trees[mysettings["ROOT"]]["vartree"].dbapi
+       vardb = trees[mysettings['EROOT']]['vartree'].dbapi
        debug = mysettings.get("PORTAGE_DEBUG") == "1"
-       retval = portage.doebuild(ebuildpath, "config", mysettings["ROOT"],
-               mysettings,
+       retval = portage.doebuild(ebuildpath, "config", settings=mysettings,
                debug=(settings.get("PORTAGE_DEBUG", "") == 1), cleanup=True,
-               mydbapi=trees[settings["ROOT"]]["vartree"].dbapi, tree="vartree")
+               mydbapi = trees[settings['EROOT']]['vartree'].dbapi, tree="vartree")
        if retval == os.EX_OK:
-               portage.doebuild(ebuildpath, "clean", mysettings["ROOT"],
-                       mysettings, debug=debug, mydbapi=vardb, tree="vartree")
+               portage.doebuild(ebuildpath, "clean", settings=mysettings,
+                       debug=debug, mydbapi=vardb, tree="vartree")
        print()
 
 def action_depclean(settings, trees, ldpath_mtimes,
@@ -551,7 +550,7 @@ def action_depclean(settings, trees, ldpath_mtimes,
                for x in msg:
                        portage.writemsg_stdout(colorize("WARN", " * ") + x)
 
-       root_config = trees[settings['ROOT']]['root_config']
+       root_config = trees[settings['EROOT']]['root_config']
        vardb = root_config.trees['vartree'].dbapi
 
        args_set = InternalPackageSet(allow_repo=True)
@@ -610,8 +609,9 @@ def calc_depclean(settings, trees, ldpath_mtimes,
 
        debug = '--debug' in myopts
        xterm_titles = "notitles" not in settings.features
-       myroot = settings["ROOT"]
-       root_config = trees[myroot]["root_config"]
+       root_len = len(settings["ROOT"])
+       eroot = settings['EROOT']
+       root_config = trees[eroot]["root_config"]
        psets = root_config.setconfig.psets
        deselect = myopts.get('--deselect') != 'n'
        required_sets = {}
@@ -650,8 +650,8 @@ def calc_depclean(settings, trees, ldpath_mtimes,
        resolver_params = create_depgraph_params(myopts, "remove")
        resolver = depgraph(settings, trees, myopts, resolver_params, spinner)
        resolver._load_vdb()
-       vardb = resolver._frozen_config.trees[myroot]["vartree"].dbapi
-       real_vardb = trees[myroot]["vartree"].dbapi
+       vardb = resolver._frozen_config.trees[eroot]["vartree"].dbapi
+       real_vardb = trees[eroot]["vartree"].dbapi
 
        if action == "depclean":
 
@@ -753,7 +753,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                del e
                                required_sets['__excluded__'].add("=" + pkg.cpv)
 
-       success = resolver._complete_graph(required_sets={myroot:required_sets})
+       success = resolver._complete_graph(required_sets={eroot:required_sets})
        writemsg_level("\b\b... done!\n")
 
        resolver.display_problems()
@@ -939,7 +939,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                        consumers = {}
 
                        for lib in pkg_dblink.getcontents():
-                               lib = lib[len(myroot):]
+                               lib = lib[root_len:]
                                lib_key = linkmap._obj_key(lib)
                                lib_consumers = consumer_cache.get(lib_key)
                                if lib_consumers is None:
@@ -1097,7 +1097,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
 
                        writemsg_level("\nCalculating dependencies  ")
                        success = resolver._complete_graph(
-                               required_sets={myroot:required_sets})
+                               required_sets={eroot:required_sets})
                        writemsg_level("\b\b... done!\n")
                        resolver.display_problems()
                        if not success:
@@ -1155,7 +1155,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                                % (priority,), noiselevel=-1, level=logging.DEBUG)
 
                                try:
-                                       atoms = resolver._select_atoms(myroot, depstr,
+                                       atoms = resolver._select_atoms(eroot, depstr,
                                                myuse=node.use.enabled, parent=node,
                                                priority=priority)[node]
                                except portage.exception.InvalidDependString:
@@ -1228,7 +1228,7 @@ def calc_depclean(settings, trees, ldpath_mtimes,
 
 def action_deselect(settings, trees, opts, atoms):
        enter_invalid = '--ask-enter-invalid' in opts
-       root_config = trees[settings['ROOT']]['root_config']
+       root_config = trees[settings['EROOT']]['root_config']
        world_set = root_config.sets['selected']
        if not hasattr(world_set, 'update'):
                writemsg_level("World @selected set does not appear to be mutable.\n",
@@ -1327,11 +1327,12 @@ def action_info(settings, trees, myopts, myfiles):
 
        output_buffer = []
        append = output_buffer.append
-       root_config = trees[settings['ROOT']]['root_config']
+       root_config = trees[settings['EROOT']]['root_config']
+       running_eroot = trees._running_eroot
 
-       append(getportageversion(settings["PORTDIR"], settings["ROOT"],
+       append(getportageversion(settings["PORTDIR"], None,
                settings.profile_path, settings["CHOST"],
-               trees[settings["ROOT"]]["vartree"].dbapi))
+               trees[settings['EROOT']]["vartree"].dbapi))
 
        header_width = 65
        header_title = "System Settings"
@@ -1371,7 +1372,7 @@ def action_info(settings, trees, myopts, myfiles):
                   "sys-devel/binutils", "sys-devel/libtool",  "dev-lang/python"]
        myvars += portage.util.grabfile(settings["PORTDIR"]+"/profiles/info_pkgs")
        atoms = []
-       vardb = trees["/"]["vartree"].dbapi
+       vardb = trees[running_eroot]['vartree'].dbapi
        for x in myvars:
                try:
                        x = Atom(x)
@@ -1384,7 +1385,7 @@ def action_info(settings, trees, myopts, myfiles):
 
        myvars = sorted(set(atoms))
 
-       portdb = trees["/"]["porttree"].dbapi
+       portdb = trees[running_eroot]['porttree'].dbapi
        main_repo = portdb.getRepositoryName(portdb.porttree_root)
        cp_map = {}
        cp_max_len = 0
@@ -1427,7 +1428,7 @@ def action_info(settings, trees, myopts, myfiles):
                append("%s %s" % \
                        ((cp + ":").ljust(cp_max_len + 1), versions))
 
-       libtool_vers = ",".join(trees["/"]["vartree"].dbapi.match("sys-devel/libtool"))
+       libtool_vers = ",".join(vardb.match("sys-devel/libtool"))
 
        repos = portdb.settings.repositories
        if "--verbose" in myopts:
@@ -1506,9 +1507,10 @@ def action_info(settings, trees, myopts, myfiles):
        # See if we can find any packages installed matching the strings
        # passed on the command line
        mypkgs = []
-       vardb = trees[settings["ROOT"]]["vartree"].dbapi
-       portdb = trees[settings["ROOT"]]["porttree"].dbapi
-       bindb = trees[settings["ROOT"]]["bintree"].dbapi
+       eroot = settings['EROOT']
+       vardb = trees[eroot]["vartree"].dbapi
+       portdb = trees[eroot]['porttree'].dbapi
+       bindb = trees[eroot]["bintree"].dbapi
        for x in myfiles:
                match_found = False
                installed_match = vardb.match(x)
@@ -1613,19 +1615,19 @@ def action_info(settings, trees, myopts, myfiles):
                                continue
 
                        if pkg_type == "installed":
-                               portage.doebuild(ebuildpath, "info", pkgsettings["ROOT"],
-                                       pkgsettings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
-                                       mydbapi=trees[settings["ROOT"]]["vartree"].dbapi,
+                               portage.doebuild(ebuildpath, "info", settings=pkgsettings,
+                                       debug=(settings.get("PORTAGE_DEBUG", "") == 1),
+                                       mydbapi=trees[settings['EROOT']]["vartree"].dbapi,
                                        tree="vartree")
                        elif pkg_type == "ebuild":
-                               portage.doebuild(ebuildpath, "info", pkgsettings["ROOT"],
-                                       pkgsettings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
-                                       mydbapi=trees[settings["ROOT"]]["porttree"].dbapi,
+                               portage.doebuild(ebuildpath, "info", settings=pkgsettings,
+                                       debug=(settings.get("PORTAGE_DEBUG", "") == 1),
+                                       mydbapi=trees[settings['EROOT']]['porttree'].dbapi,
                                        tree="porttree")
                        elif pkg_type == "binary":
-                               portage.doebuild(ebuildpath, "info", pkgsettings["ROOT"],
-                                       pkgsettings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
-                                       mydbapi=trees[settings["ROOT"]]["bintree"].dbapi,
+                               portage.doebuild(ebuildpath, "info", settings=pkgsettings,
+                                       debug=(settings.get("PORTAGE_DEBUG", "") == 1),
+                                       mydbapi=trees[settings['EROOT']]["bintree"].dbapi,
                                        tree="bintree")
                                shutil.rmtree(tmpdir)
 
@@ -1905,7 +1907,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
        enter_invalid = '--ask-enter-invalid' in myopts
        xterm_titles = "notitles" not in settings.features
        emergelog(xterm_titles, " === sync")
-       portdb = trees[settings["ROOT"]]["porttree"].dbapi
+       portdb = trees[settings['EROOT']]['porttree'].dbapi
        myportdir = portdb.porttree_root
        if not myportdir:
                myportdir = settings.get('PORTDIR', '')
@@ -2457,8 +2459,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
        # Reload the whole config from scratch.
        settings, trees, mtimedb = load_emerge_config(trees=trees)
        adjust_configs(myopts, trees)
-       root_config = trees[settings["ROOT"]]["root_config"]
-       portdb = trees[settings["ROOT"]]["porttree"].dbapi
+       root_config = trees[settings['EROOT']]['root_config']
+       portdb = trees[settings['EROOT']]['porttree'].dbapi
 
        if updatecache_flg and \
                os.path.exists(os.path.join(myportdir, 'metadata', 'cache')):
@@ -2473,13 +2475,13 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                # Reload the whole config from scratch.
                settings, trees, mtimedb = load_emerge_config(trees=trees)
                adjust_configs(myopts, trees)
-               portdb = trees[settings["ROOT"]]["porttree"].dbapi
-               root_config = trees[settings["ROOT"]]["root_config"]
+               portdb = trees[settings['EROOT']]['porttree'].dbapi
+               root_config = trees[settings['EROOT']]['root_config']
 
        mybestpv = portdb.xmatch("bestmatch-visible",
                portage.const.PORTAGE_PACKAGE_ATOM)
        mypvs = portage.best(
-               trees[settings["ROOT"]]["vartree"].dbapi.match(
+               trees[settings['EROOT']]['vartree'].dbapi.match(
                portage.const.PORTAGE_PACKAGE_ATOM))
 
        chk_updated_cfg_files(settings["EROOT"],
@@ -2512,7 +2514,8 @@ def action_uninstall(settings, trees, ldpath_mtimes,
        # For backward compat, some actions do not require leading '='.
        ignore_missing_eq = action in ('clean', 'unmerge')
        root = settings['ROOT']
-       vardb = trees[root]['vartree'].dbapi
+       eroot = settings['EROOT']
+       vardb = trees[settings['EROOT']]['vartree'].dbapi
        valid_atoms = []
        lookup_owners = []
 
@@ -2550,7 +2553,7 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                                valid_atoms.append(atom)
 
                elif x.startswith(os.sep):
-                       if not x.startswith(root):
+                       if not x.startswith(eroot):
                                writemsg_level(("!!! '%s' does not start with" + \
                                        " $ROOT.\n") % x, level=logging.ERROR, noiselevel=-1)
                                return 1
@@ -2654,13 +2657,13 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                sched.settings["PORTAGE_BACKGROUND"] = "1"
                sched.settings.backup_changes("PORTAGE_BACKGROUND")
                sched.settings.lock()
-               sched.pkgsettings[root] = portage.config(clone=sched.settings)
+               sched.pkgsettings[eroot] = portage.config(clone=sched.settings)
 
        if action in ('clean', 'unmerge') or \
                (action == 'prune' and "--nodeps" in opts):
                # When given a list of atoms, unmerge them in the order given.
                ordered = action == 'unmerge'
-               unmerge(trees[settings["ROOT"]]['root_config'], opts, action,
+               unmerge(trees[settings['EROOT']]['root_config'], opts, action,
                        valid_atoms, ldpath_mtimes, ordered=ordered,
                        scheduler=sched._sched_iface)
                rval = os.EX_OK
@@ -2793,7 +2796,7 @@ def relative_profile_path(portdir, abs_profile):
                profilever = None
        return profilever
 
-def getportageversion(portdir, target_root, profile, chost, vardb):
+def getportageversion(portdir, _unused, profile, chost, vardb):
        profilever = None
        if profile:
                profilever = relative_profile_path(portdir, profile)
@@ -2983,7 +2986,7 @@ def load_emerge_config(trees=None):
                setconfig = load_default_config(settings, root_trees)
                root_trees["root_config"] = RootConfig(settings, root_trees, setconfig)
 
-       settings = trees[trees._target_root]['vartree'].settings
+       settings = trees[trees._target_eroot]['vartree'].settings
        mtimedbfile = os.path.join(settings['EROOT'], portage.CACHE_PATH, "mtimedb")
        mtimedb = portage.MtimeDB(mtimedbfile)
        portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
index 1630a72d023797c1b803cb51ea590cabcc4fe92e..fc65f6140d834b29fb88fa3cba0049c166ffc4bc 100644 (file)
@@ -93,13 +93,13 @@ class _frozen_depgraph_config(object):
 
        def __init__(self, settings, trees, myopts, spinner):
                self.settings = settings
-               self.target_root = settings["ROOT"]
+               self.target_root = settings["EROOT"]
                self.myopts = myopts
                self.edebug = 0
                if settings.get("PORTAGE_DEBUG", "") == "1":
                        self.edebug = 1
                self.spinner = spinner
-               self._running_root = trees["/"]["root_config"]
+               self._running_root = trees[trees._running_eroot]["root_config"]
                self._opts_no_restart = frozenset(["--buildpkgonly",
                        "--fetchonly", "--fetch-all-uri", "--pretend"])
                self.pkgsettings = {}
@@ -1409,7 +1409,7 @@ class depgraph(object):
                if removal_action:
                        depend_root = myroot
                else:
-                       depend_root = "/"
+                       depend_root = self._frozen_config._running_root.root
                        root_deps = self._frozen_config.myopts.get("--root-deps")
                        if root_deps is not None:
                                if root_deps is True:
@@ -1971,13 +1971,14 @@ class depgraph(object):
                sets = root_config.sets
                depgraph_sets = self._dynamic_config.sets[root_config.root]
                myfavorites=[]
-               myroot = self._frozen_config.target_root
-               dbs = self._dynamic_config._filtered_trees[myroot]["dbs"]
-               vardb = self._frozen_config.trees[myroot]["vartree"].dbapi
-               real_vardb = self._frozen_config._trees_orig[myroot]["vartree"].dbapi
-               portdb = self._frozen_config.trees[myroot]["porttree"].dbapi
-               bindb = self._frozen_config.trees[myroot]["bintree"].dbapi
-               pkgsettings = self._frozen_config.pkgsettings[myroot]
+               eroot = root_config.root
+               root = root_config.settings['ROOT']
+               dbs = self._dynamic_config._filtered_trees[eroot]["dbs"]
+               vardb = self._frozen_config.trees[eroot]["vartree"].dbapi
+               real_vardb = self._frozen_config._trees_orig[eroot]["vartree"].dbapi
+               portdb = self._frozen_config.trees[eroot]["porttree"].dbapi
+               bindb = self._frozen_config.trees[eroot]["bintree"].dbapi
+               pkgsettings = self._frozen_config.pkgsettings[eroot]
                args = []
                onlydeps = "--onlydeps" in self._frozen_config.myopts
                lookup_owners = []
@@ -1998,7 +1999,7 @@ class depgraph(object):
                                mytbz2=portage.xpak.tbz2(x)
                                mykey=mytbz2.getelements("CATEGORY")[0]+"/"+os.path.splitext(os.path.basename(x))[0]
                                if os.path.realpath(x) != \
-                                       os.path.realpath(self._frozen_config.trees[myroot]["bintree"].getname(mykey)):
+                                       os.path.realpath(bindb.bintree.getname(mykey)):
                                        writemsg(colorize("BAD", "\n*** You need to adjust PKGDIR to emerge this package.\n\n"), noiselevel=-1)
                                        self._dynamic_config._skip_restart = True
                                        return 0, myfavorites
@@ -2044,7 +2045,7 @@ class depgraph(object):
                                args.append(PackageArg(arg=x, package=pkg,
                                        root_config=root_config))
                        elif x.startswith(os.path.sep):
-                               if not x.startswith(myroot):
+                               if not x.startswith(root):
                                        portage.writemsg(("\n\n!!! '%s' does not start with" + \
                                                " $ROOT.\n") % x, noiselevel=-1)
                                        self._dynamic_config._skip_restart = True
@@ -2055,7 +2056,7 @@ class depgraph(object):
                        elif x.startswith("." + os.sep) or \
                                x.startswith(".." + os.sep):
                                f = os.path.abspath(x)
-                               if not f.startswith(myroot):
+                               if not f.startswith(root):
                                        portage.writemsg(("\n\n!!! '%s' (resolved from '%s') does not start with" + \
                                                " $ROOT.\n") % (f, x), noiselevel=-1)
                                        self._dynamic_config._skip_restart = True
@@ -2174,7 +2175,7 @@ class depgraph(object):
                        for x in lookup_owners:
                                if not search_for_multiple and os.path.isdir(x):
                                        search_for_multiple = True
-                               relative_paths.append(x[len(myroot)-1:])
+                               relative_paths.append(x[len(root)-1:])
 
                        owners = set()
                        for pkg, relative_path in \
index b170ea32fecc9e8d00ba9ae7a430eea723e9280b..f0f50bdcac5843b58d0d83601daf51985284427b 100644 (file)
@@ -316,7 +316,7 @@ def post_emerge(myaction, myopts, myfiles,
        @type myopts: dict
        @param myfiles: emerge arguments
        @type myfiles: list
-       @param target_root: The target ROOT for myaction
+       @param target_root: The target EROOT for myaction
        @type target_root: String
        @param trees: A dictionary mapping each ROOT to it's package databases
        @type trees: dict
@@ -327,7 +327,7 @@ def post_emerge(myaction, myopts, myfiles,
        """
 
        root_config = trees[target_root]["root_config"]
-       vardbapi = trees[target_root]["vartree"].dbapi
+       vardbapi = trees[target_root]['vartree'].dbapi
        settings = vardbapi.settings
        info_mtimes = mtimedb["info"]
 
@@ -1600,7 +1600,7 @@ def emerge_main(args=None):
        # Portage needs to ensure a sane umask for the files it creates.
        os.umask(0o22)
        settings, trees, mtimedb = load_emerge_config()
-       portdb = trees[settings["ROOT"]]["porttree"].dbapi
+       portdb = trees[settings['EROOT']]['porttree'].dbapi
        rval = profile_check(trees, myaction)
        if rval != os.EX_OK:
                return rval
@@ -1618,7 +1618,7 @@ def emerge_main(args=None):
                mtimedb.commit()
                # Reload the whole config from scratch.
                settings, trees, mtimedb = load_emerge_config(trees=trees)
-               portdb = trees[settings["ROOT"]]["porttree"].dbapi
+               portdb = trees[settings['EROOT']]['porttree'].dbapi
 
        xterm_titles = "notitles" not in settings.features
        if xterm_titles:
@@ -1629,7 +1629,7 @@ def emerge_main(args=None):
                # Reload the whole config from scratch so that the portdbapi internal
                # config is updated with new FEATURES.
                settings, trees, mtimedb = load_emerge_config(trees=trees)
-               portdb = trees[settings["ROOT"]]["porttree"].dbapi
+               portdb = trees[settings['EROOT']]['porttree'].dbapi
 
        # NOTE: adjust_configs() can map options to FEATURES, so any relevant
        # options adjustments should be made prior to calling adjust_configs().
@@ -1641,9 +1641,9 @@ def emerge_main(args=None):
 
        if myaction == 'version':
                writemsg_stdout(getportageversion(
-                       settings["PORTDIR"], settings["ROOT"],
+                       settings["PORTDIR"], None,
                        settings.profile_path, settings["CHOST"],
-                       trees[settings["ROOT"]]["vartree"].dbapi) + '\n', noiselevel=-1)
+                       trees[settings['EROOT']]['vartree'].dbapi) + '\n', noiselevel=-1)
                return 0
        elif myaction == 'help':
                _emerge.help.help()
@@ -1722,7 +1722,7 @@ def emerge_main(args=None):
                        print(colorize("BAD", "\n*** emerging by path is broken and may not always work!!!\n"))
                        break
 
-       root_config = trees[settings["ROOT"]]["root_config"]
+       root_config = trees[settings['EROOT']]['root_config']
        if myaction == "list-sets":
                writemsg_stdout("".join("%s\n" % s for s in sorted(root_config.sets)))
                return os.EX_OK
@@ -1921,7 +1921,7 @@ def emerge_main(args=None):
        # SEARCH action
        elif "search"==myaction:
                validate_ebuild_environment(trees)
-               action_search(trees[settings["ROOT"]]["root_config"],
+               action_search(trees[settings['EROOT']]['root_config'],
                        myopts, myfiles, spinner)
 
        elif myaction in ('clean', 'depclean', 'deselect', 'prune', 'unmerge'):
@@ -1929,16 +1929,16 @@ def emerge_main(args=None):
                rval = action_uninstall(settings, trees, mtimedb["ldpath"],
                        myopts, myaction, myfiles, spinner)
                if not (myaction == 'deselect' or buildpkgonly or fetchonly or pretend):
-                       post_emerge(myaction, myopts, myfiles, settings["ROOT"],
+                       post_emerge(myaction, myopts, myfiles, settings['EROOT'],
                                trees, mtimedb, rval)
                return rval
 
        elif myaction == 'info':
 
                # Ensure atoms are valid before calling unmerge().
-               vardb = trees[settings["ROOT"]]["vartree"].dbapi
-               portdb = trees[settings["ROOT"]]["porttree"].dbapi
-               bindb = trees[settings["ROOT"]]["bintree"].dbapi
+               vardb = trees[settings['EROOT']]['vartree'].dbapi
+               portdb = trees[settings['EROOT']]['porttree'].dbapi
+               bindb = trees[settings['EROOT']]["bintree"].dbapi
                valid_atoms = []
                for x in myfiles:
                        if is_valid_package_atom(x):
@@ -2001,7 +2001,7 @@ def emerge_main(args=None):
                        display_news_notification(root_config, myopts)
                retval = action_build(settings, trees, mtimedb,
                        myopts, myaction, myfiles, spinner)
-               post_emerge(myaction, myopts, myfiles, settings["ROOT"],
+               post_emerge(myaction, myopts, myfiles, settings['EROOT'],
                        trees, mtimedb, retval)
 
                return retval
index 3db3a8be93d23e2e5705d5794ee65afec3ec9d40..852ad936a8f6ecee8ed1f3f6419f525ab19abe10 100644 (file)
@@ -546,8 +546,8 @@ def unmerge(root_config, myopts, unmerge_action,
                        emergelog(xterm_titles, "=== Unmerging... ("+y+")")
                        mysplit = y.split("/")
                        #unmerge...
-                       retval = portage.unmerge(mysplit[0], mysplit[1], settings["ROOT"],
-                               mysettings, unmerge_action not in ["clean","prune"],
+                       retval = portage.unmerge(mysplit[0], mysplit[1],
+                               settings=mysettings,
                                vartree=vartree, ldpath_mtimes=ldpath_mtimes,
                                scheduler=scheduler)
 
index 3dc9ae53ca847944153788947b686fb7c6daae82..03ec2866581b5afc576028bdf34c918cc2bbfb57 100644 (file)
@@ -482,8 +482,8 @@ def portageexit():
 class _trees_dict(dict):
        def __init__(self):
                super(dict, self).__init__()
-               self._running_root = None
-               self._target_root = None
+               self._running_eroot = None
+               self._target_eroot = None
 
 def create_trees(config_root=None, target_root=None, trees=None, env=None):
        if trees is None:
@@ -503,10 +503,10 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None):
                env=env, _eprefix=eprefix)
        settings.lock()
 
-       trees._target_root = settings['ROOT']
-       myroots = [(settings["ROOT"], settings)]
+       trees._target_eroot = settings['EROOT']
+       myroots = [(settings['EROOT'], settings)]
        if settings["ROOT"] == "/":
-               trees._running_root = trees._target_root
+               trees._running_eroot = trees._target_eroot
        else:
 
                # When ROOT != "/" we only want overrides from the calling
@@ -522,19 +522,19 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None):
                settings = config(config_root=None, target_root="/",
                        env=clean_env, _eprefix=eprefix)
                settings.lock()
-               trees._running_root = settings['ROOT']
-               myroots.append((settings["ROOT"], settings))
+               trees._running_eroot = settings['EROOT']
+               myroots.append((settings['EROOT'], settings))
 
        for myroot, mysettings in myroots:
                trees[myroot] = portage.util.LazyItemsDict(trees.get(myroot, {}))
                trees[myroot].addLazySingleton("virtuals", mysettings.getvirtuals)
                trees[myroot].addLazySingleton(
-                       "vartree", vartree, myroot, categories=mysettings.categories,
+                       "vartree", vartree, categories=mysettings.categories,
                                settings=mysettings)
                trees[myroot].addLazySingleton("porttree",
-                       portagetree, myroot, settings=mysettings)
+                       portagetree, settings=mysettings)
                trees[myroot].addLazySingleton("bintree",
-                       binarytree, myroot, mysettings["PKGDIR"], settings=mysettings)
+                       binarytree, pkgdir=mysettings["PKGDIR"], settings=mysettings)
        return trees
 
 if VERSION == 'HEAD':
index 72fd5c4fd601a1d4f8825ee3eed0aeed549e3822..51750431d9c5079a064b0fff7d3720e40a603c55 100644 (file)
@@ -37,7 +37,7 @@ def _global_updates(trees, prev_mtimes, quiet=False, if_mtime_changed=True):
                "SANDBOX_ACTIVE" in os.environ or \
                len(trees) != 1:
                return retupd
-       root = "/"
+       root = trees._running_eroot
        mysettings = trees[root]["vartree"].settings
        portdb = trees[root]["porttree"].dbapi
        vardb = trees[root]["vartree"].dbapi
index beba78563ca85d36cc5cfe33e778a49863d0efbe..072b3f751060a9fa30e3d9682a37c3332dac4122 100644 (file)
@@ -35,13 +35,15 @@ def _get_legacy_global(name):
        constructed.add('db')
        del portage._initializing_globals
 
-       settings = portage.db[portage.db._target_root]["vartree"].settings
+       settings = portage.db[portage.db._target_eroot]["vartree"].settings
        portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
 
        portage.settings = settings
        constructed.add('settings')
 
-       portage.root = portage.db._target_root
+       # Since portage.db now uses EROOT for keys instead of ROOT, we make
+       # portage.root refer to EROOT such that it continues works as a key.
+       portage.root = portage.db._target_eroot
        constructed.add('root')
 
        # COMPATIBILITY
index b69b363bbbf9fbf2c16e13928cdf67a936bfd78f..f76645355588bac7ad2d10f12a6cc8f8c7d586fa 100644 (file)
@@ -147,7 +147,7 @@ class vardbapi(dbapi):
                self._fs_lock_count = 0
 
                if vartree is None:
-                       vartree = portage.db[settings["ROOT"]]["vartree"]
+                       vartree = portage.db[settings['EROOT']]['vartree']
                self.vartree = vartree
                self._aux_cache_keys = set(
                        ["BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "DESCRIPTION",
@@ -1319,7 +1319,7 @@ class dblink(object):
                        raise TypeError("settings argument is required")
 
                mysettings = settings
-               myroot = settings['ROOT']
+               self._eroot = mysettings['EROOT']
                self.cat = cat
                self.pkg = pkg
                self.mycpv = self.cat + "/" + self.pkg
@@ -1327,14 +1327,10 @@ class dblink(object):
                self.mysplit[0] = "%s/%s" % (self.cat, self.mysplit[0])
                self.treetype = treetype
                if vartree is None:
-                       vartree = portage.db[myroot]["vartree"]
+                       vartree = portage.db[self._eroot]["vartree"]
                self.vartree = vartree
                self._blockers = blockers
                self._scheduler = scheduler
-
-               # WARNING: EROOT support is experimental and may be incomplete
-               # for cases in which EPREFIX is non-empty.
-               self._eroot = mysettings['EROOT']
                self.dbroot = normalize_path(os.path.join(self._eroot, VDB_PATH))
                self.dbcatdir = self.dbroot+"/"+cat
                self.dbpkgdir = self.dbcatdir+"/"+pkg
@@ -1343,14 +1339,14 @@ class dblink(object):
                self.settings = mysettings
                self._verbose = self.settings.get("PORTAGE_VERBOSE") == "1"
 
-               self.myroot=myroot
+               self.myroot = self.settings['ROOT']
                self._installed_instance = None
                self.contentscache = None
                self._contents_inodes = None
                self._contents_basenames = None
                self._linkmap_broken = False
                self._md5_merge_map = {}
-               self._hash_key = (self.myroot, self.mycpv)
+               self._hash_key = (self._eroot, self.mycpv)
                self._protect_obj = None
                self._pipe = pipe
 
index 1bf0522a703d764425b515e5154f2346c6c18e64..13d68324dc364d96e1515e9bc611476a643ac97f 100644 (file)
@@ -39,7 +39,6 @@ class NewsManager(object):
        def __init__(self, portdb, vardb, news_path, unread_path, language_id='en'):
                self.news_path = news_path
                self.unread_path = unread_path
-               self.target_root = vardb.settings["ROOT"]
                self.language_id = language_id
                self.config = vardb.settings
                self.vdb = vardb
index a2d2c8c12a718b35fd3fb45cb65cc741460dfd45..ccea574c5fb04e47c97526f86fcfc87f60808841 100644 (file)
@@ -420,9 +420,9 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
        if settings is None:
                raise TypeError("settings parameter is required")
        mysettings = settings
-       myroot = settings["ROOT"]
+       myroot = settings['EROOT']
 
-       if _unused is not None and _unused != mysettings["ROOT"]:
+       if _unused is not None and _unused != mysettings['EROOT']:
                warnings.warn("The third parameter of the "
                        "portage.doebuild() is now unused. Use "
                        "settings['ROOT'] instead.",
@@ -936,7 +936,7 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
                                # this phase. This can raise PermissionDenied if
                                # the current user doesn't have write access to $PKGDIR.
                                if hasattr(portage, 'db'):
-                                       bintree = portage.db[mysettings["ROOT"]]["bintree"]
+                                       bintree = portage.db[mysettings['EROOT']]['bintree']
                                        mysettings["PORTAGE_BINPKG_TMPFILE"] = \
                                                bintree.getname(mysettings.mycpv) + \
                                                ".%s" % (os.getpid(),)
index fe9b64829769b43c577d7fbd177d10a408f61437..6eb13610f85756e8b869ad40413c8befd0117d89 100644 (file)
@@ -24,7 +24,7 @@ class ConfigTestCase(TestCase):
                        settings = config(clone=playground.settings)
                        result = playground.run(["=dev-libs/A-1"])
                        pkg, existing_node = result.depgraph._select_package(
-                               playground.root, "=dev-libs/A-1")
+                               playground.eroot, "=dev-libs/A-1")
                        settings.setcpv(pkg)
 
                        # clone after setcpv tests deepcopy of LazyItemsDict
index cafb16d961ac53982df61b82541e2c4232ab4766..daa6e75286e32a31983b3c7aee4f88f912863f48 100644 (file)
@@ -36,7 +36,7 @@ class DoebuildSpawnTestCase(TestCase):
                                'RDEPEND'   : '>=app-shells/bash-3.2_p17 >=dev-lang/python-2.6',
                                'SLOT'      : '0',
                        }
-                       root_config = playground.trees[playground.root]['root_config']
+                       root_config = playground.trees[playground.eroot]['root_config']
                        pkg = Package(built=False, cpv=cpv, installed=False,
                                metadata=metadata, root_config=root_config,
                                type_name='ebuild')
index c2c57a38912dd3d81296ad02b36ce4ef58f954d9..aaa54d0a76264fbddec8ca7e6c83e2314d4b6a9e 100644 (file)
@@ -134,7 +134,7 @@ pkg_info() {
                eroot = settings["EROOT"]
                trees = playground.trees
                root = playground.root
-               portdb = trees[root]["porttree"].dbapi
+               portdb = trees[eroot]["porttree"].dbapi
                portdir = settings["PORTDIR"]
                var_cache_edb = os.path.join(eprefix, "var", "cache", "edb")
                cachedir = os.path.join(var_cache_edb, "dep")
@@ -214,14 +214,14 @@ pkg_info() {
                        emaint_cmd + ("--fix", "all"),
                        fixpackages_cmd,
                        regenworld_cmd,
-                       portageq_cmd + ("match", "/", "dev-libs/A"),
-                       portageq_cmd + ("best_visible", "/", "dev-libs/A"),
-                       portageq_cmd + ("best_visible", "/", "binary", "dev-libs/A"),
-                       portageq_cmd + ("contents", "/", "dev-libs/A-1"),
-                       portageq_cmd + ("metadata", "/", "ebuild", "dev-libs/A-1", "EAPI", "IUSE", "RDEPEND"),
-                       portageq_cmd + ("metadata", "/", "binary", "dev-libs/A-1", "EAPI", "USE", "RDEPEND"),
-                       portageq_cmd + ("metadata", "/", "installed", "dev-libs/A-1", "EAPI", "USE", "RDEPEND"),
-                       portageq_cmd + ("owners", "/", eroot + "usr"),
+                       portageq_cmd + ("match", eroot, "dev-libs/A"),
+                       portageq_cmd + ("best_visible", eroot, "dev-libs/A"),
+                       portageq_cmd + ("best_visible", eroot, "binary", "dev-libs/A"),
+                       portageq_cmd + ("contents", eroot, "dev-libs/A-1"),
+                       portageq_cmd + ("metadata", eroot, "ebuild", "dev-libs/A-1", "EAPI", "IUSE", "RDEPEND"),
+                       portageq_cmd + ("metadata", eroot, "binary", "dev-libs/A-1", "EAPI", "USE", "RDEPEND"),
+                       portageq_cmd + ("metadata", eroot, "installed", "dev-libs/A-1", "EAPI", "USE", "RDEPEND"),
+                       portageq_cmd + ("owners", eroot, eroot + "usr"),
                        emerge_cmd + ("-p", eroot + "usr"),
                        emerge_cmd + ("-p", "--unmerge", "-q", eroot + "usr"),
                        emerge_cmd + ("--unmerge", "--quiet", "dev-libs/A"),
index 9dae0efda034f48eb58e8c8fdf680c9dc312a48b..6c8a61c5b14469fc2ec876cbc8000d3b15989f54 100644 (file)
@@ -128,7 +128,7 @@ class SimpleRepomanTestCase(TestCase):
                settings = playground.settings
                eprefix = settings["EPREFIX"]
                eroot = settings["EROOT"]
-               portdb = playground.trees[playground.root]["porttree"].dbapi
+               portdb = playground.trees[playground.eroot]["porttree"].dbapi
                homedir = os.path.join(eroot, "home")
                distdir = os.path.join(eprefix, "distdir")
                portdir = settings["PORTDIR"]
index 4bbd03318ac976b3a615136f88aec00d4169ab38..57cdebece4f78dfdcc8c9043b9efb8b7982f5e17 100644 (file)
@@ -201,7 +201,7 @@ class ResolverPlayground(object):
                        ebuild_dir = os.path.join(repo_dir, a.cp)
                        ebuild_path = os.path.join(ebuild_dir, a.cpv.split("/")[1] + ".ebuild")
 
-                       portdb = self.trees[self.root]["porttree"].dbapi
+                       portdb = self.trees[self.eroot]["porttree"].dbapi
                        tmpsettings['O'] = ebuild_dir
                        if not digestgen(mysettings=tmpsettings, myportdb=portdb):
                                raise AssertionError('digest creation failed for %s' % ebuild_path)
@@ -549,7 +549,7 @@ class ResolverPlayground(object):
                                return
 
        def cleanup(self):
-               portdb = self.trees[self.root]["porttree"].dbapi
+               portdb = self.trees[self.eroot]["porttree"].dbapi
                portdb.close_caches()
                portage.dbapi.porttree.portdbapi.portdbapi_instances.remove(portdb)
                if self.debug:
index 65ed2dbe1860ab9552fa0723f271651efda5f2c3..14359326486b4a495cbd53622e680e630d72e55e 100644 (file)
@@ -46,12 +46,18 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                        vardbapi = vartree(settings=env).dbapi
                else:
                        if target_root is None:
+                               eprefix = portage.settings["EPREFIX"]
                                target_root = portage.settings["ROOT"]
-                       if hasattr(portage, "db") and target_root in portage.db:
-                               vardbapi = portage.db[target_root]["vartree"].dbapi
+                               target_eroot = portage.settings['EROOT']
+                       else:
+                               eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", "")
+                               target_eroot = os.path.join(target_root, eprefix)
+                               target_eroot = target_eroot.rstrip(os.sep) + os.sep
+                       if hasattr(portage, "db") and target_eroot in portage.db:
+                               vardbapi = portage.db[target_eroot]["vartree"].dbapi
                        else:
                                settings = config(config_root=target_root,
-                                       target_root=target_root)
+                                       target_root=target_root, eprefix=eprefix)
                                target_root = settings["ROOT"]
                                if env is None:
                                        env = settings