grub-static-0.97.ebuild 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. inherit mount-boot
  4. DESCRIPTION="Static GNU GRUB boot loader"
  5. HOMEPAGE="https://www.gnu.org/software/grub/"
  6. SRC_URI="mirror://gentoo/grub-static-${PV}.tar.bz2"
  7. LICENSE="GPL-2"
  8. SLOT="0"
  9. KEYWORDS="-* amd64 ~x86"
  10. IUSE=""
  11. DEPEND="!<sys-boot/grub-2"
  12. RDEPEND="${DEPEND}"
  13. src_install() {
  14. cp -a "${WORKDIR}"/* "${D}"/
  15. }
  16. #
  17. # Everything below is directly copied from the grub ebuild
  18. # please try to keep it in sync
  19. #
  20. setup_boot_dir() {
  21. local dir="${1}"
  22. [[ ! -e "${dir}" ]] && die "${dir} does not exist!"
  23. [[ ! -e "${dir}"/grub ]] && mkdir "${dir}/grub"
  24. # change menu.lst to grub.conf
  25. if [[ ! -e "${dir}"/grub/grub.conf ]] && [[ -e "${dir}"/grub/menu.lst ]] ; then
  26. mv -f "${dir}"/grub/menu.lst "${dir}"/grub/grub.conf
  27. ewarn
  28. ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
  29. ewarn
  30. fi
  31. if [[ ! -e "${dir}"/grub/menu.lst ]]; then
  32. einfo "Linking from new grub.conf name to menu.lst"
  33. ln -snf grub.conf "${dir}"/grub/menu.lst
  34. fi
  35. [[ -e "${dir}"/grub/stage2 ]] && mv "${dir}"/grub/stage2{,.old}
  36. einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}"
  37. for x in /lib*/grub/*/* /usr/lib*/grub/*/* ; do
  38. [[ -f "${x}" ]] && cp -p "${x}" "${dir}"/grub/
  39. done
  40. if [[ -e "${dir}"/grub/grub.conf ]] ; then
  41. egrep \
  42. -v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \
  43. "${dir}"/grub/grub.conf | \
  44. /sbin/grub --batch \
  45. --device-map="${dir}"/grub/device.map \
  46. > /dev/null
  47. fi
  48. }
  49. pkg_postinst() {
  50. [[ "${ROOT}" != "/" ]] && return 0
  51. [[ -n ${DONT_MOUNT_BOOT} ]] && return 0
  52. setup_boot_dir /boot
  53. einfo "To install grub files to another device (like a usb stick), just run:"
  54. einfo " emerge --config =${PF}"
  55. }
  56. pkg_config() {
  57. local dir
  58. einfo "Enter the directory where you want to setup grub:"
  59. read dir
  60. setup_boot_dir "${dir}"
  61. }