From 0ccadff7a2be9fcc858e0a1cb7825beb5d81f8c6 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 22 Nov 2022 22:51:32 +0000 Subject: [PATCH] Bundle unicode.pf2 with images Resolves: #2143725 Resolves: #2144113 Signed-off-by: Robbie Harwood --- ...ening-fonts-from-the-bundled-memdisk.patch | 78 +++++++++++++++++++ grub.macros | 32 ++++---- grub.patches | 1 + grub2.spec | 7 +- 4 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 0299-font-Try-opening-fonts-from-the-bundled-memdisk.patch diff --git a/0299-font-Try-opening-fonts-from-the-bundled-memdisk.patch b/0299-font-Try-opening-fonts-from-the-bundled-memdisk.patch new file mode 100644 index 0000000..bad9d90 --- /dev/null +++ b/0299-font-Try-opening-fonts-from-the-bundled-memdisk.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chris Coulson +Date: Wed, 16 Nov 2022 14:40:04 +0000 +Subject: [PATCH] font: Try opening fonts from the bundled memdisk + +Signed-off-by: Robbie Harwood +--- + grub-core/font/font.c | 48 +++++++++++++++++++++++++++++++----------------- + 1 file changed, 31 insertions(+), 17 deletions(-) + +diff --git a/grub-core/font/font.c b/grub-core/font/font.c +index e6616e610c..e421d1ae6f 100644 +--- a/grub-core/font/font.c ++++ b/grub-core/font/font.c +@@ -409,6 +409,27 @@ read_section_as_short (struct font_file_section *section, + return 0; + } + ++static grub_file_t ++try_open_from_prefix (const char *prefix, const char *filename) ++{ ++ grub_file_t file; ++ char *fullname, *ptr; ++ ++ fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1 ++ + sizeof ("/fonts/") + sizeof (".pf2")); ++ if (!fullname) ++ return 0; ++ ptr = grub_stpcpy (fullname, prefix); ++ ptr = grub_stpcpy (ptr, "/fonts/"); ++ ptr = grub_stpcpy (ptr, filename); ++ ptr = grub_stpcpy (ptr, ".pf2"); ++ *ptr = 0; ++ ++ file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024); ++ grub_free (fullname); ++ return file; ++} ++ + /* Load a font and add it to the beginning of the global font list. + Returns 0 upon success, nonzero upon failure. */ + grub_font_t +@@ -427,25 +448,18 @@ grub_font_load (const char *filename) + file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024); + else + { +- const char *prefix = grub_env_get ("prefix"); +- char *fullname, *ptr; +- if (!prefix) ++ file = try_open_from_prefix ("(memdisk)", filename); ++ if (!file) + { +- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), +- "prefix"); +- goto fail; ++ const char *prefix = grub_env_get ("prefix"); ++ if (!prefix) ++ { ++ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), ++ "prefix"); ++ goto fail; ++ } ++ file = try_open_from_prefix (prefix, filename); + } +- fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1 +- + sizeof ("/fonts/") + sizeof (".pf2")); +- if (!fullname) +- goto fail; +- ptr = grub_stpcpy (fullname, prefix); +- ptr = grub_stpcpy (ptr, "/fonts/"); +- ptr = grub_stpcpy (ptr, filename); +- ptr = grub_stpcpy (ptr, ".pf2"); +- *ptr = 0; +- file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024); +- grub_free (fullname); + } + if (!file) + goto fail; diff --git a/grub.macros b/grub.macros index 34f2934..7228e20 100644 --- a/grub.macros +++ b/grub.macros @@ -399,22 +399,31 @@ rm -f %{1}.conf \ gfxmenu gfxterm gzio \\\ halt hfsplus http increment iso9660 \\\ jpeg loadenv loopback linux lvm luks \\\ - luks2 mdraid09 mdraid1x minicmd net \\\ + luks2 \\\ + memdisk \\\ + mdraid09 mdraid1x minicmd net \\\ normal part_apple part_msdos part_gpt \\\ password_pbkdf2 pgp png reboot regexp \\\ search search_fs_uuid search_fs_file \\\ - search_label serial sleep syslinuxcfg \\\ + search_label serial sleep \\\ + squash4 \\\ + syslinuxcfg \\\ test tftp version video xfs zstd " \ -%ifarch x86_64 aarch64 %{arm} riscv64 +%ifarch %{efi_arch} %define efi_mkimage() \ +mkdir -p memdisk/fonts \ +cp %{4}/unicode.pf2 memdisk/fonts \ +mksquashfs memdisk memdisk.squashfs -comp xz \ %{4}./grub-mkimage -O %{1} -o %{2}.orig \\\ -p /EFI/%{efi_vendor} -d grub-core \\\ --sbat %{4}./sbat.csv \\\ + -m memdisk.squashfs \\\ ${GRUB_MODULES} \ %{4}./grub-mkimage -O %{1} -o %{3}.orig \\\ -p /EFI/BOOT -d grub-core \\\ --sbat %{4}./sbat.csv \\\ + -m memdisk.squashfs \\\ ${GRUB_MODULES} \ %{expand:%%define ___pesign_client_cert %{?___pesign_client_cert}%{!?___pesign_client_cert:%{__pesign_client_cert}}} \ %{?__pesign_client_cert:%{expand:%%define __pesign_client_cert %{___pesign_client_cert}}} \ @@ -424,20 +433,14 @@ rm -f %{1}.conf \ %{expand:%%{pesign -s -i %%{2}.onesig -o %%{2} -a %%{5} -c %%{6} -n %%{7}}} \ %{expand:%%{pesign -s -i %%{3}.onesig -o %%{3} -a %%{5} -c %%{6} -n %%{7}}} \ %{nil} -%else -%define efi_mkimage() \ -%{4}./grub-mkimage -O %{1} -o %{2} \\\ - -p /EFI/%{efi_vendor} -d grub-core \\\ - ${GRUB_MODULES} \ -%{4}./grub-mkimage -O %{1} -o %{3} \\\ - -p /EFI/BOOT -d grub-core \\\ - ${GRUB_MODULES} \ -%{nil} %endif %ifarch ppc64le %if 0%{?rhel} %define ieee1275_mkimage() \ +mkdir -p memdisk/fonts \ +cp %{4}/unicode.pf2 memdisk/fonts \ +mksquashfs memdisk memdisk.squashfs -comp xz \ APPENDED_SIG_SIZE=0 \ if [ -x /usr/bin/rpm-sign ]; then \ touch empty.unsigned \ @@ -450,6 +453,7 @@ fi \ # FIXME: using this prefix is fragile, must be done properly \ ./grub-mkimage -O %{1} -o %{2}.orig \\\ -p '/grub2' -d grub-core \\\ + -m memdisk.squashfs \\\ -x %{3} \\\ --appended-signature-size ${APPENDED_SIG_SIZE} \\\ ${GRUB_MODULES} \ @@ -581,8 +585,6 @@ install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \ %ifarch %{arm} \ install -D -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_boot}/BOOTARM.EFI \ %endif \ -install -D -m 700 unicode.pf2 \\\ - ${RPM_BUILD_ROOT}/boot/grub2/fonts/unicode.pf2 \ ${RPM_BUILD_ROOT}/%{_bindir}/grub2-editenv \\\ ${RPM_BUILD_ROOT}/boot/grub2/grubenv create \ %{expand:%%do_install_protected_file grub2-%{package_arch}} \ @@ -690,7 +692,6 @@ ln -s ../boot/grub2/grub.cfg \\\ %ifarch %{arm} \ %attr(0700,root,root) %verify(not mtime) %{efi_esp_boot}/BOOTARM.EFI \ %endif \ -%attr(0700,root,root)/boot/grub2/fonts \ %dir %attr(0700,root,root)/boot/loader/entries \ %ghost %config(noreplace) %attr(0700,root,root)/boot/grub2/grub.cfg \ %ghost %config(noreplace) %verify(not mtime) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \ @@ -712,5 +713,4 @@ ln -s ../boot/grub2/grub.cfg \\\ %{expand:%%files %{1}-cdboot} \ %defattr(-,root,root,-) \ %attr(0700,root,root) %verify(not mtime) %{efi_esp_dir}/%{3} \ -%attr(0700,root,root)/boot/grub2/fonts \ %{nil} diff --git a/grub.patches b/grub.patches index f0f1d83..0d54375 100644 --- a/grub.patches +++ b/grub.patches @@ -296,3 +296,4 @@ Patch0295: 0295-font-Fix-an-integer-underflow-in-blit_comb.patch Patch0296: 0296-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch Patch0297: 0297-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch Patch0298: 0298-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch +Patch0299: 0299-font-Try-opening-fonts-from-the-bundled-memdisk.patch diff --git a/grub2.spec b/grub2.spec index a73e4d8..5f5f801 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 65%{?dist} +Release: 66%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -529,6 +529,11 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Nov 22 2022 Robbie Harwood - 2.06-66 +- Bundle unicode.pf2 with images +- Resolves: #2143725 +- Resolves: #2144113 + * Tue Nov 22 2022 Robbie Harwood - 1:2.06-65 - Don't obsolete the tools package with extra/efi (pbrobinson)