Merge ~mwhudson/ubiquity:lp-1847721 into ubiquity:master

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 84d9b9d25f33c9966b3ee900c605e51aa490db6f
Proposed branch: ~mwhudson/ubiquity:lp-1847721
Merge into: ubiquity:master
Diff against target: 98 lines (+26/-13)
3 files modified
d-i/source/grub-installer/grub-installer (+11/-12)
scripts/plugininstall.py (+7/-0)
ubiquity/components/grubinstaller.py (+8/-1)
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+384069@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Ah this doesn't work, I think perhaps instead of hacking grub-installer like this, it would be easier to just install the packages and run chroot /target grub-install --target=x86_64-efi in the ubiquity code. Open to input here :)

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

So this depends on our goal.

At the moment, it is not possible to install _both_ grub-efi-amd64 and grub-pc, and keep both maintained correctly.

We can install both grub-pc-bin & grub-efi-amd64-bin (& grub-efi-amd64-signed) but only one of them will be updated.

So imho, for now, if we booted in bios mode we should install grub-pc + grub-efi-amd64-bin, run grub-install --target x86_64-efi, and then install grub-efi-amd64-signed.

Revision history for this message
Steve Langasek (vorlon) wrote :

> So imho, for now, if we booted in bios mode we should install
> grub-pc + grub-efi-amd64-bin, run grub-install --target x86_64-efi,
> and then install grub-efi-amd64-signed.

We ought to be installing shim-signed, which pulls in grub-efi-amd64-signed as a dependency; and this will run grub-install --target x86_64-efi for us with the right options. Is there any reason to run grub-install --target x86_64-efi manually?

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I'm putting this review on hold for now, until we have the spec done and have a coherent implementation.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

With some updates to my grub-installer MP I can do an on-rails legacy boot install and then boot it under UEFI. I'm about to push an update towards getting other scenarios to work with some XXX comments I'd love some help with :)

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

with the recent partman-efi changes, the UI complains if you don't create an ESP even when booted in legacy mode, so I think that aspect is OK. But when booted under UEFI, the default partitioning does not create a bios_grub partition and there is no complaint if you don't create one manually. So I think I'll take the "install so legacy boot works when UEFI booted" bits out of this and my grub-installer MP and we can make that work in separate changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/d-i/source/grub-installer/grub-installer b/d-i/source/grub-installer/grub-installer
2index 8879dbe..2329f0e 100755
3--- a/d-i/source/grub-installer/grub-installer
4+++ b/d-i/source/grub-installer/grub-installer
5@@ -8,11 +8,16 @@ set -e
6 if [ "$1" ]; then
7 ROOT="$1"
8 chroot=chroot
9+ shift
10 else
11 ROOT=
12 chroot=
13 fi
14
15+if [ "$1" ]; then
16+ ARCH="$1"
17+fi
18+
19 . /usr/share/grub-installer/functions.sh
20 . /usr/share/grub-installer/otheros.sh
21
22@@ -37,7 +42,7 @@ debug () {
23 [ -z "${DEBCONF_DEBUG}" ] || log "debug: $@"
24 }
25
26-ARCH="$(archdetect)"
27+ARCH="${ARCH:-$(archdetect)}"
28 info "architecture: $ARCH"
29
30 umount_dirs=
31@@ -494,17 +499,7 @@ case $ARCH in
32 if [ -f /var/lib/partman/ignore_uefi ]; then
33 grub_package="grub-pc"
34 else
35- grub_package="grub-efi"
36- # Override the package choice if we can figure out the
37- # right package to use directly
38- if [ -f /sys/firmware/efi/fw_platform_size ] ; then
39- SIZE=$(cat /sys/firmware/efi/fw_platform_size)
40- if [ $SIZE -eq 64 ] ; then
41- grub_package="grub-efi-amd64-signed"
42- elif [ $SIZE -eq 32 ] ; then
43- grub_package="grub-efi-ia32"
44- fi
45- fi
46+ grub_package="grub-efi-amd64-signed"
47 if [ ! -d /target/boot/efi ]; then
48 # No EFI System Partition, so presumably the partitioner
49 # believed this to be unnecessary, perhaps because we're
50@@ -1094,6 +1089,10 @@ EOF
51 grub_install_params="$grub_install_params --force"
52 fi
53
54+ if [ "$ARCH" = "amd64/efi" ] ; then
55+ grub_install_params="$grub_install_params --target x86_64-efi"
56+ fi
57+
58 CODE=0
59 case $ARCH:$grub_package in
60 *:grub|*:grub-pc|*:grub-efi*|sparc:grub-ieee1275|ppc64el/*:grub-ieee1275)
61diff --git a/scripts/plugininstall.py b/scripts/plugininstall.py
62index 53461ad..e9acdc9 100755
63--- a/scripts/plugininstall.py
64+++ b/scripts/plugininstall.py
65@@ -945,6 +945,13 @@ class Install(install_misc.InstallBase):
66 self.db.set('grub-installer/bootdev', response)
67 else:
68 break
69+ if arch == 'amd64' and subarch != 'efi':
70+ dbfilter = grubinstaller.GrubInstaller(
71+ None, self.db, extra_args=['amd64/efi'])
72+ ret = dbfilter.run_command(auto_process=True)
73+ if ret != 0:
74+ raise install_misc.InstallStepError(
75+ "GrubInstaller failed with code %d" % ret)
76 else:
77 raise install_misc.InstallStepError(
78 "No bootloader installer found")
79diff --git a/ubiquity/components/grubinstaller.py b/ubiquity/components/grubinstaller.py
80index 8c1af85..774d7cb 100644
81--- a/ubiquity/components/grubinstaller.py
82+++ b/ubiquity/components/grubinstaller.py
83@@ -22,8 +22,15 @@ from ubiquity.filteredcommand import FilteredCommand
84
85
86 class GrubInstaller(FilteredCommand):
87+ def __init__(self, frontend, db=None, ui=None, extra_args=None):
88+ super().__init__(frontend, db, ui)
89+ self.extra_args = extra_args
90+
91 def prepare(self):
92- return (['/usr/share/grub-installer/grub-installer', '/target'],
93+ cmd = ['/usr/share/grub-installer/grub-installer', '/target']
94+ if self.extra_args is not None:
95+ cmd.extend(self.extra_args)
96+ return (cmd,
97 ['^grub-installer/bootdev$', 'ERROR'],
98 {'OVERRIDE_UNSUPPORTED_OS': '1'})
99

Subscribers

People subscribed via source and target branches