From 562453147ab344c673ce0f06a87f1ecc563c1fa70a16b506c3ac2469eb464444 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 9 Feb 2017 10:44:34 +0000 Subject: [PATCH] Accepting request 455663 from home:michael-chang:branches:Base:System - Fix build error on glibc-2.25 * 0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch * 0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch - Fix fwpath in efi netboot (fate#321993) (bsc#1022294) * 0001-Fix-fwpath-in-efi-netboot.patch OBS-URL: https://build.opensuse.org/request/show/455663 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=251 --- 0001-Fix-fwpath-in-efi-netboot.patch | 46 +++++++ ...C_HEADER_MAJOR-to-find-device-macros.patch | 121 ++++++++++++++++++ ...eck-for-sys-sysmacros.h-under-glibc-.patch | 43 +++++++ grub2.changes | 9 ++ grub2.spec | 6 + 5 files changed, 225 insertions(+) create mode 100644 0001-Fix-fwpath-in-efi-netboot.patch create mode 100644 0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch create mode 100644 0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch diff --git a/0001-Fix-fwpath-in-efi-netboot.patch b/0001-Fix-fwpath-in-efi-netboot.patch new file mode 100644 index 0000000..f82a8ca --- /dev/null +++ b/0001-Fix-fwpath-in-efi-netboot.patch @@ -0,0 +1,46 @@ +From 562c406763d6c078ccf9fad1058e6d618b2456da Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Mon, 19 Dec 2016 17:09:04 +0800 +Subject: [PATCH] Fix fwpath in efi netboot + +The path returned by grub_efi_net_config has already been stripped for the +directory part extracted from cached bootp packet. We should just return the +result to avoild it be stripped again. + +It fixed the problem that grub.efi as NBP image always looking for grub.cfg and +platform directory in upper folder rather than current one it gets loaded while +$prefix is empty. The behavior is inconsistent with other architecture and how +we would expect empty $prefix going to be in general. + +The only exception to the general rule of empty $prefix is that when loaded +from platform directory itself, the platform part is stripped thus upper folder +is used for looking up files. It meets the case for how grub-mknetdir lay out +the files under tftp root directory, but also hide away this issue to be +identified as it appears to be just works. + +Also fix possible memory leak by moving grub_efi_get_filename() call after +grub_efi_net_config(). +--- + grub-core/kern/efi/init.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +Index: grub-2.02~beta3/grub-core/kern/efi/init.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/kern/efi/init.c ++++ grub-2.02~beta3/grub-core/kern/efi/init.c +@@ -121,10 +121,13 @@ grub_machine_get_bootlocation (char **de + if (!image) + return; + *device = grub_efidisk_get_device_name (image->device_handle); +- *path = grub_efi_get_filename (image->file_path); + if (!*device && grub_efi_net_config) +- grub_efi_net_config (image->device_handle, device, path); ++ { ++ grub_efi_net_config (image->device_handle, device, path); ++ return; ++ } + ++ *path = grub_efi_get_filename (image->file_path); + if (*path) + { + /* Get the directory. */ diff --git a/0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch b/0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch new file mode 100644 index 0000000..b0a33f3 --- /dev/null +++ b/0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch @@ -0,0 +1,121 @@ +From 7a5b301e3adb8e054288518a325135a1883c1c6c Mon Sep 17 00:00:00 2001 +From: Mike Gilbert +Date: Tue, 19 Apr 2016 14:27:22 -0400 +Subject: [PATCH] build: Use AC_HEADER_MAJOR to find device macros + +Depending on the OS/libc, device macros are defined in different +headers. This change ensures we include the right one. + +sys/types.h - BSD +sys/mkdev.h - Sun +sys/sysmacros.h - glibc (Linux) + +glibc currently pulls sys/sysmacros.h into sys/types.h, but this may +change in a future release. + +https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html +--- + configure.ac | 3 ++- + grub-core/osdep/devmapper/getroot.c | 6 ++++++ + grub-core/osdep/devmapper/hostdisk.c | 5 +++++ + grub-core/osdep/linux/getroot.c | 6 ++++++ + grub-core/osdep/unix/getroot.c | 4 +++- + 5 files changed, 22 insertions(+), 2 deletions(-) + +Index: grub-2.02~beta3/configure.ac +=================================================================== +--- grub-2.02~beta3.orig/configure.ac ++++ grub-2.02~beta3/configure.ac +@@ -388,7 +388,8 @@ fi + + # Check for functions and headers. + AC_CHECK_FUNCS(posix_memalign memalign getextmntent) +-AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) ++AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) ++AC_HEADER_MAJOR + + AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default + #include +Index: grub-2.02~beta3/grub-core/osdep/devmapper/getroot.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/osdep/devmapper/getroot.c ++++ grub-2.02~beta3/grub-core/osdep/devmapper/getroot.c +@@ -40,6 +40,12 @@ + #include + #endif + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif ++ + #include + + #include +Index: grub-2.02~beta3/grub-core/osdep/devmapper/hostdisk.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/osdep/devmapper/hostdisk.c ++++ grub-2.02~beta3/grub-core/osdep/devmapper/hostdisk.c +@@ -24,6 +24,11 @@ + #include + #include + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif + + #ifdef HAVE_DEVICE_MAPPER + # include +Index: grub-2.02~beta3/grub-core/osdep/linux/getroot.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/osdep/linux/getroot.c ++++ grub-2.02~beta3/grub-core/osdep/linux/getroot.c +@@ -35,6 +35,12 @@ + #include + #endif + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif ++ + #include + #include /* ioctl */ + #include +Index: grub-2.02~beta3/grub-core/osdep/unix/getroot.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/osdep/unix/getroot.c ++++ grub-2.02~beta3/grub-core/osdep/unix/getroot.c +@@ -51,8 +51,10 @@ + #endif + + #include +-#if defined(HAVE_SYS_MKDEV_H) ++#if defined(MAJOR_IN_MKDEV) + #include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include + #endif + + #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) +Index: grub-2.02~beta3/grub-core/osdep/linux/hostdisk.c +=================================================================== +--- grub-2.02~beta3.orig/grub-core/osdep/linux/hostdisk.c ++++ grub-2.02~beta3/grub-core/osdep/linux/hostdisk.c +@@ -45,6 +45,12 @@ + #include + #include + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif ++ + # include /* ioctl */ + # include + # ifndef BLKFLSBUF diff --git a/0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch b/0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch new file mode 100644 index 0000000..8f7ee92 --- /dev/null +++ b/0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch @@ -0,0 +1,43 @@ +From 07662af7aed55bcec448bc2a6610de1f0cb62100 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Thu, 22 Dec 2016 22:48:25 +0300 +Subject: [PATCH] configure: fix check for sys/sysmacros.h under glibc 2.25+ + +glibc 2.25 still includes sys/sysmacros.h in sys/types.h but also emits +deprecation warning. So test for sys/types.h succeeds in configure but later +compilation fails because we use -Werror by default. + +While this is fixed in current autoconf GIT, we really cannot force everyone +to use bleeding edge (that is not even released right now). So run test under +-Werror as well to force proper detection. + +This should have no impact on autoconf 2.70+ as AC_HEADER_MAJOR in this version +simply checks for header existence. + +Reported and tested by Khem Raj +--- + configure.ac | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/configure.ac b/configure.ac +index dc56564..4e980c5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -389,7 +389,14 @@ fi + # Check for functions and headers. + AC_CHECK_FUNCS(posix_memalign memalign getextmntent) + AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) ++ ++# glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation ++# warning which causes compilation failure later with -Werror. So use -Werror here ++# as well to force proper sys/sysmacros.h detection. ++SAVED_CFLAGS="$CFLAGS" ++CFLAGS="$HOST_CFLAGS -Werror" + AC_HEADER_MAJOR ++CFLAGS="$SAVED_CFLAGS" + + AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default + #include +-- +2.6.6 + diff --git a/grub2.changes b/grub2.changes index 50b16b5..9606a28 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Feb 9 03:45:16 UTC 2017 - mchang@suse.com + +- Fix build error on glibc-2.25 + * 0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch + * 0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch +- Fix fwpath in efi netboot (fate#321993) (bsc#1022294) + * 0001-Fix-fwpath-in-efi-netboot.patch + ------------------------------------------------------------------- Fri Feb 3 08:18:30 UTC 2017 - mchang@suse.com diff --git a/grub2.spec b/grub2.spec index b037776..44cf00b 100644 --- a/grub2.spec +++ b/grub2.spec @@ -188,6 +188,9 @@ Patch71: grub2-menu-unrestricted.patch Patch72: grub2-mkconfig-arm.patch Patch73: 0001-dns-fix-buffer-overflow-for-data-addresses-in-recv_h.patch Patch74: grub2-accept-empty-module.patch +Patch75: 0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch +Patch76: 0002-configure-fix-check-for-sys-sysmacros.h-under-glibc-.patch +Patch77: 0001-Fix-fwpath-in-efi-netboot.patch # Btrfs snapshot booting related patches Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch Patch102: grub2-btrfs-02-export-subvolume-envvars.patch @@ -452,6 +455,9 @@ swap partition while in resuming %patch72 -p1 %patch73 -p1 %patch74 -p1 +%patch75 -p1 +%patch76 -p1 +%patch77 -p1 %patch101 -p1 %patch102 -p1 %patch103 -p1