From 7c061836bb6951bf740cb7c8111e8f59751f0350e454dd8b552ded2f499fe31a Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Fri, 26 Oct 2012 15:06:09 +0000 Subject: [PATCH] Accepting request 139364 from devel:openSUSE:Factory build grub2-efi with grub2 transform and migrate configuration into /boot/grub2 (bnc#782891) (forwarded request 139330 from arvidjaar) OBS-URL: https://build.opensuse.org/request/show/139364 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=47 --- grub2-fix-build-error-on-flex-2.5.37.patch | 37 ++++ ...rate-and-hook-for-extended-partition.patch | 37 ++-- grub2.changes | 21 +++ grub2.spec | 178 ++++++++++-------- use-grub2-efi-as-a-package-name.patch | 100 ---------- 5 files changed, 184 insertions(+), 189 deletions(-) create mode 100644 grub2-fix-build-error-on-flex-2.5.37.patch delete mode 100644 use-grub2-efi-as-a-package-name.patch diff --git a/grub2-fix-build-error-on-flex-2.5.37.patch b/grub2-fix-build-error-on-flex-2.5.37.patch new file mode 100644 index 0000000..f59ee63 --- /dev/null +++ b/grub2-fix-build-error-on-flex-2.5.37.patch @@ -0,0 +1,37 @@ +From b9701a5d7a60dac218d9bb309560cd4aab57b6cd Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Thu, 25 Oct 2012 14:18:31 +0800 +Subject: [PATCH] fix build error on flex-2.5.37 + +Patch-Mainline: no + +New flex version 2.5.37 introduces build error like this + +[ 420s] grub_script.yy.c: In function 'yy_scan_bytes': +[ 420s] grub_script.yy.c:2296:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] +[ 420s] ./grub-core/script/yylex.l: At top level: +[ 420s] grub_script.yy.c:2351:13: error: 'yy_fatal_error' defined but not used [-Werror=unused-function] +[ 420s] cc1: all warnings being treated as errors + +This patch ignore the two diagnostic pragmas as a temporal fix, hope +someone could dig into it and get the root cause. +--- + grub-core/script/yylex.l | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l +index f6a39c5..f4ff2bd 100644 +--- a/grub-core/script/yylex.l ++++ b/grub-core/script/yylex.l +@@ -29,6 +29,8 @@ + #pragma GCC diagnostic ignored "-Wmissing-prototypes" + #pragma GCC diagnostic ignored "-Wmissing-declarations" + #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" ++#pragma GCC diagnostic ignored "-Wsign-compare" ++#pragma GCC diagnostic ignored "-Wunused-function" + + #define yyfree grub_lexer_yyfree + #define yyalloc grub_lexer_yyalloc +-- +1.7.3.4 + diff --git a/grub2-iterate-and-hook-for-extended-partition.patch b/grub2-iterate-and-hook-for-extended-partition.patch index 8870f77..0f25fd3 100644 --- a/grub2-iterate-and-hook-for-extended-partition.patch +++ b/grub2-iterate-and-hook-for-extended-partition.patch @@ -8,12 +8,19 @@ hook that makes sure we have the partition when installing. Signed-off-by: Jiri Slaby References: https://bugzilla.novell.com/show_bug.cgi?id=750897 + +From: Andrey Borzenkov + +Apply this logic only to primary extended partition. Ignore extended +partitions that are used to link together logical partitions. + +References: https://bugzilla.novell.com/show_bug.cgi?id=785341 --- -Index: grub-1.99/grub-core/partmap/msdos.c +Index: grub-2.00/grub-core/partmap/msdos.c =================================================================== ---- grub-1.99.orig/grub-core/partmap/msdos.c -+++ grub-1.99/grub-core/partmap/msdos.c -@@ -107,11 +107,15 @@ grub_partition_msdos_iterate (grub_disk_ +--- grub-2.00.orig/grub-core/partmap/msdos.c ++++ grub-2.00/grub-core/partmap/msdos.c +@@ -181,13 +181,20 @@ grub_partition_msdos_iterate (grub_disk_ (unsigned long long) p.len); /* If this partition is a normal one, call the hook. */ @@ -21,13 +28,21 @@ Index: grub-1.99/grub-core/partmap/msdos.c - && ! grub_msdos_partition_is_extended (e->type)) + if (! grub_msdos_partition_is_empty (e->type)) { - p.number++; +- p.number++; ++ if (!grub_msdos_partition_is_extended (e->type) || p.number < 3) ++ { ++ p.number++; -+ /* prevent someone doing mkfs or mkswap on an -+ extended partition, but leave room for LILO */ -+ if (grub_msdos_partition_is_extended (e->type)) -+ p.len = 2; +- if (hook (disk, &p)) +- return grub_errno; ++ /* prevent someone doing mkfs or mkswap on an ++ extended partition, but leave room for LILO */ ++ if (grub_msdos_partition_is_extended (e->type)) ++ p.len = 2; + - if (hook (disk, &p)) - return grub_errno; ++ if (hook (disk, &p)) ++ return grub_errno; ++ } } + else if (p.number < 4) + /* If this partition is a logical one, shouldn't increase the diff --git a/grub2.changes b/grub2.changes index 3a6f160..127ca50 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,24 @@ +------------------------------------------------------------------- +Fri Oct 25 17:00:35 UTC 2012 - arvidjaar@gmail.com + +- build grub2-efi with standard "grub2" prefix (bnc#782891) + - remove use-grub2-efi-as-a-package-name.patch + - migrate settings from /boot/grub2-efi to /boot/grub2 in efi post + - provide some compatibility links grub2-efi-xxx for perl-Bootloader + - workaround for /boot/grub2-efi linkk and /boot/grub2/grub.cfg + missing on update from older versions + +------------------------------------------------------------------- +Thu Oct 25 05:56:59 UTC 2012 - mchang@suse.com + +- add grub2-fix-build-error-on-flex-2.5.37.patch + +------------------------------------------------------------------- +Thu Oct 18 16:10:02 UTC 2012 - arvidjaar@gmail.com + +- modify patch grub2-iterate-and-hook-for-extended-partition.patch to + ignore extended partitions other then primary (bnc#785341) + ------------------------------------------------------------------- Wed Sep 26 08:04:48 UTC 2012 - mchang@suse.com diff --git a/grub2.spec b/grub2.spec index 19c8e35..2572846 100644 --- a/grub2.spec +++ b/grub2.spec @@ -58,6 +58,13 @@ BuildRequires: guile %else %define platform pc %endif + +%ifarch %{ix86} x86_64 +%define grubcpu i386 +%else +%define grubcpu %{_target_cpu} +%endif + # build efi bootloader on some platforms only: %if ! 0%{?efi} %global efi %{ix86} x86_64 ia64 @@ -97,7 +104,7 @@ Patch15: not-display-menu-when-boot-once.patch Patch16: grub2-fix-Grub2-with-SUSE-Xen-package-install.patch Patch17: grub2-pass-corret-root-for-nfsroot.patch Patch18: grub2-fix-locale-en.mo.gz-not-found-error-message.patch -Patch99: use-grub2-efi-as-a-package-name.patch +Patch19: grub2-fix-build-error-on-flex-2.5.37.patch PreReq: perl-Bootloader Requires: gettext-runtime Requires: os-prober @@ -166,15 +173,13 @@ cd grub-%{version} %patch16 -p1 %patch17 -p1 %patch18 -p1 +%patch19 -p1 cd .. # README.openSUSE cp %{SOURCE3} grub-%{version}/ %ifarch %{efi} (cp -a grub-%{version} grub-efi-%{version}) -cd grub-efi-%{version} -%patch99 -p1 -cd .. %endif %build @@ -190,7 +195,7 @@ export CFLAGS CXXFLAGS FFLAGS TARGET_LDFLAGS=-static \ --target=%{_target_platform} \ --with-platform=efi \ - --program-transform-name=s,grub,%{name}-efi, + --program-transform-name=s,grub,%{name}, make %{?_smp_mflags} %ifarch %{ix86} %define grubefiarch i386-efi @@ -237,17 +242,9 @@ make %{?_smp_mflags} cd grub-efi-%{version} make DESTDIR=$RPM_BUILD_ROOT install -# Ghost config file -install -d $RPM_BUILD_ROOT/boot/%{name}-efi -touch $RPM_BUILD_ROOT/boot/%{name}-efi/grub.cfg - install -m 755 -d $RPM_BUILD_ROOT/boot/efi/EFI/opensuse/ install -m 755 grub.efi $RPM_BUILD_ROOT/boot/efi/EFI/opensuse/grub.efi -# Remove devel files -rm $RPM_BUILD_ROOT/%{_libdir}/%{name}-efi/*/*.h -rm $RPM_BUILD_ROOT%{_datadir}/%{name}-efi/*.h -%find_lang %{name}-efi cd .. %endif @@ -268,6 +265,15 @@ touch $RPM_BUILD_ROOT/boot/%{name}/grub.cfg rm $RPM_BUILD_ROOT/%{_libdir}/%{name}/*/*.h rm $RPM_BUILD_ROOT%{_datadir}/%{name}/*.h +%ifarch %{efi} +# grub2-efi compatibility links until other packages are fixed +ln -sf %{name}-editenv $RPM_BUILD_ROOT%{_bindir}/%{name}-efi-editenv +ln -sf %{name}-set-default $RPM_BUILD_ROOT%{_sbindir}/%{name}-efi-set-default +ln -sf %{name}-mkconfig $RPM_BUILD_ROOT%{_sbindir}/%{name}-efi-mkconfig +ln -sf %{name}-install $RPM_BUILD_ROOT%{_sbindir}/%{name}-efi-install +ln -sf %{name} $RPM_BUILD_ROOT/boot/%{name}-efi +%endif + # Defaults install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/default/grub install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once @@ -318,19 +324,69 @@ fi %ifarch %{efi} +%triggerpostun -- %{name}-efi + +# It is needed on update only +if [ $2 -gt 0 ]; then + + # Workaround for lost /boot/grub2/grub.cfg and possibly /boot/grub2-efi + # after old grub2-efi deinstallation + if [ -f /boot/%{name}/grub.cfg.migrated ]; then + mv /boot/%{name}/grub.cfg.migrated /boot/%{name}/grub.cfg + fi + [ -h /boot/%{name}-efi ] || ln -sf %{name} /boot/%{name}-efi + +fi +exit 0 + %post efi -/sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || : -/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || : -# To check by current loader settings -if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then - . %{_sysconfdir}/etc/sysconfig/bootloader -fi -if [ "x${LOADER_TYPE}" = "xgrub2-efi" ]; then +if [ $1 -eq 1 ]; then + + # If this is new install, just create compatibility link + ln -sf grub2 /boot/grub2-efi + +else + + # Always create compatibility link even if current loader is not grub2-efi + if [ -h /boot/%{name}-efi ]; then + migrate_grub2_efi= + else + migrate_grub2_efi=yes + fi + + # To check by current loader settings + if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then + . %{_sysconfdir}/sysconfig/bootloader + fi + + if [ "x${LOADER_TYPE}" = "xgrub2-efi" ]; then + + if [ "$migrate_grub2_efi" ]; then + # Migrate settings to standard prefix /boot/grub2 + for i in custom.cfg device.map grub.cfg grubenv; do + [ -f /boot/%{name}-efi/$i ] && cp -a /boot/%{name}-efi/$i /boot/%{name} || : + done + fi + fi + + if [ "$migrate_grub2_efi" ]; then + mv /boot/%{name}-efi /boot/%{name}-efi.rpmsave + ln -sf %{name} /boot/%{name}-efi + fi + + if [ "x${LOADER_TYPE}" = "xgrub2-efi" ]; then + # It's enough to call update-bootloader --refesh to install grub2 and update it's config + /sbin/update-bootloader --refresh || true + + # Uninstallation of previous grub2-efi versions will remove + # /boot/grub2-efi/grub.cfg and possibly /boot/grub2-efi itself. + # Preserve grub2.cfg and use it as migration flag in postun trigger + [ "$migrate_grub2_efi" ] && mv /boot/%{name}/grub.cfg /boot/%{name}/grub.cfg.migrated + fi - # It's enought to call update-bootloader --refesh to install grub2 and update it's config - /sbin/update-bootloader --refresh || true fi +exit 0 %endif %preun @@ -367,15 +423,6 @@ if [ $1 = 0 ]; then fi fi -%ifarch %{efi} - -%preun efi -if [ $1 = 0 ]; then - /sbin/install-info --delete %{_infodir}/grub-dev.info %{_infodir}/dir || : - /sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || : -fi -%endif - %files -f grub-%{version}/%{name}.lang %defattr(-,root,root,-) %doc grub-%{version}/COPYING grub-%{version}/NEWS grub-%{version}/README @@ -412,21 +459,21 @@ fi %{_bindir}/%{name}-mount %{_bindir}/%{name}-script-check %dir %{_libdir}/%{name}/ -%dir %{_libdir}/%{name}/*/ +%dir %{_libdir}/%{name}/%{grubcpu}-%{platform}/ %ifnarch ppc ppc64 -%{_libdir}/%{name}/*/*.image +%{_libdir}/%{name}/%{grubcpu}-%{platform}/*.image %endif -%{_libdir}/%{name}/*/*.img -%{_libdir}/%{name}/*/*.lst -%{_libdir}/%{name}/*/*.mod -%{_libdir}/%{name}/*/*.module +%{_libdir}/%{name}/%{grubcpu}-%{platform}/*.img +%{_libdir}/%{name}/%{grubcpu}-%{platform}/*.lst +%{_libdir}/%{name}/%{grubcpu}-%{platform}/*.mod +%{_libdir}/%{name}/%{grubcpu}-%{platform}/*.module %ifarch x86_64 -%{_libdir}/%{name}/*/efiemu*.o +%{_libdir}/%{name}/%{grubcpu}-%{platform}/efiemu*.o %endif -%{_libdir}/%{name}/*/gdb_grub2 -%{_libdir}/%{name}/*/gmodule.pl -%{_libdir}/%{name}/*/kernel.exec -%{_libdir}/%{name}/*/modinfo.sh +%{_libdir}/%{name}/%{grubcpu}-%{platform}/gdb_grub2 +%{_libdir}/%{name}/%{grubcpu}-%{platform}/gmodule.pl +%{_libdir}/%{name}/%{grubcpu}-%{platform}/kernel.exec +%{_libdir}/%{name}/%{grubcpu}-%{platform}/modinfo.sh %dir %{_datadir}/%{name} %{_datadir}/%{name}/*.pf2 %{_datadir}/%{name}/grub-mkconfig_lib @@ -435,51 +482,26 @@ fi %ifarch %{efi} -%files efi -f grub-efi-%{version}/%{name}-efi.lang +%files efi %defattr(-,root,root,-) %dir /boot/efi %dir /boot/efi/EFI %dir /boot/efi/EFI/opensuse %attr(0755,root,root)/boot/efi/EFI/opensuse/grub.efi -%dir /boot/grub2-efi -%ghost /boot/grub2-efi/grub.cfg -%{_sbindir}/grub2-efi-bios-setup +%ghost /boot/grub2-efi %{_sbindir}/grub2-efi-install %{_sbindir}/grub2-efi-mkconfig -%{_sbindir}/grub2-efi-mknetdir -%{_sbindir}/grub2-efi-ofpathname -%{_sbindir}/grub2-efi-probe -%{_sbindir}/grub2-efi-reboot %{_sbindir}/grub2-efi-set-default -%{_sbindir}/grub2-efi-sparc64-setup %{_bindir}/grub2-efi-editenv -%{_bindir}/grub2-efi-fstest -%{_bindir}/grub2-efi-kbdcomp -%{_bindir}/grub2-efi-menulst2cfg -%{_bindir}/grub2-efi-mkstandalone -%{_bindir}/grub2-efi-mkfont -%{_bindir}/grub2-efi-mklayout -%{_bindir}/grub2-efi-mkimage -%{_bindir}/grub2-efi-mkpasswd-pbkdf2 -%{_bindir}/grub2-efi-mkrelpath -%ifnarch %{sparc} ppc ppc64 -%{_bindir}/grub2-efi-mkrescue -%endif -%{_bindir}/grub2-efi-mount -%{_bindir}/grub2-efi-script-check -%dir %{_libdir}/%{name}-efi/ -%dir %{_libdir}/%{name}-efi/*/ -%{_libdir}/%{name}-efi/*/*.img -%{_libdir}/%{name}-efi/*/*.lst -%{_libdir}/%{name}-efi/*/*.mod -%{_libdir}/%{name}-efi/*/*.module -%{_libdir}/%{name}-efi/*/gdb_grub2-efi -%{_libdir}/%{name}-efi/*/gmodule.pl -%{_libdir}/%{name}-efi/*/kernel.exec -%{_libdir}/%{name}-efi/*/modinfo.sh -%dir %{_datadir}/%{name}-efi -%{_datadir}/%{name}-efi/grub-mkconfig_lib -%{_datadir}/%{name}-efi/*.pf2 +%dir %{_libdir}/%{name}/%{grubefiarch}/ +%{_libdir}/%{name}/%{grubefiarch}/*.img +%{_libdir}/%{name}/%{grubefiarch}/*.lst +%{_libdir}/%{name}/%{grubefiarch}/*.mod +%{_libdir}/%{name}/%{grubefiarch}/*.module +%{_libdir}/%{name}/%{grubefiarch}/gdb_grub2 +%{_libdir}/%{name}/%{grubefiarch}/gmodule.pl +%{_libdir}/%{name}/%{grubefiarch}/kernel.exec +%{_libdir}/%{name}/%{grubefiarch}/modinfo.sh %endif %changelog diff --git a/use-grub2-efi-as-a-package-name.patch b/use-grub2-efi-as-a-package-name.patch deleted file mode 100644 index 53faf6c..0000000 --- a/use-grub2-efi-as-a-package-name.patch +++ /dev/null @@ -1,100 +0,0 @@ -From: Michael Chang -Date: Wed, 4 Jun 2012 18:33:52 +0800 -Subject: [PATCH] use grub2-efi as a package name - -References: bnc#769916 -Patch-Mainline: no - -Use grub2-efi as package name when building grub2-efi package, this -fixes inconsistent @PACKAGE@ used by the scripts, for example. - -Just fix those scripts one-by-one is probably not a good idea and -maybe tedious, as we can't know how many potential problem related -with it, better use same approach building grub2 to prevent such -discrete result. - -Index: grub-2.00/configure -=================================================================== ---- grub-2.00.orig/configure -+++ grub-2.00/configure -@@ -558,10 +558,10 @@ MFLAGS= - MAKEFLAGS= - - # Identity of this package. --PACKAGE_NAME='GRUB2' --PACKAGE_TARNAME='grub2' -+PACKAGE_NAME='GRUB2-EFI' -+PACKAGE_TARNAME='grub2-efi' - PACKAGE_VERSION='2.00' --PACKAGE_STRING='GRUB2 2.00' -+PACKAGE_STRING='GRUB2-EFI 2.00' - PACKAGE_BUGREPORT='bug-grub@gnu.org' - PACKAGE_URL='' - -@@ -1904,7 +1904,7 @@ if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF --\`configure' configures GRUB2 2.00 to adapt to many kinds of systems. -+\`configure' configures GRUB2-EFI 2.00 to adapt to many kinds of systems. - - Usage: $0 [OPTION]... [VAR=VALUE]... - -@@ -1952,7 +1952,7 @@ Fine tuning of the installation director - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] -- --docdir=DIR documentation root [DATAROOTDIR/doc/grub2] -+ --docdir=DIR documentation root [DATAROOTDIR/doc/grub2-efi] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] -@@ -1975,7 +1975,7 @@ fi - - if test -n "$ac_init_help"; then - case $ac_init_help in -- short | recursive ) echo "Configuration of GRUB2 2.00:";; -+ short | recursive ) echo "Configuration of GRUB2-EFI 2.00:";; - esac - cat <<\_ACEOF - -@@ -2108,7 +2108,7 @@ fi - test -n "$ac_init_help" && exit $ac_status - if $ac_init_version; then - cat <<\_ACEOF --GRUB2 configure 2.00 -+GRUB2-EFI configure 2.00 - generated by GNU Autoconf 2.68 - - Copyright (C) 2010 Free Software Foundation, Inc. -@@ -2812,7 +2812,7 @@ cat >config.log <<_ACEOF - This file contains any messages produced by compilers while - running configure, to aid debugging if configure makes a mistake. - --It was created by GRUB2 $as_me 2.00, which was -+It was created by GRUB2-EFI $as_me 2.00, which was - generated by GNU Autoconf 2.68. Invocation command line was - - $ $0 $@ -@@ -3789,7 +3789,7 @@ fi - - - # Define the identity of the package. -- PACKAGE='grub2' -+ PACKAGE='grub2-efi' - VERSION='2.00' - - -Index: grub-2.00/configure.ac -=================================================================== ---- grub-2.00.orig/configure.ac -+++ grub-2.00/configure.ac -@@ -32,7 +32,7 @@ dnl type, so there is no conflict. Varia - dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target - dnl type. - --AC_INIT([GRUB2],[2.00],[bug-grub@gnu.org]) -+AC_INIT([GRUB2-EFI],[2.00],[bug-grub@gnu.org]) - - AC_CONFIG_AUX_DIR([build-aux]) -