From 5833101c41beb064efb22670e1392470484b4c99 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Wed, 29 Jul 2009 14:00:10 +0200 Subject: Update device.map when upgrading (#513393) --- booty/x86.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/booty/x86.py b/booty/x86.py index 3890e698d..f90cb86da 100644 --- a/booty/x86.py +++ b/booty/x86.py @@ -417,6 +417,31 @@ class x86BootloaderInfo(efiBootloaderInfo): return config + def updateDeviceMap(self, instRoot): + if os.access(instRoot + "/boot/grub/device.map", os.R_OK): + f = open(instRoot + "/boot/grub/device.map", "r") + updatedlines = [] + update = False + for line in f: + line = line.strip() + if line.startswith('(hd'): + (grubdisk, path) = line.split()[:2] + i = int(grubdisk.lstrip('(hd ').rstrip(') ')) + actual_path = self.storage.devicetree.getDeviceByName(self.drivelist[i]).path + if path != actual_path: + line = "%s %s" % (grubdisk, actual_path) + update = True + updatedlines.append(line) + f.close() + + if update: + os.rename(instRoot + "/boot/grub/device.map", + instRoot + "/boot/grub/device.map.rpmsave") + f = open(instRoot + "/boot/grub/device.map", "w+") + upd_comment = "# file updated by anaconda\n" + f.write(upd_comment + '\n'.join(updatedlines) + '\n') + f.close() + # this is a hackish function that depends on the way anaconda writes # out the grub.conf with a #boot= comment # XXX this falls into the category of self.doUpgradeOnly @@ -450,6 +475,9 @@ class x86BootloaderInfo(efiBootloaderInfo): # migrate info to /etc/sysconfig/grub self.writeSysconfig(instRoot, theDev) + # update device.map + self.updateDeviceMap(instRoot) + # more suckage. grub-install can't work without a valid /etc/mtab # so we have to do shenanigans to get updated grub installed... # steal some more code above -- cgit