From 2873a22d16020d924e1b8666217d1a1c6c5cbf05 Mon Sep 17 00:00:00 2001 From: asamoukin Date: Tue, 13 Jan 2009 09:52:29 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5:=20os=5Froot=5Fdev=20-=20=D0=BA=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=81?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B:=20os=5Froot=5Ftype=20-=20?= =?UTF-8?q?=D1=82=D0=B8=D0=BF=20=D0=BD=D0=BE=D1=81=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BA=D0=BE=D1=80=D0=BD=D0=B5=D0=B2=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B0=20(ram,=20hdd,=20?= =?UTF-8?q?usb-hdd,=20livecd)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.calculate.ru/calculate2/calculate-lib/trunk@724 c91db197-33c1-4113-bf15-f8a5c547ca64 --- pym/cl_fill.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- pym/cl_vars.py | 8 +++++++- 2 files changed, 51 insertions(+), 2 deletions(-) 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