Added cl_chroot_status from calculate-builder.

develop
Mike Hiretsky 14 years ago
parent 69f50d57b6
commit 37051d38e9

@ -607,6 +607,13 @@ class fillVars(varsShare):
else:
return ""
def get_cl_chroot_status(self):
"""Detect chroot mode by mtab content"""
try:
return "on" if self.isChroot(os.getpid()) else "off"
except:
return "off"
def get_os_scratch(self):
"""Current system is scratch"""
if self.Get('os_root_type') == 'livecd':

@ -61,6 +61,9 @@ class Data:
# paths to clt-template files
cl_template_clt_path = {'hide':True}
# is shell in chroot
cl_chroot_status = {'hide':True}
# locale (at example: ru_RU.UTF-8)
os_locale_locale = {'hide':True}

@ -505,3 +505,21 @@ class varsShare:
reRes = reVer.search(kernelVersion)
if reRes:
return reRes.group()
reChroot = re.compile("^(?:_=.*bin/chroot|CHROOT=on)$",re.S)
def isChroot(self,pid):
"""Recursive detect chroot mode"""
if not os.access('/proc/%d/environ'%pid,R_OK):
return False
if filter(self.reChroot.match,
open('/proc/%d/environ'%pid,'r').read().split('\x00')):
return True
else:
ppid = filter(lambda x:x.startswith('PPid:'),
open('/proc/%d/status'%pid,'r').readlines())[0]
ppid = int(ppid.strip().partition('\t')[2])
if ppid == 0:
return False
else:
return self.isChroot(ppid)

Loading…
Cancel
Save