summaryrefslogtreecommitdiffstats
path: root/booty
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-03-09 13:19:55 +0100
committerHans de Goede <hdegoede@redhat.com>2009-03-09 21:14:15 +0100
commit9b23fb1cd22f6f2cc4f6b18897e65ab1e4d68328 (patch)
tree391089f89a236f409bf70952db3e71a199832ef6 /booty
parente60e58b1f7a659b448f4080075b399538878c501 (diff)
downloadanaconda-9b23fb1cd22f6f2cc4f6b18897e65ab1e4d68328.tar.gz
anaconda-9b23fb1cd22f6f2cc4f6b18897e65ab1e4d68328.tar.xz
anaconda-9b23fb1cd22f6f2cc4f6b18897e65ab1e4d68328.zip
Fix booty for dmraid
Booty was expecting the xxxxxxx part of /dev/xxxxxx paths instead of new storage device names, this patch fixes this, making booty work on dmraid with the new storage code.
Diffstat (limited to 'booty')
-rw-r--r--booty/alpha.py4
-rw-r--r--booty/bootloaderInfo.py2
-rw-r--r--booty/checkbootloader.py18
-rw-r--r--booty/ppc.py2
-rw-r--r--booty/sparc.py2
-rw-r--r--booty/util.py9
-rw-r--r--booty/x86.py51
7 files changed, 47 insertions, 41 deletions
diff --git a/booty/alpha.py b/booty/alpha.py
index abd3a636a..ca715560d 100644
--- a/booty/alpha.py
+++ b/booty/alpha.py
@@ -7,13 +7,13 @@ from util import getDiskPart
class alphaBootloaderInfo(bootloaderInfo):
def wholeDevice (self, path):
- (device, foo) = getDiskPart(path)
+ (device, foo) = getDiskPart(path, self.storage)
return device
def partitionNum (self, path):
# getDiskPart returns part numbers 0-based; we need it one based
# *sigh*
- (foo, partitionNumber) = getDiskPart(path)
+ (foo, partitionNumber) = getDiskPart(path, self.storage)
return partitionNumber + 1
def writeAboot(self, instRoot, bl, kernelList,
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index f9f684b95..2fdf16ab7 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -295,7 +295,7 @@ class bootloaderInfo:
def setDevice(self, device):
self.device = device
- (dev, part) = getDiskPart(device)
+ (dev, part) = getDiskPart(device, self.storage)
if part is None:
self.defaultDevice = "mbr"
else:
diff --git a/booty/checkbootloader.py b/booty/checkbootloader.py
index 7c6241676..9508e14a6 100644
--- a/booty/checkbootloader.py
+++ b/booty/checkbootloader.py
@@ -27,7 +27,7 @@ liloConfigFile = "/etc/lilo.conf"
yabootConfigFile = "/etc/yaboot.conf"
siloConfigFile = "/etc/silo.conf"
-def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
+def getRaidDisks(raidDevice, storage, raidLevel=None, stripPart=1):
rc = []
if raidLevel is not None:
try:
@@ -54,7 +54,7 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
if len(dev) == 0:
continue
if stripPart:
- disk = getDiskPart(dev)[0]
+ disk = getDiskPart(dev, storage)[0]
rc.append(disk)
else:
rc.append(dev)
@@ -62,7 +62,7 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
return rc
-def getBootBlock(bootDev, instRoot, seekBlocks=0):
+def getBootBlock(bootDev, instRoot, storage, seekBlocks=0):
"""Get the boot block from bootDev. Return a 512 byte string."""
block = " " * 512
if bootDev is None:
@@ -70,7 +70,7 @@ def getBootBlock(bootDev, instRoot, seekBlocks=0):
# get the devices in the raid device
if bootDev[5:7] == "md":
- bootDevs = getRaidDisks(bootDev[5:])
+ bootDevs = getRaidDisks(bootDev[5:], storage)
bootDevs.sort()
else:
bootDevs = [ bootDev[5:] ]
@@ -108,7 +108,7 @@ def getBootDevList(line):
rets.append(dev)
return string.join(rets)
-def getBootloaderTypeAndBoot(instRoot = "/"):
+def getBootloaderTypeAndBoot(instRoot, storage):
haveGrubConf = 1
haveLiloConf = 1
haveYabootConf = 1
@@ -150,7 +150,7 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
return ("GRUB", bootDev)
if bootDev is not None:
- block = getBootBlock(bootDev, instRoot)
+ block = getBootBlock(bootDev, instRoot, storage)
# XXX I don't like this, but it's what the maintainer suggested :(
if string.find(block, "GRUB") >= 0:
return ("GRUB", bootDev)
@@ -163,7 +163,7 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
bootDev = getBootDevString(line)
break
- block = getBootBlock(bootDev, instRoot)
+ block = getBootBlock(bootDev, instRoot, storage)
# this at least is well-defined
if block[6:10] == "LILO":
return ("LILO", bootDev)
@@ -200,8 +200,8 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
if bootDev is not None:
# XXX SILO sucks just like grub.
- if getDiskPart(bootDev)[1] != 3:
- block = getBootBlock(bootDev, instRoot, 1)
+ if getDiskPart(bootDev, storage)[1] != 3:
+ block = getBootBlock(bootDev, instRoot, storage, 1)
if block[24:28] == "SILO":
return ("SILO", bootDev)
diff --git a/booty/ppc.py b/booty/ppc.py
index a68c5938d..7ac9299a3 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -64,7 +64,7 @@ class ppcBootloaderInfo(bootloaderInfo):
f.write("init-message=\"Welcome to %s!\\nHit <TAB> for boot options\"\n\n"
% productName)
- (name, partNum) = getDiskPart(bootDev)
+ (name, partNum) = getDiskPart(bootDev, self.storage)
partno = partNum + 1 # 1 based
f.write("partition=%s\n" %(partno,))
diff --git a/booty/sparc.py b/booty/sparc.py
index 5ea45eebe..4ea2ceaf5 100644
--- a/booty/sparc.py
+++ b/booty/sparc.py
@@ -35,7 +35,7 @@ class sparcBootloaderInfo(bootloaderInfo):
f.write("message=%s\n" % (mf,))
f.write("timeout=%s\n" % (self.timeout or 50))
- (name, partNum) = getDiskPart(bootDev)
+ (name, partNum) = getDiskPart(bootDev, self.storage)
partno = partNum + 1
f.write("partition=%s\n" % (partno,))
diff --git a/booty/util.py b/booty/util.py
index f9a1b3e84..74ba561ed 100644
--- a/booty/util.py
+++ b/booty/util.py
@@ -1,10 +1,11 @@
import string
-def getDiskPart(dev):
+def getDiskPart(dev, storage):
+ path = storage.devicetree.getDeviceByName(dev).path[5:]
cut = len(dev)
- if (dev.startswith('rd/') or dev.startswith('ida/') or
- dev.startswith('cciss/') or dev.startswith('sx8/') or
- dev.startswith('mapper/') or dev.startswith('mmcblk')):
+ if (path.startswith('rd/') or path.startswith('ida/') or
+ path.startswith('cciss/') or path.startswith('sx8/') or
+ path.startswith('mapper/') or path.startswith('mmcblk')):
if dev[-2] == 'p':
cut = -1
elif dev[-3] == 'p':
diff --git a/booty/x86.py b/booty/x86.py
index de88458e8..05c9feb75 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -46,15 +46,18 @@ class x86BootloaderInfo(efiBootloaderInfo):
# Accepted values for "device" are raid1 md devices (i.e. "md0"),
# physical disks ("hda"), and real partitions on physical disks
# ("hda1"). Volume groups/logical volumes are not accepted.
- if string.split(device, '/', 1)[0] in map (lambda x: x.name, self.storage.lvs + self.storage.vgs):
+ path = self.storage.devicetree.getDeviceByName(device).path[5:]
+
+ if device in map (lambda x: x.name, self.storage.lvs + self.storage.vgs):
return []
- if device.startswith("mapper/luks-"):
+ if path.startswith("mapper/luks-"):
return []
- if device.startswith('md'):
+ if path.startswith('md'):
bootable = 0
- parts = checkbootloader.getRaidDisks(device, 1, stripPart=0)
+ parts = checkbootloader.getRaidDisks(device, self.storage,
+ raidLevel=1, stripPart=0)
parts.sort()
return parts
@@ -107,7 +110,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
cmds = []
for bootDev in bootDevs:
gtPart = self.getMatchingPart(bootDev, grubTarget)
- gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0])
+ gtDisk = self.grubbyPartitionName(getDiskPart(gtPart, self.storage)[0])
bPart = self.grubbyPartitionName(bootDev)
cmd = "root %s\n" % (bPart,)
@@ -135,18 +138,19 @@ class x86BootloaderInfo(efiBootloaderInfo):
os.rename(cf, cf + '.rpmsave')
grubTarget = bl.getDevice()
+ path = self.storage.devicetree.getDeviceByName(grubTarget).path[5:]
target = "mbr"
- if (grubTarget.startswith('rd/') or grubTarget.startswith('ida/') or
- grubTarget.startswith('cciss/') or
- grubTarget.startswith('sx8/') or
- grubTarget.startswith('mapper/')):
+ if (path.startswith('rd/') or path.startswith('ida/') or
+ path.startswith('cciss/') or
+ path.startswith('sx8/') or
+ path.startswith('mapper/')):
if grubTarget[-1].isdigit():
if grubTarget[-2] == 'p' or \
(grubTarget[-2].isdigit() and grubTarget[-3] == 'p'):
target = "partition"
- elif grubTarget[-1].isdigit() and not grubTarget.startswith('md'):
+ elif grubTarget[-1].isdigit() and not path.startswith('md'):
target = "partition"
-
+
f = open(cf, "w+")
f.write("# grub.conf generated by anaconda\n")
@@ -316,7 +320,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
devs = usedDevs.keys()
usedDevs = {}
for dev in devs:
- drive = getDiskPart(dev)[0]
+ drive = getDiskPart(dev, self.storage)[0]
if usedDevs.has_key(drive):
continue
usedDevs[drive] = 1
@@ -325,9 +329,9 @@ class x86BootloaderInfo(efiBootloaderInfo):
for drive in devs:
# XXX hack city. If they're not the sort of thing that'll
# be in the device map, they shouldn't still be in the list.
+ path = self.storage.devicetree.getDeviceByName(drive).path
if not drive.startswith('md'):
- f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive),
- drive))
+ f.write("(%s) %s\n" % (self.grubbyDiskName(drive), path))
f.close()
sysconf = '/etc/sysconfig/grub'
@@ -356,10 +360,10 @@ class x86BootloaderInfo(efiBootloaderInfo):
return ""
def getMatchingPart(self, bootDev, target):
- bootName, bootPartNum = getDiskPart(bootDev)
+ bootName, bootPartNum = getDiskPart(bootDev, self.storage)
devices = self.getPhysicalDevices(target)
for device in devices:
- name, partNum = getDiskPart(device)
+ name, partNum = getDiskPart(device, self.storage)
if name == bootName:
return device
return devices[0]
@@ -368,7 +372,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
return "hd%d" % self.drivelist.index(name)
def grubbyPartitionName(self, dev):
- (name, partNum) = getDiskPart(dev)
+ (name, partNum) = getDiskPart(dev, self.storage)
if partNum != None:
return "(%s,%d)" % (self.grubbyDiskName(name), partNum)
else:
@@ -448,23 +452,24 @@ class x86BootloaderInfo(efiBootloaderInfo):
# so we have to do shenanigans to get updated grub installed...
# steal some more code above
try:
- bootDev = self.storage.fsset.mountpoints["/boot"]
+ bootDev = self.storage.fsset.mountpoints["/boot"].name
grubPath = "/grub"
cfPath = "/"
except KeyError:
- bootDev = self.storage.fsset.rootDevice
+ bootDev = self.storage.fsset.rootDevice.name
grubPath = "/boot/grub"
cfPath = "/boot/"
masterBootDev = bootDev
if masterBootDev[0:2] == 'md':
- rootDevs = checkbootloader.getRaidDisks(masterBootDev, raidLevel=1,
- stripPart = 0)
+ rootDevs = checkbootloader.getRaidDisks(masterBootDev,
+ self.storage, raidLevel=1, stripPart=0)
else:
rootDevs = [masterBootDev]
if theDev[5:7] == 'md':
- stage1Devs = checkbootloader.getRaidDisks(theDev[5:], raidLevel=1)
+ stage1Devs = checkbootloader.getRaidDisks(theDev[5:], self.storage,
+ raidLevel=1)
else:
stage1Devs = [theDev[5:]]
@@ -478,7 +483,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
grubbyRootPart = self.grubbyPartitionName(rootDevs[0])
for rootDev in rootDevs:
- testGrubbyRootDev = getDiskPart(rootDev)[0]
+ testGrubbyRootDev = getDiskPart(rootDev, self.storage)[0]
testGrubbyRootDev = self.grubbyPartitionName(testGrubbyRootDev)
if grubbyStage1Dev == testGrubbyRootDev: