[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH v2 4/5] Patch the CHRP boot script



This patch requires the ofpath tool which is part of the yaboot package,
as both ofpathname (part of powerpc-ibm-utils package) and
grub-ofpathname (not available packaged but part of the GRUB source
code) do not translate a given device node into a working OF path on
type 11,2 and 7,3 G5 Power Macs.

v1 -> v2:

  - fixed changelog entry and commit message
  - now only patch the CHRP boot script shipped with the
    grub-ieee1275-bin package in the future

---
 debian/changelog |  1 +
 grub-installer   | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index bc21995..1d61497 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ grub-installer (1.147) UNRELEASED; urgency=medium
   * Install hfsutils in-target for powerpc/ppc64 newworld targets
   * Detect and select newworld bootstrap partitions
   * Handle HFS file systems (format, mount, unmount, fstab entry)
+  * Patch the CHRP boot script
 
  -- Frank Scheiner <frank.scheiner@web.de>  Thu, 16 Nov 2017 07:20:38 +0100
 
diff --git a/grub-installer b/grub-installer
index 63e4a03..7d68fb2 100755
--- a/grub-installer
+++ b/grub-installer
@@ -219,6 +219,27 @@ nw_unmount_offs()
 		return 1
 	fi
 }
+
+nw_patch_boot_script()
+{
+	local boot_script="$1"
+	local offs_part="$2"
+
+	local self="nw_patch_boot_script"
+
+	local of_path
+
+	of_path=$( in-target --pass-stdout ofpath $offs_part )
+
+	if sed -e "s/&device;:&partition;/$of_path/" -i "$boot_script"; then
+		info "$self: Successfully patched $boot_script."
+		return 0
+	else
+		error "$self: Patching of $boot_script failed." 1>&2
+		return 1
+	fi
+}
+
 ARCH="$(archdetect)"
 info "architecture: $ARCH"
 
@@ -728,6 +749,14 @@ fi
 
 grub_debian_version="$($chroot $ROOT dpkg-query -W -f '${Version}' $inst_package)"
 
+case $ARCH in
+    powerpc/powermac_newworld|ppc64/powermac_newworld)
+	# Patch CHRP boot script with the help of the ofpath tool (which is part
+	# of yaboot).
+	nw_patch_boot_script "$ROOT/usr/lib/grub/powerpc-ieee1275/grub.chrp" "$offs_part" || exit 1
+	;;
+esac
+
 db_progress STEP 1
 db_progress INFO grub-installer/progress/step_os-probe
 os-prober > /tmp/os-probed || true
-- 
1.9.1


Reply to: