void-packages/srcpkgs/grub/template
q66 fd31f6ea65 grub: use -mno-altivec explicitly on ppc32 as well
this is not really necessary by default, but might be useful for
people who explicitly add altivec in their custom cflags, as they
would otherwise get a broken grub core
2020-12-06 05:51:32 +01:00

217 lines
6 KiB
Bash

# Template file for 'grub'
pkgname=grub
version=2.04
revision=3
hostmakedepends="python3 pkg-config flex freetype-devel font-unifont-bdf"
makedepends="libusb-compat-devel ncurses-devel freetype-devel
liblzma-devel device-mapper-devel fuse-devel"
depends="os-prober"
conf_files="/etc/default/grub /etc/grub.d/*"
short_desc="GRand Unified Bootloader 2"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-3.0-or-later"
homepage="https://www.gnu.org/software/grub/"
distfiles="${GNU_SITE}/grub/grub-${version}.tar.xz"
checksum=e5292496995ad42dabe843a0192cf2a2c502e7ffcc7479398232b10a472df77d
archs="i686* x86_64* aarch64* ppc ppc-musl ppc64*"
nopie=yes
subpackages="grub-utils"
# _SUPPLEMENTARY_BUILDS is a list of <TARGET>-<PLATFORN> version of grub to build
case "$XBPS_TARGET_MACHINE" in
x86_64*)
_NATIVE_PLATFORM=pc
_SUPPLEMENTARY_BUILDS="i386-efi x86_64-efi i386-coreboot x86_64-xen"
subpackages+=" grub-i386-efi grub-x86_64-efi grub-i386-coreboot grub-xen"
;;
i686*)
CFLAGS="-D_FILE_OFFSET_BITS=64"
configure_args+=" ac_cv_sizeof_off_t=8"
_NATIVE_PLATFORM=pc
_SUPPLEMENTARY_BUILDS="i386-efi i386-coreboot i386-xen"
subpackages+=" grub-i386-efi grub-i386-coreboot grub-xen"
;;
aarch64*)
_NATIVE_PLATFORM=efi
subpackages+=" grub-arm64-efi"
;;
ppc*)
_NATIVE_PLATFORM=ieee1275
subpackages+=" grub-powerpc-ieee1275"
;;
esac
post_extract() {
sed -i -e 's,freetype/ftsynth.h,freetype2/ftsynth.h,' util/grub-mkfont.c
}
do_configure() {
unset CC AS LD RANLIB CPP
CFLAGS="$CFLAGS -fno-stack-protector"
# building with altivec generates broken grub core
case "$XBPS_TARGET_MACHINE" in
ppc*) CFLAGS="$CFLAGS -mno-altivec" ;;
esac
configure_args+=" --enable-device-mapper --enable-cache-stats --enable-nls
--enable-grub-mkfont --enable-grub-mount --disable-werror
--sbindir=/usr/bin"
# fix unifont.bdf location so grub-mkfont can create *.pf2 files
sed -i 's|/usr/share/fonts/unifont|/usr/share/fonts/misc|' configure
# build tools
_configure_args=${configure_args}
if [ -n "${_NATIVE_PLATFORM}" ]; then
_configure_args="--with-platform=${_NATIVE_PLATFORM} ${_configure_args}"
fi
msg_normal "Configuring grub tools...\n"
mkdir $wrksrc/build
cd $wrksrc/build
../configure --host=${XBPS_TARGET_MACHINE} ${_configure_args}
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_PLATFORM=${_SUPP_BUILD##*-}
msg_normal "Configuring ${_TARGET} ${_PLATFORM} grub...\n"
mkdir $wrksrc/${_PLATFORM}_${_TARGET}_build
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
../configure --host=${XBPS_TARGET_MACHINE} --target=${_TARGET} --with-platform=${_PLATFORM} ${configure_args} \
--disable-efiemu \
--libdir=/usr/lib
done
}
do_build() {
# XXX remove the strip wrapper
rm ${XBPS_WRAPPERDIR}/strip
msg_normal "Building grub tools...\n"
cd $wrksrc/build
make ${makejobs} &> make.log || tail -n100 make.log
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_PLATFORM=${_SUPP_BUILD##*-}
msg_normal "Building ${_TARGET} ${_PLATFORM} grub...\n"
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
make ${makejobs} &> make.log || tail -n100 make.log
done
}
do_install() {
# XXX remove the strip wrapper
rm ${XBPS_WRAPPERDIR}/strip
for _SUPP_BUILD in ${_SUPPLEMENTARY_BUILDS}; do
_TARGET=${_SUPP_BUILD%%-*}
_GRUB_TARGET=${_TARGET}
case "${_GRUB_TARGET}" in
aarch64*)
_GRUB_TARGET=arm64
;;
esac
_PLATFORM=${_SUPP_BUILD##*-}
cd $wrksrc/${_PLATFORM}_${_TARGET}_build
make DESTDIR=$DESTDIR/${_PLATFORM}_${_TARGET} install
# Remove non-platform specific files
rm -rf ${DESTDIR}/${_PLATFORM}_${_TARGET}/{boot,etc,usr/{share,bin}}
rm -f ${DESTDIR}/${_PLATFORM}_${_TARGET}/usr/lib/grub/${_GRUB_TARGET}-${_PLATFORM}/${_GRUB_TARGET}-*
rm -f ${DESTDIR}/${_PLATFORM}_${_TARGET}/usr/lib/grub/${_GRUB_TARGET}-${_PLATFORM}/*.{module,image}
cp -r ${DESTDIR}/${_PLATFORM}_${_TARGET}/* ${DESTDIR}
rm -rf ${DESTDIR}/${_PLATFORM}_${_TARGET}
done
cd $wrksrc/build
make DESTDIR=$DESTDIR install
# Required to compress info files.
vmkdir usr/share/info
touch -f ${DESTDIR}/usr/share/info/dir
vinstall ${FILESDIR}/grub.default 644 etc/default grub
# Kernel hooks.
vinstall ${FILESDIR}/kernel.d/grub.post 750 \
etc/kernel.d/post-install 50-grub
vinstall ${FILESDIR}/kernel.d/grub.post 750 \
etc/kernel.d/post-remove 50-grub
# update-grub for noobs.
printf "#!/bin/sh\ngrub-mkconfig -o /boot/grub/grub.cfg\nexit \$?\n" >> \
${DESTDIR}/usr/bin/update-grub
chmod 755 ${DESTDIR}/usr/bin/update-grub
vmkdir usr/share/bash-completion/completions
mv ${DESTDIR}/etc/bash_completion.d/grub \
${DESTDIR}/usr/share/bash-completion/completions
# Remove useless tools
rm ${DESTDIR}/usr/bin/grub-ofpathname
rm ${DESTDIR}/usr/bin/grub-sparc64-setup
}
grub-utils_package() {
short_desc+=" - additional utilities"
depends="grub>=${version}"
pkg_install() {
vmove usr/bin/grub-menulst2cfg
vmove usr/bin/grub-fstest
vmove usr/bin/grub-mkfont
}
}
grub-x86_64-efi_package() {
archs=noarch
depends="grub>=$version dosfstools efibootmgr"
short_desc+=" - x86_64 EFI support"
pkg_install() {
vmove usr/lib/grub/x86_64-efi
}
}
grub-i386-efi_package() {
archs=noarch
depends="grub>=$version dosfstools efibootmgr"
short_desc+=" - i386 EFI support"
pkg_install() {
vmove usr/lib/grub/i386-efi
}
}
grub-i386-coreboot_package() {
archs=noarch
depends="grub>=$version"
short_desc+=" - i386 coreboot support"
pkg_install() {
vmove usr/lib/grub/i386-coreboot
}
}
grub-xen_package() {
depends="grub>=$version"
short_desc+=" - Xen PV support"
pkg_install() {
case "$XBPS_TARGET_MACHINE" in
x86_64*)
vmove usr/lib/grub/x86_64-xen
;;
i686*)
vmove usr/lib/grub/i386-xen
;;
esac
}
}
grub-arm64-efi_package() {
archs=noarch
depends="grub>=$version dosfstools efibootmgr"
short_desc+=" - arm64 EFI support"
pkg_install() {
vmove usr/lib/grub/arm64-efi
}
}
grub-powerpc-ieee1275_package() {
archs=noarch
depends="grub>=$version powerpc-utils"
short_desc+=" - powerpc Open Firmware support"
pkg_install() {
vmove usr/lib/grub/powerpc-ieee1275
}
}