grub2/grub2.spec

661 lines
20 KiB
RPMSpec

#
# spec file for package grub2
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# needssslcertforbuild
Name: grub2
%ifarch x86_64 ppc64
BuildRequires: gcc-32bit
BuildRequires: glibc-32bit
BuildRequires: glibc-devel-32bit
%else
BuildRequires: gcc
BuildRequires: glibc-devel
%endif
BuildRequires: automake
BuildRequires: bison
BuildRequires: device-mapper-devel
BuildRequires: fdupes
BuildRequires: flex
BuildRequires: freetype2-devel
BuildRequires: fuse-devel
%if 0%{?suse_version} >= 1140
BuildRequires: gnu-unifont
%endif
BuildRequires: help2man
BuildRequires: xz
%if 0%{?suse_version} >= 1210
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: python
BuildRequires: xz-devel
%ifarch x86_64
%if 0%{?suse_version} >= 1230 || 0%{?suse_version} == 1110
BuildRequires: openssl >= 0.9.8
BuildRequires: pesign-obs-integration
%endif
%endif
# Modules code is dynamically loaded and collected from a _fixed_ path.
%define _libdir %{_exec_prefix}/lib
%ifarch ppc ppc64
%define grubcpu powerpc
%define platform ieee1275
%endif
%ifarch %{ix86} x86_64
%define grubcpu i386
%define platform pc
%endif
%define grubarch %{grubcpu}-%{platform}
# build efi bootloader on some platforms only:
%if ! 0%{?efi}
%global efi %{ix86} x86_64 ia64
%endif
%ifarch %{efi}
%ifarch %{ix86}
%define grubefiarch i386-efi
%else
%define grubefiarch %{_target_cpu}-efi
%endif
%endif
%if 0%{?suse_version} == 1110
%define only_efi %{nil}
%define only_x86_64 %{nil}
%endif
Version: 2.00
Release: 0
Summary: Bootloader with support for Linux, Multiboot and more
License: GPL-3.0+
Group: System/Boot
Url: http://www.gnu.org/software/grub/
%define rev 20120622
Source0: grub-%{version}.tar.xz
Source1: 90_persistent
Source2: grub.default
Source3: README.openSUSE
Source4: grub2.rpmlintrc
# rsync -Lrtvz translationproject.org::tp/latest/grub/ po
Source5: translations-20120622.tar.xz
Source6: grub2-once
Source7: 20_memtest86+
Source8: Makefile.util.am
Source9: Makefile.core.am
Source10: openSUSE-UEFI-CA-Certificate.crt
Source11: SLES-UEFI-CA-Certificate.crt
Source1000: PATCH_POLICY
Patch0: grub2-correct-font-path.patch
Patch1: rename-grub-info-file-to-grub2.patch
Patch2: grub2-linux.patch
Patch3: use-grub2-as-a-package-name.patch
Patch6: grub2-iterate-and-hook-for-extended-partition.patch
Patch7: grub2-install-opt-skip-fs-probe.patch
Patch8: grub2-ppc-terminfo.patch
Patch9: grub2-GRUB_CMDLINE_LINUX_RECOVERY-for-recovery-mode.patch
Patch10: grub2-fix-error-terminal-gfxterm-isn-t-found.patch
Patch11: grub2-fix-mo-not-copied-to-grubdir-locale.patch
Patch12: grub2-fix-menu-in-xen-host-server.patch
Patch13: grub2-enable-theme-for-terminal-window.patch
Patch14: grub2-stdio.in.patch
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
Patch19: grub2-fix-build-error-on-flex-2.5.37.patch
Patch20: grub2-quote-messages-in-grub.cfg.patch
Patch21: grub2-secureboot-add-linuxefi.patch
Patch22: grub2-secureboot-use-linuxefi-on-uefi.patch
Patch23: grub2-secureboot-no-insmod-on-sb.patch
Patch24: grub2-secureboot-provide-linuxefi-config.patch
Patch25: 30_os-prober_UEFI_support.patch
Patch26: grub2-fix-enumeration-of-extended-partition.patch
Patch27: grub2-add-device-to-os_prober-linux-menuentry.patch
Patch28: grub2-fix-unquoted-string-in-class.patch
Patch29: grub2-secureboot-chainloader.patch
Patch30: grub2-cdpath.patch
Patch31: efidisk-ahci-workaround
Patch32: grub2-grub-mount-return-failure-if-FUSE-failed.patch
Patch33: grub2-fix-tftp-endianness.patch
Patch34: grub2-secureboot-use-linuxefi-on-uefi-in-os-prober.patch
Requires: gettext-runtime
%if 0%{?suse_version} >= 1140
Requires: os-prober
%endif
Requires(post): /sbin/install-info
Requires(preun):/sbin/install-info
%if ! 0%{?only_efi:1}
Requires: grub2-%{grubarch} = %{version}-%{release}
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?only_x86_64:1}
ExclusiveArch: x86_64
%else
ExclusiveArch: %{ix86} x86_64 ppc ppc64
%endif
%description
This is the second version of the GRUB (Grand Unified Bootloader), a
highly configurable and customizable bootloader with modular
architecture. It support rich scale of kernel formats, file systems,
computer architectures and hardware devices.
Authors:
--------
Gordon Matzigkeit
Yoshinori K. Okuji
Colin Watson
Colin D. Bennett
Vesa Jääskeläinen
Robert Millan
Carles Pina
%package %{grubarch}
Summary: Bootloader with support for Linux, Multiboot and more
Group: System/Boot
Requires: %{name} = %{version}-%{release}
Requires(post): %{name} = %{version}-%{release}
Requires: perl-Bootloader
Requires(post): perl-Bootloader
%description %{grubarch}
The GRand Unified Bootloader (GRUB) is a highly configurable and customizable
bootloader with modular architecture. It supports rich variety of kernel formats,
file systems, computer architectures and hardware devices. This subpackage
provides support for %{platform} systems.
%ifarch %{efi}
%package %{grubefiarch}
Summary: Bootloader with support for Linux, Multiboot and more
Group: System/Boot
%ifarch ia64 x86_64
#Package is available on ia64 and x86_64 only and not necessarily needed
Requires: efibootmgr
Requires(post): efibootmgr
%endif
Requires: %{name} = %{version}-%{release}
Requires(post): %{name} = %{version}-%{release}
Requires: perl-Bootloader >= 0.706
Requires(post): perl-Bootloader >= 0.706
Provides: %{name}-efi = %{version}-%{release}
Obsoletes: %{name}-efi < %{version}-%{release}
%description %{grubefiarch}
The GRand Unified Bootloader (GRUB) is a highly configurable and customizable
bootloader with modular architecture. It supports rich variety of kernel formats,
file systems, computer architectures and hardware devices. This subpackage
provides support for EFI systems.
%endif
%prep
# We create (if we build for efi) two copies of the sources in the Builddir
%setup -q -n grub-%{version} -a 5
(cd po && ls *.po | cut -d. -f1 | xargs) >po/LINGUAS
%patch0 -p1
%patch1 -p1
# This simplifies patch handling without need to use git to create patch
# that renames file
mv docs/grub.texi docs/grub2.texi
%patch2 -p1
%patch3 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
# disable and back to use black colored terminal window (bnc#776244)
# we could enable it when
# 1 we have background with better contrast to the font's color
# 2 we confirm it's eligible to set the terminal background this way
#%patch13 -p1
%patch14 -p2
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
# README.openSUSE
cp %{SOURCE3} .
cp %{SOURCE8} .
cp %{SOURCE9} grub-core/.
mkdir build
%ifarch %{efi}
mkdir build-efi
%endif
%build
autoreconf -vi
# Not yet:
%define common_conf_options TARGET_LDFLAGS=-static --program-transform-name=s,grub,%{name},
# This does NOT work on SLE11:
%define _configure ../configure
# We don't want to let rpm override *FLAGS with default a.k.a bogus values.
CFLAGS="-fno-strict-aliasing -fno-inline-functions-called-once "
CXXFLAGS=" "
FFLAGS=" "
export CFLAGS CXXFLAGS FFLAGS
%ifarch %{efi}
cd build-efi
../configure \
TARGET_LDFLAGS=-static \
--prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \
--target=%{_target_platform} \
--libdir=%{_libdir} \
--with-platform=efi \
--program-transform-name=s,grub,%{name},
make %{?_smp_mflags}
#TODO: add efifwsetup module
FS_MODULES="ext2 btrfs ext2 xfs jfs reiserfs"
CD_MODULES=" all_video boot cat chain configfile echo \
efinet font gfxmenu gfxterm gzio halt iso9660 \
jpeg minicmd normal part_apple part_msdos part_gpt \
password_pbkdf2 png reboot search search_fs_uuid \
search_fs_file search_label sleep test video fat loadenv"
PXE_MODULES="efinet tftp"
%ifarch x86_64
CD_MODULES="${CD_MODULES} linuxefi"
%else
CD_MODULES="${CD_MODULES} linux"
%endif
GRUB_MODULES="${CD_MODULES} ${FS_MODULES} ${PXE_MODULES} mdraid09 mdraid1x lvm"
./grub-mkimage -O %{grubefiarch} -o grub.efi --prefix= \
-d grub-core ${GRUB_MODULES}
#./grub-mkimage -O %{grubefiarch} -o grub.efi -d grub-core part_gpt hfsplus fat \
# ext2 btrfs normal chain boot configfile linux appleldr minicmd \
# loadbios reboot halt search font gfxterm
%ifarch x86_64
%if 0%{?suse_version} >= 1230 || 0%{?suse_version} == 1110
if test -e %{_sourcedir}/_projectcert.crt ; then
prjsubject=$(openssl x509 -in %{_sourcedir}/_projectcert.crt -noout -subject_hash)
prjissuer=$(openssl x509 -in %{_sourcedir}/_projectcert.crt -noout -issuer_hash)
opensusesubject=$(openssl x509 -in %{SOURCE10} -noout -subject_hash)
slessubject=$(openssl x509 -in %{SOURCE11} -noout -subject_hash)
if test "$prjissuer" = "$opensusesubject" ; then
cert=%{SOURCE10}
fi
if test "$prjissuer" = "$slessubject" ; then
cert=%{SOURCE11}
fi
if test "$prjsubject" = "$prjissuer" ; then
cert=%{_sourcedir}/_projectcert.crt
fi
fi
if test -z "$cert" ; then
echo "cannot identify project, assuming openSUSE signing"
cert=%{SOURCE10}
fi
openssl x509 -in $cert -outform DER -out grub.der
%endif
%endif
cd ..
%endif
%if ! 0%{?only_efi:1}
cd build
# 64-bit x86-64 machines use 32-bit boot loader
# (We cannot just redefine _target_cpu, as we'd get i386.rpm packages then)
%ifarch x86_64
%define _target_platform i386-%{_vendor}-%{_target_os}%{?_gnu}
%endif
%ifnarch ppc ppc64
%define extraconfigure --enable-grub-emu-usb
%endif
# -static is needed so that autoconf script is able to link
# test that looks for _start symbol on 64 bit platforms
../configure TARGET_LDFLAGS=-static \
--prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \
--target=%{_target_platform} \
--with-platform=%{platform} \
%{?extraconfigure} \
--program-transform-name=s,grub,%{name},
make %{?_smp_mflags}
%endif
%install
%ifarch %{efi}
cd build-efi
make DESTDIR=$RPM_BUILD_ROOT install
install -m 644 grub.efi $RPM_BUILD_ROOT%{_libdir}/%{name}/%{grubefiarch}/.
# Create grub.efi link to system efi directory
# This is for tools like kiwi not fiddling with the path
%if "%{grubefiarch}" == "x86_64-efi"
%define sysefidir %{_exec_prefix}/lib64/efi
%else
%define sysefidir %{_libdir}/efi
%endif
install -d $RPM_BUILD_ROOT%{sysefidir}
ln -sf ../../../%{_libdir}/%{name}/%{grubefiarch}/grub.efi $RPM_BUILD_ROOT%{sysefidir}/grub.efi
%ifarch x86_64
%if 0%{?suse_version} >= 1230 || 0%{?suse_version} == 1110
export BRP_PESIGN_FILES="%{_libdir}/%{name}/%{grubefiarch}/grub.efi"
install -m 444 grub.der $RPM_BUILD_ROOT%{sysefidir}/
%endif
%endif
cd ..
%endif
%if ! 0%{?only_efi:1}
cd build
make DESTDIR=$RPM_BUILD_ROOT install
%else
cd build-efi
%endif
# Script that makes part of grub.cfg persist across updates
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/
# Script to generate memtest86+ menu entry
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/
# Ghost config file
install -d $RPM_BUILD_ROOT/boot/%{name}
touch $RPM_BUILD_ROOT/boot/%{name}/grub.cfg
# Remove devel files
rm $RPM_BUILD_ROOT/%{_libdir}/%{name}/*/*.h
%if 0%{?suse_version} >= 1140
rm $RPM_BUILD_ROOT%{_datadir}/%{name}/*.h
%endif
# Defaults
install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/default/grub
install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once
%find_lang %{name}
%fdupes %buildroot%{_bindir}
%post
/sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || :
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
%if ! 0%{?only_efi:1}
%post %{grubarch}
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/sysconfig/bootloader
fi
# If the grub is the current loader, we'll handle the grub2 testing entry
if [ "x${LOADER_TYPE}" = "xgrub" ]; then
exec >/dev/null 2>&1
# check if entry for grub2's core.img exists in the config
# if yes, we will correct obsoleted path and update grub2 stuff and config to make it work
# if no, do nothing
if [ -f /boot/grub/menu.lst ]; then
# If grub config contains obsolete core.img path, remove and use the new one
if /usr/bin/grep -l "^\s*kernel\s*.*/boot/%{name}/core.img" /boot/grub/menu.lst; then
/sbin/update-bootloader --remove --image /boot/%{name}/core.img || true
/sbin/update-bootloader --add --image /boot/%{name}/i386-pc/core.img --name "GNU GRUB 2" || true
fi
# Install grub2 stuff and config to make the grub2 testing entry to work with updated version
if /usr/bin/grep -l "^\s*kernel\s*.*/boot/%{name}/i386-pc/core.img" /boot/grub/menu.lst; then
# Determine the partition with /boot
BOOT_PARTITION=$(df -h /boot |(read; awk '{print $1; exit}'))
# Generate core.img, but don't let it be installed in boot sector
%{name}-install --grub-setup=/bin/true $BOOT_PARTITION || true
# Create a working grub2 config, otherwise that entry is un-bootable
/usr/sbin/grub2-mkconfig -o /boot/%{name}/grub.cfg
fi
fi
elif [ "x${LOADER_TYPE}" = "xgrub2" ]; then
# It's enought to call update-bootloader --refesh to install grub2 and update it's config
/sbin/update-bootloader --refresh || true
fi
%endif
%ifarch %{efi}
%post %{grubefiarch}
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/sysconfig/bootloader
fi
if [ "x${LOADER_TYPE}" = "xgrub2-efi" ]; then
if [ -d /boot/%{name}-efi ]; then
# Migrate settings to standard prefix /boot/grub2
for i in custom.cfg grubenv; do
[ -f /boot/%{name}-efi/$i ] && cp -a /boot/%{name}-efi/$i /boot/%{name} || :
done
fi
# It's enough to call update-bootloader --refesh to install grub2 and update it's config
/sbin/update-bootloader --refresh || true
fi
if [ -d /boot/%{name}-efi ]; then
mv /boot/%{name}-efi /boot/%{name}-efi.rpmsave
fi
exit 0
%endif
%preun
if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/grub-dev.info %{_infodir}/dir || :
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
%if ! 0%{?only_efi:1}
# To check by current loader settings
if [ -f %{_sysconfdir}/sysconfig/bootloader ]; then
. %{_sysconfdir}/sysconfig/bootloader
fi
if [ "x${LOADER_TYPE}" = "xgrub" ]; then
exec >/dev/null 2>&1
if [ -f /boot/grub/menu.lst ]; then
# Remove grub2 testing entry in menu.lst if has any
for i in /boot/%{name}/core.img /boot/%{name}/i386-pc/core.img; do
if /usr/bin/grep -l "^\s*kernel\s*.*$i" /boot/grub/menu.lst; then
/sbin/update-bootloader --remove --image "$i" || true
fi
done
fi
# Cleanup config, to not confuse some tools determining bootloader in use
rm -f /boot/%{name}/grub.cfg
# Cleanup installed files
# Unless grub2 provides grub2-uninstall, we don't remove any file because
# we have no idea what's been installed. (And a blind remove is dangerous
# to remove user's or other package's file accidently ..)
fi
%endif
fi
%if 0%{?only_efi:1}
%define source_dir build-efi
%else
%define source_dir build
%endif
%files -f %{source_dir}/%{name}.lang
%defattr(-,root,root,-)
%doc COPYING NEWS README
%doc THANKS TODO ChangeLog
%doc README.openSUSE
%dir /boot/%{name}
%ghost /boot/%{name}/grub.cfg
%{_sysconfdir}/bash_completion.d/grub
%config(noreplace) %{_sysconfdir}/default/grub
%dir %{_sysconfdir}/grub.d
%{_sysconfdir}/grub.d/README
%config %{_sysconfdir}/grub.d/??_*
%{_sbindir}/%{name}-bios-setup
%{_sbindir}/%{name}-install
%{_sbindir}/%{name}-mkconfig
%{_sbindir}/%{name}-mknetdir
%{_sbindir}/%{name}-once
%{_sbindir}/%{name}-ofpathname
%{_sbindir}/%{name}-probe
%{_sbindir}/%{name}-reboot
%{_sbindir}/%{name}-set-default
%{_sbindir}/%{name}-sparc64-setup
%{_bindir}/%{name}-editenv
%{_bindir}/%{name}-fstest
%{_bindir}/%{name}-kbdcomp
%{_bindir}/%{name}-menulst2cfg
%{_bindir}/%{name}-mkfont
%{_bindir}/%{name}-mkimage
%{_bindir}/%{name}-mklayout
%{_bindir}/%{name}-mkpasswd-pbkdf2
%{_bindir}/%{name}-mkrelpath
%{_bindir}/%{name}-mkrescue
%{_bindir}/%{name}-mkstandalone
%{_bindir}/%{name}-mount
%{_bindir}/%{name}-script-check
%dir %{_libdir}/%{name}
%dir %{_datadir}/%{name}
%if 0%{?suse_version} >= 1140
%{_datadir}/%{name}/*.pf2
%endif
%{_datadir}/%{name}/grub-mkconfig_lib
%{_infodir}/grub-dev.info*
%{_infodir}/%{name}.info*
%{_mandir}/man1/%{name}-editenv.1.*
%{_mandir}/man1/%{name}-fstest.1.*
%{_mandir}/man1/%{name}-kbdcomp.1.*
%{_mandir}/man1/%{name}-menulst2cfg.1.*
%{_mandir}/man1/%{name}-mkfont.1.*
%{_mandir}/man1/%{name}-mkimage.1.*
%{_mandir}/man1/%{name}-mklayout.1.*
%{_mandir}/man1/%{name}-mkpasswd-pbkdf2.1.*
%{_mandir}/man1/%{name}-mkrelpath.1.*
%{_mandir}/man1/%{name}-mkrescue.1.*
%{_mandir}/man1/%{name}-mkstandalone.1.*
%{_mandir}/man1/%{name}-mount.1.*
%{_mandir}/man1/%{name}-script-check.1.*
%{_mandir}/man8/%{name}-bios-setup.8.*
%{_mandir}/man8/%{name}-install.8.*
%{_mandir}/man8/%{name}-mkconfig.8.*
%{_mandir}/man8/%{name}-mknetdir.8.*
%{_mandir}/man8/%{name}-ofpathname.8.*
%{_mandir}/man8/%{name}-probe.8.*
%{_mandir}/man8/%{name}-reboot.8.*
%{_mandir}/man8/%{name}-set-default.8.*
%{_mandir}/man8/%{name}-sparc64-setup.8.*
%if ! 0%{?only_efi:1}
%files %{grubarch}
%defattr(-,root,root,-)
%dir %{_libdir}/%{name}/%{grubarch}
%ifnarch ppc ppc64
%{_libdir}/%{name}/%{grubarch}/*.image
%endif
%{_libdir}/%{name}/%{grubarch}/*.img
%{_libdir}/%{name}/%{grubarch}/*.lst
%{_libdir}/%{name}/%{grubarch}/*.mod
%{_libdir}/%{name}/%{grubarch}/*.module
%ifarch x86_64
%{_libdir}/%{name}/%{grubarch}/efiemu*.o
%endif
%{_libdir}/%{name}/%{grubarch}/gdb_grub2
%{_libdir}/%{name}/%{grubarch}/gmodule.pl
%{_libdir}/%{name}/%{grubarch}/kernel.exec
%{_libdir}/%{name}/%{grubarch}/modinfo.sh
%endif
%ifarch %{efi}
%files %{grubefiarch}
%defattr(-,root,root,-)
%dir %{_libdir}/%{name}/%{grubefiarch}
%{_libdir}/%{name}/%{grubefiarch}/grub.efi
%{_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
%dir %{sysefidir}
%{sysefidir}/grub.efi
%ifarch x86_64
%if 0%{?suse_version} >= 1230 || 0%{?suse_version} == 1110
%{sysefidir}/grub.der
%endif
%endif
%endif
%changelog