From ec86249e99c236c81776d4053534245e2ca43a95 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Thu, 21 Jul 2011 15:45:58 +0400 Subject: [PATCH] Add condition for grub install. --- pym/cl_fill_install.py | 5 +++++ pym/cl_install.py | 36 +++++++++++++++++++++++++++++++----- pym/cl_vars_install.py | 3 +++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index a0cfdd7..8eb1f73 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -251,6 +251,7 @@ class fillVars(object, glob_attr): continue device = props['DEVNAME'] device_hash[device] = {} + device_hash[device]['table'] = props.get('ID_PART_TABLE_TYPE','') device_hash[device]['map'] = mapnum if device in usbdevices: removablePath = '/sys/block/%s/removable'%device @@ -491,6 +492,10 @@ class fillVars(object, glob_attr): """Map number for grub""" return self.getAttributeFromHash('os_device_hash','map') + def get_os_device_table(self): + """Table on device""" + return self.getAttributeFromHash('os_device_hash','table') + def get_os_install_grub_devicemap_conf(self): """Content of device.map file for grub""" rootType = self.Get('os_install_root_type') diff --git a/pym/cl_install.py b/pym/cl_install.py index 887dd43..11d95a0 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -1492,6 +1492,24 @@ class cl_install(color_print, SignalInterrupt): ('os_install_disk_options',new_options), ('os_install_bind_path',new_bind_src), ('os_install_bind_mountpoint',new_bind_dest))) + if not self.clVars.Get('os_grub2_path'): + if not self.checkForLegacyGrub(): + return False + return True + + def checkForLegacyGrub(self): + """Check current disk configuration for installation for install + legacy grub""" + bootDiskType = varSelect("os_disk_type",where="os_install_disk_mount", + eq="/boot") + rootDiskType = varSelect("os_disk_type",where="os_install_disk_mount", + eq="/") + bootDiskType = bootDiskType or rootDiskType + if "lvm" in bootDiskType or "raid" in bootDiskType: + self.printERROR( + _("Legacy grub not support boot from raid or lvm without" + " separate /boot partition")) + return False return True def setUsers(self,listUsers): @@ -1503,11 +1521,12 @@ class cl_install(color_print, SignalInterrupt): self.clVars.Set('cl_migrate_user', migrateUsers, force=True) return True - def setMBR(self, mbrDisk): - """Set mbr by param or get from variables""" + def setBR(self, mbrDisk): + """Set boot record on disk by param or get from variables""" bootDiskGrub = "" if mbrDisk == "off": self.clVars.Set('os_install_mbr',"",force=True) + return True elif mbrDisk: if filter(lambda x: x == mbrDisk, self.clVars.Get('os_device_dev')): @@ -1515,6 +1534,13 @@ class cl_install(color_print, SignalInterrupt): else: self.printERROR(_("Cann't found disk '%s'")%mbrDisk) return False + mbr = self.clVars.Get('os_install_mbr') + tableOnBootDisk = self.varSelect('os_device_table', + where="os_device_dev",eq='mbr') + if not tableOnBootDisk: + self.printERROR(_("Disk '%s' without partition table cann't " + "contains boot record")%mbr) + return False return True def createListOptions(self): @@ -1561,12 +1587,12 @@ class cl_install(color_print, SignalInterrupt): return True def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers, - mbrDisk): - """Set install options (set users, disks and mbr""" + brDisk): + """Set install options (set users, disks and boot record""" try: if self.setUsers(listUsers) and \ self.setDisks(listDisks,listBinds,listSwaps) and \ - self.setMBR(mbrDisk): + self.setBR(brDisk): return self.createListOptions() else: return False diff --git a/pym/cl_vars_install.py b/pym/cl_vars_install.py index ed7ef81..115db89 100644 --- a/pym/cl_vars_install.py +++ b/pym/cl_vars_install.py @@ -123,6 +123,9 @@ class Data: # map number for grub os_device_map = {} + # table for device + os_device_table = {} + # content of device.map file for grub os_install_grub_devicemap_conf = {}