grub-static-0.97-r6.ebuild 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # XXX: we need to review menu.lst vs grub.conf handling. We've been converting
  4. # all systems to grub.conf (and symlinking menu.lst to grub.conf), but
  5. # we never updated any of the source code (it still all wants menu.lst),
  6. # and there is no indication that upstream is making the transition.
  7. inherit eutils mount-boot
  8. PATCHVER="1.7" # Not used, just for tracking with main grub
  9. DESCRIPTION="GNU GRUB Legacy boot loader (static build)"
  10. HOMEPAGE="https://www.gnu.org/software/grub/"
  11. SRC_URI="mirror://gentoo/${PF}.tar.bz2"
  12. LICENSE="GPL-2"
  13. SLOT="0"
  14. KEYWORDS="-* amd64 ~x86"
  15. IUSE=""
  16. DEPEND="!<sys-boot/grub-2"
  17. RDEPEND="${DEPEND}"
  18. src_install() {
  19. cp -a "${WORKDIR}"/* "${D}"/
  20. }
  21. #
  22. # Below this point, everything is also used in grub-static!
  23. # Please keep in sync!
  24. #
  25. setup_boot_dir() {
  26. local boot_dir=$1
  27. local dir=${boot_dir}
  28. [[ ! -e ${dir} ]] && die "${dir} does not exist!"
  29. [[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
  30. dir="${dir}/grub"
  31. if [[ ! -e ${dir} ]] ; then
  32. mkdir "${dir}" || die "${dir} does not exist!"
  33. fi
  34. # change menu.lst to grub.conf
  35. if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
  36. mv -f "${dir}"/menu.lst "${dir}"/grub.conf
  37. ewarn
  38. ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
  39. ewarn
  40. fi
  41. if [[ ! -e ${dir}/menu.lst ]]; then
  42. einfo "Linking from new grub.conf name to menu.lst"
  43. ln -snf grub.conf "${dir}"/menu.lst
  44. fi
  45. if [[ -e ${dir}/stage2 ]] ; then
  46. mv "${dir}"/stage2{,.old}
  47. ewarn "*** IMPORTANT NOTE: you must run grub and install"
  48. ewarn "the new version's stage1 to your MBR. Until you do,"
  49. ewarn "stage1 and stage2 will still be the old version, but"
  50. ewarn "later stages will be the new version, which could"
  51. ewarn "cause problems such as an unbootable system."
  52. ewarn "This means you must use either grub-install or perform"
  53. ewarn "root/setup manually! For more help, see the handbook:"
  54. ewarn "https://www.gentoo.org/doc/en/handbook/handbook-${ARCH}.xml?part=1&chap=10#grub-install-auto"
  55. ebeep
  56. fi
  57. einfo "Copying files from /lib/grub, /usr/lib/grub and /usr/share/grub to ${dir}"
  58. for x in \
  59. "${ROOT}"/lib*/grub/*/* \
  60. "${ROOT}"/usr/lib*/grub/*/* \
  61. "${ROOT}"/usr/share/grub/* ; do
  62. [[ -f ${x} ]] && cp -p "${x}" "${dir}"/
  63. done
  64. if [[ ! -e ${dir}/grub.conf ]] ; then
  65. s="${ROOT}/usr/share/doc/${PF}/grub.conf.gentoo"
  66. [[ -e "${s}" ]] && cat "${s}" >${dir}/grub.conf
  67. [[ -e "${s}.gz" ]] && zcat "${s}.gz" >${dir}/grub.conf
  68. [[ -e "${s}.bz2" ]] && bzcat "${s}.bz2" >${dir}/grub.conf
  69. fi
  70. # Per bug 218599, we support grub.conf.install for users that want to run a
  71. # specific set of Grub setup commands rather than the default ones.
  72. grub_config=${dir}/grub.conf.install
  73. [[ -e ${grub_config} ]] || grub_config=${dir}/grub.conf
  74. if [[ -e ${grub_config} ]] ; then
  75. egrep \
  76. -v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \
  77. "${grub_config}" | \
  78. /sbin/grub --batch \
  79. --device-map="${dir}"/device.map \
  80. > /dev/null
  81. fi
  82. # the grub default commands silently piss themselves if
  83. # the default file does not exist ahead of time
  84. if [[ ! -e ${dir}/default ]] ; then
  85. grub-set-default --root-directory="${boot_dir}" default
  86. fi
  87. einfo "Grub has been installed to ${boot_dir} successfully."
  88. }
  89. pkg_postinst() {
  90. if [[ -n ${DONT_MOUNT_BOOT} ]]; then
  91. elog "WARNING: you have DONT_MOUNT_BOOT in effect, so you must apply"
  92. elog "the following instructions for your /boot!"
  93. elog "Neglecting to do so may cause your system to fail to boot!"
  94. elog
  95. else
  96. setup_boot_dir "${ROOT}"/boot
  97. # Trailing output because if this is run from pkg_postinst, it gets mixed into
  98. # the other output.
  99. einfo ""
  100. fi
  101. elog "To interactively install grub files to another device such as a USB"
  102. elog "stick, just run the following and specify the directory as prompted:"
  103. elog " emerge --config =${PF}"
  104. elog "Alternately, you can export GRUB_ALT_INSTALLDIR=/path/to/use to tell"
  105. elog "grub where to install in a non-interactive way."
  106. }
  107. pkg_config() {
  108. local dir
  109. if [ ! -d "${GRUB_ALT_INSTALLDIR}" ]; then
  110. einfo "Enter the directory where you want to setup grub:"
  111. read dir
  112. else
  113. dir="${GRUB_ALT_INSTALLDIR}"
  114. fi
  115. setup_boot_dir "${dir}"
  116. }