# $Id$ PNAME="grub" PVER="2.02_rc2" PBUILD="r1" 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-libs/zlib-1.2.5 >= media-libs/freetype-2.5 >= sys-fs/device-mapper-2.02" SDEPEND=">= sys-libs/ncurses-dev-5.9 >= sys-libs/zlib-dev-1.2.5 >= media-libs/freetype-dev-2.5" SRCFILE="${PNAME}-${PVER/_/\~}.tar.gz" SRCDIR="${BUILDDIR}/${PNAME}-${PVER/_/\~}" ALX_PKG_KEEP="boot/grub etc/conf.d etc/grub.d usr/sbin/grub-bios-setup usr/sbin/grub-install usr/sbin/grub-mkconfig usr/sbin/grub-probe usr/sbin/grub-reboot usr/sbin/grub-set-default usr/bin/grub-mkimage usr/bin/grub-editenv usr/bin/grub-mkrelpath usr/bin/grub-script-check usr/share/grub/grub-mkconfig_lib usr/$(mlibdir)/grub/i386-pc" sminclude mtools alx-split # += to add injection files (alx.sminc) SRC_URI+=( #gnu://${PNAME}/${SRCFILE} http://alpha.gnu.org/gnu/${PNAME}/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/${PNAME}-2.02-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.00-alx-add-includedir-function.patch mirror://${PNAME}/${PNAME}-2.02-busybox-linux-install.patch mirror://${PNAME}/${PNAME}-2.00-grub-mkconfig-fallback-to-blkid-instead-of-grub-probe-for-unknown-root-partition-types.patch ) 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.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 # grub-mkconfig: fallback to blkid instead of grub probe for unknown root partition types like f2fs mpatch ${PNAME}-2.00-grub-mkconfig-fallback-to-blkid-instead-of-grub-probe-for-unknown-root-partition-types.patch || die # fixes some issues with busybox # not required anymore with busybox-1.26 and above, grep -vx|-qx is now supported #mpatch ${PNAME}-${PVER}-busybox.patch || die mpatch ${PNAME}-2.02-busybox-linux-install.patch || die # add includedir() function to grub-mkconfig_lib # includedir() includes all grub configuration snippets of given directory mpatch ${PNAME}-2.00-alx-add-includedir-function.patch || die } src_compile() { cd ${SRCDIR} mconfigure --disable-efiemu --disable-werror --disable-nls || die mmake || die } alx_generic_src_install() { cd ${SRCDIR} mmake DESTDIR=${BINDIR} install || die # not required by pretty name patch anymore # set distribution #echo 'GRUB_DISTRIBUTOR="ALX Thinclient"' >> ${BINDIR}/usr/share/grub/grub-mkconfig_lib || die # install only grub dir, no default config minstalldir /boot/grub || 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 # docs minstalldocs AUTHORS ChangeLog COPYING NEWS README THANKS TODO || die # setup a proper grub default conf minstalldir /etc/conf.d || die mcinjectfile grub.confd /etc/conf.d/grub || die # minstalldir /etc/conf.d/grub.d || die # mcinjectfile grub-alx.confd /etc/conf.d/grub.d/10-alx || die # # use custom creation scripts and delete the provided ones # echo -e ${COLGREEN}" injecting custom grub-configs"${COLDEFAULT} # local i # for i in ${BINDIR}/etc/grub.d/10_linux \ # ${BINDIR}/etc/grub.d/20_linux_xen \ # ${BINDIR}/etc/grub.d/30_os-prober \ # ${BINDIR}/etc/grub.d/40_custom \ # ${BINDIR}/etc/grub.d/41_custom \ # ${BINDIR}/etc/grub.d/README # do # if [[ -f ${i} ]] # then # rm ${i} || die # fi # done # mcinjectexec 05_alx_header /etc/grub.d/ || die # mcinjectexec 10_alx /etc/grub.d/ || die # only keep 10_linux script for i in ${BINDIR}/etc/grub.d/20_linux_xen \ ${BINDIR}/etc/grub.d/30_os-prober \ ${BINDIR}/etc/grub.d/40_custom \ ${BINDIR}/etc/grub.d/41_custom \ ${BINDIR}/etc/grub.d/README do if [[ -f ${i} ]] then rm ${i} || die fi done } preinstall_grub() { mount /boot &> /dev/null add_conf_prot_mask /etc/conf.d/grub /etc/grub.d /etc/conf.d/grub.d } postinstall_grub() { [ ! -d ${MROOT}/boot/grub ] && install -d ${MROOT}/boot/grub # creates some essential links [ ! -e ${MROOT}/boot/boot ] && ln -sf . ${MROOT}/boot/boot # clean up old helpers, which are now consolidated to the '10_alx' script, and delete 10_alx too, we're using 10_linux now local i for i in 30_alx_hwdetect 40_alx_reset 10-alx do if [ -f ${MROOT}/etc/grub/${i} ] then rm ${MROOT}/etc/grub/${i} fi done if [ -f ${MROOT}/etc/conf.d/grub.conf.d/10-alx ] then rm ${MROOT}/etc/conf.d/grub.conf.d/10-alx fi if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] && [[ ${MAGE_BOOTSTRAP} != true ]] then # create a device.map if [[ ! -f /boot/grub/device.map ]] then grub-mkdevicemap 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 }