Here is a proposed patch that updates a PowerPC's BIOS to boot from the newly installed hard disk rather than back to the installer.
--- pyanaconda/bootloader.py | 11 +++++++ pyanaconda/platform.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index ca43868..e156be9 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -1832,6 +1832,17 @@ class IPSeriesYaboot(Yaboot): config.write("nonvram\n") # only on pSeries? config.write("fstype=raw\n")
+ # + # installation + # + + def install(self, install_root=""): + import platform + + platform.updatePowerPCBootList(self.storage) + + super(IPSeriesYaboot, self).install(install_root=install_root) +
class MacYaboot(Yaboot): prog = "mkofboot" diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 82b4b55..779cb01 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -32,6 +32,9 @@ import gettext _ = lambda x: gettext.ldgettext("anaconda", x) N_ = lambda x: x
+import logging +log = logging.getLogger("storage") + class Platform(object): """Platform
@@ -322,3 +325,76 @@ def getPlatform(anaconda): return X86(anaconda) else: raise SystemError, "Could not determine system architecture." + +def updatePowerPCBootList(storage): + if not iutil.isPPC(): + # This function is only for PowerPC machines! + return + + # ofpathname relies on bc being installed! + rc = iutil.execWithRedirect("which", ["bc"], + stdout="/dev/null", stderr="/dev/hvc1", + root="/") + + if rc: + log.error ("FAIL: bc is not installed!") + + return + + buf = iutil.execWithCapture("nvram", + ["--print-config=boot-device"], + stderr="/dev/hvc1", + root="/") + + 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) + + import parted + + prep_locations = [] + + for partition in storage.partitions: + if partition.getFlag(parted.PARTITION_PREP): + log.debug ("updatePowerPCBootList: %s partition is a prep partition" % partition.path) + + buf = iutil.execWithCapture("ofpathname", + [partition.path], + stderr="/dev/hvc1", + root="/") + + if len(buf) > 0: + of_location = buf.strip () + prep_locations += [of_location] + + else: + log.error ("FAIL: ofpathname %s" % partition.path) + + log.debug ("updatePowerPCBootList: prep_locations = %s" % prep_locations) + + # Right now, booting to a machine with only one PReP partition is easy. + # If there are two or more, then we would need a new dialog + if len(prep_locations) == 1: + boot_disk = prep_locations[0] + + # 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: boot_list = %s" % boot_list) + + update_value = "boot-device=%s" % (" ".join (boot_list),) + + rc = iutil.execWithRedirect("nvram", ["--update-config", update_value], + stdout="/dev/hvc1", stderr="/dev/hvc1", + root="/") + 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) -- 1.7.6.4
Hey Mark - thanks for sending this patch!
On Tue, 2011-10-25 at 15:48 -0500, Mark Hamzy wrote:
Here is a proposed patch that updates a PowerPC's BIOS to boot from the newly installed hard disk rather than back to the installer.
Heh, HTML email breaks inline python super-hard. You might want to try attaching it as a file - preferably created with git format-patch, like: git format-patch -1 [commitid] But a link to fpaste would work in a pinch (just *thinking* about trying to do attachments with Notes makes my brain throb a little..)
Can you give us a general idea of what this patch is trying to do? AFAICT it's updating nvram to make the OF 'boot-device' variable point to the device we're installing on. Is that right?
- def install(self, install_root=""):
- import platform
- platform.updatePowerPCBootList(self.storage)
Why not just make updatePowerPCBootList() a method of IPSeriesYaboot?
+def updatePowerPCBootList(storage):
[snip]
- prep_locations = []
So, it needs a list of PREP locations? I feel like that information might already available inside the IPSeriesYaboot class - like from the stage1_devices property. (Another reason to move this method there.)
I'm not really an expert on how the bootloader/platform stuff works, though - can anyone help clarify here?
-w
I second wwoods' comments and add my own.
On 10/25/11 16:48, Mark Hamzy wrote:
Here is a proposed patch that updates a PowerPC's BIOS to boot from the newly installed hard disk rather than back to the installer.
pyanaconda/bootloader.py | 11 +++++++ pyanaconda/platform.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index ca43868..e156be9 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -1832,6 +1832,17 @@ class IPSeriesYaboot(Yaboot): config.write("nonvram\n") # only on pSeries? config.write("fstype=raw\n")
- #
- # installation
- #
- def install(self, install_root=""):
- import platform
- platform.updatePowerPCBootList(self.storage)
- super(IPSeriesYaboot, self).install(install_root=install_root)
class MacYaboot(Yaboot): prog = "mkofboot" diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 82b4b55..779cb01 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -32,6 +32,9 @@ import gettext _ = lambda x: gettext.ldgettext("anaconda", x) N_ = lambda x: x
+import logging +log = logging.getLogger("storage")
class Platform(object): """Platform
@@ -322,3 +325,76 @@ def getPlatform(anaconda): return X86(anaconda) else: raise SystemError, "Could not determine system architecture."
+def updatePowerPCBootList(storage):
- if not iutil.isPPC():
- # This function is only for PowerPC machines!
- return
- # ofpathname relies on bc being installed!
- rc = iutil.execWithRedirect("which", ["bc"],
- stdout="/dev/null", stderr="/dev/hvc1",
- root="/")
- if rc:
- log.error ("FAIL: bc is not installed!")
And this depends on 'which' in the installer environment, which is entirely unnecessary. If bc is required for a successful ofpathname run, we just need to ensure it's in the installer environment. ofpathname can report bc not existing (it should if it doesn't).
- return
- buf = iutil.execWithCapture("nvram",
- ["--print-config=boot-device"],
- stderr="/dev/hvc1",
- root="/")
- 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)
- import parted
- prep_locations = []
- for partition in storage.partitions:
- if partition.getFlag(parted.PARTITION_PREP):
- log.debug ("updatePowerPCBootList: %s partition is a prep partition" %
partition.path)
- buf = iutil.execWithCapture("ofpathname",
- [partition.path],
- stderr="/dev/hvc1",
- root="/")
- if len(buf) > 0:
- of_location = buf.strip ()
- prep_locations += [of_location]
- else:
- log.error ("FAIL: ofpathname %s" % partition.path)
- log.debug ("updatePowerPCBootList: prep_locations = %s" % prep_locations)
- # Right now, booting to a machine with only one PReP partition is easy.
- # If there are two or more, then we would need a new dialog
- if len(prep_locations) == 1:
- boot_disk = prep_locations[0]
- # 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: boot_list = %s" % boot_list)
- update_value = "boot-device=%s" % (" ".join (boot_list),)
- rc = iutil.execWithRedirect("nvram", ["--update-config", update_value],
- stdout="/dev/hvc1", stderr="/dev/hvc1",
- root="/")
- 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)
On Wed, 2011-10-26 at 09:59 -0400, David Cantrell wrote:
I second wwoods' comments and add my own.
Likewise. Will was correct. I just have a couple of minor comments.
On 10/25/11 16:48, Mark Hamzy wrote:
Here is a proposed patch that updates a PowerPC's BIOS to boot from the newly installed hard disk rather than back to the installer.
pyanaconda/bootloader.py | 11 +++++++ pyanaconda/platform.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index ca43868..e156be9 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -1832,6 +1832,17 @@ class IPSeriesYaboot(Yaboot): config.write("nonvram\n") # only on pSeries? config.write("fstype=raw\n")
- #
- # installation
- #
- def install(self, install_root=""):
- import platform
- platform.updatePowerPCBootList(self.storage)
- super(IPSeriesYaboot, self).install(install_root=install_root)
class MacYaboot(Yaboot): prog = "mkofboot" diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 82b4b55..779cb01 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -32,6 +32,9 @@ import gettext _ = lambda x: gettext.ldgettext("anaconda", x) N_ = lambda x: x
+import logging +log = logging.getLogger("storage")
class Platform(object): """Platform
@@ -322,3 +325,76 @@ def getPlatform(anaconda): return X86(anaconda) else: raise SystemError, "Could not determine system architecture."
+def updatePowerPCBootList(storage):
- if not iutil.isPPC():
- # This function is only for PowerPC machines!
- return
- # ofpathname relies on bc being installed!
- rc = iutil.execWithRedirect("which", ["bc"],
- stdout="/dev/null", stderr="/dev/hvc1",
- root="/")
- if rc:
- log.error ("FAIL: bc is not installed!")
And this depends on 'which' in the installer environment, which is entirely unnecessary. If bc is required for a successful ofpathname run, we just need to ensure it's in the installer environment. ofpathname can report bc not existing (it should if it doesn't).
David is correct, but as a point of information we also have iutil.find_program_in_path("bc") which will return either the full path to the executable or None if it isn't present.
- return
- buf = iutil.execWithCapture("nvram",
- ["--print-config=boot-device"],
- stderr="/dev/hvc1",
- root="/")
- 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)
- import parted
- prep_locations = []
- for partition in storage.partitions:
- if partition.getFlag(parted.PARTITION_PREP):
- log.debug ("updatePowerPCBootList: %s partition is a prep partition" %
partition.path)
- buf = iutil.execWithCapture("ofpathname",
- [partition.path],
- stderr="/dev/hvc1",\
- root="/")
- if len(buf) > 0:
- of_location = buf.strip ()
- prep_locations += [of_location]
- else:
- log.error ("FAIL: ofpathname %s" % partition.path)
- log.debug ("updatePowerPCBootList: prep_locations = %s" % prep_locations)
- # Right now, booting to a machine with only one PReP partition is easy.
- # If there are two or more, then we would need a new dialog
- if len(prep_locations) == 1:
- boot_disk = prep_locations[0]
- # 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: boot_list = %s" % boot_list)
- update_value = "boot-device=%s" % (" ".join (boot_list),)
- rc = iutil.execWithRedirect("nvram", ["--update-config", update_value],
- stdout="/dev/hvc1", stderr="/dev/hvc1",
- root="/")
- 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)
Normally we only alter the PReP partition that we're using to boot from, which is BootLoader.stage1_device.
Dave
anaconda-devel@lists.fedoraproject.org