From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OYQkA-00008h-JS for mharc-grub-devel@gnu.org; Mon, 12 Jul 2010 17:40:54 -0400 Received: from [140.186.70.92] (port=57130 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYQk7-000088-UN for grub-devel@gnu.org; Mon, 12 Jul 2010 17:40:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYQk6-0006bf-67 for grub-devel@gnu.org; Mon, 12 Jul 2010 17:40:51 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:62386) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYQk5-0006bP-TW for grub-devel@gnu.org; Mon, 12 Jul 2010 17:40:50 -0400 Received: by wwb39 with SMTP id 39so548540wwb.30 for ; Mon, 12 Jul 2010 14:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=+VOmRHWwIeKkkbDzUDIwnuo9/5Bp4JtTpi2Ov5MSvEE=; b=YxKytr9cTuwaIINvLhhaPmLw/pDU4V/JUYHu1v4RdpZvP6U4+n6hmjVrlVgN+H6LVw utt4+voImR+W/La7cgj21O7ONdzauwfcLy4yOA1Ha6vBI09Y4Ju5j0SQxglDmRBhPR33 8MNP39mGeSYUZB7HRwW0ygtt2kibCWtsbz968= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=o5mV2D6PbCDlX2d5AY2c5hInu03OdHasXVX3UBJjomzRfsKeCtvJxRivr2NRpM31Oi z/AVpg3ESyS3kk3hEGWUf1PV4w4FLEiZGbg9+kTmcHsQu2lrPDLYEBPovJ86zgCLWmnl lyro7WfEwdr9t6ks+RhCJ1Fqc4LwqwRvghdPA= Received: by 10.227.142.203 with SMTP id r11mr13193602wbu.134.1278970848301; Mon, 12 Jul 2010 14:40:48 -0700 (PDT) Received: from debian.bg45.phnet (82.159.167.40.static.user.ono.com [82.159.167.40]) by mx.google.com with ESMTPS id s59sm2025070wec.2.2010.07.12.14.40.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 12 Jul 2010 14:40:46 -0700 (PDT) Message-ID: <4C3B8BD4.9010706@gmail.com> Date: Mon, 12 Jul 2010 23:40:36 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100620 Icedove/3.0.5 MIME-Version: 1.0 To: grub-devel@gnu.org References: <20100712115236.GL21862@riva.ucam.org> In-Reply-To: <20100712115236.GL21862@riva.ucam.org> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig5D76B127531A1A2BEF5C0557" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] Improve EFI grub-install to handle non-Apple systems X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2010 21:40:53 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5D76B127531A1A2BEF5C0557 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/12/2010 01:52 PM, Colin Watson wrote: > At the moment, the EFI grub-install script only handles Apple Mac > systems. This patch adds support for systems that conform to the UEFI > specification, while retaining support for Apple systems. > > =20 Apple systems seem to support generic way too. So if this way is properly tested on different Apple systems we should switch to generic way altogether. > I couldn't find anything approaching a standard for where the EFI Syste= m > Partition should be mounted, so I chose to look for it in /boot/efi, > since I don't like creating new top-level directories. If there's a > different convention then I'd be happy to add support for it. > > =20 Where to mount X or Y depends on distribution. I'm happy to support whatever you feel is right. This will probably set a precedent and other distros will follow. > Vladimir asked whether I could merge util/i386/efi/grub-install.in into= > util/grub-install.in at the same time. This is of course desirable but= > I haven't got round to it yet, and I didn't want to stall this patch > indefinitely until I find time for that. > > 2010-07-12 Colin Watson > > * util/i386/efi/grub-install.in: Add support for systems that > conform to the UEFI specification, as well as Apple systems. > Currently looks for the EFI System Partition on /boot/efi. > > =3D=3D=3D modified file 'util/i386/efi/grub-install.in' > --- util/i386/efi/grub-install.in 2010-07-04 12:23:55 +0000 > +++ util/i386/efi/grub-install.in 2010-07-12 11:43:20 +0000 > @@ -24,6 +24,7 @@ exec_prefix=3D@exec_prefix@ > sbindir=3D@sbindir@ > bindir=3D@bindir@ > libdir=3D@libdir@ > +sysconfdir=3D@sysconfdir@ > PACKAGE_NAME=3D@PACKAGE_NAME@ > PACKAGE_TARNAME=3D@PACKAGE_TARNAME@ > PACKAGE_VERSION=3D@PACKAGE_VERSION@ > @@ -43,10 +44,14 @@ rootdir=3D > grub_prefix=3D`echo /boot/grub | sed ${transform}` > modules=3D > =20 > +efibootmgr=3D`which efibootmgr 2>/dev/null || true` > + > no_floppy=3D > force_lba=3D > recheck=3Dno > +removable=3Dno > debug=3Dno > +efi_quiet=3D > =20 > # Usage: usage > # Print the usage. > @@ -65,6 +70,7 @@ Install GRUB on your EFI partition. > --grub-probe=3DFILE use FILE as grub-probe > --no-floppy do not probe any floppy drive > --recheck probe a device map even if it already exists= > + --removable the installation device is removable > =20 > $self copies GRUB images into the DIR/boot directory specified by > --root-directory. > @@ -127,9 +133,14 @@ do > no_floppy=3D"--no-floppy" ;; > --recheck) > recheck=3Dyes ;; > + --removable) > + removable=3Dyes ;; > # This is an undocumented feature... > --debug) > debug=3Dyes ;; > + # Intentionally undocumented; for compatibility only. > + -f | --force) > + ;; > *) > echo "Unrecognized option \`$option'" 1>&2 > usage > @@ -138,9 +149,13 @@ do > esac > done > =20 > +# for make_system_path_relative_to_its_root() > +. ${libdir}/grub/grub-mkconfig_lib > + > # If the debugging feature is enabled, print commands. > if test $debug =3D yes; then > set -x > + efi_quiet=3D-q > fi > =20 > # Initialize these directories here, since ROOTDIR was initialized. > @@ -177,6 +192,106 @@ else > exit 1 > fi > =20 > +# Get GRUB_DISTRIBUTOR. > +if test -f ${sysconfdir}/default/grub ; then > + . ${sysconfdir}/default/grub > +fi > + > +# Find the EFI System Partition. > +efidir=3D > +if test -d ${bootdir}/efi; then > + install_device=3D`$grub_mkdevicemap --device-map=3D/dev/stdout | $= grub_probe --target=3Ddevice --device-map=3D/dev/stdin ${bootdir}/efi` > + # Is it a mount point? > + if test "x$install_device" !=3D "x`$grub_mkdevicemap --device-map=3D= /dev/stdout | $grub_probe --target=3Ddevice --device-map=3D/dev/stdin ${b= ootdir}`"; then > + efidir=3D${bootdir}/efi > + fi > +elif test -n "$rootdir" && test "x$rootdir" !=3D "x/"; then > + # The EFI System Partition may have been given directly using > + # --root-directory. > + install_device=3D`$grub_mkdevicemap --device-map=3D/dev/stdout | $= grub_probe --target=3Ddevice --device-map=3D/dev/stdin ${rootdir}` > + # Is it a mount point? > + if test "x$install_device" !=3D "x`$grub_mkdevicemap --device-map=3D= /dev/stdout | $grub_probe --target=3Ddevice --device-map=3D/dev/stdin ${r= ootdir}/..`"; then > + efidir=3D${rootdir} > + fi > +fi > + > =20 This seems to change the meaning of --root-directory. Perhaps another option would be better? > +if test -n "$efidir"; then > + efi_fs=3D`$grub_probe --target=3Dfs --device-map=3D${device_map} $= {efidir}` > + if test "x$efi_fs" =3D xfat; then :; else > + echo "${efidir} doesn't look like an EFI partition." 1>&2 > + efidir=3D > + fi > +fi > + > +if test -n "$efidir"; then > + # The EFI specification requires that an EFI System Partition must= > + # contain an "EFI" subdirectory, and that OS loaders are stored in= > + # subdirectories below EFI. Vendors are expected to pick names th= at do > + # not collide with other vendors. To minimise collisions, we use = the > + # name of our distributor if possible. > =20 I'm not sure how well this is implemented in a real world. We may need to change that to efi_distributor=3DBOOT If real implementations don't work as well as expected > + if test $removable =3D yes; then > + # The specification makes stricter requirements of removable > + # devices, in order that only one image can be automatically loaded > + # from them. The image must always reside under /EFI/BOOT, and it > + # must have a specific file name depending on the architecture. > + efi_distributor=3DBOOT > + case "$target_cpu" in > + i386) > + efi_file=3DBOOTIA32.EFI > + ;; > + x86-64) > + efi_file=3DBOOTX64.EFI > + ;; > + # GRUB does not yet support these architectures, but they're defined > + # by the specification so we include them here to ease future > + # expansion. > + ia64) > + efi_file=3DBOOTIA64.EFI > + ;; > + arm) > + efi_file=3DBOOTARM.EFI > + ;; > + esac > + else > + efi_distributor=3D"$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | = cut -d' ' -f1)" > =20 Perhaps we need a check that name contains no non-ASCII characters. EFI is supposed to support unicode but some parts of its spec contradict Unicode. > +# Try to make this image bootable using the EFI Boot Manager, if avail= able. > +if test "$removable" =3D no && test -n "$efi_distributor" && \ > + test -n "$efibootmgr"; then > + # On Linux, we need the efivars kernel modules. > + case "$host_os" in > + linux*) > + modprobe -q efivars 2>/dev/null || true > + ;; > + esac > + > =20 What about using efi_distributor=3Dboot if efivars fails to load? Many people have a mismatchin Linux and EFI and so use "noefi" on command line. Or "noefi" is there for some other reason. > + # Delete old entries from the same distributor. > + for bootnum in `efibootmgr | grep '^Boot[0-9]' | \ > + fgrep " $efi_distributor" | cut -b5-8`; do > + efibootmgr $efi_quiet -b "$bootnum" -B > + done > + > =20 This would conflict with installing both ia32 and x64 because second install will erase first one. Sane way may be to use efibootmgr only if installed version matches current EFI. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig5D76B127531A1A2BEF5C0557 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAkw7i9oACgkQNak7dOguQgmCSgD8DAwC6zUBXiYfEZHvgu3XltHO rcKk6OUCjfp+OCTKOdAA/3nNe1caUIZc90wbzooGdqdaRAj6WlvjMNzin7DosICQ =hPR7 -----END PGP SIGNATURE----- --------------enig5D76B127531A1A2BEF5C0557--