本文整理汇总了Python中snakeoil.osutils.normpath函数的典型用法代码示例。如果您正苦于以下问题:Python normpath函数的具体用法?Python normpath怎么用?Python normpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normpath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_from_abspath
def test_from_abspath(self):
self.mk_profiles({"name": "profiles"}, {"name": "profiles/1"})
base = pjoin(self.dir, "profiles")
p = self.kls.from_abspath(pjoin(base, "1"))
self.assertNotEqual(p, None)
self.assertEqual(normpath(p.basepath), normpath(base))
self.assertEqual(normpath(p.profile), normpath(pjoin(base, "1")))
开发者ID:veelai,项目名称:pkgcore,代码行数:7,代码来源:test_profiles.py
示例2: _internal_offset_iter_scan
def _internal_offset_iter_scan(path, chksum_handlers, offset, stat_func=os.lstat,
hidden=True, backup=True):
offset = normpath(offset)
path = normpath(path)
dirs = collections.deque([path[len(offset):]])
if dirs[0]:
yield gen_obj(dirs[0], chksum_handlers=chksum_handlers,
stat_func=stat_func)
sep = os.path.sep
while dirs:
base = dirs.popleft()
real_base = pjoin(offset, base.lstrip(sep))
base = base.rstrip(sep) + sep
for x in listdir(real_base):
if not hidden and x.startswith('.'):
continue
if not backup and x.endswith('~'):
continue
path = pjoin(base, x)
obj = gen_obj(path, chksum_handlers=chksum_handlers,
real_location=pjoin(real_base, x),
stat_func=os.lstat)
yield obj
if obj.is_dir:
dirs.append(path)
开发者ID:radhermit,项目名称:pkgcore,代码行数:26,代码来源:livefs.py
示例3: _cmd_implementation_sanity_check
def _cmd_implementation_sanity_check(self, domain):
pkg = self.pkg
eapi = pkg.eapi_obj
if eapi.options.has_required_use:
use = pkg.use
for node in pkg.required_use:
if not node.match(use):
print(textwrap.dedent(
"""
REQUIRED_USE requirement wasn't met
Failed to match: {}
from: {}
for USE: {}
pkg: {}
""".format(node, pkg.required_use, " ".join(use), pkg.cpvstr)
))
return False
if 'pretend' not in pkg.mandatory_phases:
return True
commands = None
if not pkg.built:
commands = {"request_inherit": partial(inherit_handler, self._eclass_cache)}
env = expected_ebuild_env(pkg)
tmpdir = normpath(domain._get_tempspace())
builddir = pjoin(tmpdir, env["CATEGORY"], env["PF"])
pkg_tmpdir = normpath(pjoin(builddir, "temp"))
ensure_dirs(pkg_tmpdir, mode=0770, gid=portage_gid, minimal=True)
env["ROOT"] = domain.root
env["T"] = pkg_tmpdir
try:
logger.debug("running ebuild pkg_pretend sanity check for %s", pkg.cpvstr)
start = time.time()
ret = run_generic_phase(pkg, "pretend", env, userpriv=True, sandbox=True,
fakeroot=False, extra_handlers=commands)
logger.debug("pkg_pretend sanity check for %s took %2.2f seconds",
pkg.cpvstr, time.time() - start)
return ret
except format.GenericBuildError as e:
logger.error("pkg_pretend sanity check for %s failed with exception %r"
% (pkg.cpvstr, e))
return False
finally:
shutil.rmtree(builddir)
# try to wipe the cat dir; if not empty, ignore it
try:
os.rmdir(os.path.dirname(builddir))
except EnvironmentError as e:
if e.errno != errno.ENOTEMPTY:
raise
开发者ID:floppym,项目名称:pkgcore,代码行数:49,代码来源:ebd.py
示例4: _add_profile
def _add_profile(self, profile_override=None):
if profile_override is None:
profile = self._find_profile_link()
else:
profile = normpath(abspath(profile_override))
if not os.path.exists(profile):
raise errors.ComplexInstantiationError(f"{profile} doesn't exist")
paths = profiles.OnDiskProfile.split_abspath(profile)
if paths is None:
raise errors.ComplexInstantiationError(
'%s expands to %s, but no profile detected' %
(pjoin(self.dir, 'make.profile'), profile))
user_profile_path = pjoin(self.dir, 'profile')
if os.path.isdir(user_profile_path):
self["profile"] = basics.AutoConfigSection({
"class": "pkgcore.ebuild.profiles.UserProfile",
"parent_path": paths[0],
"parent_profile": paths[1],
"user_path": user_profile_path,
})
else:
self["profile"] = basics.AutoConfigSection({
"class": "pkgcore.ebuild.profiles.OnDiskProfile",
"basepath": paths[0],
"profile": paths[1],
})
开发者ID:radhermit,项目名称:pkgcore,代码行数:28,代码来源:portage_conf.py
示例5: add_profile
def add_profile(config, base_path, user_profile_path=None, profile_override=None):
if profile_override is None:
profile = _find_profile_link(base_path)
else:
profile = normpath(abspath(profile_override))
if not os.path.exists(profile):
raise_from(errors.ComplexInstantiationError(
"%s doesn't exist" % (profile,)))
paths = profiles.OnDiskProfile.split_abspath(profile)
if paths is None:
raise errors.ComplexInstantiationError(
'%s expands to %s, but no profile detected' %
(pjoin(base_path, 'make.profile'), profile))
if os.path.isdir(user_profile_path):
config["profile"] = basics.AutoConfigSection({
"class": "pkgcore.ebuild.profiles.UserProfile",
"parent_path": paths[0],
"parent_profile": paths[1],
"user_path": user_profile_path,
})
else:
config["profile"] = basics.AutoConfigSection({
"class": "pkgcore.ebuild.profiles.OnDiskProfile",
"basepath": paths[0],
"profile": paths[1],
})
开发者ID:vapier,项目名称:pkgcore,代码行数:28,代码来源:portage_conf.py
示例6: __init__
def __init__(self, location, strict=True, **d):
d["location"] = normpath(location)
s = object.__setattr__
if strict:
for k in self.__attrs__:
s(self, k, d[k])
else:
for k, v in d.iteritems():
s(self, k, v)
开发者ID:chutz,项目名称:pkgcore,代码行数:11,代码来源:fs.py
示例7: init_distfiles_env
def init_distfiles_env(self):
# cvs/svn ebuilds need to die.
distdir_write = self.domain.fetcher.get_storage_path()
if distdir_write is None:
raise format.GenericBuildError("no usable distdir was found "
"for PORTAGE_ACTUAL_DISTDIR from fetcher %s" % self.domain.fetcher)
self.env["PORTAGE_ACTUAL_DISTDIR"] = distdir_write
self.env["DISTDIR"] = normpath(
pjoin(self.builddir, "distdir"))
for x in ("PORTAGE_ACTUAL_DISTDIR", "DISTDIR"):
self.env[x] = os.path.realpath(self.env[x]).rstrip("/") + "/"
开发者ID:chutz,项目名称:pkgcore,代码行数:11,代码来源:ebd.py
示例8: _find_profile_link
def _find_profile_link(self):
make_profile = pjoin(self.dir, 'make.profile')
try:
return normpath(abspath(
pjoin(self.dir, os.readlink(make_profile))))
except EnvironmentError as e:
if e.errno in (errno.ENOENT, errno.EINVAL):
raise errors.ComplexInstantiationError(
f"{make_profile} must be a symlink pointing to a real target") from e
raise errors.ComplexInstantiationError(
f"{make_profile}: unexpected error- {e.strerror}") from e
开发者ID:radhermit,项目名称:pkgcore,代码行数:11,代码来源:portage_conf.py
示例9: __init__
def __init__(self, mode, tempdir, hooks, csets, preserves, observer,
offset=None, disable_plugins=False, parallelism=None):
if observer is None:
observer = observer_mod.repo_observer(observer_mod.null_output)
self.observer = observer
self.mode = mode
if tempdir is not None:
tempdir = normpath(tempdir) + '/'
self.tempdir = tempdir
if parallelism is None:
parallelism = get_proc_count()
self.parallelism = parallelism
self.hooks = ImmutableDict((x, []) for x in hooks)
self.preserve_csets = []
self.cset_sources = {}
# instantiate these separately so their values are preserved
self.preserved_csets = LazyValDict(
self.preserve_csets, self._get_cset_source)
for k, v in csets.iteritems():
if isinstance(v, basestring):
v = getattr(self, v, v)
if not callable(v):
raise TypeError(
"cset values must be either the string name of "
"existing methods, or callables (got %s)" % v)
if k in preserves:
self.add_preserved_cset(k, v)
else:
self.add_cset(k, v)
if offset is None:
offset = "/"
self.offset = offset
if not disable_plugins:
# merge in default triggers first.
for trigger in get_plugins('triggers'):
t = trigger()
t.register(self)
# merge in overrides
for hook, triggers in hooks.iteritems():
for trigger in triggers:
self.add_trigger(hook, trigger)
self.regenerate_csets()
for x in hooks:
setattr(self, x, partial(self.execute_hook, x))
开发者ID:floppym,项目名称:pkgcore,代码行数:53,代码来源:engine.py
示例10: _init_distfiles_env
def _init_distfiles_env(self):
# TODO: PORTAGE_ACTUAL_DISTDIR usage by vcs eclasses needs to be killed off
distdir_write = self.domain.fetcher.get_storage_path()
if distdir_write is None:
raise format.GenericBuildError(
"no usable distdir was found "
f"for PORTAGE_ACTUAL_DISTDIR from fetcher {self.domain.fetcher}")
self.env["PORTAGE_ACTUAL_DISTDIR"] = distdir_write
self.env["DISTDIR"] = normpath(
pjoin(self.builddir, "distdir"))
for x in ("PORTAGE_ACTUAL_DISTDIR", "DISTDIR"):
self.env[x] = os.path.realpath(self.env[x]).rstrip(os.sep) + os.sep
开发者ID:radhermit,项目名称:pkgcore,代码行数:12,代码来源:ebd.py
示例11: gen_config_protect_filter
def gen_config_protect_filter(offset, extra_protects=(), extra_disables=()):
collapsed_d, inc, colon = collapse_envd(pjoin(offset, "etc/env.d"))
collapsed_d.setdefault("CONFIG_PROTECT", []).extend(extra_protects)
collapsed_d.setdefault("CONFIG_PROTECT_MASK", []).extend(extra_disables)
r = [values.StrGlobMatch(normpath(x).rstrip("/") + "/")
for x in set(stable_unique(collapsed_d["CONFIG_PROTECT"] + ["/etc"]))]
if len(r) > 1:
r = values.OrRestriction(*r)
else:
r = r[0]
neg = stable_unique(collapsed_d["CONFIG_PROTECT_MASK"])
if neg:
if len(neg) == 1:
r2 = values.StrGlobMatch(normpath(neg[0]).rstrip("/") + "/",
negate=True)
else:
r2 = values.OrRestriction(
negate=True,
*[values.StrGlobMatch(normpath(x).rstrip("/") + "/")
for x in set(neg)])
r = values.AndRestriction(r, r2)
return r
开发者ID:vapier,项目名称:pkgcore,代码行数:23,代码来源:triggers.py
示例12: _set_op_vars
def _set_op_vars(self, tmp_offset):
# don't fool with this, without fooling with setup.
self.tmpdir = self.domain.pm_tmpdir
if tmp_offset:
self.tmpdir = pjoin(self.tmpdir, tmp_offset.strip(os.sep))
self.builddir = pjoin(self.tmpdir, self.env["CATEGORY"], self.env["PF"])
for x, y in (("T", "temp"),
("WORKDIR", "work"),
("D", "image"),
("HOME", "homedir")):
self.env[x] = normpath(pjoin(self.builddir, y))
self.env["D"] += self.eapi.options.trailing_slash
self.env["PORTAGE_LOGFILE"] = normpath(pjoin(self.env["T"], "build.log"))
# XXX: Note that this is just EAPI 3 support, not yet prefix
# full awareness.
if self.prefix_mode:
self.env["ED"] = normpath(
pjoin(self.env["D"].rstrip(os.sep), self.prefix.rstrip(os.sep))) \
+ self.eapi.options.trailing_slash
# temporary install dir correct for all EAPIs
self.ED = self.env.get('ED', self.env['D'])
开发者ID:radhermit,项目名称:pkgcore,代码行数:24,代码来源:ebd.py
示例13: _internal_iter_scan
def _internal_iter_scan(path, chksum_handlers, stat_func=os.lstat):
dirs = collections.deque([normpath(path)])
obj = gen_obj(dirs[0], chksum_handlers=chksum_handlers,
stat_func=stat_func)
yield obj
if not obj.is_dir:
return
while dirs:
base = dirs.popleft()
for x in listdir(base):
path = pjoin(base, x)
obj = gen_obj(path, chksum_handlers=chksum_handlers,
real_location=path, stat_func=stat_func)
yield obj
if obj.is_dir:
dirs.append(path)
开发者ID:den4ix,项目名称:pkgcore,代码行数:16,代码来源:livefs.py
示例14: iter_child_nodes
def iter_child_nodes(self, start_point):
"""Yield a stream of nodes that are fs entries contained within the
passed in start point.
:param start_point: fs filepath all yielded nodes must be within.
"""
if isinstance(start_point, fs.fsBase):
if start_point.is_sym:
start_point = start_point.target
else:
start_point = start_point.location
for x in self:
cn_path = normpath(start_point).rstrip(path.sep) + path.sep
# what about sym targets?
if x.location.startswith(cn_path):
yield x
开发者ID:den4ix,项目名称:pkgcore,代码行数:17,代码来源:contents.py
示例15: _find_profile_link
def _find_profile_link(base_path, portage_compat=False):
make_profile = pjoin(base_path, 'make.profile')
try:
return normpath(abspath(
pjoin(base_path, os.readlink(make_profile))))
except EnvironmentError as oe:
if oe.errno in (errno.ENOENT, errno.EINVAL):
if oe.errno == errno.ENOENT:
if portage_compat:
return None
profile = _find_profile_link(pjoin(base_path, 'portage'), True)
if profile is not None:
return profile
raise_from(errors.ComplexInstantiationError(
"%s must be a symlink pointing to a real target" % (
make_profile,)))
raise_from(errors.ComplexInstantiationError(
"%s: unexpected error- %s" % (make_profile, oe.strerror)))
开发者ID:vapier,项目名称:pkgcore,代码行数:18,代码来源:portage_conf.py
示例16: __delitem__
def __delitem__(self, obj):
"""
remove a fs obj to the set
:type obj: a derivative of :obj:`pkgcore.fs.fs.fsBase`
or a string location of an obj in the set.
:raise KeyError: if the obj isn't found
"""
if not self.mutable:
# weird, but keeping with set.
raise AttributeError(
"%s is frozen; no remove functionality" % self.__class__)
if fs.isfs_obj(obj):
del self._dict[obj.location]
else:
del self._dict[normpath(obj)]
开发者ID:den4ix,项目名称:pkgcore,代码行数:18,代码来源:contents.py
示例17: _internal_iter_scan
def _internal_iter_scan(path, chksum_handlers, stat_func=os.lstat,
hidden=True, backup=True):
dirs = collections.deque([normpath(path)])
obj = gen_obj(dirs[0], chksum_handlers=chksum_handlers,
stat_func=stat_func)
yield obj
if not obj.is_dir:
return
while dirs:
base = dirs.popleft()
for x in listdir(base):
if not hidden and x.startswith('.'):
continue
if not backup and x.endswith('~'):
continue
path = pjoin(base, x)
obj = gen_obj(path, chksum_handlers=chksum_handlers,
real_location=path, stat_func=stat_func)
yield obj
if obj.is_dir:
dirs.append(path)
开发者ID:radhermit,项目名称:pkgcore,代码行数:21,代码来源:livefs.py
示例18: __init__
#.........这里部分代码省略.........
self._preloaded_eclasses = {}
self._eclass_caching = False
self._outstanding_expects = []
self._metadata_paths = None
if fakeroot and (sandbox or not userpriv):
traceback.print_stack()
logger.error("Both sandbox and fakeroot cannot be enabled at the same time")
raise InitializationError("cannot initialize with sandbox and fakeroot")
if userpriv:
self.__userpriv = True
spawn_opts.update({
"uid": os_data.portage_uid,
"gid": os_data.portage_gid,
"groups": [os_data.portage_gid]})
else:
if pkgcore.spawn.is_userpriv_capable():
spawn_opts.update({"gid": os_data.portage_gid,
"groups": [0, os_data.portage_gid]})
self.__userpriv = False
# open the pipes to be used for chatting with the new daemon
cread, cwrite = os.pipe()
dread, dwrite = os.pipe()
self.__sandbox = False
self.__fakeroot = False
# since it's questionable which spawn method we'll use (if
# sandbox or fakeroot fex), we ensure the bashrc is invalid.
env = {x: "/etc/portage/spork/not/valid/ha/ha"
for x in ("BASHRC", "BASH_ENV")}
if int(os.environ.get('PKGCORE_PERF_DEBUG', 1)) > 1:
env["PKGCORE_PERF_DEBUG"] = os.environ['PKGCORE_PERF_DEBUG']
# append script dir to PATH for git repo or unpacked tarball
if "PKGCORE_REPO_PATH" in os.environ:
env["PATH"] = os.pathsep.join(
[os.environ["PATH"], pjoin(os.environ["PKGCORE_REPO_PATH"], 'bin')])
args = []
if sandbox:
if not pkgcore.spawn.is_sandbox_capable():
raise ValueError("spawn lacks sandbox capabilities")
if fakeroot:
raise InitializationError('fakeroot was on, but sandbox was also on')
self.__sandbox = True
spawn_func = pkgcore.spawn.spawn_sandbox
# env.update({"SANDBOX_DEBUG":"1", "SANDBOX_DEBUG_LOG":"/var/tmp/test"})
elif fakeroot:
if not pkgcore.spawn.is_fakeroot_capable():
raise ValueError("spawn lacks fakeroot capabilities")
self.__fakeroot = True
spawn_func = pkgcore.spawn.spawn_fakeroot
args.append(save_file)
else:
spawn_func = pkgcore.spawn.spawn
# force to a neutral dir so that sandbox/fakeroot won't explode if
# ran from a nonexistent dir
spawn_opts["cwd"] = e_const.EAPI_BIN_PATH
# little trick. we force the pipes to be high up fd wise so
# nobody stupidly hits 'em.
max_fd = min(pkgcore.spawn.max_fd_limit, 1024)
env.update({
"PKGCORE_EBD_READ_FD": str(max_fd-2),
"PKGCORE_EBD_WRITE_FD": str(max_fd-1)})
self.pid = spawn_func(
["/bin/bash", self.ebd, "daemonize"],
fd_pipes={0: 0, 1: 1, 2: 2, max_fd-2: cread, max_fd-1: dwrite},
returnpid=True, env=env, *args, **spawn_opts)[0]
os.close(cread)
os.close(dwrite)
self.ebd_write = os.fdopen(cwrite, "w")
self.ebd_read = os.fdopen(dread, "r")
# basically a quick "yo" to the daemon
self.write("dude?")
if not self.expect("dude!"):
logger.error("error in server coms, bailing.")
raise InitializationError(
"expected 'dude!' response from ebd, which wasn't received. "
"likely a bug")
self.write(e_const.EAPI_BIN_PATH)
# send PKGCORE_PYTHON_BINARY...
self.write(pkgcore.spawn.find_invoking_python())
self.write(
os.pathsep.join([
normpath(abspath(pjoin(pkgcore.__file__, os.pardir, os.pardir))),
os.environ.get('PYTHONPATH', '')])
)
if self.__sandbox:
self.write("sandbox_log?")
self.__sandbox_log = self.read().split()[0]
self.dont_export_vars = self.read().split()
# locking isn't used much, but w/ threading this will matter
self.unlock()
开发者ID:vapier,项目名称:pkgcore,代码行数:101,代码来源:processor.py
示例19: __init__
def __init__(self, userpriv, sandbox):
"""
:param sandbox: enables a sandboxed processor
:param userpriv: enables a userpriv'd processor
"""
self.lock()
self.ebd = e_const.EBUILD_DAEMON_PATH
spawn_opts = {'umask': 0002}
self._preloaded_eclasses = {}
self._eclass_caching = False
self._outstanding_expects = []
self._metadata_paths = None
if userpriv:
self.__userpriv = True
spawn_opts.update({
"uid": os_data.portage_uid,
"gid": os_data.portage_gid,
"groups": [os_data.portage_gid]})
else:
if pkgcore.spawn.is_userpriv_capable():
spawn_opts.update({"gid": os_data.portage_gid,
"groups": [0, os_data.portage_gid]})
self.__userpriv = False
# open the pipes to be used for chatting with the new daemon
cread, cwrite = os.pipe()
dread, dwrite = os.pipe()
self.__sandbox = False
# since it's questionable which spawn method we'll use (if
# sandbox fex), we ensure the bashrc is invalid.
env = {x: "/etc/portage/spork/not/valid/ha/ha"
for x in ("BASHRC", "BASH_ENV")}
if int(os.environ.get('PKGCORE_PERF_DEBUG', 0)):
env["PKGCORE_PERF_DEBUG"] = os.environ['PKGCORE_PERF_DEBUG']
if int(os.environ.get('PKGCORE_DEBUG', 0)):
env["PKGCORE_DEBUG"] = os.environ['PKGCORE_DEBUG']
if int(os.environ.get('PKGCORE_NOCOLOR', 0)):
env["PKGCORE_NOCOLOR"] = os.environ['PKGCORE_NOCOLOR']
if sandbox:
env["NOCOLOR"] = os.environ['PKGCORE_NOCOLOR']
# prepend script dir to PATH for git repo or unpacked tarball, for
# installed versions it's empty
env["PATH"] = os.pathsep.join(
list(const.PATH_FORCED_PREPEND) + [os.environ["PATH"]])
args = []
if sandbox:
if not pkgcore.spawn.is_sandbox_capable():
raise ValueError("spawn lacks sandbox capabilities")
self.__sandbox = True
spawn_func = pkgcore.spawn.spawn_sandbox
# env.update({"SANDBOX_DEBUG":"1", "SANDBOX_DEBUG_LOG":"/var/tmp/test"})
else:
spawn_func = pkgcore.spawn.spawn
# force to a neutral dir so that sandbox won't explode if
# ran from a nonexistent dir
spawn_opts["cwd"] = e_const.EBD_PATH
# Force the pipes to be high up fd wise so nobody stupidly hits 'em, we
# start from max-3 to avoid a bug in older bash where it doesn't check
# if an fd is in use before claiming it.
max_fd = min(pkgcore.spawn.max_fd_limit, 1024)
env.update({
"PKGCORE_EBD_READ_FD": str(max_fd-4),
"PKGCORE_EBD_WRITE_FD": str(max_fd-3)})
# pgid=0: Each ebuild processor is the process group leader for all its
# spawned children so everything can be terminated easily if necessary.
self.pid = spawn_func(
[const.BASH_BINARY, self.ebd, "daemonize"],
fd_pipes={0: 0, 1: 1, 2: 2, max_fd-4: cread, max_fd-3: dwrite},
returnpid=True, env=env, pgid=0, *args, **spawn_opts)[0]
os.close(cread)
os.close(dwrite)
self.ebd_write = os.fdopen(cwrite, "w")
self.ebd_read = os.fdopen(dread, "r")
# basically a quick "yo" to the daemon
self.write("dude?")
if not self.expect("dude!"):
logger.error("error in server coms, bailing.")
raise InitializationError(
"expected 'dude!' response from ebd, which wasn't received. "
"likely a bug")
self.write(e_const.EBD_PATH)
# send PKGCORE_PYTHON_BINARY...
self.write(pkgcore.spawn.find_invoking_python())
self.write(
os.pathsep.join([
normpath(abspath(pjoin(pkgcore.__file__, os.pardir, os.pardir))),
os.environ.get('PYTHONPATH', '')])
)
if self.__sandbox:
#.........这里部分代码省略.........
开发者ID:den4ix,项目名称:pkgcore,代码行数:101,代码来源:processor.py
示例20: config_from_make_conf
def config_from_make_conf(location="/etc/", profile_override=None, **kwargs):
"""
generate a config from a file location
:param location: location the portage configuration is based in,
defaults to /etc
:param profile_override: profile to use instead of the current system
profile, i.e. the target of the /etc/portage/make.profile
(or deprecated /etc/make.profile) symlink
"""
# this actually differs from portage parsing- we allow
# make.globals to provide vars used in make.conf, portage keeps
# them separate (kind of annoying)
config_root = os.environ.get("PORTAGE_CONFIGROOT", "/")
base_path = pjoin(config_root, location.strip("/"))
portage_base = pjoin(base_path, "portage")
# this isn't preserving incremental behaviour for features/use
# unfortunately
conf_dict = {}
try:
load_make_config(conf_dict, pjoin(base_path, 'make.globals'))
except errors.ParsingError as e:
if not getattr(getattr(e, 'exc', None), 'errno', None) == errno.ENOENT:
raise
try:
if 'PKGCORE_REPO_PATH' in os.environ:
config_path = pjoin(os.environ['PKGCORE_REPO_PATH'], 'config')
else:
config_path = pjoin(
config_root, sys.prefix.lstrip('/'), 'share/pkgcore/config')
load_make_config(conf_dict, pjoin(config_path, 'make.globals'))
except IGNORED_EXCEPTIONS:
raise
except:
raise_from(errors.ParsingError(
"failed to find a usable make.globals"))
load_make_config(
conf_dict, pjoin(base_path, 'make.conf'), required=False,
allow_sourcing=True, incrementals=True)
load_make_config(
conf_dict, pjoin(portage_base, 'make.conf'), required=False,
allow_sourcing=True, incrementals=True)
root = os.environ.get("ROOT", conf_dict.get("ROOT", "/"))
gentoo_mirrors = [
x.rstrip("/") + "/distfiles" for x in conf_dict.pop("GENTOO_MIRRORS", "").split()]
# this is flawed... it'll pick up -some-feature
features = conf_dict.get("FEATURES", "").split()
new_config = {}
triggers = []
def add_trigger(name, kls_path, **extra_args):
d = extra_args.copy()
d['class'] = kls_path
new_config[name] = basics.ConfigSectionFromStringDict(d)
triggers.append(name)
# sets...
add_sets(new_config, root, portage_base)
user_profile_path = pjoin(base_path, "portage", "profile")
add_profile(new_config, base_path, user_profile_path, profile_override)
kwds = {
"class": "pkgcore.vdb.ondisk.tree",
"location": pjoin(root, 'var', 'db', 'pkg'),
"cache_location": pjoin(
config_root, 'var', 'cache', 'edb', 'dep', 'var', 'db', 'pkg'),
}
new_config["vdb"] = basics.AutoConfigSection(kwds)
# options used by rsync-based syncers
rsync_opts = isolate_rsync_opts(conf_dict)
repo_opts = {}
overlay_syncers = {}
try:
default_repo_opts, repo_opts = load_repos_conf(
pjoin(portage_base, 'repos.conf'))
except errors.ParsingError as e:
if not getattr(getattr(e, 'exc', None), 'errno', None) == errno.ENOENT:
raise
if repo_opts:
main_repo_id = default_repo_opts['main-repo']
main_repo = repo_opts[main_repo_id]['location']
overlay_repos = [opts['location'] for repo, opts in repo_opts.iteritems()
if opts['location'] != main_repo]
main_syncer = repo_opts[main_repo_id].get('sync-uri', None)
else:
# fallback to PORTDIR and PORTDIR_OVERLAY settings
main_repo = normpath(os.environ.get(
"PORTDIR", conf_dict.pop("PORTDIR", "/usr/portage")).strip())
overlay_repos = os.environ.get(
#.........这里部分代码省略.........
开发者ID:vapier,项目名称:pkgcore,代码行数:101,代码来源:portage_conf.py
注:本文中的snakeoil.osutils.normpath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论