Commit 831b6df6 authored by Lorenzo "Palinuro" Faletra's avatar Lorenzo "Palinuro" Faletra
Browse files

Import Debian changes 2.02+dfsg1-11parrot1

grub2 (2.02+dfsg1-11parrot1) testing; urgency=medium

  * Import new Debian release.

grub2 (2.02+dfsg1-11) unstable; urgency=medium

  [ Colin Watson ]
  * Apply patches from Alexander Graf to set arm64-efi code offset to
    EFI_PAGE_SIZE (closes: #919012, LP: #1812317).
  * Upgrade to debhelper v10.
  * Set Rules-Requires-Root: no.
  * Add help and ls modules to signed UEFI images (closes: #919955).
  * Fix application of answers from dpkg-reconfigure to /etc/default/grub
    (based loosely on a patch by Steve Langasek, for which thanks; closes:
    #921702).

  [ Steve McIntyre ]
  * Make grub-efi-amd64-signed recommend shim-signed (closes: #919067).

  [ Jeroen Dekkers ]
  * Initialize keyboard in at_keyboard module init if keyboard is ready
    (closes: #741464).

  [ John Paul Adrian Glaubitz ]
  * Include a.out header in assembly of sparc64 boot loader (closes:
    #921249).

  [ Hervé Werner ]
  * Fix setup on Secure Boot systems where cryptodisk is in use (closes:
    #917117).

  [ Debconf translations ]
  * [de] German (Helge Kreutzmann and Holger Wansing; closes: #921018).
parent 0105bd6d
# see git-dpm(1) from git-dpm package
0e3e215f58cbacbd623a19c5283da412d729cc65
0e3e215f58cbacbd623a19c5283da412d729cc65
ec85b3d37cd12b4121a286a47e84ecb79a714df8
ec85b3d37cd12b4121a286a47e84ecb79a714df8
59aeb1cfaa3d5bfd7bbeeee0f0d37f6d9eed51fe
59aeb1cfaa3d5bfd7bbeeee0f0d37f6d9eed51fe
grub2_2.02+dfsg1.orig.tar.xz
......
......@@ -99,6 +99,7 @@ CD_MODULES="
gfxterm_background
gzio
halt
help
hfsplus
iso9660
jpeg
......@@ -106,6 +107,7 @@ CD_MODULES="
loadenv
loopback
linux
ls
lsefi
lsefimmap
lsefisystab
......
grub2 (2.02+dfsg1-11parrot1) testing; urgency=medium
* Import new Debian release.
-- Lorenzo "Palinuro" Faletra <palinuro@parrotsec.org> Thu, 28 Feb 2019 14:40:16 +0100
grub2 (2.02+dfsg1-11) unstable; urgency=medium
[ Colin Watson ]
* Apply patches from Alexander Graf to set arm64-efi code offset to
EFI_PAGE_SIZE (closes: #919012, LP: #1812317).
* Upgrade to debhelper v10.
* Set Rules-Requires-Root: no.
* Add help and ls modules to signed UEFI images (closes: #919955).
* Fix application of answers from dpkg-reconfigure to /etc/default/grub
(based loosely on a patch by Steve Langasek, for which thanks; closes:
#921702).
[ Steve McIntyre ]
* Make grub-efi-amd64-signed recommend shim-signed (closes: #919067).
[ Jeroen Dekkers ]
* Initialize keyboard in at_keyboard module init if keyboard is ready
(closes: #741464).
[ John Paul Adrian Glaubitz ]
* Include a.out header in assembly of sparc64 boot loader (closes:
#921249).
[ Hervé Werner ]
* Fix setup on Secure Boot systems where cryptodisk is in use (closes:
#917117).
[ Debconf translations ]
* [de] German (Helge Kreutzmann and Holger Wansing; closes: #921018).
-- Colin Watson <cjwatson@debian.org> Sun, 10 Feb 2019 18:53:41 +0000
grub2 (2.02+dfsg1-10parrot1) parrot; urgency=medium
* Import new Debian and Kali updates.
......
......@@ -3,10 +3,8 @@ Section: admin
Priority: optional
Maintainer: GRUB Maintainers <pkg-grub-devel@alioth-lists.debian.net>
Uploaders: Felix Zielcke <fzielcke@z-51.de>, Jordi Mallach <jordi@debian.org>, Colin Watson <cjwatson@debian.org>, Ian Campbell <ijc@debian.org>
Build-Depends: debhelper (>= 7.4.2~),
Build-Depends: debhelper (>= 10~),
patchutils,
dh-autoreconf,
automake,
python,
flex,
bison,
......@@ -39,6 +37,7 @@ Standards-Version: 3.9.6
Homepage: https://www.gnu.org/software/grub/
Vcs-Git: https://salsa.debian.org/grub-team/grub.git
Vcs-Browser: https://salsa.debian.org/grub-team/grub
Rules-Requires-Root: no
Package: grub2
Section: oldlibs
......
From a701b9525ebe6f7343ed2a36395009cdfad74dee Mon Sep 17 00:00:00 2001
From: Jeroen Dekkers <jeroen@dekkers.ch>
Date: Sat, 12 Jan 2019 21:02:18 +0100
Subject: at_keyboard: initialize keyboard in module init if keyboard is ready
The change in 0c62a5b2 caused at_keyboard to fail on some
machines. Immediately initializing the keyboard in the module init if
the keyboard is ready makes the problem go away.
Bug-Debian: https://bugs.debian.org/741464
Last-Update: 2019-02-09
Patch-Name: at-keyboard-module-init.patch
---
grub-core/term/at_keyboard.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c
index b4ea9ff7e..d3fef0b67 100644
--- a/grub-core/term/at_keyboard.c
+++ b/grub-core/term/at_keyboard.c
@@ -607,6 +607,14 @@ grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
}
}
+static grub_err_t
+grub_keyboard_controller_mod_init (struct grub_term_input *term __attribute__ ((unused))) {
+ if (KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ grub_keyboard_controller_init ();
+
+ return GRUB_ERR_NONE;
+}
+
static void
grub_keyboard_controller_init (void)
{
@@ -677,6 +685,7 @@ grub_at_restore_hw (void)
static struct grub_term_input grub_at_keyboard_term =
{
.name = "at_keyboard",
+ .init = grub_keyboard_controller_mod_init,
.fini = grub_keyboard_controller_fini,
.getkey = grub_at_keyboard_getkey
};
From f13b30739d150f264892975e75fa4b2d8fc68aee Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Mon, 28 Jan 2019 14:35:28 +0100
Subject: mkimage: Align efi sections on 4k boundary
There is UEFI firmware popping up in the wild now that implements stricter
permission checks using NX and write protect page table entry bits.
This means that firmware now may fail to load binaries if its individual
sections are not page aligned, as otherwise it can not ensure permission
boundaries.
So let's bump all efi section alignments up to 4k (EFI page size). That way
we will stay compatible going forward.
Unfortunately our internals can't deal very well with a mismatch of alignment
between the virtual and file offsets, so we have to also pad our target
binary a bit.
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Julien ROBIN <julien.robin28@free.fr>
Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a51f953f4ee87cbfbf25a7df564304c5e9fea6a0
Bug-Debian: https://bugs.debian.org/919012
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1812317
Last-Update: 2019-02-09
Patch-Name: mkimage_Align_efi_sections_on_4k_boundary.patch
---
include/grub/efi/pe32.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h
index 7d44732d2..207b0382e 100644
--- a/include/grub/efi/pe32.h
+++ b/include/grub/efi/pe32.h
@@ -20,6 +20,7 @@
#define GRUB_EFI_PE32_HEADER 1
#include <grub/types.h>
+#include <grub/efi/memory.h>
/* The MSDOS compatibility stub. This was copied from the output of
objcopy, and it is not necessary to care about what this means. */
@@ -50,8 +51,14 @@
/* According to the spec, the minimal alignment is 512 bytes...
But some examples (such as EFI drivers in the Intel
Sample Implementation) use 32 bytes (0x20) instead, and it seems
- to be working. For now, GRUB uses 512 bytes for safety. */
-#define GRUB_PE32_SECTION_ALIGNMENT 0x200
+ to be working.
+
+ However, there is firmware showing up in the field now with
+ page alignment constraints to guarantee that page protection
+ bits take effect. Because currently existing GRUB code can not
+ properly distinguish between in-memory and in-file layout, let's
+ bump all alignment to GRUB_EFI_PAGE_SIZE. */
+#define GRUB_PE32_SECTION_ALIGNMENT GRUB_EFI_PAGE_SIZE
#define GRUB_PE32_FILE_ALIGNMENT GRUB_PE32_SECTION_ALIGNMENT
struct grub_pe32_coff_header
From 055c41e800656075ba09775eda5faa642963a8b0 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Mon, 28 Jan 2019 14:35:27 +0100
Subject: mkimage: Use EFI32_HEADER_SIZE define in arm-efi case
The efi-arm case was defining its own header size calculation, even though it's
100% identical to the common EFI32_HEADER_SIZE definition.
So let's clean it up to use the common define.
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Julien ROBIN <julien.robin28@free.fr>
Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e347f40c1af2457a634af71e3cc75e851c641847
Bug-Debian: https://bugs.debian.org/919012
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1812317
Last-Update: 2019-02-09
Patch-Name: mkimage_arm-efi_Use_EFI32_HEADER_SIZE.patch
---
util/mkimage.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index c3bd23479..7621c911d 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -563,12 +563,7 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
- .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
- + GRUB_PE32_SIGNATURE_SIZE
- + sizeof (struct grub_pe32_coff_header)
- + sizeof (struct grub_pe32_optional_header)
- + 4 * sizeof (struct grub_pe32_section_table),
- GRUB_PE32_SECTION_ALIGNMENT),
+ .vaddr_offset = EFI32_HEADER_SIZE,
.pe_target = GRUB_PE32_MACHINE_ARMTHUMB_MIXED,
.elf_target = EM_ARM,
},
From 6427cc7c960f320163674e549d5e64f2a5ce65c0 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Mon, 28 Jan 2019 14:35:29 +0100
Subject: mkimage: Clarify file alignment in efi case
There are a few spots in the PE generation code for EFI binaries that uses
the section alignment rather than file alignment, even though the alignment
is really only file bound.
Replace those cases with the file alignment constant instead.
Reported-by: Daniel Kiper <dkiper@net-space.pl>
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Julien ROBIN <julien.robin28@free.fr>
Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=9223eff8f8025511938c7eec908d60bdaa74106a
Bug-Debian: https://bugs.debian.org/919012
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1812317
Last-Update: 2019-02-09
Patch-Name: mkimage_clarify_file_alignment_efi.patch
---
util/mkimage.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index 7621c911d..7f366c3d2 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -66,14 +66,14 @@
+ sizeof (struct grub_pe32_coff_header) \
+ sizeof (struct grub_pe32_optional_header) \
+ 4 * sizeof (struct grub_pe32_section_table), \
- GRUB_PE32_SECTION_ALIGNMENT)
+ GRUB_PE32_FILE_ALIGNMENT)
#define EFI64_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \
+ GRUB_PE32_SIGNATURE_SIZE \
+ sizeof (struct grub_pe32_coff_header) \
+ sizeof (struct grub_pe64_optional_header) \
+ 4 * sizeof (struct grub_pe32_section_table), \
- GRUB_PE32_SECTION_ALIGNMENT)
+ GRUB_PE32_FILE_ALIGNMENT)
static const struct grub_install_image_target_desc image_targets[] =
{
@@ -1170,10 +1170,10 @@ grub_install_generate_image (const char *dir, const char *prefix,
header_size = EFI64_HEADER_SIZE;
reloc_addr = ALIGN_UP (header_size + core_size,
- image_target->section_align);
+ GRUB_PE32_FILE_ALIGNMENT);
pe_size = ALIGN_UP (reloc_addr + layout.reloc_size,
- image_target->section_align);
+ GRUB_PE32_FILE_ALIGNMENT);
pe_img = xmalloc (reloc_addr + layout.reloc_size);
memset (pe_img, 0, header_size);
memcpy ((char *) pe_img + header_size, core_img, core_size);
@@ -1223,7 +1223,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
o->image_base = 0;
o->section_alignment = grub_host_to_target32 (image_target->section_align);
- o->file_alignment = grub_host_to_target32 (image_target->section_align);
+ o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT);
o->image_size = grub_host_to_target32 (pe_size);
o->header_size = grub_host_to_target32 (header_size);
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
@@ -1258,7 +1258,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
o->code_base = grub_cpu_to_le32 (header_size);
o->image_base = 0;
o->section_alignment = grub_host_to_target32 (image_target->section_align);
- o->file_alignment = grub_host_to_target32 (image_target->section_align);
+ o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT);
o->image_size = grub_host_to_target32 (pe_size);
o->header_size = grub_host_to_target32 (header_size);
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
......@@ -120,3 +120,9 @@ xen-pvh-elfnote-defines.patch
xen-pvh-mkimage.patch
xen-pvh-install.patch
xen-pvh-configure.patch
mkimage_arm-efi_Use_EFI32_HEADER_SIZE.patch
mkimage_Align_efi_sections_on_4k_boundary.patch
mkimage_clarify_file_alignment_efi.patch
at-keyboard-module-init.patch
sparc64-aout-fix.patch
uefi-secure-boot-cryptomount.patch
From b5148a73117bceb9d831e7b53509893618bff3df Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Sat, 9 Feb 2019 09:49:29 +0000
Subject: ieee1275: Include a.out header in assembly of sparc64 boot loader
Recent versions of binutils dropped support for the a.out and COFF
formats on sparc64 targets. Since the boot loader on sparc64 is
supposed to be an a.out binary and the a.out header entries are
rather simple to calculate in our case, we just write the header
ourselves instead of relying external tools to do that.
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Bug-Debian: https://bugs.debian.org/921249
Forwarded: https://lists.gnu.org/archive/html/grub-devel/2019-02/msg00014.html
Last-Update: 2019-02-09
Patch-Name: sparc64-aout-fix.patch
---
grub-core/Makefile.core.def | 6 ++----
grub-core/boot/sparc64/ieee1275/boot.S | 16 +++++++++++++---
include/grub/sparc64/ieee1275/boot.h | 3 +--
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 94a15f8c7..0f6c5f874 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -381,8 +381,7 @@ image = {
i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
- sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
- sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
objcopyflags = '-O binary';
enable = i386_pc;
@@ -411,8 +410,7 @@ image = {
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
- sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
- sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
sparc64_ieee1275_cppflags = '-DCDBOOT=1';
objcopyflags = '-O binary';
diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S
index 9ea9b4e06..0c8459e35 100644
--- a/grub-core/boot/sparc64/ieee1275/boot.S
+++ b/grub-core/boot/sparc64/ieee1275/boot.S
@@ -21,6 +21,16 @@
.text
.align 4
+ /* The a.out header, as binutils decided to drop a.out
+ */
+ .word 0x1030107 /* A_MAGIC */
+ .word 512 - GRUB_BOOT_AOUT_HEADER_SIZE /* text size */
+ .word 0 /* data size */
+ .word 0 /* bss size */
+ .word 0 /* symbol table size */
+ .word _start /* entry point */
+ .word 0 /* text relocations */
+ .word 0 /* data relocations */
.globl _start
_start:
/* OF CIF entry point arrives in %o4 */
@@ -41,9 +51,9 @@ pic_base:
* After loading in that block we will execute it by jumping to the
* load address plus the size of the prepended A.OUT header (32 bytes).
*/
- .org GRUB_BOOT_MACHINE_BOOT_DEVPATH
+ .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + GRUB_BOOT_AOUT_HEADER_SIZE
boot_path:
- .org GRUB_BOOT_MACHINE_KERNEL_BYTE
+ .org GRUB_BOOT_MACHINE_KERNEL_BYTE + GRUB_BOOT_AOUT_HEADER_SIZE
boot_path_end:
kernel_byte: .xword (2 << 9)
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
@@ -52,7 +62,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#define boot_path_end (_start + 1024)
#include <grub/offsets.h>
- .org 8
+ .org 8 + GRUB_BOOT_AOUT_HEADER_SIZE
kernel_byte: .xword (2 << 9)
kernel_size: .word 512
kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h
index 02d53f28e..cc5a941e3 100644
--- a/include/grub/sparc64/ieee1275/boot.h
+++ b/include/grub/sparc64/ieee1275/boot.h
@@ -46,8 +46,7 @@
#define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80
-#define GRUB_BOOT_MACHINE_CODE_END \
- (0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE)
+#define GRUB_BOOT_MACHINE_CODE_END 0x1fc
#define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200
From ec85b3d37cd12b4121a286a47e84ecb79a714df8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Werner?= <dud225@hotmail.com>
Date: Mon, 28 Jan 2019 17:24:23 +0100
Subject: Fix setup on Secure Boot systems where cryptodisk is in use
On full-encrypted systems, including /boot, the current code omits
cryptodisk commands needed to open the drives if Secure Boot is enabled.
This prevents grub2 from reading any further configuration residing on
the encrypted disk.
This patch fixes this issue by adding the needed "cryptomount" commands in
the load.cfg file that is then copied in the EFI partition.
Bug-Debian: https://bugs.debian.org/917117
Last-Update: 2019-02-10
Patch-Name: uefi-secure-boot-cryptomount.patch
---
util/grub-install.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/util/grub-install.c b/util/grub-install.c
index 6bc96fc8f..81b648efc 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1502,6 +1502,23 @@ main (int argc, char *argv[])
|| uefi_secure_boot)
{
char *uuid = NULL;
+
+ if (uefi_secure_boot && config.is_cryptodisk_enabled)
+ {
+ if (grub_dev->disk)
+ probe_cryptodisk_uuid (grub_dev->disk);
+
+ for (curdrive = grub_drives + 1; *curdrive; curdrive++)
+ {
+ grub_device_t dev = grub_device_open (*curdrive);
+ if (!dev)
+ continue;
+ if (dev->disk)
+ probe_cryptodisk_uuid (dev->disk);
+ grub_device_close (dev);
+ }
+ }
+
/* generic method (used on coreboot and ata mod). */
if (!force_file_id && grub_fs->uuid && grub_fs->uuid (grub_dev,
&uuid))
......@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: 2.02~beta3-4\n"
"Report-Msgid-Bugs-To: grub2@packages.debian.org\n"
"POT-Creation-Date: 2017-01-20 00:29+0000\n"
"PO-Revision-Date: 2017-01-20 21:15+0100\n"
"PO-Revision-Date: 2019-01-31 18:13+0100\n"
"Last-Translator: Helge Kreutzmann <debian@helgefjell.de>\n"
"Language-Team: German <debian-l10n-german@lists.debian.org>\n"
"Language: de\n"
......@@ -122,7 +122,7 @@ msgid ""
"use the blocklist mechanism, which makes it less reliable, and therefore is "
"not recommended."
msgstr ""
"Hinweis: Sie können GRUB auch in die Boot-Blöcke von Partionen schreiben."
"Hinweis: Sie können GRUB auch in die Boot-Blöcke von Partitionen schreiben."
"Hier werden auch einige geeignete Partitionen angeboten. Das zwingt GRUB "
"allerdings dazu, den Blocklist-Mechanismus zu verwenden. Dieser ist weniger "
"zuverlässig und wird daher nicht empfohlen."
......
#!/bin/bash
set -e
# Apply a sed expression using extended regular expressions in place to a
# file, if it exists. The file is the first argument in order to work
# neatly with apply_conf_tweaks.
sed_conf()
{
if [ -e "$1" ]; then
sed -i -re "$2" "$1"
fi
}
# Substitute a debconf answer into a configuration file with the syntax of
# /etc/default/grub.
merge_debconf_into_conf()
{
local tmpfile; tmpfile="$1"
......@@ -18,6 +30,21 @@ merge_debconf_into_conf()
fi
}
# Apply the same configuration tweak to multiple files.
apply_conf_tweaks()
{
local files; files="$1"
local cmd; cmd="$2"
local file
shift 2
for file in $files; do
if [ -e "$file" ]; then
"$cmd" "$file" "$@"
fi
done
}
get_wubi_device()
{
if [ ! -x /usr/share/lupin-support/grub-mkimage ] || \
......@@ -371,16 +398,37 @@ case "$1" in
trap "rm -f ${tmp_default_grub}" EXIT
cp -p /usr/share/grub/default/grub ${tmp_default_grub}
merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX grub2/linux_cmdline
merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX_DEFAULT grub2/linux_cmdline_default
# Apply configuration from debconf to both the template configuration
# file (so that any ucf conflict resolution is shown with the configured
# values in place) and to /etc/default/grub (in order that debconf
# changes are effective even if we have to use UCF_FORCE_CONFFOLD=1).
#
# The config script takes care to read current values from
# /etc/default/grub before possibly prompting the user to change them,
# so this should comply with policy's strictures on configuration file
# handling: the debconf prompts constitute an explicit administrator
# request to change the configuration file.
#
# If the administrator changes their answers to any of these debconf
# questions in the same run as a change to the template, then they'll
# get a spurious ucf conflict. To fix this, we'd need to keep track of
# the old answers, substitute the old answers into $tmp_default_grub,
# and substitute the new answers into /etc/default/grub. Fortunately,
# debconf won't normally ask these questions again during an upgrade, so
# this should be rare in practice.
conf_files="$tmp_default_grub /etc/default/grub"
apply_conf_tweaks "$conf_files" merge_debconf_into_conf GRUB_CMDLINE_LINUX grub2/linux_cmdline
apply_conf_tweaks "$conf_files" merge_debconf_into_conf GRUB_CMDLINE_LINUX_DEFAULT grub2/linux_cmdline_default
case @PACKAGE@ in
grub-pc)
merge_debconf_into_conf "$tmp_default_grub" GRUB_TIMEOUT grub-pc/timeout
sed -i -e 's/^\(GRUB_TIMEOUT=\)"\([0-9][0-9]*\)"/\1\2/' "$tmp_default_grub"
apply_conf_tweaks "$conf_files" merge_debconf_into_conf GRUB_TIMEOUT grub-pc/timeout
apply_conf_tweaks "$conf_files" sed_conf 's/^(GRUB_TIMEOUT=)"([0-9][0-9]*)"/\1\2/'
db_get grub-pc/hidden_timeout
if [ "$RET" = false ]; then
sed -i -e 's/^GRUB_HIDDEN_TIMEOUT=/#&/' "$tmp_default_grub"
apply_conf_tweaks "$conf_files" sed_conf 's/^GRUB_HIDDEN_TIMEOUT=/#&/'
fi
;;
esac
......@@ -390,7 +438,8 @@ case "$1" in
# debconf-based customisations on top of the template configuration
# file.
if [ -e /var/lib/grub/ucf/grub.previous ] && \
cmp -s /usr/share/grub/default/grub /var/lib/grub/ucf/grub.previous; then
cmp -s /usr/share/grub/default/grub /var/lib/grub/ucf/grub.previous && \
[ -e /etc/default/grub ]; then
ucf_env=UCF_FORCE_CONFFOLD=1
else
ucf_env=
......
......@@ -17,7 +17,6 @@ HOST_CFLAGS := -Wall -Wno-error=unused-result $(shell dpkg-buildflags --get CFLA
HOST_LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
export DEB_HOST_ARCH
unexport CFLAGS
export HOST_CPPFLAGS
export HOST_CFLAGS
export HOST_LDFLAGS
......@@ -28,6 +27,12 @@ ifneq (,$(filter sparc sparc64,$(DEB_HOST_ARCH_CPU)))
export TARGET_CCASFLAGS := -fno-PIE
endif
# Ensure that debhelper doesn't try to set these; we need to be careful
# about HOST_* vs. TARGET_*.
export CPPFLAGS :=
export CFLAGS :=
export LDFLAGS :=
ifeq (,$(shell which qemu-system-i386 2>/dev/null))
with_check := no
else
......@@ -39,6 +44,7 @@ CC := gcc-8
confflags = \
PACKAGE_VERSION="$(deb_version)" PACKAGE_STRING="GRUB $(deb_version)" \
CC=$(CC) TARGET_CC=$(CC) \
--libdir=\$${