summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>2000-01-25 19:09:38 +0000
committerErik Troan <ewt@redhat.com>2000-01-25 19:09:38 +0000
commit6a9410f38252dc50035a5ff1d22ea2c506af4e70 (patch)
treebf5fb0da95b37a950f2d2e29decfa1adb5a8b40a
parentfa78894d50846940538ce364ae2773140f0cdc53 (diff)
downloadanaconda-6a9410f38252dc50035a5ff1d22ea2c506af4e70.tar.gz
anaconda-6a9410f38252dc50035a5ff1d22ea2c506af4e70.tar.xz
anaconda-6a9410f38252dc50035a5ff1d22ea2c506af4e70.zip
reworked lilo config into separate lilo.py, fixed numerous bugs (now
merges upgraded lilo.cf file into new one)
-rw-r--r--iw/lilo.py72
-rw-r--r--lilo.py292
-rw-r--r--text.py2
-rw-r--r--textw/lilo.py56
-rw-r--r--textw/partitioning.py7
-rw-r--r--todo.py209
6 files changed, 381 insertions, 257 deletions
diff --git a/iw/lilo.py b/iw/lilo.py
index 7e31dafd5..d4e6c5032 100644
--- a/iw/lilo.py
+++ b/iw/lilo.py
@@ -31,17 +31,34 @@ class LiloWindow (InstallWindow):
self.todo.bootdisk = 0
if self.lilo.get_active ():
- self.todo.setLiloLocation (None)
- elif self.todo.allowLiloLocationConfig():
+ liloDevice = None
+ elif self.todo.lilo.allowLiloLocationConfig(self.todo.fstab):
if self.mbr.get_active ():
- self.todo.setLiloLocation ("mbr")
+ liloDevice = "mbr"
else:
- self.todo.setLiloLocation ("partition")
-
- self.todo.setLiloImages(self.images)
-
- self.todo.liloLinear = self.linearCheck.get_active()
- self.todo.liloAppend = self.appendEntry.get_text()
+ liloDevice = "partition"
+
+ images = {}
+ default = None
+ linuxDevice = None
+ for index in range(self.numImages):
+ device = self.imageList.get_text(index, 1)[5:]
+ type = self.types[index]
+ label = self.imageList.get_text(index, 3)
+ images[device] = (label, type)
+ if self.default == index:
+ default = label
+ if type == 2:
+ linuxDevice = label
+
+ if not default:
+ default = linuxDevice
+
+ self.todo.lilo.setDevice(liloDevice)
+ self.todo.lilo.setLiloImages(images)
+ self.todo.lilo.setLinear(self.linearCheck.get_active())
+ self.todo.lilo.setAppend(self.appendEntry.get_text())
+ self.todo.lilo.setDefault(default)
def typeName(self, type):
if (type == 2):
@@ -63,7 +80,8 @@ class LiloWindow (InstallWindow):
self.imageList, self.liloLocationBox, self.radioBox ]:
n.set_sensitive (state)
- if state and not self.todo.allowLiloLocationConfig():
+ if state and not \
+ self.todo.lilo.allowLiloLocationConfig(self.todo.fstab):
self.liloLocationBox.set_sensitive(0)
self.mbr.set_sensitive(0)
self.part.set_sensitive(0)
@@ -99,13 +117,12 @@ class LiloWindow (InstallWindow):
def labelSelected(self, *args):
index = self.imageList.selection[0]
device = self.imageList.get_text(index, 1)
+ type = self.imageList.get_text(index, 2)
label = self.imageList.get_text(index, 3)
self.deviceLabel.set_text(_("Partition") + ": " + device)
device = device[5:]
- type = self.images[device][1]
-
self.typeLabel.set_text(_("Type") + ":" + self.typeName(type))
self.labelEntry.set_text(label)
@@ -124,7 +141,8 @@ class LiloWindow (InstallWindow):
self.todo.bootdisk = 1
return None
- self.images = self.todo.getLiloImages()
+ (imageList, defaultLabel) = \
+ self.todo.lilo.getLiloImages(self.todo.fstab)
self.ignoreSignals = 0
if self.todo.fstab.mountList()[0][0] != '/': return None
@@ -157,10 +175,10 @@ class LiloWindow (InstallWindow):
self.linearCheck = GtkCheckButton(
_("Use linear mode (needed for some SCSI drives)"))
- self.linearCheck.set_active(self.todo.liloLinear)
+ self.linearCheck.set_active(self.todo.lilo.getLinear())
self.radioBox.attach(self.linearCheck, 0, 2, 4, 5)
- if not self.todo.allowLiloLocationConfig():
+ if not self.todo.lilo.allowLiloLocationConfig(self.todo.fstab):
self.liloLocationBox.set_sensitive(0)
self.mbr.set_sensitive(0)
self.part.set_sensitive(0)
@@ -169,8 +187,8 @@ class LiloWindow (InstallWindow):
label = GtkLabel(_("Kernel parameters") + ":")
label.set_alignment(0.0, 0.5)
self.appendEntry = GtkEntry()
- if self.todo.liloAppend:
- self.appendEntry.set_text(self.todo.liloAppend)
+ if self.todo.lilo.getAppend():
+ self.appendEntry.set_text(self.todo.lilo.getAppend())
box = GtkHBox(FALSE, 5)
box.pack_start(label)
box.pack_start(self.appendEntry)
@@ -199,26 +217,28 @@ class LiloWindow (InstallWindow):
self.imageList = GtkCList (4,
( _("Default"), _("Device"), _("Partition type"), _("Boot label")))
- self.imageList.connect("select_row", self.labelSelected)
- sortedKeys = self.images.keys()
+ sortedKeys = imageList.keys()
sortedKeys.sort()
+ self.numImages = len(sortedKeys)
self.default = None
count = 0
+ self.types = []
for n in sortedKeys:
- (label, type) = self.images[n]
+ (label, type) = imageList[n]
+ self.types.append(type)
self.imageList.append(("", "/dev/" + n, self.typeName(type),
label))
- if (label == "linux"):
+ if (label == defaultLabel):
self.default = count
self.imageList.set_pixmap(count, 0, self.checkMark)
count = count + 1
+ self.imageList.connect("select_row", self.labelSelected)
self.imageList.columns_autosize ()
self.imageList.column_title_passive (1)
self.imageList.set_border_width (5)
- self.imageList.set_column_justification(2, JUSTIFY_CENTER)
self.deviceLabel = GtkLabel(_("Partition") + ":")
self.typeLabel = GtkLabel(_("Type") + ":")
@@ -257,4 +277,12 @@ class LiloWindow (InstallWindow):
sw.add (self.imageList)
box.pack_start (sw, TRUE)
+ where = self.todo.lilo.getDevice()
+ if not where:
+ self.lilo.set_active(1)
+ elif where == "mbr":
+ self.mbr.set_active(1)
+ else:
+ self.part.set_active(1)
+
return box
diff --git a/lilo.py b/lilo.py
index a79101cdb..708e7cdb7 100644
--- a/lilo.py
+++ b/lilo.py
@@ -1,7 +1,9 @@
import string
import os
+import isys
+import iutil
-class LiloConfiguration:
+class LiloConfigFile:
def __repr__ (self, tab = 0):
s = ""
for n in self.order:
@@ -20,14 +22,26 @@ class LiloConfiguration:
s = s + cl.__repr__(1)
return s
- def addEntry(self, item, val = None):
+ def addEntry(self, item, val = None, replace = 1):
if not self.items.has_key(item):
self.order.append(item)
+ elif not replace:
+ return
+
if (val):
self.items[item] = str(val)
else:
self.items[item] = None
+ def getEntry(self, item):
+ return self.items[item]
+
+ def getImage(self, name):
+ for (type, label, config) in self.images:
+ if label == name:
+ return (type, config)
+ raise IndexError, "unknown image %s" % (name,)
+
def addImage (self, type, name, config):
self.images.append((type, name, config))
@@ -37,6 +51,12 @@ class LiloConfiguration:
if label == name:
self.images.remove (entry)
+ def listImages (self):
+ l = []
+ for (type, label, config) in self.images:
+ l.append(label)
+ return l
+
def write(self, file):
f = open(file, "w")
f.write(self.__repr__())
@@ -57,11 +77,11 @@ class LiloConfiguration:
fields = string.split(l, '=', 1)
if (len(fields) == 2):
if (fields[0] == "image"):
- image = LiloConfiguration()
+ image = LiloConfigFile()
self.addImage(fields[0], fields[1], image)
args = None
elif (fields[0] == "other"):
- image = LiloConfiguration()
+ image = LiloConfigFile()
self.addImage(fields[0], fields[1], image)
args = None
else:
@@ -78,18 +98,272 @@ class LiloConfiguration:
def __init__(self):
self.order = []
- self.images = [] # more (type, name, LiloConfiguration) pair
+ self.images = [] # more (type, name, LiloConfigFile) pair
self.items = {}
+class LiloConfiguration:
+
+ def allowLiloLocationConfig(self, fstab):
+ bootDevice = fstab.getBootDevice()
+ if bootDevice[0:2] == "md":
+ self.setDevice(("raid", bootDevice))
+ return None
+
+ return 1
+
+ def setLiloImages(self, images):
+ self.liloImages = images
+
+ def getLiloImages(self, fstab):
+ (drives, raid) = fstab.raidList()
+
+ # rearrange the fstab so it's indexed by device
+ mountsByDev = {}
+ for (mntpoint, device, fsystem, doFormat, size) in \
+ fstab.mountList():
+ mountsByDev[device] = mntpoint
+
+ for (mntpoint, device, fstype, raidType, start, size, makeup) in raid:
+ mountsByDev[device] = mntpoint
+ drives.append(device, "", 2, 0, 0)
+
+ for (device, mntpoint, fsystem, makeup) in fstab.existingRaidList():
+ mountsByDev[device] = mntpoint
+ drives.append(device, "", 2, 0, 0)
+
+ oldImages = {}
+ for dev in self.liloImages.keys():
+ oldImages[dev] = self.liloImages[dev]
+
+ self.liloImages = {}
+ foundDos = 0
+ for (dev, devName, type, start, size) in drives:
+ # ext2 and raid partitions get listed if they're / -- we do
+ # not allow non-mounted partitions to be booted anymore as
+ # modules are so unlikely to work out as to be not worth
+ # worrying about
+ #
+ # there is a good chance we should configure them as chain
+ # loadable, but we don't
+
+ # only list dos and ext2 partitions
+ if type != 1 and type != 2:
+ continue
+
+ if (mountsByDev.has_key(dev)):
+ if mountsByDev[dev] == '/':
+ if oldImages.has_key(dev):
+ self.liloImages[dev] = oldImages[dev]
+ else:
+ self.liloImages[dev] = ("linux", 2)
+
+ if type == 1:
+ if foundDos: continue
+
+ foundDos = 1
+ isys.makeDevInode(dev, '/tmp/' + dev)
+ bootable = isys.checkBoot('/tmp/' + dev)
+ os.unlink('/tmp/' + dev)
+
+ if bootable:
+ if oldImages.has_key(dev):
+ self.liloImages[dev] = oldImages[dev]
+ else:
+ self.liloImages[dev] = ("dos", type)
+
+ # if there is no default image (self.default is None, or invalid)
+ # set the default image to the liunx partition
+ if self.default:
+ for (label, type) in self.liloImages.values():
+ if label == self.default: break
+ if label != self.default:
+ self.default = None
+
+ if not self.default:
+ for (label, type) in self.liloImages.values():
+ if type == 2:
+ self.default = label
+ break
+
+ return (self.liloImages, self.default)
+
+ def install (self, fstab):
+ # If self.liloDevice is None, skipping lilo doesn't work
+ if not self.liloDevice: return
+
+ # If the root partition is on a loopback device, lilo won't work!
+ if fstab.rootOnLoop():
+ return
+
+ if not self.liloImages:
+ self.setLiloImages(self.getLiloImages())
+
+ # on upgrade read in the lilo config file
+ if os.access (self.instPath + '/etc/lilo.conf', os.R_OK):
+ lilo.read (self.instPath + '/etc/lilo.conf')
+ lilo = LiloConfigFile ()
+
+ # Remove any invalid entries that are in the file; we probably
+ # just removed those kernels. While we're here, build an index
+ # to the already-configured (and valid) lilo images by the lilo
+ # label, as we can normally only get them by filename which isn't
+ # easily done.
+ imagesByLabel = {}
+ for image in lilo.listImages():
+ (type, sl) = lilo.getImage(image)
+ if type == "other": continue
+ if not os.access(self.instPath + image):
+ lilo.delImage(image)
+ else:
+ imagesByLabel[sl.getEntry('label')] = image
+
+ bootpart = fstab.getBootDevice()
+ boothd = fstab.getMbrDevice()
+
+ if (self.liloDevice == "mbr"):
+ liloTarget = boothd
+ elif (type(self.liloDevice) == type((1,)) and
+ self.liloDevice[0] == "raid"):
+ liloTarget = self.liloDevice[1]
+ else:
+ liloTarget = bootpart
+
+ lilo.addEntry("boot", '/dev/' + liloTarget, replace = 0)
+ lilo.addEntry("map", "/boot/map", replace = 0)
+ lilo.addEntry("install", "/boot/boot.b", replace = 0)
+ lilo.addEntry("prompt", replace = 0)
+ lilo.addEntry("timeout", "50", replace = 0)
+ if self.liloLinear:
+ lilo.addEntry("linear", replace = 0)
+
+ smpInstalled = (self.hdList.has_key('kernel-smp') and
+ self.hdList['kernel-smp'].selected)
+
+ # This is a bit odd, but old versions of Red Hat could install
+ # SMP kernels on UP systems, but (properly) configure the UP version.
+ # We don't want to undo that, but we do want folks using this install
+ # to be able to override the kernel to use during installs. This rule
+ # seems to nail this.
+ if (self.upgrade and not isys.smpAvailable()):
+ smpInstalled = 0
+
+ rootDev = fstab.getRootDevice ()
+ if rootDev:
+ # strip off the filesystem; we don't need it
+ rootDev = rootDev[0]
+ else:
+ raise RuntimeError, "Installing lilo, but there is no root device"
+
+ kernelList = []
+ otherList = []
+
+ main = self.default
+
+ for (drive, (label, liloType)) in self.liloImages.items ():
+ if (drive == rootDev) and label:
+ main = label
+ elif label:
+ otherList.append (label, "/dev/" + drive)
+
+ lilo.addEntry("default", main)
+
+ label = main
+ if (smpInstalled):
+ kernelList.append((main, self.hdList['kernel-smp'], "smp"))
+ label = main + "-up"
+
+ kernelList.append((label, self.hdList['kernel'], ""))
+
+ for (label, kernel, tag) in kernelList:
+ if imagesByLabel.has_key(label):
+ (type, sl) = lilo.getImage(imagesByLabel[label])
+ lilo.delImage(imagesByLabel[label])
+ else:
+ sl = LiloConfigFile()
+
+ kernelTag = "-%s-%s%s" % (kernel['version'], kernel['release'], tag)
+ kernelFile = "/boot/vmlinuz" + kernelTag
+
+ initrd = self.makeInitrd (kernelTag)
+
+ sl.addEntry("label", label)
+ if os.access (self.instPath + initrd, os.R_OK):
+ sl.addEntry("initrd", initrd)
+
+ sl.addEntry("read-only")
+ sl.addEntry("root", '/dev/' + rootDev)
+
+ if self.liloAppend:
+ sl.addEntry('append', '"%s"' % (self.liloAppend,))
+
+ lilo.addImage ("image", kernelFile, sl)
+
+ for (label, device) in otherList:
+ try:
+ (type, sl) = lilo.getImage(device)
+ lilo.delImage(device)
+ except IndexError:
+ sl = LiloConfigFile()
+
+ sl.addEntry("label", label)
+ lilo.addImage ("other", device, sl)
+
+ lilo.write(self.instPath + "/etc/lilo.conf")
+
+ # XXX make me "not test mode"
+ if self.setupFilesystems:
+ iutil.execWithRedirect(self.instPath + '/sbin/lilo' ,
+ [ "lilo", "-r", self.instPath ],
+ stdout = None)
+
+ def setDevice(self, device):
+ if (type(device) == type((1,))):
+ self.liloDevice = device
+ elif device != "mbr" and device != "partition" and device:
+ raise ValueError, "device must be raid, mbr, partition, or None"
+ self.liloDevice = device
+
+ def setLinear(self, linear):
+ self.liloLinear = linear
+
+ def setAppend(self, append):
+ self.liloAppend = append
+
+ def setDefault(self, default):
+ for (label, type) in self.liloImages.values():
+ if label == default:
+ self.default = default
+ return
+ raise IndexError, "unknown lilo label %s" % (default,)
+
+ def getLinear(self):
+ return self.liloLinear
+
+ def getDevice(self):
+ return self.liloDevice
+
+ def getAppend(self):
+ return self.liloAppend
+
+ def __init__(self):
+ self.liloImages = {}
+ self.liloDevice = 'mbr'
+ self.liloLinear = 1
+ self.liloAppend = None
+ self.default = None
+
+
if __name__ == "__main__":
- config = LiloConfiguration ()
- config.read ('lilo.conf')
+ config = LiloConfigFile ()
+ config.read ('/etc/lilo.conf')
print config
+ print "image list", config.listImages()
config.delImage ('/boot/vmlinuz-2.2.5-15')
print '----------------------------------'
+ config = LiloConfigFile ()
+ config.read ('/etc/lilo.conf')
print config
- config.delImage ('/dev/hda3')
print '----------------------------------'
- print config
+ print config.getImage('/boot/vmlinuz-2.2.5-15')
diff --git a/text.py b/text.py
index eeb40124e..4a72afb10 100644
--- a/text.py
+++ b/text.py
@@ -984,7 +984,7 @@ class InstallInterface:
self.screen.suspendCallback(killSelf, self.screen)
# uncomment this line to drop into the python debugger on <Ctrl+Z>
# --VERY handy--
-# self.screen.suspendCallback(debugSelf, self.screen)
+ #self.screen.suspendCallback(debugSelf, self.screen)
self.individual = Flag(0)
self.step = 0
self.dir = 1
diff --git a/textw/lilo.py b/textw/lilo.py
index b97765eba..54ba57b49 100644
--- a/textw/lilo.py
+++ b/textw/lilo.py
@@ -22,10 +22,10 @@ class LiloAppendWindow:
"aren't sure, leave this blank."))
cb = Checkbox(_("Use linear mode (needed for some SCSI drives)"),
- isOn = todo.liloLinear)
+ isOn = todo.lilo.getLinear())
entry = Entry(48, scroll = 1, returnExit = 1)
- if todo.liloAppend:
- entry.set(todo.liloAppend)
+ if todo.lilo.getAppend():
+ entry.set(todo.lilo.getAppend())
buttons = ButtonBar(screen, [(_("OK"), "ok"), (_("Skip"), "skip"),
(_("Back"), "back") ] )
@@ -44,15 +44,15 @@ class LiloAppendWindow:
if button == "skip":
todo.skipLilo = 1
- todo.setLiloLocation(None)
+ todo.lilo.setDevice(None)
else:
todo.skipLilo = 0
- todo.liloLinear = cb.selected()
+ todo.lilo.setLinear(cb.selected())
if entry.value():
- todo.liloAppend = string.strip(entry.value())
+ todo.lilo.setAppend(string.strip(entry.value()))
else:
- todo.liloAppend = None
+ todo.lilo.setAppend(None)
return INSTALL_OK
@@ -62,15 +62,15 @@ class LiloWindow:
if mount != '/': return INSTALL_NOOP
if todo.skipLilo: return INSTALL_NOOP
- if not todo.allowLiloLocationConfig():
+ if not todo.lilo.allowLiloLocationConfig(todo.fstab):
return INSTALL_NOOP
bootpart = todo.fstab.getBootDevice()
boothd = todo.fstab.getMbrDevice()
- if (todo.getLiloLocation () == "mbr"):
+ if (todo.lilo.getDevice () == "mbr"):
default = 0
- elif (todo.getLiloLocation () == "partition"):
+ elif (todo.lilo.getDevice () == "partition"):
default = 1
else:
default = 0
@@ -86,9 +86,9 @@ class LiloWindow:
buttons = [ _("OK"), _("Back") ])
if sel == 0:
- todo.setLiloLocation("mbr")
+ todo.lilo.setDevice("mbr")
else:
- todo.setLiloLocation("partition")
+ todo.lilo.setDevice("partition")
if rc == string.lower (_("Back")):
return INSTALL_BACK
@@ -101,7 +101,8 @@ class LiloImagesWindow:
device = Label("/dev/" + partition)
newLabel = Entry (20, scroll = 1, returnExit = 1, text = itemLabel)
- buttons = ButtonBar(screen, [_("Ok"), _("Clear"), _("Cancel")])
+ buttons = ButtonBar(screen, [(_("Ok"), "ok"), (_("Clear"), "clear"),
+ (_("Cancel"), "cancel")])
subgrid = Grid(2, 2)
subgrid.setField(devLabel, 0, 0, anchorLeft = 1)
@@ -114,15 +115,15 @@ class LiloImagesWindow:
g.add(buttons, 0, 1, growx = 1)
result = ""
- while (result != string.lower(_("Ok")) and result != newLabel):
+ while (result != "ok" and result != "F12" and result != newLabel):
result = g.run()
if (buttons.buttonPressed(result)):
result = buttons.buttonPressed(result)
- if (result == string.lower(_("Cancel"))):
+ if (result == "cancel"):
screen.popWindow ()
return itemLabel
- elif (result == string.lower(_("Clear"))):
+ elif (result == "clear"):
newLabel.set("")
screen.popWindow()
@@ -147,10 +148,18 @@ class LiloImagesWindow:
return "%-10s %-25s %-7s %-10s" % ( "/dev/" + device, type, default, label)
def __call__(self, screen, todo):
- images = todo.getLiloImages()
+ (images, default) = todo.lilo.getLiloImages(todo.fstab)
if not images: return INSTALL_NOOP
if todo.skipLilo: return INSTALL_NOOP
+ # the default item is kept as a label (which makes more sense for the
+ # user), but we want our listbox "indexed" by device, which so we keep
+ # the default item as a device
+ for (dev, (label, type)) in images.items():
+ if label == default:
+ default = dev
+ break
+
sortedKeys = images.keys()
sortedKeys.sort()
@@ -158,11 +167,11 @@ class LiloImagesWindow:
( _("Device"), _("Partition type"), _("Default"), _("Boot label")))
listbox = Listbox(5, scroll = 1, returnExit = 1)
- default = ""
-
for n in sortedKeys:
(label, type) = images[n]
listbox.append(self.formatDevice(type, label, n, default), n)
+ if n == default:
+ listbox.setCurrent(n)
buttons = ButtonBar(screen, [ (_("Ok"), "ok"), (_("Edit"), "edit"),
(_("Back"), "back") ] )
@@ -213,7 +222,14 @@ class LiloImagesWindow:
if (result == "back"):
return INSTALL_BACK
- todo.setLiloImages(images)
+ # find the label for the default device
+ for (dev, (label, type)) in images.items():
+ if dev == default:
+ default = label
+ break
+
+ todo.lilo.setLiloImages(images)
+ todo.lilo.setDefault(label)
return INSTALL_OK
diff --git a/textw/partitioning.py b/textw/partitioning.py
index b9930c17e..b537158d8 100644
--- a/textw/partitioning.py
+++ b/textw/partitioning.py
@@ -113,7 +113,10 @@ class AutoPartitionWindow:
if not todo.getPartitionWarningText():
todo.fstab.setRunDruid(0)
todo.fstab.setDruid(druid, todo.instClass.raidList)
- todo.allowLiloLocationConfig()
+
+ # sets up lilo for raid boot partitions during kickstart
+ todo.lilo.allowLiloLocationConfig(todo.fstab)
+
todo.fstab.formatAllFilesystems()
todo.instClass.addToSkipList("format")
return
@@ -139,7 +142,7 @@ class AutoPartitionWindow:
else:
todo.fstab.setRunDruid(0)
todo.fstab.setDruid(druid, todo.instClass.raidList)
- todo.allowLiloLocationConfig()
+ todo.lilo.allowLiloLocationConfig(todo.fstab)
todo.fstab.formatAllFilesystems()
todo.instClass.addToSkipList("format")
diff --git a/todo.py b/todo.py
index 3c32d5ceb..59f587e66 100644
--- a/todo.py
+++ b/todo.py
@@ -283,7 +283,8 @@ class ToDo:
self.ddruidReadOnly = 0
self.badBlockCheck = 0
self.bootdisk = 1
- self.liloImages = {}
+ self.lilo = LiloConfiguration()
+
# liloDevice, liloLinear, liloAppend are initialized form the
# default install class
arch = iutil.getArch ()
@@ -358,67 +359,6 @@ class ToDo:
def setTimezoneInfo(self, timezone, asUtc = 0, asArc = 0):
self.timezone = (timezone, asUtc, asArc)
- def allowLiloLocationConfig(self):
- bootDevice = self.fstab.getBootDevice()
- if bootDevice[0:2] == "md":
- self.setLiloLocation(("raid", bootDevice))
- return None
-
- return 1
-
- def setLiloImages(self, images):
- self.liloImages = images
-
- def getLiloImages(self):
- if not self.__dict__.has_key('fstab'):
- raise RuntimeError, "No fstab object"
-
- (drives, raid) = self.fstab.raidList()
-
- # rearrange the fstab so it's indexed by device
- mountsByDev = {}
- for (mntpoint, device, fsystem, doFormat, size) in \
- self.fstab.mountList():
- mountsByDev[device] = mntpoint
-
- for (mntpoint, device, fstype, raidType, start, size, makeup) in raid:
- mountsByDev[device] = mntpoint
- drives.append(device, "", 2, 0, 0)
-
- for (device, mntpoint, fsystem, makeup) in self.fstab.existingRaidList():
- mountsByDev[device] = mntpoint
- drives.append(device, "", 2, 0, 0)
-
- oldImages = {}
- for dev in self.liloImages.keys():
- oldImages[dev] = self.liloImages[dev]
-
- self.liloImages = {}
- foundDos = 0
- for (dev, devName, type, start, size) in drives:
- # ext2 and raid partitions get listed if
- # 1) they're /
- # 2) they're not mounted
-
- # only list dos and ext2 partitions
- if type != 1 and type != 2:
- continue
-
- if (mountsByDev.has_key(dev)):
- if mountsByDev[dev] == '/':
- self.liloImages[dev] = ("linux", 2)
- else:
- if not oldImages.has_key(dev):
- self.liloImages[dev] = ("", type)
- else:
- self.liloImages[dev] = oldImages[dev]
- if type == 1:
- if foundDos: continue
- foundDos = 1
- self.liloImages[dev] = ("dos", type)
-
- return self.liloImages
-
def addMount(self, device, location, fsystem, reformat = 1):
if fsystem == "swap":
ufs = 0
@@ -503,137 +443,6 @@ class ToDo:
if rc:
raise RuntimeError, "boot disk creation failed"
- def installLilo (self):
- # If self.liloDevice is None, skipping lilo doesn't work
- if not self.liloDevice: return
-
- # If the root partition is on a loopback device, lilo won't work!
- if self.fstab.rootOnLoop():
- return
-
- lilo = LiloConfiguration ()
-
- if not self.liloImages:
- self.setLiloImages(self.getLiloImages())
-
- # OK - for this release we need to just blow away the old lilo.conf
- # just like we used to.
-## # on upgrade read in the lilo config file
-## if os.access (self.instPath + '/etc/lilo.conf', os.R_OK):
-## lilo.read (self.instPath + '/etc/lilo.conf')
-
- if os.access (self.instPath + '/etc/lilo.conf', os.R_OK):
- os.rename(self.instPath + '/etc/lilo.conf',
- self.instPath + '/etc/lilo.conf.rpmsave')
-
- if os.access (self.instPath + '/etc/lilo.conf', os.R_OK):
- os.rename(self.instPath + '/etc/lilo.conf',
- self.instPath + '/etc/lilo.conf.rpmsave')
-
- bootpart = self.fstab.getBootDevice()
- boothd = self.fstab.getMbrDevice()
-
- if (type((1,)) == type(bootpart)):
- (kind, self.liloDevice) = bootpart
- elif (self.liloDevice == "mbr"):
- self.liloDevice = boothd
- else:
- self.liloDevice = bootpart
-
- if self.liloDevice:
- lilo.addEntry("boot", '/dev/' + self.liloDevice)
- lilo.addEntry("map", "/boot/map")
- lilo.addEntry("install", "/boot/boot.b")
- lilo.addEntry("prompt")
- lilo.addEntry("timeout", "50")
- if self.liloLinear:
- lilo.addEntry("linear")
-
- smpInstalled = (self.hdList.has_key('kernel-smp') and
- self.hdList['kernel-smp'].selected)
- if (self.upgrade and not isys.smpAvailable()):
- smpInstalled = 0
-
- rootDev = self.fstab.getRootDevice ()
- if rootDev:
- rootDev = rootDev[0]
- else:
- raise RuntimeError, "Installing lilo, but there is no root device"
-
- kernelList = []
- otherList = []
-
- main = "linux"
-
- for (drive, (label, liloType)) in self.liloImages.items ():
- if (drive == rootDev) and label:
- main = label
- elif label:
- otherList.append (label, "/dev/" + drive)
-
- lilo.addEntry("default", main)
-
- label = main
- if (smpInstalled):
- kernelList.append((main, self.hdList['kernel-smp'], "smp"))
- label = main + "-up"
-
- kernelList.append((label, self.hdList['kernel'], ""))
-
- for (label, kernel, tag) in kernelList:
- kernelTag = "-%s-%s%s" % (kernel['version'], kernel['release'], tag)
- initrd = self.makeInitrd (kernelTag)
-
- sl = LiloConfiguration()
-
- sl.addEntry("label", label)
- if os.access (self.instPath + initrd, os.R_OK):
- sl.addEntry("initrd", initrd)
-
- sl.addEntry("read-only")
- sl.addEntry("root", '/dev/' + rootDev)
- kernelFile = "/boot/vmlinuz" + kernelTag
-
- if self.liloAppend:
- sl.addEntry('append', '"%s"' % (self.liloAppend,))
-
- lilo.addImage ("image", kernelFile, sl)
-
- for (label, device) in otherList:
- sl = LiloConfiguration()
- sl.addEntry("label", label)
- lilo.addImage ("other", device, sl)
-
- for (liloType, name, config) in lilo.images:
- # remove entries for missing kernels (upgrade)
- if liloType == "image":
- if not os.access (self.instPath + name, os.R_OK):
- lilo.delImage (name)
- # remove entries for unbootable partitions
- elif liloType == "other":
- device = name[5:]
- isys.makeDevInode(device, '/tmp/' + device)
- if not isys.checkBoot ('/tmp/' + device):
- lilo.delImage (name)
- os.remove ('/tmp/' + device)
-
- # pass 2, remove duplicate entries
- labels = []
-
- for (liloType, name, config) in lilo.images:
- if not name in labels:
- labels.append (name)
- else: # duplicate entry, first entry wins
- lilo.delImage (name)
-
- lilo.write(self.instPath + "/etc/lilo.conf")
-
- # XXX make me "not test mode"
- if self.setupFilesystems:
- iutil.execWithRedirect(self.instPath + '/sbin/lilo' ,
- [ "lilo", "-r", self.instPath ],
- stdout = None)
-
def freeHeaderList(self):
if (self.hdList):
self.hdList = None
@@ -646,12 +455,6 @@ class ToDo:
w.pop()
return self.hdList
- def setLiloLocation(self, location):
- self.liloDevice = location
-
- def getLiloLocation (self):
- return self.liloDevice
-
def getCompsList(self):
if (not self.comps):
self.getHeaderList()
@@ -970,9 +773,9 @@ class ToDo:
todo.bootdisk = todo.instClass.getMakeBootdisk()
todo.zeroMbr = todo.instClass.zeroMbr
(where, linear, append) = todo.instClass.getLiloInformation()
- todo.liloDevice = where
- todo.liloLinear = linear
- todo.liloAppend = append
+ todo.lilo.setDevice(where)
+ todo.lilo.setLinear(linear)
+ todo.lilo.setAppend(append)
for (mntpoint, (dev, fstype, reformat)) in todo.instClass.fstab:
todo.addMount(dev, mntpoint, fstype, reformat)
@@ -1407,7 +1210,7 @@ class ToDo:
if arch == "sparc":
self.silo.installSilo ()
elif arch == "i386":
- self.installLilo ()
+ self.lilo.install (self.fstab)
elif arch == "alpha":
self.milo.write ()
else: