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"),
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
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()
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):
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():
# 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)
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",
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:
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:
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)
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)
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):
try:
if uses_root:
- args[0] = portage.settings["ROOT"]
+ args[0] = portage.settings['EROOT']
retval = function(args)
if retval:
sys.exit(retval)
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"]
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()
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):
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
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
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:
__uniqlist__.append(pkgline)
return True
-root = portage.settings['ROOT']
eroot = portage.settings['EROOT']
world_file = os.path.join(eroot, portage.WORLD_FILE)
# 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:
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)
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,
}}
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
% (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
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 = {}
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
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
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
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):
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
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:
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:
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]
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,
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)
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 = {}
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":
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()
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:
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:
% (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:
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",
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"
"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)
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
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:
# 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)
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)
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', '')
# 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')):
# 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"],
# 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 = []
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
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
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)
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'])
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 = {}
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:
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 = []
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
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
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
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 \
@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
"""
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"]
# 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
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:
# 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().
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()
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
# 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'):
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):
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
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)
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:
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
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':
"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
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
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",
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
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
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
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
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.",
# 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(),)
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
'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')
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")
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"),
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"]
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)
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:
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