summaryrefslogtreecommitdiffstats
path: root/booty/alpha.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-02-19 14:28:22 -0500
committerChris Lumens <clumens@redhat.com>2009-03-04 15:37:04 -0500
commit38eee03b0803cc286f05c42c969912c576713685 (patch)
treeb2eba0bd2c0131fdf4d4c911809fcf1fbceafd0a /booty/alpha.py
parent2c8c10290688b9c2038b1448e7bed9723012641e (diff)
downloadanaconda-38eee03b0803cc286f05c42c969912c576713685.tar.gz
anaconda-38eee03b0803cc286f05c42c969912c576713685.tar.xz
anaconda-38eee03b0803cc286f05c42c969912c576713685.zip
Move each bootloader class into its own file.
Diffstat (limited to 'booty/alpha.py')
-rw-r--r--booty/alpha.py143
1 files changed, 143 insertions, 0 deletions
diff --git a/booty/alpha.py b/booty/alpha.py
new file mode 100644
index 000000000..5e62c93ca
--- /dev/null
+++ b/booty/alpha.py
@@ -0,0 +1,143 @@
+import os
+import rhpl.executil
+
+from bootloaderInfo import *
+import fsset
+
+class alphaBootloaderInfo(bootloaderInfo):
+ def wholeDevice (self, path):
+ (device, foo) = fsset.getDiskPart(path)
+ return device
+
+ def partitionNum (self, path):
+ # getDiskPart returns part numbers 0-based; we need it one based
+ # *sigh*
+ (foo, partitionNumber) = getDiskPart(path)
+ return partitionNumber + 1
+
+ def writeAboot(self, instRoot, fsset, bl, kernelList,
+ chainList, defaultDev, justConfig):
+ # Get bootDevice and rootDevice
+ rootDevice = fsset.getEntryByMountPoint("/").device.getDevice()
+ if fsset.getEntryByMountPoint("/boot"):
+ bootDevice = fsset.getEntryByMountPoint("/boot").device.getDevice()
+ else:
+ bootDevice = rootDevice
+ bootnotroot = bootDevice != rootDevice
+
+ # If /etc/aboot.conf already exists we rename it
+ # /etc/aboot.conf.rpmsave.
+ if os.path.isfile(instRoot + self.configfile):
+ os.rename (instRoot + self.configfile,
+ instRoot + self.configfile + ".rpmsave")
+
+ # Then we create the necessary files. If the root device isn't
+ # the boot device, we create /boot/etc/ where the aboot.conf
+ # will live, and we create /etc/aboot.conf as a symlink to it.
+ if bootnotroot:
+ # Do we have /boot/etc ? If not, create one
+ if not os.path.isdir (instRoot + '/boot/etc'):
+ os.mkdir(instRoot + '/boot/etc', 0755)
+
+ # We install the symlink (/etc/aboot.conf has already been
+ # renamed in necessary.)
+ os.symlink("../boot" + self.configfile, instRoot + self.configfile)
+
+ cfPath = instRoot + "/boot" + self.configfile
+ # Kernel path is set to / because a boot partition will
+ # be a root on its own.
+ kernelPath = '/'
+ # Otherwise, we just need to create /etc/aboot.conf.
+ else:
+ cfPath = instRoot + self.configfile
+ kernelPath = self.kernelLocation
+
+ # If we already have an aboot.conf, rename it
+ if os.access (cfPath, os.R_OK):
+ self.perms = os.stat(cfPath)[0] & 0777
+ os.rename(cfPath, cfPath + '.rpmsave')
+
+ # Now we're going to create and populate cfPath.
+ f = open (cfPath, 'w+')
+ f.write ("# aboot default configurations\n")
+
+ if bootnotroot:
+ f.write ("# NOTICE: You have a /boot partition. This means that\n")
+ f.write ("# all kernel paths are relative to /boot/\n")
+
+ # bpn is the boot partition number.
+ bpn = self.partitionNum(bootDevice)
+ lines = 0
+
+ # We write entries line using the following format:
+ # <line><bpn><kernel-name> root=<rootdev> [options]
+ # We get all the kernels we need to know about in kernelList.
+
+ for (kernel, tag, version) in kernelList:
+ kernelTag = "-" + version
+ kernelFile = "%svmlinuz%s" %(kernelPath, kernelTag)
+
+ f.write("%d:%d%s" %(lines, bpn, kernelFile))
+
+ # See if we can come up with an initrd argument that exists
+ initrd = self.makeInitrd(kernelTag)
+ if os.path.isfile(instRoot + initrd):
+ f.write(" initrd=%sinitrd%s.img" %(kernelPath, kernelTag))
+
+ realroot = getRootDevName(initrd, fsset, rootDevice, instRoot)
+ f.write(" root=%s" %(realroot,))
+
+ args = self.args.get()
+ if args:
+ f.write(" %s" %(args,))
+
+ f.write("\n")
+ lines = lines + 1
+
+ # We're done writing the file
+ f.close ()
+ del f
+
+ if not justConfig:
+ # Now we're ready to write the relevant boot information. wbd
+ # is the whole boot device, bdpn is the boot device partition
+ # number.
+ wbd = self.wholeDevice (bootDevice)
+ bdpn = self.partitionNum (bootDevice)
+
+ # Calling swriteboot. The first argument is the disk to write
+ # to and the second argument is a path to the bootstrap loader
+ # file.
+ args = ("swriteboot", ("/dev/%s" % wbd), "/boot/bootlx")
+ rhpl.executil.execWithRedirect ('/sbin/swriteboot', args,
+ root = instRoot,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+
+ # Calling abootconf to configure the installed aboot. The
+ # first argument is the disk to use, the second argument is
+ # the number of the partition on which aboot.conf resides.
+ # It's always the boot partition whether it's / or /boot (with
+ # the mount point being omitted.)
+ args = ("abootconf", ("/dev/%s" % wbd), str (bdpn))
+ rhpl.executil.execWithRedirect ('/sbin/abootconf', args,
+ root = instRoot,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+
+
+ def write(self, instRoot, fsset, bl, kernelList, chainList,
+ defaultDev, justConfig, intf):
+ if len(kernelList) < 1:
+ self.noKernelsWarn(intf)
+
+ self.writeAboot(instRoot, fsset, bl, kernelList,
+ chainList, defaultDev, justConfig)
+
+ def __init__(self):
+ bootloaderInfo.__init__(self)
+ self.useGrubVal = 0
+ self.configfile = "/etc/aboot.conf"
+ # self.kernelLocation is already set to what we need.
+ self.password = None
+ self.pure = None