diff --git a/pym/cl_fill.py b/pym/cl_fill.py index 37495da..4436511 100755 --- a/pym/cl_fill.py +++ b/pym/cl_fill.py @@ -16,6 +16,7 @@ import re import os +import types import cl_utils import cl_base @@ -131,4 +132,46 @@ class fillVars(object, cl_base.glob_attr): def get_os_arch_machine(self): """архитектура процессора""" march = self._runos("""%s uname -m"""%self.path_env) - return march \ No newline at end of file + return march + + def get_os_root_dev(self): + """корневой раздел файловой системы""" + for record in open('/proc/cmdline','rb').readlines(): + re_res=re.search('^root=(\/dev\/[a-z]+[0-9]).*',record.strip()) + if re_res: + return re_res.group(1) + else: + mountLunes = self._runos("""%s mount"""%self.path_env) + if type(mountLunes) == types.ListType: + root_dev = mountLunes[0].split("on / type")[0].strip() + if root_dev: + return root_dev + return "" + + def get_os_root_type(self): + """тип носителя (ram, hdd, livecd)""" + mountLunes = self._runos("""%s mount"""%self.path_env) + rootType = "hdd" + if type(mountLunes) == types.ListType: + for line in mountLunes: + if "/dev/loop0 on / type" in line: + rootType = "ram" + break + if rootType == "ram" and os.path.exists("/mnt/livecd"): + rootType = "livecd" + return rootType + rootDev = self.Get("os_root_dev") + if rootType != "ram" and rootDev: + slpRootDev = rootDev.split("/dev/") + if len(slpRootDev) == 2: + rDev = slpRootDev[1] + devLines = self._runos("%s LANG=C ls -la /dev/disk/by-id/"\ + %self.path_env) + if type(devLines) == types.ListType: + for line in devLines: + if rDev in line and "usb-" in line: + rootType = "usb-hdd" + break + return rootType + else: + return "" \ No newline at end of file diff --git a/pym/cl_vars.py b/pym/cl_vars.py index f1d0961..0b70851 100644 --- a/pym/cl_vars.py +++ b/pym/cl_vars.py @@ -59,4 +59,10 @@ class Data: os_arch_machine = {} # обрабатываемый файл профиля - cl_pass_file = {'mode':"w"} \ No newline at end of file + cl_pass_file = {'mode':"w"} + + # корневой раздел файловой системы + os_root_dev = {} + + # тип носителя (ram, hdd, usb-hdd, livecd) + os_root_type = {} \ No newline at end of file