summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Vykydal <rvykydal@redhat.com>2009-07-29 14:00:10 +0200
committerRadek Vykydal <rvykydal@redhat.com>2009-07-30 11:59:02 +0200
commit5833101c41beb064efb22670e1392470484b4c99 (patch)
tree2a0a07c9e4ae8f016f4a4cc0b87b1fcba03ca99f
parent84e4a0281a30eaeb8a0e73d15ecd36a8ab9af0e8 (diff)
downloadanaconda-5833101c41beb064efb22670e1392470484b4c99.tar.gz
anaconda-5833101c41beb064efb22670e1392470484b4c99.tar.xz
anaconda-5833101c41beb064efb22670e1392470484b4c99.zip
Update device.map when upgrading (#513393)
-rw-r--r--booty/x86.py28
1 files changed, 28 insertions, 0 deletions
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