d9d99f
# vim:filetype=spec
d9d99f
# Modules always contain just 32-bit code
d9d99f
%global _libdir %{_exec_prefix}/lib
d9d99f
%global _binaries_in_noarch_packages_terminate_build 0
d9d99f
#%%undefine _missing_build_ids_terminate_build
d9d99f
%{expand:%%{!?buildsubdir:%%global buildsubdir grub-%{tarversion}}}
d9d99f
%{expand:%%{!?_licensedir:%%global license %%%%doc}}
d9d99f
d9d99f
%global _configure ../configure
d9d99f
d9d99f
%if %{?_with_ccache: 1}%{?!_with_ccache: 0}
d9d99f
%global cc_equals CC=/usr/%{_lib}/ccache/gcc
d9d99f
%else
d9d99f
%global cc_equals %{nil}
d9d99f
%endif
d9d99f
d9d99f
%global cflags_sed						\\\
d9d99f
	sed							\\\
d9d99f
		-e 's/-O. //g'					\\\
d9d99f
		-e 's/-fplugin=annobin //g'			\\\
d9d99f
		-e 's,-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ,,g' \\\
d9d99f
		-e 's/-fstack-protector[[:alpha:]-]\\+//g'	\\\
d9d99f
		-e 's/-Wp,-D_FORTIFY_SOURCE=[[:digit:]]\\+//g'	\\\
d9d99f
		-e 's/--param=ssp-buffer-size=4//g'		\\\
d9d99f
		-e 's/-mregparm=3/-mregparm=4/g'		\\\
d9d99f
		-e 's/-fexceptions//g'				\\\
d9d99f
		-e 's/-fasynchronous-unwind-tables//g'		\\\
d9d99f
		-e 's/^/ -fno-strict-aliasing /'		\\\
d9d99f
		%{nil}
d9d99f
d9d99f
e0db32
%global host_cflags %{expand:%%(echo %{build_cflags} %{?_hardening_cflags} | %{cflags_sed})}
e0db32
%global legacy_host_cflags					\\\
e0db32
	%{expand:%%(echo %{host_cflags}	|			\\\
d9d99f
	%{cflags_sed}						\\\
d9d99f
		-e 's/-m64//g'					\\\
d9d99f
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
d9d99f
	)}
e0db32
%global efi_host_cflags %{expand:%%(echo %{host_cflags})}
e0db32
e0db32
%global target_cflags %{expand:%%(echo %{build_cflags} | %{cflags_sed})}
e0db32
%global legacy_target_cflags					\\\
e0db32
	%{expand:%%(echo %{target_cflags} | 			\\\
d9d99f
	%{cflags_sed}						\\\
d9d99f
		-e 's/-m64//g'					\\\
d9d99f
		-e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g'	\\\
d9d99f
	)}
d9d99f
%global efi_target_cflags %{expand:%%(echo %{target_cflags})}
d9d99f
e0db32
%global ldflags_sed						\\\
e0db32
	sed							\\\
e0db32
		-e 's/^$//'					\\\
e0db32
		%{nil}
e0db32
e0db32
%global host_ldflags %{expand:%%(echo %{build_ldflags} %{?_hardening_ldflags} | %{ldflags_sed})}
e0db32
%global legacy_host_ldflags					    \\\
e0db32
	%{expand:%%(echo %{host_ldflags} |			    \\\
e0db32
	%{ldflags_sed}						    \\\
e0db32
	)}
e0db32
%global efi_host_ldflags %{expand:%%(echo %{host_ldflags})}
e0db32
e0db32
%global target_ldflags %{expand:%%(echo %{build_ldflags} -static | %{ldflags_sed})}
e0db32
%global legacy_target_ldflags					\\\
e0db32
	%{expand:%%(echo %{target_ldflags} | 			\\\
e0db32
	%{ldflags_sed}						\\\
e0db32
	)}
e0db32
%global efi_target_ldflags %{expand:%%(echo %{target_ldflags})}
e0db32
d9d99f
%global with_efi_arch 0
d9d99f
%global with_alt_efi_arch 0
d9d99f
%global with_legacy_arch 0
d9d99f
%global grubefiarch %{nil}
d9d99f
%global grublegacyarch %{nil}
6bd801
%global grubelfname %{nil}
d9d99f
d9d99f
# sparc is always compiled 64 bit
d9d99f
%ifarch %{sparc}
d9d99f
%global target_cpu_name sparc64
d9d99f
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
d9d99f
%global legacy_target_cpu_name %{_arch}
d9d99f
%global legacy_package_arch ieee1275
d9d99f
%global platform ieee1275
d9d99f
%endif
d9d99f
# ppc is always compiled 64 bit
d9d99f
%ifarch ppc ppc64 ppc64le
d9d99f
%global target_cpu_name %{_arch}
d9d99f
%global legacy_target_cpu_name powerpc
d9d99f
%global legacy_package_arch %{_arch}
d9d99f
%global legacy_grub_dir powerpc-ieee1275
d9d99f
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
d9d99f
%global platform ieee1275
d9d99f
%endif
d9d99f
d9d99f
d9d99f
%global efi_only aarch64 %{arm}
d9d99f
%global efi_arch x86_64 ia64 %{efi_only}
d9d99f
%ifarch %{efi_arch}
d9d99f
%global with_efi_arch 1
d9d99f
%else
d9d99f
%global with_efi_arch 0
d9d99f
%endif
d9d99f
%ifarch %{efi_only}
d9d99f
%global with_efi_only 1
d9d99f
%else
d9d99f
%global with_efi_only 0
d9d99f
%endif
d9d99f
%{!?with_efi_arch:%global without_efi_arch 0}
d9d99f
%{?with_efi_arch:%global without_efi_arch 1}
d9d99f
%{!?with_efi_only:%global without_efi_only 0}
d9d99f
%{?with_efi_only:%global without_efi_only 1}
d9d99f
6bd801
6bd801
%ifarch %{efi_arch}
b71686
%global efi_modules " efi_netfs efifwsetup efinet lsefi lsefimmap connectefi "
6bd801
%endif
6bd801
6bd801
%ifarch x86_64 %{ix86}
6bd801
%global platform_modules " backtrace chain usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard "
6bd801
%endif
6bd801
6bd801
%ifarch ppc64le
6bd801
%global platform_modules " appendedsig "
6bd801
%endif
6bd801
d9d99f
%ifarch aarch64 %{arm}
d9d99f
%global platform_modules " "
d9d99f
%endif
d9d99f
6bd801
d9d99f
%ifarch aarch64 %{arm}
d9d99f
%global legacy_provides -l
d9d99f
%endif
d9d99f
d9d99f
%ifarch %{ix86}
d9d99f
%global efiarch ia32
d9d99f
%global target_cpu_name i386
d9d99f
%global grub_target_name i386-efi
d9d99f
%global package_arch efi-ia32
d9d99f
d9d99f
%global legacy_target_cpu_name i386
d9d99f
%global legacy_package_arch pc
d9d99f
%global platform pc
d9d99f
%endif
d9d99f
d9d99f
%ifarch x86_64
d9d99f
%global efiarch x64
d9d99f
%global target_cpu_name %{_arch}
d9d99f
%global grub_target_name %{_arch}-efi
d9d99f
%global package_arch efi-x64
d9d99f
d9d99f
%global legacy_target_cpu_name i386
d9d99f
%global legacy_package_arch pc
d9d99f
%global platform pc
d9d99f
d9d99f
%global alt_efi_arch ia32
d9d99f
%global alt_target_cpu_name i386
d9d99f
%global alt_grub_target_name i386-efi
d9d99f
%global alt_platform efi
d9d99f
%global alt_package_arch efi-ia32
d9d99f
d9d99f
%global alt_efi_host_cflags %{expand:%%(echo %{efi_host_cflags})}
d9d99f
%global alt_efi_target_cflags					\\\
d9d99f
	%{expand:%%(echo %{target_cflags} |			\\\
d9d99f
	%{cflags_sed}						\\\
d9d99f
		-e 's/-m64//g'					\\\
d9d99f
	)}
d9d99f
%endif
d9d99f
d9d99f
%ifarch aarch64
d9d99f
%global efiarch aa64
d9d99f
%global target_cpu_name aarch64
d9d99f
%global grub_target_name arm64-efi
d9d99f
%global package_arch efi-aa64
d9d99f
%endif
d9d99f
d9d99f
%ifarch %{arm}
d9d99f
%global efiarch arm
d9d99f
%global target_cpu_name arm
d9d99f
%global grub_target_name arm-efi
d9d99f
%global package_arch efi-arm
d9d99f
%global efi_target_cflags						\\\
d9d99f
	%{expand:%%(echo %{optflags} |					\\\
d9d99f
	%{cflags_sed}							\\\
d9d99f
		-e 's/-march=armv7-a[[:alnum:]+-]*/&+nofp/g'		\\\
d9d99f
		-e 's/-mfpu=[[:alnum:]-]\\+//g'				\\\
d9d99f
		-e 's/-mfloat-abi=[[:alpha:]]\\+/-mfloat-abi=soft/g'	\\\
d9d99f
	)}
d9d99f
%endif
d9d99f
d9d99f
%global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
d9d99f
%global _alt_target_platform %{alt_target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu}
d9d99f
d9d99f
%ifarch %{efi_arch}
d9d99f
%global with_efi_arch 1
d9d99f
%global grubefiname grub%{efiarch}.efi
d9d99f
%global grubeficdname gcd%{efiarch}.efi
d9d99f
%global grubefiarch %{target_cpu_name}-efi
d9d99f
%ifarch %{ix86}
d9d99f
%global with_efi_modules 0
d9d99f
%global without_efi_modules 1
d9d99f
%else
d9d99f
%global with_efi_modules 1
d9d99f
%global without_efi_modules 0
d9d99f
%endif
d9d99f
%endif
d9d99f
d9d99f
%if 0%{?alt_efi_arch:1}
d9d99f
%global with_alt_efi_arch 1
d9d99f
%global grubaltefiname grub%{alt_efi_arch}.efi
d9d99f
%global grubalteficdname gcd%{alt_efi_arch}.efi
d9d99f
%global grubaltefiarch %{alt_target_cpu_name}-efi
d9d99f
%endif
d9d99f
d9d99f
%ifnarch %{efi_only}
d9d99f
%global with_legacy_arch 1
d9d99f
%global grublegacyarch %{legacy_target_cpu_name}-%{platform}
d9d99f
%global moduledir %{legacy_target_cpu_name}-%{platform}
6bd801
%global grubelfname core.elf
d9d99f
%endif
d9d99f
d9d99f
%global evr %{epoch}:%{version}-%{release}
d9d99f
d9d99f
%ifarch x86_64
d9d99f
%global with_efi_common 1
d9d99f
%global with_legacy_modules 0
d9d99f
%global with_legacy_common 0
d9d99f
%else
d9d99f
%global with_efi_common 0
d9d99f
%global with_legacy_common 1
d9d99f
%global with_legacy_modules 1
d9d99f
%endif
d9d99f
d9d99f
%define define_legacy_variant()						\
d9d99f
%{expand:%%package %%{1}}						\
d9d99f
Summary:	Bootloader with support for Linux, Multiboot, and more	\
d9d99f
Group:		System Environment/Base					\
d9d99f
Provides:	%{name} = %{evr}					\
d9d99f
Obsoletes:	%{name} < %{evr}					\
d9d99f
Requires:	%{name}-common = %{evr}					\
d9d99f
Requires:	%{name}-tools-minimal = %{evr}				\
d9d99f
Requires:	%{name}-%{1}-modules = %{evr}				\
d9d99f
Requires:	gettext which file					\
d9d99f
Requires:	%{name}-tools-extra = %{evr}				\
d9d99f
Requires:	%{name}-tools = %{evr}					\
d9d99f
Requires(pre):	dracut							\
d9d99f
Requires(post): dracut							\
d9d99f
%{expand:%%description %%{1}}						\
d9d99f
%{desc}									\
d9d99f
This subpackage provides support for %%{1} systems.			\
d9d99f
									\
d9d99f
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
d9d99f
%{expand:%%if 0%%{with_legacy_modules}					\
d9d99f
%%package %%{1}-modules							\
d9d99f
Summary:	Modules used to build custom grub images		\
d9d99f
Group:		System Environment/Base					\
d9d99f
BuildArch:	noarch							\
d9d99f
Requires:	%%{name}-common = %%{evr}				\
d9d99f
%%description %%{1}-modules						\
d9d99f
%%{desc}								\
d9d99f
This subpackage provides support for rebuilding your own grub.efi.	\
d9d99f
%%endif									\
d9d99f
}									\
d9d99f
									\
d9d99f
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\
d9d99f
%{expand:%%package %%{1}-tools}						\
d9d99f
Summary:	Support tools for GRUB.					\
d9d99f
Group:		System Environment/Base					\
d9d99f
Requires:	gettext os-prober which file system-logos		\
d9d99f
Requires:	%{name}-common = %{evr}					\
d9d99f
Requires:	%{name}-tools-minimal = %{evr}				\
d9d99f
Requires:	os-prober >= 1.58-11					\
d9d99f
Requires:	gettext which file					\
d9d99f
									\
d9d99f
%{expand:%%description %%{1}-tools}					\
d9d99f
%{desc}									\
d9d99f
This subpackage provides tools for support of %%{1} platforms.		\
d9d99f
%{nil}
d9d99f
d9d99f
%define define_efi_variant(o)						\
d9d99f
%{expand:%%package %{1}}						\
d9d99f
Summary:	GRUB for EFI systems.					\
d9d99f
Group:		System Environment/Base					\
d9d99f
Requires:	efi-filesystem						\
d9d99f
Requires:	%{name}-common = %{evr}					\
d9d99f
Requires:	%{name}-tools-minimal >= %{evr}				\
d9d99f
Requires:	%{name}-tools-extra = %{evr}				\
d9d99f
Requires:	%{name}-tools = %{evr}					\
d9d99f
Provides:	%{name}-efi = %{evr}					\
d9d99f
%{?legacy_provides:Provides:	%{name} = %{evr}}			\
d9d99f
%{-o:Obsoletes:	%{name}-efi < %{evr}}					\
d9d99f
									\
d9d99f
%{expand:%%description %{1}}						\
d9d99f
%{desc}									\
d9d99f
This subpackage provides support for %{1} systems.			\
d9d99f
									\
d9d99f
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%{1}-%{tarversion}}}\
d9d99f
%{expand:%if 0%{?with_efi_modules}					\
d9d99f
%{expand:%%package %{1}-modules}					\
d9d99f
Summary:	Modules used to build custom grub.efi images		\
d9d99f
Group:		System Environment/Base					\
d9d99f
BuildArch:	noarch							\
d9d99f
Requires:	%{name}-common = %{evr}					\
d9d99f
Provides:	%{name}-efi-modules = %{evr}				\
d9d99f
Obsoletes:	%{name}-efi-modules < %{evr}				\
d9d99f
%{expand:%%description %{1}-modules}					\
d9d99f
%{desc}									\
d9d99f
This subpackage provides support for rebuilding your own grub.efi.	\
d9d99f
%endif}									\
d9d99f
									\
d9d99f
%{expand:%%package %{1}-cdboot}						\
d9d99f
Summary:	Files used to boot removeable media with EFI		\
d9d99f
Group:		System Environment/Base					\
d9d99f
Requires:	%{name}-common = %{evr}					\
d9d99f
Provides:	%{name}-efi-cdboot = %{evr}				\
d9d99f
%{expand:%%description %{1}-cdboot}					\
d9d99f
%{desc}									\
d9d99f
This subpackage provides optional components of grub used with removeable media on %{1} systems.\
d9d99f
%{nil}
d9d99f
d9d99f
%global do_common_setup()					\
d9d99f
%setup -q -n grub-%{tarversion}					\
d9d99f
rm -fv docs/*.info						\
d9d99f
cp %{SOURCE6} .gitignore					\
d9d99f
cp %{SOURCE8} ./grub-core/tests/strtoull_test.c			\
d9d99f
git init							\
d9d99f
echo '![[:digit:]][[:digit:]]_*.in' > util/grub.d/.gitignore	\
d9d99f
echo '!*.[[:digit:]]' > util/.gitignore				\
d9d99f
echo '!config.h' > include/grub/emu/.gitignore			\
d9d99f
git config user.email "%{name}-owner@fedoraproject.org"		\
d9d99f
git config user.name "Fedora Ninjas"				\
d9d99f
git config gc.auto 0						\
d9d99f
rm -f configure							\
d9d99f
git add .							\
d9d99f
git commit -a -q -m "%{tarversion} baseline."			\
d9d99f
git apply --index --whitespace=nowarn %{SOURCE3}		\
d9d99f
git commit -a -q -m "%{tarversion} master."			\
d9d99f
git am --whitespace=nowarn %%{patches} 
d9d99f
autoreconf -vi							\
d9d99f
git add .							\
d9d99f
git commit -a -q -m "autoreconf"				\
d9d99f
autoconf							\
d9d99f
PYTHON=python3 ./autogen.sh					\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_efi_configure()					\
d9d99f
%configure							\\\
d9d99f
	%{cc_equals}						\\\
e0db32
	HOST_CFLAGS="%{3}"					\\\
e0db32
	HOST_CPPFLAGS="-I$(pwd)"				\\\
e0db32
	HOST_LDFLAGS="%{efi_host_ldflags}"			\\\
e0db32
	TARGET_CFLAGS="%{2}"					\\\
e0db32
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
e0db32
	TARGET_LDFLAGS="%{efi_target_ldflags}"			\\\
d9d99f
	--with-platform=efi					\\\
d9d99f
	--with-utils=host					\\\
d9d99f
	--target=%{1}						\\\
d9d99f
	--with-grubdir=%{name}					\\\
d9d99f
	--program-transform-name=s,grub,%{name},		\\\
d9d99f
	--disable-grub-mount					\\\
3efed6
	--with-debug-timestamps					\\\
3efed6
	--enable-boot-time					\\\
d9d99f
	--disable-werror || ( cat config.log ; exit 1 )		\
d9d99f
git add .							\
d9d99f
git commit -m "After efi configure"				\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_efi_build_modules()					\
d9d99f
make %{?_smp_mflags} ascii.h widthspec.h			\
d9d99f
make %{?_smp_mflags} -C grub-core				\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_efi_build_all()					\
d9d99f
make %{?_smp_mflags}						\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_efi_link_utils()					\
d9d99f
for x in grub-mkimage ; do					\\\
d9d99f
	ln ../grub-%{1}-%{tarversion}/${x} ./ ;			\\\
d9d99f
done								\
d9d99f
%{nil}
d9d99f
bf0270
%global grub_modules " all_video boot blscfg 			\\\
6bd801
		cat configfile cryptodisk echo ext2		\\\
6bd801
		fat font gcry_rijndael gcry_rsa gcry_serpent	\\\
6bd801
		gcry_sha256 gcry_twofish gcry_whirlpool		\\\
bf0270
		gfxmenu gfxterm gzio halt  http			\\\
6bd801
		increment iso9660 jpeg loadenv loopback linux	\\\
6bd801
		lvm luks mdraid09 mdraid1x minicmd net		\\\
6bd801
		normal part_apple part_msdos part_gpt		\\\
6bd801
		password_pbkdf2 png reboot regexp search	\\\
6bd801
		search_fs_uuid search_fs_file search_label	\\\
6bd801
		serial sleep syslinuxcfg test tftp video xfs"	\
6bd801
d9d99f
%ifarch x86_64 aarch64 %{arm}
6bd801
%define efi_mkimage()						\
d9d99f
%{4}./grub-mkimage -O %{1} -o %{2}.orig				\\\
6bd801
	-p /EFI/%{efi_vendor} -d grub-core			\\\
6bd801
	--sbat %{4}./sbat.csv					\\\
6bd801
	${GRUB_MODULES}						\
d9d99f
%{4}./grub-mkimage -O %{1} -o %{3}.orig				\\\
6bd801
	-p /EFI/BOOT -d grub-core				\\\
6bd801
	--sbat %{4}./sbat.csv					\\\
6bd801
	${GRUB_MODULES}						\
c294fc
%{expand:%%{pesign -s -i %%{2}.orig -o %%{2}.one -a %%{5} -c %%{6} -n %%{7}}}	\
c294fc
%{expand:%%{pesign -s -i %%{3}.orig -o %%{3}.one -a %%{5} -c %%{6} -n %%{7}}}	\
c294fc
%{expand:%%{pesign -s -i %%{2}.one -o %%{2} -a %%{8} -c %%{9} -n %%{10}}}	\
c294fc
%{expand:%%{pesign -s -i %%{3}.one -o %%{3} -a %%{8} -c %%{9} -n %%{10}}}	\
d9d99f
%{nil}
d9d99f
%else
6bd801
%define efi_mkimage()						\
d9d99f
%{4}./grub-mkimage -O %{1} -o %{2}				\\\
6bd801
	-p /EFI/%{efi_vendor} -d grub-core			\\\
6bd801
	${GRUB_MODULES}						\
d9d99f
%{4}./grub-mkimage -O %{1} -o %{3}				\\\
6bd801
	-p /EFI/BOOT -d grub-core				\\\
6bd801
	${GRUB_MODULES}						\
6bd801
%{nil}
6bd801
%endif
6bd801
6bd801
%ifarch ppc64le
6bd801
%define ieee1275_mkimage()					\
6bd801
APPENDED_SIG_SIZE=0						\
6bd801
if [ -x /usr/bin/rpm-sign ]; then				\
6bd801
	touch empty.unsigned					\
6bd801
	rpm-sign --key %{5}					\\\
6bd801
		 --lkmsign empty.unsigned			\\\
6bd801
		 --output empty.signed				\
6bd801
	APPENDED_SIG_SIZE="$(stat -c '%s' empty.signed)"	\
6bd801
	rm empty.{un,}signed					\
6bd801
fi								\
6bd801
# FIXME: using this prefix is fragile, must be done properly	\
6bd801
./grub-mkimage -O %{1} -o %{2}.orig				\\\
6bd801
	-p '/grub2' -d grub-core				\\\
6bd801
	-x %{3} -x %{4}						\\\
6bd801
	--appended-signature-size ${APPENDED_SIG_SIZE}		\\\
6bd801
	${GRUB_MODULES}						\
6bd801
if [ -x /usr/bin/rpm-sign ]; then				\
6bd801
	truncate -s -${APPENDED_SIG_SIZE} %{2}.orig		\
6bd801
	rpm-sign --key %{5}					\\\
6bd801
		 --lkmsign %{2}.orig				\\\
6bd801
		 --output %{2}					\
6bd801
else								\
6bd801
	mv %{2}.orig %{2}					\
6bd801
fi								\
d9d99f
%{nil}
d9d99f
%endif
d9d99f
d9d99f
%define do_efi_build_images()					\
6bd801
GRUB_MODULES+=%{grub_modules}					\
6bd801
GRUB_MODULES+=%{efi_modules}					\
d9d99f
GRUB_MODULES+=%{platform_modules}				\
6bd801
%{expand:%%{efi_mkimage %{1} %{2} %{3} %{4} %{5} %{6} %{7} %{8} %{9} %{10}}}	\
6bd801
%{nil}
6bd801
6bd801
%define do_ieee1275_build_images()				\
6bd801
GRUB_MODULES+=%{grub_modules}					\
6bd801
GRUB_MODULES+=%{platform_modules}				\
6bd801
cd grub-%{1}-%{tarversion}					\
6bd801
%{expand:%%ieee1275_mkimage %%{1} %%{2} %%{3} %%{4} %%{5}}	\
6bd801
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_primary_efi_build()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
%{expand:%%do_efi_configure %%{4} %%{5} %%{6}}			\
d9d99f
%do_efi_build_all						\
c294fc
%{expand:%%do_efi_build_images %{grub_target_name} %{2} %{3} ./ %{7} %{8} %{9} %{10} %{11} %{12}} \
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_alt_efi_build()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
%{expand:%%do_efi_configure %%{4} %%{5} %%{6}}			\
d9d99f
%do_efi_build_modules						\
d9d99f
%{expand:%%do_efi_link_utils %{grubefiarch}}			\
c294fc
%{expand:%%do_efi_build_images %{alt_grub_target_name} %{2} %{3} ../grub-%{grubefiarch}-%{tarversion}/ %{7} %{8} %{9} %{10} %{11} %{12}} \
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_legacy_build()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
%configure							\\\
d9d99f
	%{cc_equals}						\\\
e0db32
	HOST_CFLAGS="%{legacy_host_cflags}"			\\\
e0db32
	HOST_CPPFLAGS="-I$(pwd)"				\\\
e0db32
	HOST_LDFLAGS="%{legacy_host_ldflags}"			\\\
e0db32
	TARGET_CFLAGS="%{legacy_target_cflags}"			\\\
e0db32
	TARGET_CPPFLAGS="-I$(pwd)"				\\\
e0db32
	TARGET_LDFLAGS="%{legacy_target_ldflags}"		\\\
d9d99f
	--with-platform=%{platform}				\\\
d9d99f
	--with-utils=host					\\\
d9d99f
	--target=%{_target_platform}				\\\
d9d99f
	--with-grubdir=%{name}					\\\
d9d99f
	--program-transform-name=s,grub,%{name},		\\\
d9d99f
	--disable-grub-mount					\\\
3efed6
	--with-debug-timestamps					\\\
3efed6
	--enable-boot-time					\\\
d9d99f
	--disable-werror || ( cat config.log ; exit 1 )		\
d9d99f
git add .							\
e0db32
git commit -m "After legacy configure"				\
d9d99f
make %{?_smp_mflags}						\
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_alt_efi_install()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
install -d -m 755 $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \
d9d99f
find . '(' -iname gdb_grub					\\\
d9d99f
	-o -iname kernel.exec					\\\
d9d99f
	-o -iname kernel.img					\\\
d9d99f
	-o -iname config.h					\\\
d9d99f
	-o -iname gmodule.pl					\\\
d9d99f
	-o -iname modinfo.sh					\\\
d9d99f
	-o -iname '*.lst'					\\\
d9d99f
	-o -iname '*.mod'					\\\
d9d99f
	')'							\\\
d9d99f
	-exec cp {} $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \\\; \
d9d99f
find $RPM_BUILD_ROOT -type f -iname "*.mod*" -exec chmod a-x {} '\;'	\
d9d99f
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2}	\
d9d99f
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_efi_install()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
make DESTDIR=$RPM_BUILD_ROOT install				\
d9d99f
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
d9d99f
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
d9d99f
fi								\
d9d99f
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
d9d99f
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
d9d99f
fi								\
d9d99f
find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;'	\
d9d99f
touch $RPM_BUILD_ROOT%{efi_esp_dir}/grub.cfg			\
d9d99f
ln -sf ..%{efi_esp_dir}/grub.cfg				\\\
d9d99f
	$RPM_BUILD_ROOT%{_sysconfdir}/%{name}-efi.cfg		\
d9d99f
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2}		\
d9d99f
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3}		\
d9d99f
install -D -m 700 unicode.pf2					\\\
d9d99f
	$RPM_BUILD_ROOT%{efi_esp_dir}/fonts/unicode.pf2		\
d9d99f
${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv			\\\
d9d99f
	${RPM_BUILD_ROOT}%{efi_esp_dir}/grubenv create		\
d9d99f
ln -sf ../efi/EFI/%{efi_vendor}/grubenv				\\\
d9d99f
	$RPM_BUILD_ROOT/boot/grub2/grubenv			\
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_legacy_install()					\
d9d99f
cd grub-%{1}-%{tarversion}					\
d9d99f
make DESTDIR=$RPM_BUILD_ROOT install				\
d9d99f
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then		\
d9d99f
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info		\
d9d99f
fi								\
d9d99f
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then	\
d9d99f
	rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info		\
d9d99f
fi								\
6bd801
%{expand:%ifarch ppc64le					\
6bd801
	install -m 700 %{grubelfname} $RPM_BUILD_ROOT/%{_libdir}/grub/%{1} \
6bd801
%endif}								\
d9d99f
ln -s ../boot/%{name}/grub.cfg					\\\
d9d99f
	${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg		\
d9d99f
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \
d9d99f
	mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp	\\\
d9d99f
	   $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp	\
d9d99f
fi								\
d9d99f
if [ %{3} -eq 0 ]; then						\
d9d99f
	${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv		\\\
d9d99f
		${RPM_BUILD_ROOT}/boot/%{name}/grubenv create	\
d9d99f
fi								\
d9d99f
cd ..								\
d9d99f
%{nil}
d9d99f
d9d99f
%define do_common_install()					\
d9d99f
install -d -m 0755 						\\\
d9d99f
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
d9d99f
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\\\
d9d99f
	$RPM_BUILD_ROOT%{_infodir}/				\
d9d99f
cp -a $RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot		\\\
d9d99f
	$RPM_BUILD_ROOT%{_datarootdir}/locale/en		\
d9d99f
cp docs/grub.info $RPM_BUILD_ROOT%{_infodir}/%{name}.info	\
d9d99f
cp docs/grub-dev.info						\\\
d9d99f
	$RPM_BUILD_ROOT%{_infodir}/%{name}-dev.info		\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}%{efi_esp_dir}/		\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/grub2/		\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/loader/entries	\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/%{name}/themes/system	\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/default	\
d9d99f
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig	\
d9d99f
touch ${RPM_BUILD_ROOT}%{_sysconfdir}/default/grub		\
d9d99f
ln -sf ../default/grub						\\\
d9d99f
	${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub		\
d9d99f
touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg			\
d9d99f
%{nil}
d9d99f
d9d99f
%define define_legacy_variant_files()				\
d9d99f
%{expand:%%files %{1}}						\
d9d99f
%defattr(-,root,root,-)						\
d9d99f
%config(noreplace) %{_sysconfdir}/%{name}.cfg			\
d9d99f
%ghost %config(noreplace) /boot/%{name}/grub.cfg		\
d9d99f
%dir %attr(0700,root,root)/boot/loader/entries			\
6bd801
%ifarch ppc64le						\
6bd801
%dir %{_libdir}/grub/%{2}/					\
6bd801
%{_libdir}/grub/%{2}/%{grubelfname}				\
6bd801
%endif								\
d9d99f
								\
d9d99f
%{expand:%if 0%{?with_legacy_modules}				\
d9d99f
%{expand:%%files %{1}-modules}					\
d9d99f
%defattr(-,root,root)						\
d9d99f
%dir %{_libdir}/grub/%{2}/					\
d9d99f
%{_libdir}/grub/%{2}/*						\
6bd801
%ifarch ppc64le						\
6bd801
%exclude %{_libdir}/grub/%{2}/%{grubelfname}			\
6bd801
%endif								\
d9d99f
%exclude %{_libdir}/grub/%{2}/*.module				\
d9d99f
%exclude %{_libdir}/grub/%{2}/{boot,boot_hybrid,cdboot,diskboot,lzma_decompress,pxeboot}.image \
d9d99f
%exclude %{_libdir}/grub/%{2}/*.o				\
d9d99f
%else								\
d9d99f
%%exclude %%{_libdir}/grub/%%{grublegacyarch}/*			\
d9d99f
%endif}								\
d9d99f
%{nil}
d9d99f
d9d99f
%define define_efi_variant_files()				\
d9d99f
%{expand:%%files %{1}}						\
d9d99f
%defattr(0700,root,root,-)					\
d9d99f
%config(noreplace) %{_sysconfdir}/%{name}-efi.cfg		\
d9d99f
%attr(0700,root,root)%{efi_esp_dir}/%{2}			\
d9d99f
%dir %attr(0700,root,root)%{efi_esp_dir}/fonts			\
d9d99f
%dir %attr(0700,root,root)/boot/loader/entries			\
d9d99f
%ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg	\
3efed6
%config(noreplace) %verify(not size mode md5 mtime) /boot/grub2/grubenv	\
d9d99f
%ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grubenv	\
d9d99f
%{expand:%if 0%{?without_efi_modules}				\
d9d99f
%exclude %{_libdir}/grub/%{6}					\
d9d99f
%exclude %{_libdir}/grub/%{6}/*					\
d9d99f
%endif}								\
d9d99f
								\
d9d99f
%{expand:%if 0%{?with_efi_modules}				\
d9d99f
%{expand:%%files %{1}-modules}					\
d9d99f
%defattr(-,root,root,-)						\
d9d99f
%dir %{_libdir}/grub/%{6}/					\
d9d99f
%{_libdir}/grub/%{6}/*						\
d9d99f
%exclude %{_libdir}/grub/%{6}/*.module				\
d9d99f
%endif}								\
d9d99f
								\
d9d99f
%{expand:%%files %{1}-cdboot}					\
d9d99f
%defattr(0700,root,root,-)					\
d9d99f
%attr(0700,root,root)%{efi_esp_dir}/%{3}			\
d9d99f
%attr(0700,root,root)%{efi_esp_dir}/fonts			\
d9d99f
%{nil}