# $Id$ PNAME="grub" PVER="2.02" PBUILD="r3" PCAT="sys-apps" DESCRIPTION="GNU GRUB2 boot loader." HOMEPAGE="http://www.gnu.org/software/grub/" DEPEND=">= sys-apps/mage-release-1 >= sys-libs/ncurses-5.9 >= sys-dev/gettext-0.19 >= sys-libs/zlib-1.2.5 >= media-libs/freetype-2.5 >= app-arch/xz-utils-5 >= sys-apps/os-prober-1.56 >= sys-fs/device-mapper-2.02 >= sys-fs/dosfstools-4.1" SDEPEND=">= dev-util/pkgconfig-0.25" SRCFILE="${PNAME}-${PVER}.tar.gz" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" sminclude mtools # grub.confd revision CONF_REV=1.4 SRC_URI=( gnu://${PNAME}/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/${PNAME}-2.02-confd-2.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.02-gcc8.patch mirror://${PNAME}/${PNAME}-2.02-x86_64_PLT32.patch mirror://${PNAME}/grub.confd-${CONF_REV} ) UP2DATE="updatecmd_gnu ${PNAME} gz" # grub doesn't like CFLAG optimation, # and do you really want that at your bootloader ?? unset CFLAGS unset CXXFLAGS src_prepare() { munpack ${SRCFILE} || die cd ${SRCDIR} # use /etc/conf.d/grub instead of /etc/default/grub mpatch ${PNAME}-2.02-confd-2.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 # fix build with gcc8 mpatch ${PNAME}-2.02-gcc8.patch || die # fix x86_64_plt32 issues with 32bit builds mpatch ${PNAME}-2.02-x86_64_PLT32.patch || die # setup build dirs install -d ${SRCDIR}/build_bios || die install -d ${SRCDIR}/build_efi || die } src_compile() { local myconf local myarch # common configure options # grub-mount requires fuse2 # grub-mkfont requires freetype2 myconf="--prefix=/usr --host=${CHOST} --build=${CHOST} --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/$(mlibdir) --disable-static --enable-shared --disable-efiemu --disable-werror --enable-device-mapper --enable-grub-mkfont --disable-grub-mount" # fix freetype build issues export FREETYPE="pkg-config freetype2" export BUILD_FREETYPE="pkg-config freetype2" # build bios version cd ${SRCDIR}/build_bios myarch="i386" ../configure --with-platform=pc --target="${myarch}" ${myconf} || die mmake || die # build efi version cd ${SRCDIR}/build_efi case ${ARCH} in x86_64) myarch="${ARCH}" ;; i*86) myarch="i386" ;; esac ../configure --with-platform=efi --target="${myarch}" ${myconf} || die mmake || die } src_install() { local myarch # install bios version cd ${SRCDIR}/build_bios mmake 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 # install efi version cd ${SRCDIR}/build_efi case ${ARCH} in x86_64) myarch="${ARCH}" ;; i*86) myarch="i386" ;; esac mmake 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 # 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 # 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 }