b50565e
# vim:filetype=spec
b50565e
# Modules always contain just 32-bit code
b50565e
%global _libdir %{_exec_prefix}/lib
b50565e
%global _binaries_in_noarch_packages_terminate_build 0
b50565e
#%%undefine _missing_build_ids_terminate_build
b50565e
%{expand:%%{!?buildsubdir:%%global buildsubdir grub-%{tarversion}}}
b50565e
%{expand:%%{!?_licensedir:%%global license %%%%doc}}
b50565e
3619a3f
%global _configure ../configure
31ca145
b50565e
%if %{?_with_ccache: 1}%{?!_with_ccache: 0}
8a74d28
%global ccpath /usr/%{_lib}/ccache/gcc
b50565e
%else
8a74d28
%global ccpath %{__cc}
b50565e
%endif
b50565e
8a74d28
# gnulib actively ignores CFLAGS because it's terrible
7b857b8
%global cc_equals "CC=%{ccpath} -fPIE -Wl,-z,noexecstack -Wl,--no-warn-rwx-segments"
8a74d28
dcee992
%global cflags_sed						\\\
b50565e
	sed							\\\
b50565e
		-e 's/-O. //g'					\\\
fe0248c
		-e 's/-fplugin=annobin//g'			\\\
fe0248c
		-e 's,-specs=[[:alnum:]/_-]*annobin[[:alnum:]_-]*,,g' \\\
b50565e
		-e 's/-fstack-protector[[:alpha:]-]\\+//g'	\\\
3ce59ed
		-e 's/-[^ ]*D_FORTIFY_SOURCE=[[:digit:]][^ ]*\\+//g'	\\\
b50565e
		-e 's/--param=ssp-buffer-size=4//g'		\\\
b50565e
		-e 's/-mregparm=3/-mregparm=4/g'		\\\
b50565e
		-e 's/-fexceptions//g'				\\\
3a8f1e2
		-e 's/-fcf-protection//g'			\\\
b50565e
		-e 's/-fasynchronous-unwind-tables//g'		\\\
dcee992
		-e 's/^/ -fno-strict-aliasing /'		\\\
dcee992
		%{nil}
dcee992
217ae25
%global host_cflags_ %{expand:%%(echo %{build_cflags} %{?_hardening_cflags} | %{cflags_sed})} -fstack-protector-strong
217ae25
%ifarch x86_64
217ae25
%global host_cflags %{host_cflags_} -fcf-protection
217ae25
%else
217ae25
%global host_cflags %{host_cflags_}
217ae25
%endif
7388f24
%global legacy_host_cflags					\\\
7388f24
	%{expand:%%(echo %{host_cflags} |			\\\
b84b21f
	sed							\\\
8d56311
		-e 's/-m64//g'					\\\
8d56311
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
8d56311
	)}
7388f24
%global efi_host_cflags %{expand:%%(echo %{host_cflags})}
7388f24
7388f24
%global target_cflags %{expand:%%(echo %{build_cflags} | %{cflags_sed})}
7388f24
%global legacy_target_cflags					\\\
7388f24
	%{expand:%%(echo %{target_cflags} | 			\\\
dcee992
	%{cflags_sed}						\\\
b50565e
		-e 's/-m64//g'					\\\
b50565e
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
dcee992
	)}
8d56311
%global efi_target_cflags %{expand:%%(echo %{target_cflags})}
8d56311
7388f24
%global ldflags_sed						\\\
7388f24
	sed							\\\
fe0248c
		-e 's,-specs=[[:alnum:]/_-]*annobin[[:alnum:]_-]*,,g' \\\
7388f24
		-e 's/^$//'					\\\
7388f24
		%{nil}
7388f24
7388f24
%global host_ldflags %{expand:%%(echo %{build_ldflags} %{?_hardening_ldflags} | %{ldflags_sed})}
7388f24
%global legacy_host_ldflags					\\\
7388f24
	%{expand:%%(echo %{host_ldflags} |			\\\
7388f24
	%{ldflags_sed}						\\\
7388f24
	)}
7388f24
%global efi_host_ldflags %{expand:%%(echo %{host_ldflags})}
7388f24
7b857b8
%global target_ldflags %{expand:%%(echo %{build_ldflags} -Wl,--no-warn-rwx-segments -static | %{ldflags_sed})}
7388f24
%global legacy_target_ldflags					\\\
7388f24
	%{expand:%%(echo %{target_ldflags} | 			\\\
7388f24
	%{ldflags_sed}						\\\
7388f24
	)}
7388f24
%global efi_target_ldflags %{expand:%%(echo %{target_ldflags})}
7388f24
b50565e
%global with_efi_arch 0
b50565e
%global with_alt_efi_arch 0
b50565e
%global with_legacy_arch 0
a18e8e6
%global with_emu_arch 1
a18e8e6
%global emuarch %{_arch}
b50565e
%global grubefiarch %{nil}
b50565e
%global grublegacyarch %{nil}
06e51d2
%global grubelfname %{nil}
b50565e
b50565e
# sparc is always compiled 64 bit
b50565e
%ifarch %{sparc}
b50565e
%global target_cpu_name sparc64
b50565e
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
b50565e
%global legacy_target_cpu_name %{_arch}
b50565e
%global legacy_package_arch ieee1275
b50565e
%global platform ieee1275
b50565e
%endif
b50565e
# ppc is always compiled 64 bit
b50565e
%ifarch ppc ppc64 ppc64le
a18e8e6
# GRUB emu fails to build on ppc64le
a18e8e6
%global with_emu_arch 0
b50565e
%global target_cpu_name %{_arch}
b50565e
%global legacy_target_cpu_name powerpc
b50565e
%global legacy_package_arch %{_arch}
b50565e
%global legacy_grub_dir powerpc-ieee1275
b50565e
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
b50565e
%global platform ieee1275
b50565e
%endif
b50565e
53a4172
David Abdurachmanov b888fb3
%global efi_only aarch64 %{arm} riscv64
11b49b8
%global efi_arch x86_64 ia64 %{efi_only}
b50565e
%ifarch %{efi_arch}
b50565e
%global with_efi_arch 1
b50565e
%else
b50565e
%global with_efi_arch 0
b50565e
%endif
b50565e
%ifarch %{efi_only}
b50565e
%global with_efi_only 1
b50565e
%else
b50565e
%global with_efi_only 0
b50565e
%endif
b50565e
%{!?with_efi_arch:%global without_efi_arch 0}
b50565e
%{?with_efi_arch:%global without_efi_arch 1}
b50565e
%{!?with_efi_only:%global without_efi_only 0}
b50565e
%{?with_efi_only:%global without_efi_only 1}
b50565e
06e51d2
%ifarch %{efi_arch}
06e51d2
%global efi_modules " efi_netfs efifwsetup efinet lsefi lsefimmap connectefi "
06e51d2
%endif
06e51d2
06e51d2
%ifarch x86_64 %{ix86}
06e51d2
%global platform_modules " backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard "
06e51d2
%endif
06e51d2
06e51d2
%ifarch ppc64le
06e51d2
%global platform_modules " appendedsig tpm ofnet "
06e51d2
%endif
06e51d2
David Abdurachmanov b888fb3
%ifarch aarch64 %{arm} riscv64
06e51d2
%global platform_modules " "
b50565e
%endif
b50565e
David Abdurachmanov b888fb3
%ifarch aarch64 %{arm} riscv64
e1f4c0e
%global legacy_provides -l
e1f4c0e
%endif
e1f4c0e
a91fed7
%ifarch %{ix86}
a91fed7
%global efiarch ia32
a91fed7
%global target_cpu_name i386
a91fed7
%global grub_target_name i386-efi
a91fed7
%global package_arch efi-ia32
a91fed7
a91fed7
%global legacy_target_cpu_name i386
a91fed7
%global legacy_package_arch pc
a91fed7
%global platform pc
a91fed7
%endif
a91fed7
b50565e
%ifarch x86_64
b50565e
%global efiarch x64
b50565e
%global target_cpu_name %{_arch}
b50565e
%global grub_target_name %{_arch}-efi
b50565e
%global package_arch efi-x64
b50565e
b50565e
%global legacy_target_cpu_name i386
b50565e
%global legacy_package_arch pc
b50565e
%global platform pc
b50565e
b50565e
%global alt_efi_arch ia32
b50565e
%global alt_target_cpu_name i386
b50565e
%global alt_grub_target_name i386-efi
b50565e
%global alt_platform efi
b50565e
%global alt_package_arch efi-ia32
8d56311
8d56311
%global alt_efi_host_cflags %{expand:%%(echo %{efi_host_cflags})}
8d56311
%global alt_efi_target_cflags					\\\
8d56311
	%{expand:%%(echo %{target_cflags} |			\\\
dcee992
	%{cflags_sed}						\\\
dcee992
		-e 's/-m64//g'					\\\
dcee992
	)}
b50565e
%endif
b50565e
b50565e
%ifarch aarch64
a18e8e6
%global emuarch arm64
b50565e
%global efiarch aa64
b50565e
%global target_cpu_name aarch64
b50565e
%global grub_target_name arm64-efi
b50565e
%global package_arch efi-aa64
b50565e
%endif
b50565e
David Abdurachmanov b888fb3
%ifarch riscv64
David Abdurachmanov b888fb3
%global emuarch riscv64
David Abdurachmanov b888fb3
%global efiarch riscv64
David Abdurachmanov b888fb3
%global target_cpu_name riscv64
David Abdurachmanov b888fb3
%global grub_target_name riscv64-efi
David Abdurachmanov b888fb3
%global package_arch efi-riscv64
David Abdurachmanov b888fb3
%endif
David Abdurachmanov b888fb3
b50565e
%ifarch %{arm}
b50565e
%global efiarch arm
b50565e
%global target_cpu_name arm
b50565e
%global grub_target_name arm-efi
b50565e
%global package_arch efi-arm
8d56311
%global efi_target_cflags						\\\
8d56311
	%{expand:%%(echo %{optflags} |					\\\
8d56311
	%{cflags_sed}							\\\
8d56311
		-e 's/-march=armv7-a[[:alnum:]+-]*/&+nofp/g'		\\\
8d56311
		-e 's/-mfpu=[[:alnum:]-]\\+//g'				\\\
8d56311
		-e 's/-mfloat-abi=[[:alpha:]]\\+/-mfloat-abi=soft/g'	\\\
8d56311
	)}
b50565e
%endif
b50565e
b50565e
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
b50565e
%global _alt_target_platform %{alt_target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
b50565e
b50565e
%ifarch %{efi_arch}
b50565e
%global with_efi_arch 1
b50565e
%global grubefiname grub%{efiarch}.efi
b50565e
%global grubeficdname gcd%{efiarch}.efi
b50565e
%global grubefiarch %{target_cpu_name}-efi
a91fed7
%ifarch %{ix86}
a91fed7
%global with_efi_modules 0
a91fed7
%global without_efi_modules 1
a91fed7
%else
a91fed7
%global with_efi_modules 1
a91fed7
%global without_efi_modules 0
a91fed7
%endif
b50565e
%endif
b50565e
b50565e
%if 0%{?alt_efi_arch:1}
b50565e
%global with_alt_efi_arch 1
b50565e
%global grubaltefiname grub%{alt_efi_arch}.efi
b50565e
%global grubalteficdname gcd%{alt_efi_arch}.efi
b50565e
%global grubaltefiarch %{alt_target_cpu_name}-efi
b50565e
%endif
b50565e
b50565e
%ifnarch %{efi_only}
b50565e
%global with_legacy_arch 1
b50565e
%global grublegacyarch %{legacy_target_cpu_name}-%{platform}
b50565e
%global moduledir %{legacy_target_cpu_name}-%{platform}
06e51d2
%global grubelfname core.elf
b50565e
%endif
b50565e
b50565e
%global evr %{epoch}:%{version}-%{release}
b50565e
53a4172
%ifarch x86_64
b50565e
%global with_efi_common 1
eeff763
%global with_legacy_modules 1
eeff763
%global with_legacy_common 1
53a4172
%else
53a4172
%global with_efi_common 0
53a4172
%global with_legacy_common 1
53a4172
%global with_legacy_modules 1
b50565e
%endif
b50565e
b50565e
%define define_legacy_variant()						\
b50565e
%{expand:%%package %%{1}}						\
b50565e
Summary:	Bootloader with support for Linux, Multiboot, and more	\
f9344de
Provides:	grub2 = %{evr}					\
f9344de
Obsoletes:	grub2 < %{evr}					\
f9344de
Requires:	grub2-common = %{evr}					\
f9344de
Requires:	grub2-tools-minimal = %{evr}				\
f9344de
Requires:	grub2-%{1}-modules = %{evr}				\
c1f53c8
Requires:	gettext-runtime which file				\
f9344de
Requires:	grub2-tools = %{evr}					\
b50565e
Requires(pre):	dracut							\
b50565e
Requires(post): dracut							\
b50565e
%{expand:%%description %%{1}}						\
b50565e
%{desc}									\
af06f22
This subpackage provides support for %{1} systems.			\
b50565e
									\
b50565e
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
53a4172
%{expand:%%if 0%%{with_legacy_modules}					\
53a4172
%%package %%{1}-modules							\
b50565e
Summary:	Modules used to build custom grub images		\
b50565e
BuildArch:	noarch							\
f9344de
Requires:	grub2-common = %%{evr}				\
53a4172
%%description %%{1}-modules						\
53a4172
%%{desc}								\
b50565e
This subpackage provides support for rebuilding your own grub.efi.	\
53a4172
%%endif									\
53a4172
}									\
b50565e
									\
b50565e
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
b50565e
%{expand:%%package %%{1}-tools}						\
b50565e
Summary:	Support tools for GRUB.					\
c1f53c8
Requires:	gettext-runtime os-prober which file system-logos	\
f9344de
Requires:	grub2-common = %{evr}					\
f9344de
Requires:	grub2-tools-minimal = %{evr}				\
b50565e
Requires:	os-prober >= 1.58-11					\
b50565e
									\
b50565e
%{expand:%%description %%{1}-tools}					\
b50565e
%{desc}									\
b50565e
This subpackage provides tools for support of %%{1} platforms.		\
b50565e
%{nil}
b50565e
152cdcd
%define define_efi_variant(o)						\
b50565e
%{expand:%%package %{1}}						\
b50565e
Summary:	GRUB for EFI systems.					\
a52365a
Requires:	efi-filesystem						\
f9344de
Requires:	grub2-common = %{evr}					\
f9344de
Requires:	grub2-tools-minimal >= %{evr}				\
f9344de
Requires:	grub2-tools = %{evr}					\
f9344de
Provides:	grub2-efi = %{evr}					\
f9344de
%{?legacy_provides:Provides:	grub2 = %{evr}}			\
f9344de
%{-o:Obsoletes:	grub2-efi < %{evr}}					\
b50565e
									\
b50565e
%{expand:%%description %{1}}						\
b50565e
%{desc}									\
b50565e
This subpackage provides support for %{1} systems.			\
b50565e
									\
b50565e
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%{1}-%{tarversion}}}\
a91fed7
%{expand:%if 0%{?with_efi_modules}					\
b50565e
%{expand:%%package %{1}-modules}					\
b50565e
Summary:	Modules used to build custom grub.efi images		\
b50565e
BuildArch:	noarch							\
f9344de
Requires:	grub2-common = %{evr}					\
f9344de
Provides:	grub2-efi-modules = %{evr}				\
f9344de
Obsoletes:	grub2-efi-modules < %{evr}				\
b50565e
%{expand:%%description %{1}-modules}					\
b50565e
%{desc}									\
b50565e
This subpackage provides support for rebuilding your own grub.efi.	\
a91fed7
%endif}									\
b50565e
									\
b50565e
%{expand:%%package %{1}-cdboot}						\
b50565e
Summary:	Files used to boot removeable media with EFI		\
f9344de
Requires:	grub2-common = %{evr}					\
f9344de
Provides:	grub2-efi-cdboot = %{evr}				\
b50565e
%{expand:%%description %{1}-cdboot}					\
b50565e
%{desc}									\
b50565e
This subpackage provides optional components of grub used with removeable media on %{1} systems.\
b50565e
%{nil}
b50565e
b50565e
%global do_common_setup()					\
b50565e
%setup -q -n grub-%{tarversion}					\
b50565e
rm -fv docs/*.info						\
b50565e
cp %{SOURCE6} .gitignore					\
e153146
cp %{SOURCE7} bootstrap						\
e153146
cp %{SOURCE8} bootstrap.conf					\
e153146
cp %{SOURCE9} ./grub-core/tests/strtoull_test.c			\
0cb30b7
cp %{SOURCE2} gnulib-%{gnulibversion}.tar.gz			\
e153146
tar -zxf gnulib-%{gnulibversion}.tar.gz				\
e153146
mv gnulib-%{gnulibversion} gnulib				\
b50565e
git init							\
b50565e
echo '![[:digit:]][[:digit:]]_*.in' > util/grub.d/.gitignore	\
b50565e
echo '!*.[[:digit:]]' > util/.gitignore				\
b50565e
echo '!config.h' > include/grub/emu/.gitignore			\
f9344de
git config user.email "grub2-owner@fedoraproject.org"		\
b50565e
git config user.name "Fedora Ninjas"				\
b50565e
git config gc.auto 0						\
da0e16c
rm -f configure							\
b50565e
git add .							\
b50565e
git commit -a -q -m "%{tarversion} baseline."			\
15a2072
git am --whitespace=nowarn %%{patches} 
8a74d28
rm -r build-aux m4						\
e153146
./bootstrap							\
b50565e
%{nil}
b50565e
b50565e
%define do_efi_configure()					\
b50565e
%configure							\\\
b50565e
	%{cc_equals}						\\\
7388f24
	HOST_CFLAGS="%{3}"					\\\
7388f24
	HOST_CPPFLAGS="-I$(pwd)"				\\\
7388f24
	HOST_LDFLAGS="%{efi_host_ldflags}"			\\\
7388f24
	TARGET_CFLAGS="%{2}"					\\\
7388f24
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
7388f24
	TARGET_LDFLAGS="%{efi_target_ldflags}"			\\\
867b41f
	--with-rpm-version=%{version}-%{release}		\\\
a451613
	--with-platform=efi					\\\
8d56311
	--with-utils=host					\\\
b50565e
	--target=%{1}						\\\
f9344de
	--with-grubdir=grub2					\\\
f9344de
	--program-transform-name=s,grub,grub2,		\\\
dd0009e
	--disable-werror || ( cat config.log ; exit 1 )		\
dbfd2e6
git add .							\
dbfd2e6
git commit -m "After efi configure"				\
b50565e
%{nil}
b50565e
b50565e
%define do_efi_build_modules()					\
b50565e
make %{?_smp_mflags} ascii.h widthspec.h			\
b50565e
make %{?_smp_mflags} -C grub-core				\
b50565e
%{nil}
b50565e
b50565e
%define do_efi_build_all()					\
b50565e
make %{?_smp_mflags}						\
b50565e
%{nil}
b50565e
b50565e
%define do_efi_link_utils()					\
b50565e
for x in grub-mkimage ; do					\\\
b50565e
	ln ../grub-%{1}-%{tarversion}/${x} ./ ;			\\\
b50565e
done								\
b50565e
%{nil}
b50565e
8c2cf1c
%define do_install_protected_file()				\
8c2cf1c
touch %{1}.conf							\
8c2cf1c
echo %{1} > %{1}.conf						\
8c2cf1c
install -d -m 755 ${RPM_BUILD_ROOT}/etc/dnf/protected.d/	\
8c2cf1c
install -m 644 %{1}.conf ${RPM_BUILD_ROOT}/etc/dnf/protected.d/ \
8c2cf1c
rm -f %{1}.conf							\
8c2cf1c
%{nil}
8c2cf1c
06e51d2
%global grub_modules  " all_video boot blscfg btrfs		\\\
06e51d2
			cat configfile cryptodisk		\\\
06e51d2
			echo ext2 f2fs fat font			\\\
06e51d2
			gcry_rijndael gcry_rsa gcry_serpent	\\\
06e51d2
			gcry_sha256 gcry_twofish gcry_whirlpool	\\\
06e51d2
			gfxmenu gfxterm gzio			\\\
06e51d2
			halt hfsplus http increment iso9660	\\\
06e51d2
			jpeg loadenv loopback linux lvm luks	\\\
0ccadff
			luks2					\\\
0ccadff
			memdisk					\\\
0ccadff
			mdraid09 mdraid1x minicmd net		\\\
06e51d2
			normal part_apple part_msdos part_gpt	\\\
06e51d2
			password_pbkdf2 pgp png reboot regexp	\\\
06e51d2
			search search_fs_uuid search_fs_file	\\\
0ccadff
			search_label serial sleep		\\\
0ccadff
			squash4					\\\
0ccadff
			syslinuxcfg				\\\
06e51d2
			test tftp version video xfs zstd "	\
06e51d2
0ccadff
%ifarch %{efi_arch}
06e51d2
%define efi_mkimage()						\
0ccadff
mkdir -p memdisk/fonts						\
0ccadff
cp %{4}/unicode.pf2 memdisk/fonts				\
0c1c922
mksquashfs memdisk memdisk.squashfs -comp lzo			\
b50565e
%{4}./grub-mkimage -O %{1} -o %{2}.orig				\\\
9e46a97
	-d grub-core						\\\
06e51d2
	--sbat %{4}./sbat.csv					\\\
0ccadff
	-m memdisk.squashfs					\\\
9e46a97
	-p /EFI/%{efi_vendor}					\\\
06e51d2
	${GRUB_MODULES}						\
b50565e
%{4}./grub-mkimage -O %{1} -o %{3}.orig				\\\
9e46a97
	-d grub-core						\\\
06e51d2
	--sbat %{4}./sbat.csv					\\\
0ccadff
	-m memdisk.squashfs					\\\
9e46a97
	-p /EFI/BOOT						\\\
06e51d2
	${GRUB_MODULES}						\
47cf637
%{expand:%%define ___pesign_client_cert %{?___pesign_client_cert}%{!?___pesign_client_cert:%{__pesign_client_cert}}} \
47cf637
%{?__pesign_client_cert:%{expand:%%define __pesign_client_cert %{___pesign_client_cert}}} \
47cf637
%{expand:%%{pesign -s -i %%{2}.orig -o %%{2}.onesig -a %%{5} -c %%{6} -n %%{7}}}	\
47cf637
%{expand:%%{pesign -s -i %%{3}.orig -o %%{3}.onesig -a %%{5} -c %%{6} -n %%{7}}}	\
af038a0
%{expand:%%define __pesign_client_cert grub2-signer} \
47cf637
%{expand:%%{pesign -s -i %%{2}.onesig -o %%{2} -a %%{5} -c %%{6} -n %%{7}}}	\
47cf637
%{expand:%%{pesign -s -i %%{3}.onesig -o %%{3} -a %%{5} -c %%{6} -n %%{7}}}	\
b50565e
%{nil}
b50565e
%endif
b50565e
06e51d2
%ifarch ppc64le
55921d8
# RHEL signs, Fedora + ELN don't (but ELN defines rhel)
55921d8
%if 0%{?fedora} || 0%{?eln}
06e51d2
%define ieee1275_mkimage()					\
0ccadff
mkdir -p memdisk/fonts						\
55921d8
cp %{5}/unicode.pf2 memdisk/fonts				\
0c1c922
mksquashfs memdisk memdisk.squashfs -comp lzo			\
55921d8
./grub-mkimage -O %{1} -o %{2} -p '/grub2' -d grub-core ${GRUB_MODULES} \
55921d8
%{nil}
55921d8
%else
55921d8
%define ieee1275_mkimage()					\
55921d8
mkdir -p memdisk/fonts						\
55921d8
cp %{5}/unicode.pf2 memdisk/fonts				\
0c1c922
mksquashfs memdisk memdisk.squashfs -comp lzo			\
06e51d2
APPENDED_SIG_SIZE=0						\
06e51d2
if [ -x /usr/bin/rpm-sign ]; then				\
06e51d2
	touch empty.unsigned					\
06e51d2
	rpm-sign --key %{4}					\\\
06e51d2
		 --lkmsign empty.unsigned			\\\
06e51d2
		 --output empty.signed				\
06e51d2
	APPENDED_SIG_SIZE="$(stat -c '%s' empty.signed)"	\
06e51d2
	rm empty.{un,}signed					\
06e51d2
fi								\
06e51d2
# FIXME: using this prefix is fragile, must be done properly	\
06e51d2
./grub-mkimage -O %{1} -o %{2}.orig				\\\
9e46a97
	-d grub-core						\\\
0ccadff
	-m memdisk.squashfs					\\\
9e46a97
	-p '/grub2'						\\\
06e51d2
	-x %{3}							\\\
06e51d2
	--appended-signature-size ${APPENDED_SIG_SIZE}		\\\
06e51d2
	${GRUB_MODULES}						\
06e51d2
if [ -x /usr/bin/rpm-sign ]; then				\
06e51d2
	truncate -s -${APPENDED_SIG_SIZE} %{2}.orig		\
06e51d2
	rpm-sign --key %{4}					\\\
06e51d2
		 --lkmsign %{2}.orig				\\\
06e51d2
		 --output %{2}					\
06e51d2
else								\
06e51d2
	mv %{2}.orig %{2}					\
06e51d2
fi								\
06e51d2
%{nil}
06e51d2
%endif
06e51d2
%endif
06e51d2
b50565e
%define do_efi_build_images()					\
06e51d2
GRUB_MODULES+=%{grub_modules}					\
b50565e
GRUB_MODULES+=%{efi_modules}					\
06e51d2
GRUB_MODULES+=%{platform_modules}				\
06e51d2
%{expand:%%{efi_mkimage %{1} %{2} %{3} %{4}}}			\
06e51d2
%{nil}
06e51d2
06e51d2
%define do_ieee1275_build_images()			\
06e51d2
GRUB_MODULES+=%{grub_modules}				\
06e51d2
GRUB_MODULES+=%{platform_modules}			\
06e51d2
cd grub-%{1}-%{tarversion}				\
55921d8
%{expand:%%ieee1275_mkimage %%{1} %%{2} %%{3} %%{4} ./ }\
06e51d2
cd ..							\
b50565e
%{nil}
b50565e
b50565e
%define do_primary_efi_build()					\
b50565e
cd grub-%{1}-%{tarversion}					\
8d56311
%{expand:%%do_efi_configure %%{4} %%{5} %%{6}}			\
b50565e
%do_efi_build_all						\
b50565e
%{expand:%%do_efi_build_images %{grub_target_name} %{2} %{3} ./ } \
b50565e
cd ..								\
b50565e
%{nil}
b50565e
b50565e
%define do_alt_efi_build()					\
b50565e
cd grub-%{1}-%{tarversion}					\
8d56311
%{expand:%%do_efi_configure %%{4} %%{5} %%{6}}			\
b50565e
%do_efi_build_modules						\
b50565e
%{expand:%%do_efi_link_utils %{grubefiarch}}			\
b50565e
%{expand:%%do_efi_build_images %{alt_grub_target_name} %{2} %{3} ../grub-%{grubefiarch}-%{tarversion}/ } \
b50565e
cd ..								\
b50565e
%{nil}
b50565e
b50565e
%define do_legacy_build()					\
b50565e
cd grub-%{1}-%{tarversion}					\
b50565e
%configure							\\\
b50565e
	%{cc_equals}						\\\
7388f24
	HOST_CFLAGS="%{legacy_host_cflags}"			\\\
7388f24
	HOST_CPPFLAGS="-I$(pwd)"				\\\
7388f24
	HOST_LDFLAGS="%{legacy_host_ldflags}"			\\\
7388f24
	TARGET_CFLAGS="%{legacy_target_cflags}"			\\\
7388f24
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
7388f24
	TARGET_LDFLAGS="%{legacy_target_ldflags}"		\\\
a451613
	--with-platform=%{platform}				\\\
8d56311
	--with-utils=host					\\\
b50565e
	--target=%{_target_platform}				\\\
f9344de
	--with-grubdir=grub2					\\\
f9344de
	--program-transform-name=s,grub,grub2,		\\\
dd0009e
	--disable-werror || ( cat config.log ; exit 1 )		\
dbfd2e6
git add .							\
7388f24
git commit -m "After legacy configure"				\
b50565e
make %{?_smp_mflags}						\
b50565e
cd ..								\
b50565e
%{nil}
b50565e
a18e8e6
%define do_emu_build()						\
a18e8e6
cd grub-emu-%{tarversion}					\
a18e8e6
%configure							\\\
a18e8e6
	%{cc_equals}						\\\
51b7d62
	HOST_CFLAGS="%{legacy_host_cflags}"			\\\
51b7d62
	HOST_CPPFLAGS="-I$(pwd)"				\\\
51b7d62
	HOST_LDFLAGS="%{legacy_host_ldflags}"			\\\
a18e8e6
	--with-platform=emu					\\\
f9344de
	--with-grubdir=grub2					\\\
f9344de
	--program-transform-name=s,grub,grub2,		\\\
a18e8e6
	--disable-werror || ( cat config.log ; exit 1 )		\
a18e8e6
git add .							\
a18e8e6
git commit -m "After emu configure"				\
a18e8e6
make %{?_smp_mflags} ascii.h widthspec.h			\
e153146
make %{?_smp_mflags} -C grub-core/lib/gnulib			\
a18e8e6
make %{?_smp_mflags} -C grub-core				\
a18e8e6
cd ..								\
a18e8e6
%{nil}
a18e8e6
b50565e
%define do_alt_efi_install()					\
b50565e
cd grub-%{1}-%{tarversion}					\
bf33524
install -d -m 755 $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \
b50565e
find . '(' -iname gdb_grub					\\\
b50565e
	-o -iname kernel.exec					\\\
b50565e
	-o -iname kernel.img					\\\
b50565e
	-o -iname config.h					\\\
b50565e
	-o -iname gmodule.pl					\\\
b50565e
	-o -iname modinfo.sh					\\\
b50565e
	-o -iname '*.lst'					\\\
b50565e
	-o -iname '*.mod'					\\\
b50565e
	')'							\\\
b50565e
	-exec cp {} $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \\\; \
Petr Å abata 50a9c3a
find $RPM_BUILD_ROOT -type f -iname "*.mod*" -exec chmod a-x {} '\;'	\
a52365a
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2}	\
a52365a
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \
f9344de
%{expand:%%do_install_protected_file grub2-%{alt_package_arch}} \
b50565e
cd ..								\
b50565e
%{nil}
b50565e
b50565e
%define do_efi_install()					\
b50565e
cd grub-%{1}-%{tarversion}					\
b50565e
make DESTDIR=$RPM_BUILD_ROOT install				\
b50565e
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
b50565e
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
b50565e
fi								\
b50565e
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
b50565e
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
b50565e
fi								\
b50565e
find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;'	\
f9344de
ln -s ../boot/grub2/grub.cfg					\\\
f9344de
	$RPM_BUILD_ROOT%{_sysconfdir}/grub2-efi.cfg		\
a52365a
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2}		\
a52365a
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3}		\
0993459
%ifarch %{arm}							\
0993459
install -D -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_boot}/BOOTARM.EFI \
0993459
%endif								\
1af3942
install -D -m 700 unicode.pf2					\\\
1af3942
	${RPM_BUILD_ROOT}/boot/grub2/fonts/unicode.pf2		\
f9344de
${RPM_BUILD_ROOT}/%{_bindir}/grub2-editenv			\\\
f9344de
		${RPM_BUILD_ROOT}/boot/grub2/grubenv create	\
f9344de
%{expand:%%do_install_protected_file grub2-%{package_arch}}	\
b50565e
cd ..								\
b50565e
%{nil}
b50565e
b50565e
%define do_legacy_install()					\
b50565e
cd grub-%{1}-%{tarversion}					\
b50565e
make DESTDIR=$RPM_BUILD_ROOT install				\
b50565e
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
b50565e
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
b50565e
fi								\
b50565e
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
b50565e
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
b50565e
fi								\
06e51d2
%{expand:%ifarch ppc64le					\
06e51d2
	install -m 700 %{grubelfname} $RPM_BUILD_ROOT/%{_libdir}/grub/%{1} \
06e51d2
%endif}								\
af038a0
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \
af038a0
	mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp	\\\
af038a0
	   $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp	\
b50565e
fi								\
a52365a
if [ %{3} -eq 0 ]; then						\
f9344de
	${RPM_BUILD_ROOT}/%{_bindir}/grub2-editenv		\\\
f9344de
		${RPM_BUILD_ROOT}/boot/grub2/grubenv create	\
a52365a
fi								\
ab62564
%{expand:%ifnarch ppc64le					\
9d4d1e9
mkdir pxe							\
9d4d1e9
./grub-mknetdir							\\\
9d4d1e9
	--directory ./grub-core					\\\
9d4d1e9
	--fonts=""						\\\
9d4d1e9
	--locales=""						\\\
9d4d1e9
	--themes=""						\\\
9d4d1e9
	--modules="configfile gzio linux reboot test"		\\\
9d4d1e9
	--net-directory=pxe					\\\
9d4d1e9
	--subdir .						\
9d4d1e9
mv pxe/*/core.0 $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/		\
ab62564
%endif}								\
f9344de
%{expand:%%do_install_protected_file grub2-%{legacy_package_arch}} \
dcee992
cd ..								\
b50565e
%{nil}
b50565e
a18e8e6
%define do_emu_install()					\
a18e8e6
cd grub-emu-%{tarversion}					\
a18e8e6
make DESTDIR=$RPM_BUILD_ROOT install -C grub-core		\
a18e8e6
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
a18e8e6
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
a18e8e6
fi								\
a18e8e6
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
a18e8e6
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
a18e8e6
fi								\
af038a0
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \
af038a0
	mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp	\\\
a18e8e6
	   $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp	\
a18e8e6
fi								\
a18e8e6
cd ..								\
a18e8e6
%{nil}
a18e8e6
b50565e
%define do_common_install()					\
b50565e
install -d -m 0755 						\\\
b50565e
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
b50565e
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\\\
b50565e
	$RPM_BUILD_ROOT%{_infodir}/				\
b50565e
cp -a $RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
b50565e
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\
f9344de
cp docs/grub.info $RPM_BUILD_ROOT%{_infodir}/grub2.info	\
b50565e
cp docs/grub-dev.info						\\\
f9344de
	$RPM_BUILD_ROOT%{_infodir}/grub2-dev.info		\
a52365a
install -d -m 0700 ${RPM_BUILD_ROOT}%{efi_esp_dir}/		\
af038a0
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/grub2/		\
1b55f4c
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/loader/entries	\
f9344de
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/grub2/themes/system	\
1b55f4c
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/default	\
1b55f4c
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig	\
b50565e
touch ${RPM_BUILD_ROOT}%{_sysconfdir}/default/grub		\
b50565e
ln -sf ../default/grub						\\\
b50565e
	${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub		\
f9344de
touch ${RPM_BUILD_ROOT}/boot/grub2/grub.cfg			\
f9344de
ln -s ../boot/grub2/grub.cfg					\\\
af038a0
	${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg		\
b50565e
%{nil}
b50565e
b50565e
%define define_legacy_variant_files()				\
b50565e
%{expand:%%files %{1}}						\
b50565e
%defattr(-,root,root,-)						\
f9344de
%config(noreplace) %{_sysconfdir}/grub2.cfg			\
f9344de
%ghost %config(noreplace) %attr(0700,root,root)/boot/grub2/grub.cfg	\
78e1a10
%dir %attr(0700,root,root)/boot/loader/entries			\
f9344de
%attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/grub2-%{1}.conf \
06e51d2
%ifarch ppc64le							\
06e51d2
%dir %{_libdir}/grub/%{2}/					\
06e51d2
%{_libdir}/grub/%{2}/%{grubelfname}				\
06e51d2
%endif								\
b50565e
								\
53a4172
%{expand:%if 0%{?with_legacy_modules}				\
b50565e
%{expand:%%files %{1}-modules}					\
b50565e
%defattr(-,root,root)						\
b50565e
%dir %{_libdir}/grub/%{2}/					\
b50565e
%{_libdir}/grub/%{2}/*						\
06e51d2
%ifarch ppc64le							\
06e51d2
%exclude %{_libdir}/grub/%{2}/%{grubelfname}			\
06e51d2
%endif								\
b50565e
%exclude %{_libdir}/grub/%{2}/*.module				\
31ea67e
%exclude %{_libdir}/grub/%{2}/{boot,boot_hybrid,cdboot,diskboot,lzma_decompress,pxeboot}.image \
b50565e
%exclude %{_libdir}/grub/%{2}/*.o				\
53a4172
%else								\
53a4172
%%exclude %%{_libdir}/grub/%%{grublegacyarch}/*			\
53a4172
%endif}								\
b50565e
%{nil}
b50565e
b50565e
%define define_efi_variant_files()				\
b50565e
%{expand:%%files %{1}}						\
504ecff
%defattr(-,root,root,-)						\
f9344de
%config(noreplace) %{_sysconfdir}/grub2.cfg			\
f9344de
%config(noreplace) %{_sysconfdir}/grub2-efi.cfg		\
89d7a29
%attr(0700,root,root) %verify(not mtime) %{efi_esp_dir}/%{2} 	\
0993459
%ifarch %{arm}							\
89d7a29
%attr(0700,root,root) %verify(not mtime) %{efi_esp_boot}/BOOTARM.EFI \
0993459
%endif								\
1af3942
%attr(0700,root,root)/boot/grub2/fonts			\
1b55f4c
%dir %attr(0700,root,root)/boot/loader/entries			\
f9344de
%ghost %config(noreplace) %attr(0700,root,root)/boot/grub2/grub.cfg	\
89d7a29
%ghost %config(noreplace) %verify(not mtime) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg	\
af038a0
%config(noreplace) %verify(not size mode md5 mtime) /boot/grub2/grubenv	\
f9344de
%attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/grub2-%{1}.conf \
a91fed7
%{expand:%if 0%{?without_efi_modules}				\
a91fed7
%exclude %{_libdir}/grub/%{6}					\
a91fed7
%exclude %{_libdir}/grub/%{6}/*					\
a91fed7
%endif}								\
b50565e
								\
a91fed7
%{expand:%if 0%{?with_efi_modules}				\
b50565e
%{expand:%%files %{1}-modules}					\
b50565e
%defattr(-,root,root,-)						\
b50565e
%dir %{_libdir}/grub/%{6}/					\
b50565e
%{_libdir}/grub/%{6}/*						\
b50565e
%exclude %{_libdir}/grub/%{6}/*.module				\
a91fed7
%endif}								\
b50565e
								\
b50565e
%{expand:%%files %{1}-cdboot}					\
504ecff
%defattr(-,root,root,-)						\
89d7a29
%attr(0700,root,root) %verify(not mtime) %{efi_esp_dir}/%{3}	\
1af3942
%attr(0700,root,root)/boot/grub2/fonts			\
b50565e
%{nil}