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

Re: EFI patches rollup



On Thu, Sep 20, 2012 at 04:05:51PM +0100, Steve McIntyre wrote:
>On Thu, Sep 20, 2012 at 04:46:36PM +0200, Cyril Brulebois wrote:
>>
>>All committed and uploaded, except for grub-installer. There are some
>>bits of logic for /proc handling, maybe that could be reused/united with
>>the /sys and /proc you need? Maybe umount once you're done?
>
>Could do, I guess... Any clues on where to look?
>
>>Also, it looks to me like there's a missing grub-gfxpayload-lists in the
>>dpkg -P call in the grub-pc case?
>
>Probably better to just drop that mention altogether, it's an
>Ubuntu-specific package AFAICS.

Right, both of these fixed up in the latest attached patch.

>>Christian, new template as mentioned in <20120822135919.GE497@einval.com>
>>for partman-efi's debian/partman-efi.templates:
>>
>>+Template: partman-efi/too_small_efi
>>+Type: error
>>+# :sl5:
>>+_Description: EFI partition too small
>>+ EFI boot partitions on this architecture cannot be created with a size less
>>+ than 35 MB. Please make the EFI boot partition larger.
>
>I hope we won't need any more than this...

Unfortunately, we do - YA new template:

+Template: grub-installer/mounterr
+Type: error
+# :sl4:
+_Description: Failed to mount /target/proc
+ Mounting the proc file system on /target/proc failed.
+ .
+ Check /var/log/syslog or see virtual console 4 for the details.
+ .
+ Warning: Your system may be unbootable!

It's exactly the same text as yaboot-installer/mounterr,
nobootloader/mounterr and quik-installer/mounterr. We really should
factor out some of these templates, I think... :-/

-- 
Steve McIntyre, Cambridge, UK.                                steve@einval.com
  Getting a SCSI chain working is perfectly simple if you remember that there
  must be exactly three terminations: one on one end of the cable, one on the
  far end, and the goat, terminated over the SCSI chain with a silver-handled
  knife whilst burning *black* candles. --- Anthony DeBoer
>From 795bfde96c812d6ae17d22cc639eeb25f5799eb6 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Thu, 20 Sep 2012 18:04:10 +0100
Subject: [PATCH] Add support for EFI on amd64 and i386

  * Allow grub for amd64/efi and i386/efi, installing grub-efi instead of
    grub-pc.
  * Make sure that we have /sys and /proc mounted in /target in the
    postinst, so that efibootmgr will work ok.
---
 debian/changelog                |    7 +++++++
 debian/grub-installer.templates |   10 ++++++++++
 debian/postinst                 |   37 +++++++++++++++++++++++++++++++++++++
 grub-installer                  |   22 +++++++++++++++-------
 4 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4fa88fd..186837a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,14 @@
 grub-installer (1.79) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Don't try to use local outside a function.
 
+  [ Steve McIntyre ]
+  * Allow grub for amd64/efi and i386/efi, installing grub-efi instead of
+    grub-pc.
+  * Make sure that we have /sys and /proc mounted in /target in the
+    postinst, so that efibootmgr will work ok.
+
  -- Colin Watson <cjwatson@debian.org>  Thu, 20 Sep 2012 13:33:13 +0100
 
 grub-installer (1.78) unstable; urgency=low
diff --git a/debian/grub-installer.templates b/debian/grub-installer.templates
index 8b5b7bf..888a656 100644
--- a/debian/grub-installer.templates
+++ b/debian/grub-installer.templates
@@ -219,3 +219,13 @@ Type: boolean
 Default: true
 Description: for internal use; can be preseeded
  Make sure that at least one partition is marked as active (bootable).
+
+Template: grub-installer/mounterr
+Type: error
+# :sl4:
+_Description: Failed to mount /target/proc
+ Mounting the proc file system on /target/proc failed.
+ .
+ Check /var/log/syslog or see virtual console 4 for the details.
+ .
+ Warning: Your system may be unbootable!
diff --git a/debian/postinst b/debian/postinst
index b32a1d0..4b12027 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -1,2 +1,39 @@
 #! /bin/sh -e
+
+log () {
+	logger -t grub-installer "$@"
+}
+
+error () {
+	log "error: $@"
+}
+
+die () {
+	local template="$1"
+	shift
+
+	error "$@"
+	db_input critical "$template" || [ $? -eq 30 ]
+	db_go || true
+	exit 1
+}
+
+mountvirtfs () {
+	fstype="$1"
+	path="$2"
+	if grep -q "[[:space:]]$fstype\$" /proc/filesystems && \
+	   ! grep -q "^[^ ]\+ \+$path " /proc/mounts; then
+		mkdir -p "$path" || \
+			die grub-installer/mounterr "Error creating $path"
+		mount -t "$fstype" "$fstype" "$path" || \
+			die grub-installer/mounterr "Error mounting $path"
+		trap "umount $path" HUP INT QUIT KILL PIPE TERM EXIT
+	fi
+}
+
+# If we're installing grub-efi, it wants /sys mounted in the
+# target. Maybe /proc too?
+mountvirtfs proc /target/proc
+mountvirtfs sysfs /target/sys
+
 grub-installer /target
diff --git a/grub-installer b/grub-installer
index 3e830db..7056f11 100755
--- a/grub-installer
+++ b/grub-installer
@@ -312,11 +312,16 @@ case $ARCH in
 	if [ -d /sys/firmware/efi ]; then
 		# This point can't be reached (yet).  See debian/isinstallable.
 		grub_package="grub-efi"
-		experimental_arch
 	else
 		grub_package="grub-pc"
 	fi
 	;;
+    i386/efi|amd64/efi)
+	grub_package="grub-efi"
+	;;
+    i386/*|amd64/*)
+	grub_package="grub-pc"
+	;;
     powerpc/*)
 	grub_package="grub-ieee1275"
 	experimental_arch
@@ -409,11 +414,14 @@ db_progress INFO grub-installer/progress/step_install
 # to grub legacy, or vice-versa
 case "$grub_package" in
     grub)
-	log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc-bin grub-pc
+	log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc-bin grub-pc grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32
 	;;
     grub-pc)
-	log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy
-	;;
+	log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32
+    ;;
+    grub-efi)
+	log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-pc-bin grub-pc
+    ;;
 esac
 
 exit_code=0
@@ -662,7 +670,7 @@ if [ -z "$frdisk" ]; then
 
 		CODE=0
 		case $ARCH:$grub_package in
-		    *:grub|*:grub-pc|sparc:grub-ieee1275)
+		    *:grub|*:grub-pc|*:grub-efi|sparc:grub-ieee1275)
 			info "Running $chroot $ROOT grub-install $grub_install_params \"$bootdev\""
 			log-output -t grub-installer $chroot $ROOT grub-install $grub_install_params "$bootdev" || CODE=$?
 			;;
@@ -675,7 +683,7 @@ if [ -z "$frdisk" ]; then
 			info "grub-install ran successfully"
 		else
 			case $ARCH:$grub_package in
-			    *:grub|*:grub-pc|sparc:grub-ieee1275)
+			    *:grub|*:grub-pc|*:grub-efi|sparc:grub-ieee1275)
 				error "Running 'grub-install $grub_install_params \"$bootdev\"' failed."
 				;;
 			    *)
@@ -962,7 +970,7 @@ if [ "$serial" ] ; then
 		) >$ROOT/boot/grub/$menu_file.new
 		mv $ROOT/boot/grub/$menu_file.new $ROOT/boot/grub/$menu_file
 		;;
-	    grub-pc)
+	    grub-pc|grub-efi)
 		if grep -q "^GRUB_TERMINAL=" $ROOT/etc/default/grub; then
 			sed -i $ROOT/etc/default/grub -e "s/^\(GRUB_TERMINAL\)=.*/\1=serial/g"
 		else
-- 
1.7.10.4


Reply to: