This is a patch to switch ppc from using Yaboot to using Grub2. Because the default
terminal size is 80x24 and Open Firmware's default size is a little larger than that
so repaints will mess up the display. Therefore, tell grub to configure
'terminfo -g 80x24 ofconsole'. We do this with a new GRUB_TERMINFO variable and
enablement script in grub.
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 0e759f5..792d1e9 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1794,7 +1794,7 @@ class GRUB2(GRUB):
def install(self):
# XXX will installing to multiple drives work as expected with GRUBv2?
for (stage1dev, stage2dev) in self.install_targets:
- args = ["--no-floppy", self.grub_device_name(stage1dev)]
+ args = ["--no-floppy", stage1dev.path]
if stage1dev == stage2dev:
# This is hopefully a temporary hack. GRUB2 currently refuses
# to install to a partition's boot block without --force.
@@ -2002,6 +2002,76 @@ class IPSeriesYaboot(Yaboot):
log.info("Updated PPC boot list with the command: nvram --update-config %s" % update_value)
+class IPSeriesGRUB2(GRUB2):
+
+ # GRUB2 sets /boot bootable and not the PReP partition. This causes the Open Firmware BIOS not
+ # to present the disk as a bootable target. If stage2_bootable is False, then the PReP partition
+ # will be marked bootable. Confusing.
+ stage2_bootable = False
+
+ #
+ # installation
+ #
+
+ def install(self):
+ self.updatePowerPCBootList()
+
+ super(IPSeriesGRUB2, self).install()
+
+ def updatePowerPCBootList(self):
+
+ log.debug("updatePowerPCBootList: self.stage1_device.path = %s" % self.stage1_device.path)
+
+ buf = iutil.execWithCapture("nvram",
+ ["--print-config=boot-device"],
+ stderr="/dev/tty5")
+
+ if len(buf) == 0:
+ log.error ("FAIL: nvram --print-config=boot-device")
+ return
+
+ boot_list = buf.strip().split()
+ log.debug("updatePowerPCBootList: boot_list = %s" % boot_list)
+
+ buf = iutil.execWithCapture("ofpathname",
+ [self.stage1_device.path],
+ stderr="/dev/tty5")
+
+ if len(buf) > 0:
+ boot_disk = buf.strip()
+ log.debug("updatePowerPCBootList: boot_disk = %s" % boot_disk)
+ else:
+ log.error("FAIL: ofpathname %s" % self.stage1_device.path)
+ return
+
+ # Place the disk containing the PReP partition first.
+ # Remove all other occurances of it.
+ boot_list = [boot_disk] + filter(lambda x: x != boot_disk, boot_list)
+
+ log.debug("updatePowerPCBootList: updated boot_list = %s" % boot_list)
+
+ update_value = "boot-device=%s" % " ".join(boot_list)
+
+ rc = iutil.execWithRedirect("nvram", ["--update-config", update_value],
+ stdout="/dev/tty5", stderr="/dev/tty5")
+ if rc:
+ log.error("FAIL: nvram --update-config %s" % update_value)
+ else:
+ log.info("Updated PPC boot list with the command: nvram --update-config %s" % update_value)
+
+ #
+ # In addition to the normal grub configuration variable, add one more to set the size of the
+ # console's window to a standard 80x24
+ #
+ def write_defaults(self):
+ super(IPSeriesGRUB2, self).write_defaults()
+
+ defaults_file = "%s%s" % (ROOT_PATH, self.defaults_file)
+ defaults = open(defaults_file, "a+")
+ defaults.write("GRUB_TERMINFO="%s -g %dx%d %s"
" % ("terminfo", 80, 24, "console"))
+ defaults.close()
+
+
class MacYaboot(Yaboot):
prog = "mkofboot"
can_dual_boot = True
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py
index 536a849..cfadbb3 100644
--- a/pyanaconda/platform.py
+++ b/pyanaconda/platform.py
@@ -231,7 +231,7 @@ class MacEFI(EFI):
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
03-09-2012, 02:28 PM
David Lehman
Migrate PPC from Yaboot to Grub2 for Anaconda
On Fri, 2012-03-09 at 08:43 -0600, Mark Hamzy wrote:
> This is a patch to switch ppc from using Yaboot to using Grub2. Because the default
> terminal size is 80x24 and Open Firmware's default size is a little larger than that
> so repaints will mess up the display. Therefore, tell grub to configure
> 'terminfo -g 80x24 ofconsole'. We do this with a new GRUB_TERMINFO variable and
> enablement script in grub.
Looks good in general, but I have several comments below.
>
> ---
> pyanaconda/bootloader.py | 72 +++++++++++++++++++++++++++++++++++++++++++++-
> pyanaconda/platform.py | 4 +-
> 2 files changed, 73 insertions(+), 3 deletions(-)
>
> diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
> index 0e759f5..792d1e9 100644
> --- a/pyanaconda/bootloader.py
> +++ b/pyanaconda/bootloader.py
> @@ -1794,7 +1794,7 @@ class GRUB2(GRUB):
> def install(self):
> # XXX will installing to multiple drives work as expected with GRUBv2?
> for (stage1dev, stage2dev) in self.install_targets:
> - args = ["--no-floppy", self.grub_device_name(stage1dev)]
> + args = ["--no-floppy", stage1dev.path]
> if stage1dev == stage2dev:
> # This is hopefully a temporary hack. GRUB2 currently refuses
> # to install to a partition's boot block without --force.
> @@ -2002,6 +2002,76 @@ class IPSeriesYaboot(Yaboot):
> log.info("Updated PPC boot list with the command: nvram --update-config %s" % update_value)
>
>
> +class IPSeriesGRUB2(GRUB2):
> +
> + # GRUB2 sets /boot bootable and not the PReP partition. This causes the Open Firmware BIOS not
> + # to present the disk as a bootable target. If stage2_bootable is False, then the PReP partition
> + # will be marked bootable. Confusing.
> + stage2_bootable = False
> +
> + #
> + # installation
> + #
> +
> + def install(self):
> + self.updatePowerPCBootList()
> +
> + super(IPSeriesGRUB2, self).install()
> +
> + def updatePowerPCBootList(self):
Can we rename this to updatePPCBootList so that common searches for
ppc-specific stuff will find this? Maybe even updateNVRAMBootList
instead?
I'd personally prefer a more generic message here like "failed to
determine nvram boot device". Remember that program.log will contain a
record of every command run, complete with arguments and output. And,
since it's already going to have "ERROR" at the beginning of the line in
the log you could certainly leave out the "FAIL:" part. Likewise for the
other log statements in this method.
> + return
Installation will continue unless you raise an exception -- is this your
intention?
Should this be a fatal error? Returning instead of raising an exception
here means the bootloader installation will continue instead of
aborting.
> +
> + # Place the disk containing the PReP partition first.
> + # Remove all other occurances of it.
> + boot_list = [boot_disk] + filter(lambda x: x != boot_disk, boot_list)
> +
> + log.debug("updatePowerPCBootList: updated boot_list = %s" % boot_list)
Just a few lines down this information will get entered into program.log
as the command line for nvram --update-config so you don't need to log
it here separately.
Is this necessary? It makes the default bootloader on ppc grub2. I
realize it may not matter if all the ppc platforms that actually get
used have their own bootloader class definition, but if grub2 can't
actually boot most ppcs maybe we should leave this as yaboot for now.
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 0e759f5..c339e58 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1794,7 +1794,7 @@ class GRUB2(GRUB):
def install(self):
# XXX will installing to multiple drives work as expected with GRUBv2?
for (stage1dev, stage2dev) in self.install_targets:
- args = ["--no-floppy", self.grub_device_name(stage1dev)]
+ args = ["--no-floppy", stage1dev.path]
if stage1dev == stage2dev:
# This is hopefully a temporary hack. GRUB2 currently refuses
# to install to a partition's boot block without --force.
@@ -2002,6 +2002,73 @@ class IPSeriesYaboot(Yaboot):
log.info("Updated PPC boot list with the command: nvram --update-config %s" % update_value)
+class IPSeriesGRUB2(GRUB2):
+
+ # GRUB2 sets /boot bootable and not the PReP partition. This causes the Open Firmware BIOS not
+ # to present the disk as a bootable target. If stage2_bootable is False, then the PReP partition
+ # will be marked bootable. Confusing.
+ stage2_bootable = False
+
+ #
+ # installation
+ #
+
+ def install(self):
+ self.updateNVRAMBootList()
+
+ super(IPSeriesGRUB2, self).install()
+
+ # This will update the PowerPC's (ppc) bios boot devive order list
+ def updateNVRAMBootList(self):
+
+ log.debug("updateNVRAMBootList: self.stage1_device.path = %s" % self.stage1_device.path)
+
+ buf = iutil.execWithCapture("nvram",
+ ["--print-config=boot-device"],
+ stderr="/dev/tty5")
+
+ if len(buf) == 0:
+ log.error ("Failed to determine nvram boot device")
+ return
+
+ boot_list = buf.strip().split()
+ log.debug("updateNVRAMBootList: boot_list = %s" % boot_list)
+
+ buf = iutil.execWithCapture("ofpathname",
+ [self.stage1_device.path],
+ stderr="/dev/tty5")
+
+ if len(buf) > 0:
+ boot_disk = buf.strip()
+ else:
+ log.error("Failed to translate boot path into device name")
+ return
+
+ # Place the disk containing the PReP partition first.
+ # Remove all other occurances of it.
+ boot_list = [boot_disk] + filter(lambda x: x != boot_disk, boot_list)
+
+ update_value = "boot-device="%s"" % " ".join(boot_list)
+
+ rc = iutil.execWithRedirect("nvram", ["--update-config", update_value],
+ stdout="/dev/tty5", stderr="/dev/tty5")
+ if rc:
+ log.error("Failed to update new boot device order")
+
+ #
+ # In addition to the normal grub configuration variable, add one more to set the size of the
+ # console's window to a standard 80x24
+ #
+ def write_defaults(self):
+ super(IPSeriesGRUB2, self).write_defaults()
+
+ defaults_file = "%s%s" % (ROOT_PATH, self.defaults_file)
+ defaults = open(defaults_file, "a+")
+ # The terminfo's X and Y size, and output location could change in the future
+ defaults.write("GRUB_TERMINFO="terminfo -g 80x24 console"
")
+ defaults.close()
+
+
class MacYaboot(Yaboot):
prog = "mkofboot"
can_dual_boot = True
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py
index 536a849..cfadbb3 100644
--- a/pyanaconda/platform.py
+++ b/pyanaconda/platform.py
@@ -231,7 +231,7 @@ class MacEFI(EFI):