# $Id$ PNAME="grub" PVER="2.06" PBUILD="r6" PCAT="sys-apps" DESCRIPTION="GNU GRUB2 boot loader." HOMEPAGE="http://www.gnu.org/software/grub/" DEPEND=">= sys-apps/mage-release-1 >= sys-libs/ncurses-6.4 >= sys-dev/gettext-0.22 >= sys-libs/zlib-1.2 >= media-libs/freetype-2.13 >= virtual/xz-utils >= sys-apps/os-prober-1.56 >= sys-fs/device-mapper-2.02 >= sys-fs/dosfstools-4.2 >= sys-apps/efibootmgr-18" SDEPEND=">= virtual/pkgconfig >= net-misc/rsync-3 >= app-text/help2man-1 >= sys-dev/autogen-5 >= sys-dev/autoconf-10 >= sys-dev/automake-10" SRCFILE="${PNAME}-${PVER}.tar.gz" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" UNIFONT_PVER=15.0.06 UNIFONT_SRCFILE="unifont-${UNIFONT_PVER}.pcf.gz" if [[ ${GRUB_GIT_SOURCE} = 1 ]] then GNULIB_SRCFILE="gnulib-20230809.tar.bz2" GNULIB_SRCDIR="${BUILDDIR}/gnulib" fi sminclude mtools # grub.confd revision CONF_REV=1.4 # grub sources from git # 1=yes; 0=no GRUB_GIT_SOURCE=0 # build ia32 on x64 platforms # 1=yes; 0=no BUILD_X64_IA32=1 msetfeature "!strip static !ccache !distcc" SRC_URI=( gnu://${PNAME}/${SRCFILE} https://unifoundry.com/pub/unifont/unifont-${UNIFONT_PVER}/font-builds/${UNIFONT_SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/${UNIFONT_SRCFILE} mirror://${PNAME}/${PNAME}-2.06-confd.patch mirror://${PNAME}/${PNAME}-2.02-cosmetic.patch mirror://${PNAME}/${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch mirror://${PNAME}/${PNAME}-2.06-e2fsprogs-1.47-fixes.patch mirror://${PNAME}/grub.confd-${CONF_REV} ) if [[ ${GRUB_GIT_SOURCE} = 1 ]] then SRC_URI+=( mirror://${PNAME}/${GNULIB_SRCFILE} ) fi UP2DATE="updatecmd_gnu ${PNAME} gz" # grub doesn't like CFLAG optimation, # and do you really want that at your bootloader ?? unset CFLAGS unset CXXFLAGS unset LTOFLAGS src_prepare() { munpack ${SRCFILE} || die if [[ ${GRUB_GIT_SOURCE} = 1 ]] then munpack ${GNULIB_SRCFILE} || die fi cd ${SRCDIR} # upstream fixes mpatch -Np1 ${PNAME}-2.06-e2fsprogs-1.47-fixes.patch || die # use /etc/conf.d/grub instead of /etc/default/grub mpatch ${PNAME}-2.06-confd.patch || die # cosmetic fixes mpatch ${PNAME}-2.02-cosmetic.patch || die # generate pretty names from os-release if GRUB_DISTRIBUTOR is not set mpatch ${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847 gzip -cd ${SOURCEDIR}/${PNAME}/${UNIFONT_SRCFILE} > unifont.bdf || die if [[ ${GRUB_GIT_SOURCE} = 1 ]] then # run bootstrap (only required for versions from git) ./bootstrap --gnulib-srcdir=${GNULIB_SRCDIR} --no-git || die fi # regen aclocal with automake 1.16 WANT_AUTOMAKE=1.16 ./autogen.sh || die # setup build dirs cp -r ${SRCDIR} ${BUILDDIR}/build_bios || die cp -r ${SRCDIR} ${BUILDDIR}/build_efi || die if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] then cp -r ${SRCDIR} ${BUILDDIR}/build_efi_ia32 || die fi } src_compile() { local myconf local myarch local efiemu # common configure options # grub-mount requires fuse3 # grub-mkfont requires freetype2 myconf="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datarootdir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/$(mlibdir) --disable-static --enable-shared --enable-nls --disable-werror --disable-silent-rules --enable-device-mapper --enable-cache-stats --enable-boot-time --enable-grub-mkfont --disable-grub-mount --with-bootdir=/boot --with-grubdir=grub" # fix freetype build issues export FREETYPE="pkg-config freetype2" export BUILD_FREETYPE="pkg-config freetype2" # set version export PACKAGE_VERSION="${PVER}-${PBUILD}" # unset all build flags unset CFLAGS unset CPPFLAGS unset CXXFLAGS unset LDFLAGS unset LTOFLAGS unset MAKEFLAGS unset MAKEOPTS # build bios version cd ${BUILDDIR}/build_bios myarch="i386" if [[ ${ARCH} = x86_64 ]] then efiemu="--enable-efiemu" else efiemu="--disable-efiemu" fi ./configure --with-platform=pc --target="${myarch}" ${myconf} ${efiemu} || die make || die # build efi version cd ${BUILDDIR}/build_efi case ${ARCH} in x86_64) myarch="${ARCH}" ;; i*86) myarch="i386" ;; esac efiemu="--disable-efiemu" ./configure --with-platform=efi --target="${myarch}" ${myconf} ${efiemu} || die make || die # build ia32 efi version on x86_64 if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] then cd ${BUILDDIR}/build_efi_ia32 myarch="i386" efiemu="--disable-efiemu" ./configure --with-platform=efi --target="${myarch}" ${myconf} ${efiemu} || die make || die fi } src_install() { local myarch # install efi version first cd ${BUILDDIR}/build_efi case ${ARCH} in x86_64) myarch="${ARCH}" ;; i*86) myarch="i386" ;; esac make DESTDIR=${BINDIR} install || die # remove debugging related files mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.module || die #mdelete -f /usr/$(mlibdir)/grub/${myarch}-efi/\*.image || die # may or may not exist mdelete /usr/$(mlibdir)/grub/${myarch}-efi/kernel.exec || die mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gdb_grub || die mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gmodule.pl || die # install efi_ia32 version if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] then cd ${BUILDDIR}/build_efi_ia32 myarch="i386" make DESTDIR=${BINDIR} install || die # remove debugging related files mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.module || die #mdelete -f /usr/$(mlibdir)/grub/${myarch}-efi/\*.image || die # may or may not exist mdelete /usr/$(mlibdir)/grub/${myarch}-efi/kernel.exec || die mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gdb_grub || die mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gmodule.pl || die fi # install bios version last cd ${BUILDDIR}/build_bios make DESTDIR=${BINDIR} install || die # remove debugging related files mdelete /usr/$(mlibdir)/grub/i386-pc/\*.module || die mdelete /usr/$(mlibdir)/grub/i386-pc/\*.image || die mdelete /usr/$(mlibdir)/grub/i386-pc/kernel.exec || die mdelete /usr/$(mlibdir)/grub/i386-pc/gdb_grub || die mdelete /usr/$(mlibdir)/grub/i386-pc/gmodule.pl || die # not required by pretty name patch anymore # set distribution #echo 'GRUB_DISTRIBUTOR="Magellan-Linux"' >> ${BINDIR}/usr/share/grub/grub-mkconfig_lib || die # setup a proper grub default conf minstallconf grub.confd-${CONF_REV} grub || die # enable a splash screen by default sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/s:\"\(.*\)\":\"\1 splash\":' ${BINDIR}/etc/conf.d/grub || die # needed dir minstalldir /boot/grub || die # install unifont minstalldir /usr/share/fonts/unifont || die gunzip -c ${SOURCEDIR}/${PNAME}/${UNIFONT_SRCFILE} > ${BINDIR}/usr/share/fonts/unifont/unifont.pcf || die # docs cd ${SRCDIR} minstalldocs AUTHORS ChangeLog COPYING NEWS README THANKS TODO || die } preinstall() { mount /boot &> /dev/null } postinstall() { [ ! -d ${MROOT}/boot/grub ] && install -d ${MROOT}/boot/grub # creates some essential links [ ! -e ${MROOT}/boot/boot ] && ln -sf . ${MROOT}/boot/boot if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] && [[ ${MAGE_BOOTSTRAP} != true ]] then # create a device.map if [[ ! -f /boot/grub/device.map ]] then if [[ -x $(type -P grub-mkdevicemap) ]] then grub-mkdevicemap fi fi # needed by grub-mkconfig on the first run if [[ ! -f /boot/grub/video.lst ]] then install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst fi # update grub.cfg LC_ALL=C grub-mkconfig -o /boot/grub/grub.cfg # install bootloader to disk #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))" local bootdisk bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" # Generate core.img, but don't let it be installed in boot sector grub-install --no-floppy "${bootdisk}" fi }