summaryrefslogtreecommitdiffstats
path: root/lilo.py
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>2000-01-28 17:14:09 +0000
committerMatt Wilson <msw@redhat.com>2000-01-28 17:14:09 +0000
commitff5cf9b11961385cd1ffe45504e63976a52b74dd (patch)
tree1edaeaeb69b03fc7344daa1b613105d60116c6cc /lilo.py
parente7bb99c192e824bb7ad7800760cfaebae21432af (diff)
downloadanaconda-ff5cf9b11961385cd1ffe45504e63976a52b74dd.tar.gz
anaconda-ff5cf9b11961385cd1ffe45504e63976a52b74dd.tar.xz
anaconda-ff5cf9b11961385cd1ffe45504e63976a52b74dd.zip
basic changes to get new lilo code working
Diffstat (limited to 'lilo.py')
-rw-r--r--lilo.py88
1 files changed, 50 insertions, 38 deletions
diff --git a/lilo.py b/lilo.py
index 708e7cdb7..a21abdba9 100644
--- a/lilo.py
+++ b/lilo.py
@@ -17,8 +17,8 @@ class LiloConfigFile:
s = s + "=" + self.items[n]
s = s + '\n'
for image in self.images:
- (type, name, cl) = image
- s = s + "\n%s=%s\n" % (type, name)
+ (fsType, name, cl) = image
+ s = s + "\n%s=%s\n" % (fsType, name)
s = s + cl.__repr__(1)
return s
@@ -37,23 +37,23 @@ class LiloConfigFile:
return self.items[item]
def getImage(self, name):
- for (type, label, config) in self.images:
+ for (fsType, label, config) in self.images:
if label == name:
- return (type, config)
+ return (fsType, config)
raise IndexError, "unknown image %s" % (name,)
- def addImage (self, type, name, config):
- self.images.append((type, name, config))
+ def addImage (self, fsType, name, config):
+ self.images.append((fsType, name, config))
def delImage (self, name):
for entry in self.images:
- type, label, config = entry
+ fsType, label, config = entry
if label == name:
self.images.remove (entry)
def listImages (self):
l = []
- for (type, label, config) in self.images:
+ for (fsType, label, config) in self.images:
l.append(label)
return l
@@ -98,7 +98,7 @@ class LiloConfigFile:
def __init__(self):
self.order = []
- self.images = [] # more (type, name, LiloConfigFile) pair
+ self.images = [] # more (fsType, name, LiloConfigFile) pair
self.items = {}
class LiloConfiguration:
@@ -137,7 +137,7 @@ class LiloConfiguration:
self.liloImages = {}
foundDos = 0
- for (dev, devName, type, start, size) in drives:
+ for (dev, devName, fsType, 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
@@ -147,7 +147,7 @@ class LiloConfiguration:
# loadable, but we don't
# only list dos and ext2 partitions
- if type != 1 and type != 2:
+ if fsType != 1 and fsType != 2:
continue
if (mountsByDev.has_key(dev)):
@@ -157,7 +157,7 @@ class LiloConfiguration:
else:
self.liloImages[dev] = ("linux", 2)
- if type == 1:
+ if fsType == 1:
if foundDos: continue
foundDos = 1
@@ -169,25 +169,38 @@ class LiloConfiguration:
if oldImages.has_key(dev):
self.liloImages[dev] = oldImages[dev]
else:
- self.liloImages[dev] = ("dos", type)
+ self.liloImages[dev] = ("dos", fsType)
# 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():
+ for (label, fsType) 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:
+ for (label, fsType) in self.liloImages.values():
+ if fsType == 2:
self.default = label
break
return (self.liloImages, self.default)
- def install (self, fstab):
+ def makeInitrd (self, kernelTag, instRoot):
+ initrd = "/boot/initrd%s.img" % (kernelTag, )
+ if not self.initrdsMade.has_key(initrd):
+ iutil.execWithRedirect("/sbin/mkinitrd",
+ [ "/sbin/mkinitrd",
+ "--ifneeded",
+ initrd,
+ kernelTag[1:] ],
+ stdout = None, stderr = None, searchPath = 1,
+ root = instRoot)
+ self.initrdsMade[kernelTag] = 1
+ return initrd
+
+ def install (self, fstab, instRoot, hdList, upgrade):
# If self.liloDevice is None, skipping lilo doesn't work
if not self.liloDevice: return
@@ -199,8 +212,8 @@ class LiloConfiguration:
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')
+ if os.access (instRoot + '/etc/lilo.conf', os.R_OK):
+ lilo.read (instRoot + '/etc/lilo.conf')
lilo = LiloConfigFile ()
# Remove any invalid entries that are in the file; we probably
@@ -210,9 +223,9 @@ class LiloConfiguration:
# easily done.
imagesByLabel = {}
for image in lilo.listImages():
- (type, sl) = lilo.getImage(image)
- if type == "other": continue
- if not os.access(self.instPath + image):
+ (fsType, sl) = lilo.getImage(image)
+ if fsType == "other": continue
+ if not os.access(instRoot + image):
lilo.delImage(image)
else:
imagesByLabel[sl.getEntry('label')] = image
@@ -236,15 +249,15 @@ class LiloConfiguration:
if self.liloLinear:
lilo.addEntry("linear", replace = 0)
- smpInstalled = (self.hdList.has_key('kernel-smp') and
- self.hdList['kernel-smp'].selected)
+ smpInstalled = (hdList.has_key('kernel-smp') and
+ 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()):
+ if (upgrade and not isys.smpAvailable()):
smpInstalled = 0
rootDev = fstab.getRootDevice ()
@@ -269,14 +282,14 @@ class LiloConfiguration:
label = main
if (smpInstalled):
- kernelList.append((main, self.hdList['kernel-smp'], "smp"))
+ kernelList.append((main, hdList['kernel-smp'], "smp"))
label = main + "-up"
- kernelList.append((label, self.hdList['kernel'], ""))
+ kernelList.append((label, hdList['kernel'], ""))
for (label, kernel, tag) in kernelList:
if imagesByLabel.has_key(label):
- (type, sl) = lilo.getImage(imagesByLabel[label])
+ (fsType, sl) = lilo.getImage(imagesByLabel[label])
lilo.delImage(imagesByLabel[label])
else:
sl = LiloConfigFile()
@@ -284,10 +297,10 @@ class LiloConfiguration:
kernelTag = "-%s-%s%s" % (kernel['version'], kernel['release'], tag)
kernelFile = "/boot/vmlinuz" + kernelTag
- initrd = self.makeInitrd (kernelTag)
+ initrd = self.makeInitrd (kernelTag, instRoot)
sl.addEntry("label", label)
- if os.access (self.instPath + initrd, os.R_OK):
+ if os.access (instRoot + initrd, os.R_OK):
sl.addEntry("initrd", initrd)
sl.addEntry("read-only")
@@ -300,7 +313,7 @@ class LiloConfiguration:
for (label, device) in otherList:
try:
- (type, sl) = lilo.getImage(device)
+ (fsType, sl) = lilo.getImage(device)
lilo.delImage(device)
except IndexError:
sl = LiloConfigFile()
@@ -308,13 +321,11 @@ class LiloConfiguration:
sl.addEntry("label", label)
lilo.addImage ("other", device, sl)
- lilo.write(self.instPath + "/etc/lilo.conf")
+ lilo.write(instRoot + "/etc/lilo.conf")
- # XXX make me "not test mode"
- if self.setupFilesystems:
- iutil.execWithRedirect(self.instPath + '/sbin/lilo' ,
- [ "lilo", "-r", self.instPath ],
- stdout = None)
+ iutil.execWithRedirect(instRoot + '/sbin/lilo' ,
+ [ "lilo", "-r", instRoot ],
+ stdout = None)
def setDevice(self, device):
if (type(device) == type((1,))):
@@ -330,7 +341,7 @@ class LiloConfiguration:
self.liloAppend = append
def setDefault(self, default):
- for (label, type) in self.liloImages.values():
+ for (label, fsType) in self.liloImages.values():
if label == default:
self.default = default
return
@@ -351,6 +362,7 @@ class LiloConfiguration:
self.liloLinear = 1
self.liloAppend = None
self.default = None
+ self.initrdsMade = {}
if __name__ == "__main__":