From d35317eb25900e4050646aa69f93b947e0c37dc37ea4be4cda4ce223920f6d16 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Wed, 22 Feb 2017 12:58:49 +0000 Subject: [PATCH] Accepting request 459690 from openSUSE:Factory Revert - attempt to fix uefi_usb boot OBS-URL: https://build.opensuse.org/request/show/459690 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=154 --- ...mands-introduce-read_file-subcommand.patch | 70 ------- grub2-efi-chainload-harder.patch | 103 ----------- grub2-emu-4-all.patch | 170 ----------------- grub2-once | 175 ++---------------- grub2-s390x-04-grub2-install.patch | 44 ++--- grub2-s390x-06-loadparm.patch | 47 ----- ...0x-07-add-image-param-for-zipl-setup.patch | 41 ---- grub2-s390x-08-workaround-part-to-disk.patch | 15 -- grub2.changes | 37 ---- grub2.spec | 101 +++------- 10 files changed, 57 insertions(+), 746 deletions(-) delete mode 100644 grub2-commands-introduce-read_file-subcommand.patch delete mode 100644 grub2-efi-chainload-harder.patch delete mode 100644 grub2-emu-4-all.patch delete mode 100644 grub2-s390x-06-loadparm.patch delete mode 100644 grub2-s390x-07-add-image-param-for-zipl-setup.patch delete mode 100644 grub2-s390x-08-workaround-part-to-disk.patch diff --git a/grub2-commands-introduce-read_file-subcommand.patch b/grub2-commands-introduce-read_file-subcommand.patch deleted file mode 100644 index a82ebbc..0000000 --- a/grub2-commands-introduce-read_file-subcommand.patch +++ /dev/null @@ -1,70 +0,0 @@ -From: Raymund Will -Subject: Introduce a 'read_file' sub-command. -References: bsc#892852, bsc#891946 -Patch-Mainline: not yet - -Needed to allow s390x-emu to be telecontrolled via LOADPARM. ---- - grub-core/commands/read.c | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - ---- a/grub-core/commands/read.c -+++ b/grub-core/commands/read.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -77,16 +78,49 @@ grub_cmd_read (grub_command_t cmd __attr - return 0; - } - -+static grub_err_t -+grub_cmd_read_from_file (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) -+{ -+ char *line; -+ int i = 0; -+ grub_file_t file; -+ -+ if (argc < 1) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("file name expected")); -+ if (argc < 2) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected")); -+ file = grub_file_open (args[i++]); -+ if (! file) -+ return grub_errno; -+ while ( i < argc ) -+ { -+ line = grub_file_getline (file); -+ if ( !line ) -+ break; -+ grub_env_set (args[i++], line); -+ grub_free (line); -+ } -+ grub_file_close (file); -+ if (i != argc) -+ return GRUB_ERR_OUT_OF_RANGE; -+ return 0; -+} -+ - static grub_command_t cmd; -+static grub_command_t cme; - - GRUB_MOD_INIT(read) - { - cmd = grub_register_command ("read", grub_cmd_read, - N_("[ENVVAR]"), - N_("Set variable with user input.")); -+ cme = grub_register_command ("read_file", grub_cmd_read_from_file, -+ N_("FILE ENVVAR [...]"), -+ N_("Set variable(s) with line(s) from FILE.")); - } - - GRUB_MOD_FINI(read) - { - grub_unregister_command (cmd); -+ grub_unregister_command (cme); - } diff --git a/grub2-efi-chainload-harder.patch b/grub2-efi-chainload-harder.patch deleted file mode 100644 index b1557cf..0000000 --- a/grub2-efi-chainload-harder.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- - grub-core/loader/efi/chainloader.c | 62 +++++++++++++++++++++---------------- - 1 file changed, 36 insertions(+), 26 deletions(-) - -Index: grub-2.02~beta2/grub-core/loader/efi/chainloader.c -=================================================================== ---- grub-2.02~beta2.orig/grub-core/loader/efi/chainloader.c -+++ grub-2.02~beta2/grub-core/loader/efi/chainloader.c -@@ -326,40 +326,41 @@ grub_secure_mode (void) - static grub_efi_boolean_t - read_header (void *data, grub_efi_uint32_t size, pe_coff_loader_image_context_t *context) - { -- grub_efi_guid_t guid = SHIM_LOCK_GUID; -- grub_efi_shim_lock_t *shim_lock; -- grub_efi_status_t status; -- -- shim_lock = grub_efi_locate_protocol (&guid, NULL); -+ char *msdos = (char *)data; -+ struct grub_pe32_header_no_msdos_stub *pe32 = (struct grub_pe32_header_no_msdos_stub *)data; - -- if (!shim_lock) -+ if (size < sizeof (*pe32)) - { -- grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol"); -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid image"); - return 0; - } - -- status = shim_lock->context (data, size, context); -- -- if (status == GRUB_EFI_SUCCESS) -+ if (grub_memcmp (msdos, "MZ", 2) == 0) - { -- grub_dprintf ("chain", "context success\n"); -- return 1; -+ grub_uint32_t off = *((grub_uint32_t *) (msdos + 0x3c)); -+ pe32 = (struct grub_pe32_header_no_msdos_stub *) ((char *)data + off); - } - -- switch (status) -+ if (grub_memcmp (pe32->signature, "PE\0\0", 4) != 0 || -+ pe32->coff_header.machine != GRUB_PE32_MACHINE_X86_64 || -+ pe32->optional_header.magic != GRUB_PE32_PE64_MAGIC) - { -- case GRUB_EFI_UNSUPPORTED: -- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error unsupported"); -- break; -- case GRUB_EFI_INVALID_PARAMETER: -- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error invalid parameter"); -- break; -- default: -- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error code"); -- break; -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Not supported image"); -+ return 0; - } - -- return 0; -+ context->number_of_rva_and_sizes = pe32->optional_header.num_data_directories; -+ context->size_of_headers = pe32->optional_header.header_size; -+ context->image_size = pe32->optional_header.image_size; -+ context->image_address = pe32->optional_header.image_base; -+ context->entry_point = pe32->optional_header.entry_addr; -+ context->reloc_dir = &pe32->optional_header.base_relocation_table; -+ context->sec_dir = &pe32->optional_header.certificate_table; -+ context->number_of_sections = pe32->coff_header.num_sections; -+ context->pe_hdr = pe32; -+ context->first_section = (struct grub_pe32_section_table *)((char *)(&pe32->optional_header) + pe32->coff_header.optional_header_size); -+ -+ return 1; - } - - static void* -@@ -623,6 +624,9 @@ error_exit: - if (buffer) - efi_call_1 (b->free_pool, buffer); - -+ if (grub_errno) -+ grub_print_error (); -+ - return 0; - - } -@@ -845,6 +849,19 @@ grub_cmd_chainloader (grub_command_t cmd - status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, - boot_image, fsize, - &image_handle); -+#ifdef SUPPORT_SECURE_BOOT -+ if (status == GRUB_EFI_SECURITY_VIOLATION && !grub_secure_mode()) -+ { -+ /* If it failed with security violation while not in secure boot mode, -+ the firmware might be broken. We try to workaround on that by forcing -+ the SB method! (bsc#887793) */ -+ grub_dprintf ("chain", "Possible firmware flaw! Security violation while not in secure boot mode.\n"); -+ grub_file_close (file); -+ grub_loader_set (grub_secureboot_chainloader_boot, -+ grub_secureboot_chainloader_unload, 0); -+ return 0; -+ } -+#endif - if (status != GRUB_EFI_SUCCESS) - { - if (status == GRUB_EFI_OUT_OF_RESOURCES) diff --git a/grub2-emu-4-all.patch b/grub2-emu-4-all.patch deleted file mode 100644 index 38ff1ee..0000000 --- a/grub2-emu-4-all.patch +++ /dev/null @@ -1,170 +0,0 @@ ---- - Makefile.util.def | 10 +++++----- - configure.ac | 1 + - grub-core/Makefile.core.def | 14 +++++--------- - grub-core/osdep/unix/emuconsole.c | 5 +++-- - 4 files changed, 14 insertions(+), 16 deletions(-) - -Index: grub-2.02~rc1/Makefile.util.def -=================================================================== ---- grub-2.02~rc1.orig/Makefile.util.def -+++ grub-2.02~rc1/Makefile.util.def -@@ -352,7 +352,7 @@ program = { - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_FUNC=grub_util_bios_setup'; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - program = { -@@ -373,7 +373,7 @@ program = { - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_FUNC=grub_util_sparc_setup'; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - program = { -@@ -389,7 +389,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - program = { -@@ -420,7 +420,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - data = { -@@ -1345,7 +1345,7 @@ program = { - ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - program = { -Index: grub-2.02~rc1/grub-core/Makefile.core.def -=================================================================== ---- grub-2.02~rc1.orig/grub-core/Makefile.core.def -+++ grub-2.02~rc1/grub-core/Makefile.core.def -@@ -1057,7 +1057,7 @@ module = { - module = { - name = videotest; - common = commands/videotest.c; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - module = { -@@ -1470,7 +1470,7 @@ module = { - common = gfxmenu/gui_progress_bar.c; - common = gfxmenu/gui_util.c; - common = gfxmenu/gui_string_util.c; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - module = { -@@ -1886,13 +1886,13 @@ module = { - name = gfxterm; - common = term/gfxterm.c; - enable = videomodules; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - module = { - name = gfxterm_background; - common = term/gfxterm_background.c; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - module = { -@@ -2005,9 +2005,7 @@ module = { - enable = i386_pc; - enable = i386_efi; - enable = x86_64_efi; -- enable = emu; - enable = xen; -- emu_condition = COND_NOT_s390x; - }; - - module = { -@@ -2054,7 +2052,7 @@ module = { - module = { - name = gfxterm_menu; - common = tests/gfxterm_menu.c; -- emu_condition = COND_NOT_s390x; -+ emu_condition = COND_NOT_emu; - }; - - module = { -@@ -2205,9 +2203,7 @@ module = { - enable = i386_pc; - enable = i386_efi; - enable = x86_64_efi; -- enable = emu; - enable = xen; -- emu_condition = COND_NOT_s390x; - }; - - module = { -Index: grub-2.02~rc1/configure.ac -=================================================================== ---- grub-2.02~rc1.orig/configure.ac -+++ grub-2.02~rc1/configure.ac -@@ -1884,6 +1884,7 @@ AC_SUBST(BUILD_LIBM) - - AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) - AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) -+AM_CONDITIONAL([COND_NOT_emu], [test x$platform != xemu]) - AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) - AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) - AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) -Index: grub-2.02~rc1/grub-core/osdep/unix/emuconsole.c -=================================================================== ---- grub-2.02~rc1.orig/grub-core/osdep/unix/emuconsole.c -+++ grub-2.02~rc1/grub-core/osdep/unix/emuconsole.c -@@ -50,13 +50,12 @@ static struct termios new_tty; - static int console_mode = 0; - - #define MAX_LEN 1023 --#if defined(__s390x__) -+ - static int - dummy (void) - { - return 0; - } --#endif - #if 0 - static char msg[MAX_LEN+1]; - static void -@@ -128,6 +127,7 @@ readkey (struct grub_term_input *term) - return -1; - } - -+#if defined(__s390x__) - #define NO_KEY ((grub_uint8_t)-1) - static int - readkey_dumb (struct grub_term_input *term) -@@ -158,6 +158,7 @@ readkey_dumb (struct grub_term_input *te - p = c; - return c; - } -+#endif - - static void - grub_dumb_putchar (struct grub_term_output *term, diff --git a/grub2-once b/grub2-once index 3a402c6..9dd6213 100644 --- a/grub2-once +++ b/grub2-once @@ -8,151 +8,13 @@ use strict; my $grub2_dir; my $grub2_reboot; -my $grub2_editenv; my $show_mapped; my $id_name; my @menuentry; -my @enumentry; -my %E; -sub dPrint($) { - #print( STDERR @_[0]); -} +sub parse_menuentry { -sub sh_test($) { - my ( $exp ) = @_; - - dPrint( "?? '$exp' "); - $exp .= " ]" if ( $exp =~ m{^\[.*[^\]]\s*$} ); # gnaaa - #my $t = qx{set -x; $exp}; - my $t = qx{$exp}; - my $ret = $? >> 8; - $ret = ($ret == 0) ? 1 : 0; - dPrint("=> $ret ($t)\n"); - return $ret; -} - -sub read_cfg($$) { - my ($dir, $cfg) = @_; - - my $fh; - my $m = ""; - my $state = 1; # 1 == normal, 010 == if-false, 011 == if-true, 110 == else-false, 111 == else-true - my @State = (); - - if ($dir) { - %E = ( "config_directory" => $dir ); - dPrint("# VE: 'cd'='$dir'\n"); - $dir .= "/"; - if ($> == 0) { - open($fh, "$grub2_editenv - list |") || die "cannot read grub2 environment: $!\n"; - while (<$fh>) { - chomp; - if ( m{^([^\s=]+?)=(.*)$} ) { - my ($k, $v) = ($1, $2); - $v =~ s{^"([^"]*)"$}{$1}; - dPrint("# VE: '$k'='$v'\n"); - $E{$k} = $v; - } - } - close($fh); - } - } - - dPrint("# open($dir$cfg)\n"); - open($fh, "<$dir$cfg") || die "cannot read $cfg in $dir: $!\n"; - - LINE: while ( <$fh> ) { - s{^#.*$}{}; # get rid of trailing comments, - s{\s+$}{}; # trailing whitespace - s{\s*;$}{}; # including semicolons - next if (m{^\s*$}); # and empty lines. - s{^\s*}{ }; # force leading whitespace to one - - dPrint(sprintf("#%d: '%s' [%s]%04b\n", $., $_, join(",",@State), $state)); - if ( m{^ fi$} ) { - $state = pop( @State); - $m .= "$_\n"; - dPrint(sprintf(">FI: [%s]0b%04b\n", join(",",@State), $state)); - next; - } - if ($state & 0b10) { # {if,else}-* - if ( m{^ elif\s+(.*?)\s*; then$} && !($state & 0b1000)) { - if ($state & 0b1) { - $state = 0b110; # else-false - } else { - $state = 0b010 + sh_test( $1); # if-? - dPrint(sprintf("=EI: 0b%03b\n", $state)); - $m .= "$_\n"; - next; - } - } elsif ( m{^ else$} && !($state & 0b1000)) { - if (($state & 0b111) == 0b010) { # in 'if' but neither 'else' nor 'true' - $state = 0b111; # else-true - } else { - $state = 0b110; # else-false - } - $m .= "$_\n"; - dPrint(sprintf("=EL: 0b%03b\n", $state)); - next; - } - } - if ($state & 0b1) { # *-true or normal - dPrint("-I1: $_\n"); - } else { # *-false - dPrint("-I0: $_\n"); - if ( m{^ if (.*?)\s*; then$} ) { - push( @State, $state); - $state = 0b1000; - $m .= "$_\n"; - } - next; - } - - while ( m'(?:[^\\])(\$(?:{([^}]+?)}|([A-Za-z0-9_]+)))' ) { - my ($s, $k1, $k2) = ($1, $2, $3); - my $k = (defined($k1)) ? $k1 : $k2; - dPrint("# VT: '$k'\n"); - if (exists( $E{$k})) { - $s =~ s{([\$\{\}\"])}{\\$1}g; - dPrint("# VB: '$_'\n"); - s{$s}{$E{$k}} || die; - dPrint("# VR: '$_'\n"); - } else { - $s =~ s{([\$\{\}\"])}{\\$1}g; - s{$s}{} || die; - dPrint("# VR: '$_'\n"); - } - } - - if ( m{^ if (.*?)\s*; then$} ) { - push( @State, $state); - $state = 0b010 + sh_test( $1); - dPrint(sprintf("$title" : "$title"; - my $eId = (($pId ne "") ? "$pId>" : "") . $c++; if ($type eq "menuentry") { push @menuentry, $name; - push @enumentry, [$name, $eId]; } elsif ($type eq "submenu") { - parse_menuentry ($name, $eId, $data); + &parse_menuentry ($name, $data); } } } @@ -207,7 +67,6 @@ while () { if ($bl eq "grub2" || $bl eq "grub2-efi") { $grub2_dir = "/boot/grub2"; $grub2_reboot = "/usr/sbin/grub2-reboot"; - $grub2_editenv = "/usr/bin/grub2-editenv"; } last; } @@ -224,22 +83,26 @@ if ($id_name eq "--help" or $id_name eq "-h") die "no grub2_dir" if ($grub2_dir eq ""); -my $m = read_cfg( $grub2_dir, "grub.cfg"); -# Note: only *one* top-level call to parse_menuentry() is possible -# or else it will start again with 0 (and no parent)! -parse_menuentry ("", "", $m); +open(MENU, "<$grub2_dir/grub.cfg") || die "cannot read grub.cfg in $grub2_dir: $!\n"; +undef $/; + +while () { + &parse_menuentry ("", $_); +} + +close (MENU); + +if (open(MENU, "<$grub2_dir/custom.cfg")) { + while () { + &parse_menuentry ("", $_); + } + close (MENU); +} my $ret = ""; my $name = ""; my $id = -1; -if ($id_name eq '--enum') { - foreach my $e (@enumentry) { - printf "%-7s %s\n", $e->[1], $e->[0]; - } - exit 0; -} - if ($id_name eq '--list') { my $c = 0; @@ -288,4 +151,4 @@ if ($show_mapped > 0) { system "$grub2_reboot \"$name\""; enable_restore_grubenv_service; } - + diff --git a/grub2-s390x-04-grub2-install.patch b/grub2-s390x-04-grub2-install.patch index 80408fa..2847574 100644 --- a/grub2-s390x-04-grub2-install.patch +++ b/grub2-s390x-04-grub2-install.patch @@ -41,10 +41,6 @@ V13: * dracut-grub2.sh: provide /boot from above to grub2-emu in chroot. V14: * grub2-zipl-setup: actually remove obsolete kernel/initrds. [bnc#892810] -V15: - * zipl2grub.conf: turn of zipl-prompt and quiescent plymouth. [bsc#898198] -V16: - * dracut-grub2.sh: force read-only '/usr' for kexec. [bsc#932951] --- Makefile.util.def | 39 +++ @@ -56,11 +52,11 @@ V16: include/grub/util/install.h | 4 util/grub-install-common.c | 1 util/grub-install.c | 43 +++ - util/s390x/dracut-grub2.sh.in | 110 +++++++++ + util/s390x/dracut-grub2.sh.in | 106 ++++++++ util/s390x/dracut-module-setup.sh.in | 19 + util/s390x/zipl2grub.conf.in | 26 ++ util/s390x/zipl2grub.pl.in | 424 +++++++++++++++++++++++++++++++++++ - 13 files changed, 702 insertions(+), 4 deletions(-) + 13 files changed, 698 insertions(+), 4 deletions(-) Index: grub-2.02~rc1/Makefile.util.def =================================================================== @@ -90,23 +86,15 @@ Index: grub-2.02~rc1/Makefile.util.def }; program = { -@@ -417,6 +420,7 @@ program = { +@@ -402,6 +405,7 @@ program = { ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + emu_condition = COND_NOT_s390x; }; - data = { -@@ -628,6 +632,7 @@ program = { - common = grub-core/disk/host.c; - - common = util/resolve.c; -+ emu_condition = COND_s390x; - common = grub-core/kern/emu/argp_common.c; - common = grub-core/osdep/init.c; - -@@ -697,6 +702,38 @@ script = { + program = { +@@ -697,6 +701,38 @@ script = { }; script = { @@ -145,7 +133,7 @@ Index: grub-2.02~rc1/Makefile.util.def name = grub-mkconfig_lib; common = util/grub-mkconfig_lib.in; installdir = noinst; -@@ -1308,6 +1345,7 @@ program = { +@@ -1292,6 +1328,7 @@ program = { ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; @@ -469,7 +457,7 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in =================================================================== --- /dev/null +++ grub-2.02~rc1/util/s390x/dracut-grub2.sh.in -@@ -0,0 +1,110 @@ +@@ -0,0 +1,106 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh @@ -478,14 +466,12 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in +if getargbool 0 initgrub && [ ! -e /grub2skip ] || [ -e /grub2force ]; then + #type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + checkro() { -+ local tgt="$1" + local dev mp fs opts dc -+ local rofs=true ++ local rofs=false + while read dev mp fs opts dc; do -+ [ "$mp" = "$tgt" ] || continue ++ [ "$mp" = "/sysroot" ] || continue + case ",$opts," in + (*,ro,*) rofs=true;; -+ (*) rofs=false;; + esac + done < /proc/mounts + echo $rofs @@ -527,9 +513,9 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in + bindir=@bindir@ + if [ -e /sysroot$bindir/grub2-emu ]; then + ++ + export TERM=$(getterm) -+ export grub2rofs=$(checkro /sysroot) -+ export grub2roufs=$(checkro /sysroot/usr) ++ export grub2rofs=$(checkro) + export grub2sysfs=$(checkd /sysroot/sys/devices/system/memory) + export grub2procfs=$(checkd /sysroot/proc/self) + export grub2bootfs=$(checkboot) @@ -554,7 +540,6 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in + + CTTY="$CTTY --wait" + $grub2rofs || mount -o remount,ro /sysroot -+ $grub2roufs || mount -o remount,ro /sysroot/usr + $grub2sysfs || mount --bind {,/sysroot}/sys + $grub2procfs || mount --bind {,/sysroot}/proc + $grub2bootfs || mount --bind {,/sysroot}/boot @@ -573,7 +558,6 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in + $grub2bootfs || umount /sysroot/boot + $grub2procfs || umount /sysroot/proc + $grub2sysfs || umount /sysroot/sys -+ $grub2roufs || mount -o remount,rw /sysroot/usr + $grub2rofs || mount -o remount,rw /sysroot + else + info "No $bindir/grub2-emu in /sysroot--trying to proceed without kexec..." @@ -619,7 +603,7 @@ Index: grub-2.02~rc1/util/s390x/zipl2grub.conf.in + target = @zipldir@ + ramdisk = @zipldir@/initrd,0x2000000 + image = @zipldir@/image -+ parameters = "root=@GRUB_DEVICE@ @GRUB_EMU_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ initgrub quiet splash=silent plymouth.enable=0 " ++ parameters = "root=@GRUB_DEVICE@ @GRUB_EMU_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ initgrub quiet splash=silent " + +[skip-grub2] + target = @zipldir@ @@ -631,7 +615,7 @@ Index: grub-2.02~rc1/util/s390x/zipl2grub.conf.in + target = @zipldir@ + timeout = 16 + default = 1 -+ prompt = 0 ++ prompt = 1 + 1 = grub2 + 2 = skip-grub2 + diff --git a/grub2-s390x-06-loadparm.patch b/grub2-s390x-06-loadparm.patch deleted file mode 100644 index e7c93ad..0000000 --- a/grub2-s390x-06-loadparm.patch +++ /dev/null @@ -1,47 +0,0 @@ -From: Raymund Will -Subject: Allow s390x-emu to telecontrolled by LOADPARM -References: bsc#892852, bsc#891946 -Patch-Mainline: no - ---- - util/grub.d/00_header.in | 27 +++++++++++++++++++++++++++ - 1 file changed, 27 insertions(+) - -Index: grub-2.02~beta3/util/grub.d/00_header.in -=================================================================== ---- grub-2.02~beta3.orig/util/grub.d/00_header.in -+++ grub-2.02~beta3/util/grub.d/00_header.in -@@ -52,6 +52,33 @@ if [ "\${env_block}" ] ; then - fi - - EOF -+if [ "`uname -m`" = "s390x" ]; then -+ cat <' -+ regexp -s 1:z_1 -s 2:z_2 '^([0-9][0-9>]*)\.([0-9][0-9.]*)$' "\$z_gp" -+ if [ ! "\$z_1" -o ! "\$z_2" ]; then break; fi -+ set z_gp="\$z_1>\$z_2" -+ done -+ if [ ! "\$z_gp" ]; then break; fi -+ set next_entry="\$z_gp" -+ unset z_gp -+ unset loadparm -+ break -+done -+EOF -+fi - if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then - cat < 0); -- $msg .= "Usage: $C [-v] [-d] [-f] [-T template] [-z ZIPLDIR]\n"; -+ $msg .= "Usage: $C [-v] [-d] [-f] [-T template] [-z ZIPLDIR] [-i imagepath]\n"; - Panic( $_[0], $msg . "\n"); - } - -@@ -184,6 +187,7 @@ while ( $#ARGV >= 0 ) { - (/^--?help/ || /^-h/) && (Usage(0)); - (/^--zipldir$/ || /^-z$/) && ($zipldir = shift || Usage(2), next); - (/^--template$/ || /^-T$/) && ($in = shift || Usage(3), next); -+ (/^--image$/ || /^-i$/) && ($Image = shift || Usage(5), $force = 1, next); - (/^-/) && (Usage(1)); - Usage(1); - } -@@ -379,11 +383,8 @@ if ( ! $debug ) { - } - - # copy out kernel and initrd --my $defimage = "/boot/image"; --my $definitrd = "/boot/initrd"; - my $ziplimage = "$zipldir/image"; - my $ziplinitrd = "$zipldir/initrd"; --my $Image = "$defimage"; - - if ( ! $running && ! $force ) { - chomp( $running = qx{uname -r}); diff --git a/grub2-s390x-08-workaround-part-to-disk.patch b/grub2-s390x-08-workaround-part-to-disk.patch deleted file mode 100644 index d93cf8a..0000000 --- a/grub2-s390x-08-workaround-part-to-disk.patch +++ /dev/null @@ -1,15 +0,0 @@ -Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c -=================================================================== ---- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c -+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c -@@ -713,6 +713,10 @@ grub_util_part_to_disk (const char *os_d - if (! realpath (os_dev, path)) - return NULL; - -+#ifdef __s390x__ -+ return path; -+#endif -+ - if (strncmp ("/dev/", path, 5) == 0) - { - char *p = path + 5; diff --git a/grub2.changes b/grub2.changes index 162bcec..69f714e 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,40 +1,3 @@ -------------------------------------------------------------------- -Fri Feb 17 06:46:11 UTC 2017 - mchang@suse.com - -- grub2.spec: fix s390x file list. - -------------------------------------------------------------------- -Wed Feb 15 07:25:02 UTC 2017 - mchang@suse.com - -- Merge changes from SLE12 -- add grub2-emu-4-all.patch - * Build 'grub2-emu' wherever possible, to allow a better - implementation of that feature. -- add grub2-s390x-06-loadparm.patch, -- add grub2-commands-introduce-read_file-subcommand.patch: - * allow s390x to telecontrol grub2. (bsc#891946, bsc#892852) -- add grub2-s390x-06-loadparm.patch: - * ignore case and fix transliteration of parameter. (bsc#891946) -- add grub2-s390x-07-add-image-param-for-zipl-setup.patch - * Add --image switch to force zipl update to specific kernel - (bsc#928131) -- add grub2-s390x-08-workaround-part-to-disk.patch - * Ignore partition tables on s390x. (bsc#935127) -- add grub2-efi-chainload-harder.patch: - * allow XEN to be chain-loaded despite firmware flaws. (bnc#887793) - * Do not use shim lock protocol for reading pe header, it won't be - available when secure boot disabled (bsc#943380) - * Make firmware flaw condition be more precisely detected and add - debug message for the case - * Check msdos header to find PE file header (bsc#954126) -- grub2-s390x-04-grub2-install.patch: - * streamline boot to grub menu. (bsc#898198) - * Force '/usr' to read-only before calling kexec. (bsc#932951) -- grub2-once: - * add '--enum' option to enumerate boot-entries in a way - actually understood by 'grub2'. (bsc#892852, bsc#892811) - * Examine variables from grub environment in 'grub2-once'. (fate#319632) - ------------------------------------------------------------------- Fri Feb 10 17:58:22 UTC 2017 - arvidjaar@gmail.com diff --git a/grub2.spec b/grub2.spec index 0640b10..ca197f8 100644 --- a/grub2.spec +++ b/grub2.spec @@ -64,14 +64,9 @@ BuildRequires: update-bootloader-rpm-macros # Modules code is dynamically loaded and collected from a _fixed_ path. %define _libdir %{_exec_prefix}/lib -# Build grub2-emu everywhere (it may be "required" by 'grub2-once') -%define emu 1 - %ifarch ppc ppc64 ppc64le %define grubcpu powerpc %define platform ieee1275 -# emu does not build here yet... :-( -%define emu 0 %endif %ifarch %{ix86} x86_64 @@ -89,18 +84,15 @@ BuildRequires: update-bootloader-rpm-macros %define platform uboot %endif -%ifarch aarch64 -%define grubcpu arm64 -%define platform efi -%define only_efi 1 -%endif - %define grubarch %{grubcpu}-%{platform} # build efi bootloader on some platforms only: %if ! 0%{?efi:1} %global efi %{ix86} x86_64 ia64 aarch64 %{arm} %endif +%ifarch aarch64 +%define only_efi 1 +%endif %ifarch %{efi} %ifarch %{ix86} @@ -126,11 +118,6 @@ BuildRequires: update-bootloader-rpm-macros %define grubxenarch x86_64-xen %endif -%if %{platform} == emu -# force %{emu} to 1, e.g. for s390 -%define emu 1 -%endif - %if 0%{?suse_version} == 1110 %define only_efi %{nil} %define only_x86_64 %{nil} @@ -200,12 +187,6 @@ Patch70: grub2-default-distributor.patch Patch71: grub2-menu-unrestricted.patch Patch72: grub2-mkconfig-arm.patch Patch74: grub2-accept-empty-module.patch -Patch75: grub2-s390x-06-loadparm.patch -Patch76: grub2-s390x-07-add-image-param-for-zipl-setup.patch -Patch77: grub2-s390x-08-workaround-part-to-disk.patch -Patch78: grub2-commands-introduce-read_file-subcommand.patch -Patch79: grub2-efi-chainload-harder.patch -Patch80: grub2-emu-4-all.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 @@ -299,7 +280,6 @@ Requires: %{name} = %{version}-%{release} %description branding-upstream Upstream branding for GRUB2's graphical console -%if ! 0%{?only_efi:1} %package %{grubarch} Summary: Bootloader with support for Linux, Multiboot and more @@ -329,8 +309,6 @@ bootloader with modular architecture. It supports rich variety of kernel format file systems, computer architectures and hardware devices. This subpackage provides support for %{platform} systems. -%endif - %ifarch %{efi} %package %{grubefiarch} @@ -455,12 +433,6 @@ swap partition while in resuming %patch71 -p1 %patch72 -p1 %patch74 -p1 -%patch75 -p1 -%patch76 -p1 -%patch77 -p1 -%patch78 -p1 -%patch79 -p1 -%patch80 -p1 %patch101 -p1 %patch102 -p1 %patch103 -p1 @@ -515,9 +487,6 @@ mkdir build-efi %ifarch %{ix86} x86_64 mkdir build-xen %endif -%if %{emu} -mkdir build-emu -%endif %build # autogen calls autoreconf -vi @@ -533,28 +502,6 @@ CXXFLAGS=" " FFLAGS=" " export CFLAGS CXXFLAGS FFLAGS -%if %{emu} -cd build-emu -%define arch_specific --enable-device-mapper --disable-grub-mount -TFLAGS="-fPIC" - -# -static is needed so that autoconf script is able to link -# test that looks for _start symbol on 64 bit platforms -../configure TARGET_LDFLAGS=$TFLAGS \ - --prefix=%{_prefix} \ - --sysconfdir=%{_sysconfdir} \ - --target=%{_target_platform} \ - --with-platform=emu \ - %{arch_specific} \ - --program-transform-name=s,grub,%{name}, -make %{?_smp_mflags} -cd .. -if [ "%{platform}" = "emu" ]; then - rmdir build - mv build-emu build -fi -%endif - %ifarch %{ix86} x86_64 cd build-xen ../configure \ @@ -646,9 +593,13 @@ cd build %define _target_platform i386-%{_vendor}-%{_target_os}%{?_gnu} %endif -%if %{platform} != "emu" +%ifarch s390x +%define arch_specific --enable-device-mapper --disable-grub-mount +TFLAGS="-fPIC" +%else %define arch_specific --enable-device-mapper TFLAGS="-static" +%endif # -static is needed so that autoconf script is able to link # test that looks for _start symbol on 64 bit platforms @@ -661,8 +612,6 @@ TFLAGS="-static" --program-transform-name=s,grub,%{name}, make %{?_smp_mflags} %endif -cd .. -%endif %install @@ -702,17 +651,10 @@ cd .. %if ! 0%{?only_efi:1} cd build make DESTDIR=$RPM_BUILD_ROOT install -cd .. +%else +cd build-efi %endif -if [ -d build-emu/grub-core ]; then - cd build-emu/grub-core - install -m 755 grub-emu $RPM_BUILD_ROOT%{_bindir}/%{name}-emu - install -m 755 grub-emu-lite $RPM_BUILD_ROOT%{_bindir}/%{name}-emu-lite - install -m 644 grub-emu.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}-emu.1 - cd ../.. -fi - # *.module files are installed with executable bits due to the way grub2 build # system works. Clear executable bits to not confuse find-debuginfo.sh find $RPM_BUILD_ROOT%{_libdir}/%{name} \ @@ -936,11 +878,16 @@ if [ $1 = 0 ]; then fi %endif fi +%if 0%{?only_efi:1} +%define source_dir build-efi +%else +%define source_dir build +%endif %postun %service_del_postun grub2-once.service -%files -f %{name}.lang +%files -f %{source_dir}/%{name}.lang %defattr(-,root,root,-) %doc COPYING NEWS README %doc THANKS TODO ChangeLog @@ -970,6 +917,7 @@ fi %{_bindir}/%{name}-editenv %{_bindir}/%{name}-file %{_bindir}/%{name}-fstest +%{_bindir}/%{name}-glue-efi %{_bindir}/%{name}-kbdcomp %{_bindir}/%{name}-menulst2cfg %{_bindir}/%{name}-mkfont @@ -982,7 +930,6 @@ fi %{_bindir}/%{name}-mkstandalone %{_bindir}/%{name}-render-label %{_bindir}/%{name}-script-check -%{_bindir}/%{name}-syslinux2cfg %if 0%{?has_systemd:1} %{_unitdir}/grub2-once.service %endif @@ -998,6 +945,7 @@ fi %{_mandir}/man1/%{name}-editenv.1.* %{_mandir}/man1/%{name}-file.1.* %{_mandir}/man1/%{name}-fstest.1.* +%{_mandir}/man1/%{name}-glue-efi.1.* %{_mandir}/man1/%{name}-kbdcomp.1.* %{_mandir}/man1/%{name}-menulst2cfg.1.* %{_mandir}/man1/%{name}-mkfont.1.* @@ -1010,30 +958,29 @@ fi %{_mandir}/man1/%{name}-mkstandalone.1.* %{_mandir}/man1/%{name}-render-label.1.* %{_mandir}/man1/%{name}-script-check.1.* -%{_mandir}/man1/%{name}-syslinux2cfg.1.* %{_mandir}/man8/%{name}-install.8.* %{_mandir}/man8/%{name}-mkconfig.8.* %{_mandir}/man8/%{name}-probe.8.* %{_mandir}/man8/%{name}-reboot.8.* %{_mandir}/man8/%{name}-set-default.8.* -%if %{emu} -%{_bindir}/%{name}-emu* +%ifarch s390x +%{_bindir}/%{name}-emu +%{_bindir}/%{name}-emu-lite %{_mandir}/man1/%{name}-emu.1.* -%endif -%ifnarch s390x +%else %config %{_sysconfdir}/grub.d/30_os-prober -%{_bindir}/%{name}-glue-efi %{_bindir}/%{name}-mount +%{_bindir}/%{name}-syslinux2cfg %{_sbindir}/%{name}-bios-setup %{_sbindir}/%{name}-macbless %{_sbindir}/%{name}-ofpathname %{_sbindir}/%{name}-sparc64-setup -%{_mandir}/man1/%{name}-glue-efi.1.* %{_mandir}/man1/%{name}-mount.1.* %{_mandir}/man8/%{name}-bios-setup.8.* %{_mandir}/man8/%{name}-macbless.8.* %{_mandir}/man8/%{name}-ofpathname.8.* %{_mandir}/man8/%{name}-sparc64-setup.8.* +%{_mandir}/man1/%{name}-syslinux2cfg.1.* %endif %files branding-upstream