From 9c4050de123950d7a4ccc70d5f784b6b7828ab22 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Wed, 11 Aug 2010 15:43:44 +0400 Subject: [PATCH] Add using cl_install_root_from --- pym/cl_fill_install.py | 20 ++++++++++++-------- pym/cl_install.py | 21 +++++++-------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 6af8e3f..fcec051 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -782,8 +782,14 @@ class fillVars(object, glob_attr): return self.Get('os_root_type') def get_os_install_dev_from(self): - if self.Get('os_root_type') == "hdd": - return self.Get('os_root_dev') + """Detect previous system""" + calculate1ini = "/etc/calculate/calculate.ini" + calculate1param = "install.devfrom" + if pathexists(calculate1ini): + return reduce(lambda x,y: [y.rpartition('=')[2].strip()], + filter(lambda x: x.partition("=")[0] == calculate1param, + open(calculate1ini,"r")), + None) else: return "" @@ -885,12 +891,10 @@ class fillVars(object, glob_attr): reGrubEntry = re.compile("title.*?(?=title|$)", re.S | re.I ) grubconf = reRemoveComments.sub("",open(pathGrubConf,'r').read()) roothd = filter(lambda x: x[1] == '/', - zip(self.objVar.Get('os_disk_dev'), - self.objVar.Get('os_install_disk_mount'))) + zip(self.Get('os_disk_dev'), + self.Get('os_install_disk_mount'))) if roothd: roothd = "root=%s" % roothd[0][0] - replace = ("".join(filter(lambda x: not roothd in x, + return ("".join(filter(lambda x: not roothd in x, reGrubEntry.findall(grubconf)))).strip() - textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\ - textTemplateTmp[resS.end():] - return textTemplateTmp + return "" diff --git a/pym/cl_install.py b/pym/cl_install.py index d1cfaf0..1a1aba3 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -753,7 +753,7 @@ class cl_install(color_print): listDisks = map(convObj, listDisks) # detect previous system if not specified root partition if not filter(lambda x: x['mountPoint'] == '/',listDisks): - prevRootDev = self.detectPreviousSystem() + prevRootDev = self.clVars.Get('os_install_dev_from') if prevRootDev: listDisks += map(convObj, [{'mountPoint': '', 'options': [], @@ -1041,16 +1041,6 @@ class cl_install(color_print): else: return "" - def detectPreviousSystem(self): - """Detect previous system""" - calculate1ini = "/etc/calculate/calculate.ini" - calculate1param = "install.devfrom" - if pathexists(calculate1ini): - return reduce(lambda x,y: [y.rpartition('=')[2].strip()], - filter(lambda x: x.partition("=")[0] == calculate1param, - open(calculate1ini,"r")), - None) - def installBootloader(self,target, grubDisk="0"): """Install boot loader @@ -1244,8 +1234,11 @@ class cl_install(color_print): return True def writeInstallVars(self): - if not self.clVars.WriteVars(header="install"): - raise InstallError(self.getError()) + if self.Get('os_root_type') == 'hdd': + self.clVars.Write("os_install_dev_from", + self.clVars.Get('os_root_dev'), header="install") + #if not self.clVars.WriteVars(header="install"): + # raise InstallError(self.getError()) def installSystem(self, force=False, bootDisk=None, users=[]): """install System by current variable enviroment""" @@ -1370,7 +1363,7 @@ the system") + " (yes/no)" # install distributive self.printSUCCESS( _("Unpacking system image into target")+" ... ",printBR=False) - self.clVars('os_grub_conf') + self.clVars.Get('os_grub_conf') targetDistr.installFrom(sourceDistr) self.printSUCCESS("Unpacking complete")