|
|
|
@ -603,7 +603,7 @@ def stderr_devnull():
|
|
|
|
|
sys.stderr = oldstderr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PortageConfigProxy(object):
|
|
|
|
|
class PortageConfigWrapper(object):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self._dict = {}
|
|
|
|
|
self.repositories = []
|
|
|
|
@ -618,33 +618,46 @@ class PortageConfigProxy(object):
|
|
|
|
|
return item in self._dict
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def getconfig(cls, chroot):
|
|
|
|
|
from portage.package.ebuild.config import config
|
|
|
|
|
def getconfig_chroot(cls, chroot):
|
|
|
|
|
return cls.getconfig_python(process("/usr/bin/chroot",
|
|
|
|
|
chroot, "/usr/bin/python3"))
|
|
|
|
|
|
|
|
|
|
def target(chroot_path, queue):
|
|
|
|
|
@classmethod
|
|
|
|
|
def getconfig(cls):
|
|
|
|
|
return cls.getconfig_python(process("/usr/bin/python3"))
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def getconfig_python(cls, pythonprocess):
|
|
|
|
|
import json
|
|
|
|
|
pythonprocess.write(
|
|
|
|
|
"from portage.package.ebuild.config import config\n"
|
|
|
|
|
"import json\n"
|
|
|
|
|
"c = config()\n"
|
|
|
|
|
"obj = {}\n"
|
|
|
|
|
"for key in ('CONFIG_PROTECT_MASK', 'CONFIG_PROTECT',\n"
|
|
|
|
|
" 'FEATURES', 'DISTDIR',\n"
|
|
|
|
|
" 'PKGDIR', 'EMERGE_DEFAULT_OPTS', 'LINGUAS'):\n"
|
|
|
|
|
" obj[key] = c[key]\n"
|
|
|
|
|
"obj['repositories'] = {}\n"
|
|
|
|
|
"for x in c.repositories:\n"
|
|
|
|
|
" obj['repositories'][x.name] = x.location\n"
|
|
|
|
|
"print(json.dumps(obj))\n")
|
|
|
|
|
pythonprocess.stdin.close()
|
|
|
|
|
if pythonprocess.success():
|
|
|
|
|
data = pythonprocess.read()
|
|
|
|
|
try:
|
|
|
|
|
os.chroot(chroot_path)
|
|
|
|
|
with stderr_devnull():
|
|
|
|
|
c = config()
|
|
|
|
|
c = json.loads(data)
|
|
|
|
|
obj = cls()
|
|
|
|
|
for key in ('CONFIG_PROTECT_MASK', 'CONFIG_PROTECT',
|
|
|
|
|
'FEATURES',
|
|
|
|
|
'FEATURES', 'DISTDIR',
|
|
|
|
|
'PKGDIR', 'EMERGE_DEFAULT_OPTS', 'LINGUAS'):
|
|
|
|
|
obj[key] = c[key]
|
|
|
|
|
obj.repositories = [RepoConfigProxy(x.name, x.location)
|
|
|
|
|
for x in c.repositories]
|
|
|
|
|
queue.put(obj)
|
|
|
|
|
except Exception:
|
|
|
|
|
queue.put(None)
|
|
|
|
|
|
|
|
|
|
queue = multiprocessing.Queue()
|
|
|
|
|
p = multiprocessing.Process(target=target, args=(chroot, queue))
|
|
|
|
|
p.start()
|
|
|
|
|
p.join(10)
|
|
|
|
|
return queue.get(timeout=10)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return "EmergeConfig"
|
|
|
|
|
obj.repositories = [RepoConfigProxy(name, location)
|
|
|
|
|
for name, location in c['repositories'].items()]
|
|
|
|
|
return obj
|
|
|
|
|
except ValueError as e:
|
|
|
|
|
pass
|
|
|
|
|
raise VariableError(_("Failed to receive portage config"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClEmergeConfig(ReadonlyVariable):
|
|
|
|
@ -657,16 +670,11 @@ class VariableClEmergeConfig(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
try:
|
|
|
|
|
if self.systemRoot == '/':
|
|
|
|
|
from portage.package.ebuild.config import config
|
|
|
|
|
|
|
|
|
|
config.__str__ = lambda self: "EmergeConfig"
|
|
|
|
|
with stderr_devnull():
|
|
|
|
|
c = config()
|
|
|
|
|
if c.repositories.repoLocationList(): # and c["LINGUAS"]:
|
|
|
|
|
return c
|
|
|
|
|
c = PortageConfigWrapper.getconfig()
|
|
|
|
|
else:
|
|
|
|
|
c = PortageConfigProxy.getconfig(self.systemRoot)
|
|
|
|
|
return c or ""
|
|
|
|
|
c = PortageConfigWrapper.getconfig_chroot(self.systemRoot)
|
|
|
|
|
c.__str__ = lambda self: "EmergeConfig"
|
|
|
|
|
return c
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
return ""
|
|
|
|
|