nalika / rpms / grub2

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