From e7343378930f6de8c42e10d80056a098b198ad5b Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Wed, 11 Aug 2010 15:23:14 +0400 Subject: [PATCH] Fix getting grub for newsystem in multipartition --- pym/cl_fill_install.py | 18 ++++++++++++++++++ pym/cl_install.py | 1 + pym/cl_vars_install.py | 3 +++ 3 files changed, 22 insertions(+) diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 573c204..6af8e3f 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -876,3 +876,21 @@ class fillVars(object, glob_attr): def get_os_install_initrd_install(self): return self.getInitrd(suffix="install") + def get_os_grub_conf(self): + """Use for generate grub.conf for new system""" + pathGrubConf = "/boot/grub/grub.conf" + replace = "" + if os.access(pathGrubConf,os.R_OK): + reRemoveComments = re.compile("(^|\n)\s*#[^\n]*?(?=\n|$)", re.S) + 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'))) + if roothd: + roothd = "root=%s" % roothd[0][0] + replace = ("".join(filter(lambda x: not roothd in x, + reGrubEntry.findall(grubconf)))).strip() + textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\ + textTemplateTmp[resS.end():] + return textTemplateTmp diff --git a/pym/cl_install.py b/pym/cl_install.py index 5e0d1e5..d1cfaf0 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -1370,6 +1370,7 @@ the system") + " (yes/no)" # install distributive self.printSUCCESS( _("Unpacking system image into target")+" ... ",printBR=False) + self.clVars('os_grub_conf') targetDistr.installFrom(sourceDistr) self.printSUCCESS("Unpacking complete") diff --git a/pym/cl_vars_install.py b/pym/cl_vars_install.py index 7277ae7..5e05d82 100644 --- a/pym/cl_vars_install.py +++ b/pym/cl_vars_install.py @@ -261,3 +261,6 @@ class Data: # install initramfs filename os_install_initrd_install = {} + + # current grub + os_grub_conf = {}