grub-2.02_rc1.ebuild 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. if [[ ${PV} == 9999 ]]; then
  5. GRUB_AUTOGEN=1
  6. fi
  7. if [[ -n ${GRUB_AUTOGEN} ]]; then
  8. PYTHON_COMPAT=( python{2_7,3_3,3_4,3_5} )
  9. WANT_LIBTOOL=none
  10. inherit autotools python-any-r1
  11. fi
  12. inherit autotools bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs versionator
  13. if [[ ${PV} != 9999 ]]; then
  14. if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
  15. # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
  16. MY_P=${P/_/'~'}
  17. SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
  18. S=${WORKDIR}/${MY_P}
  19. else
  20. SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
  21. S=${WORKDIR}/${P%_*}
  22. fi
  23. KEYWORDS="~amd64 ~arm64 ~x86"
  24. else
  25. inherit git-r3
  26. EGIT_REPO_URI="git://git.sv.gnu.org/grub.git
  27. http://git.savannah.gnu.org/r/grub.git"
  28. fi
  29. PATCHES=(
  30. "${FILESDIR}"/gfxpayload.patch
  31. "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
  32. )
  33. DEJAVU=dejavu-sans-ttf-2.37
  34. UNIFONT=unifont-9.0.06
  35. SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
  36. themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
  37. DESCRIPTION="GNU GRUB boot loader"
  38. HOMEPAGE="https://www.gnu.org/software/grub/"
  39. # Includes licenses for dejavu and unifont
  40. LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
  41. SLOT="2/${PVR}"
  42. IUSE="debug device-mapper doc efiemu +fonts mount multislot nls static sdl test +themes truetype libzfs"
  43. GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 )
  44. IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
  45. REQUIRED_USE="
  46. grub_platforms_coreboot? ( fonts )
  47. grub_platforms_qemu? ( fonts )
  48. grub_platforms_ieee1275? ( fonts )
  49. grub_platforms_loongson? ( fonts )
  50. "
  51. # os-prober: Used on runtime to detect other OSes
  52. # xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
  53. RDEPEND="
  54. app-arch/xz-utils
  55. >=sys-libs/ncurses-5.2-r5:0=
  56. debug? (
  57. sdl? ( media-libs/libsdl )
  58. )
  59. device-mapper? ( >=sys-fs/lvm2-2.02.45 )
  60. libzfs? ( sys-fs/zfs )
  61. mount? ( sys-fs/fuse )
  62. truetype? ( media-libs/freetype:2= )
  63. ppc? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
  64. ppc64? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
  65. "
  66. DEPEND="${RDEPEND}
  67. ${PYTHON_DEPS}
  68. app-misc/pax-utils
  69. sys-devel/flex
  70. sys-devel/bison
  71. sys-apps/help2man
  72. sys-apps/texinfo
  73. fonts? ( media-libs/freetype:2 )
  74. grub_platforms_xen? ( app-emulation/xen-tools:= )
  75. grub_platforms_xen-32? ( app-emulation/xen-tools:= )
  76. static? (
  77. app-arch/xz-utils[static-libs(+)]
  78. truetype? (
  79. app-arch/bzip2[static-libs(+)]
  80. media-libs/freetype[static-libs(+)]
  81. sys-libs/zlib[static-libs(+)]
  82. )
  83. )
  84. test? (
  85. dev-libs/libisoburn
  86. app-emulation/qemu
  87. )
  88. themes? (
  89. app-arch/unzip
  90. media-libs/freetype:2
  91. )
  92. "
  93. RDEPEND+="
  94. kernel_linux? (
  95. grub_platforms_efi-32? ( sys-boot/efibootmgr )
  96. grub_platforms_efi-64? ( sys-boot/efibootmgr )
  97. )
  98. !multislot? ( !sys-boot/grub:0 !sys-boot/grub-static )
  99. nls? ( sys-devel/gettext )
  100. "
  101. DEPEND+=" !!=media-libs/freetype-2.5.4"
  102. RESTRICT="strip !test? ( test )"
  103. QA_EXECSTACK="usr/bin/grub*-emu* usr/lib/grub/*"
  104. QA_WX_LOAD="usr/lib/grub/*"
  105. QA_MULTILIB_PATHS="usr/lib/grub/.*"
  106. src_unpack() {
  107. if [[ ${PV} == 9999 ]]; then
  108. git-r3_src_unpack
  109. fi
  110. default
  111. }
  112. src_prepare() {
  113. default
  114. sed -i -e /autoreconf/d autogen.sh || die
  115. if use multislot; then
  116. # fix texinfo file name, bug 416035
  117. sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die
  118. fi
  119. if [[ -n ${GRUB_AUTOGEN} ]]; then
  120. python_setup
  121. bash autogen.sh || die
  122. autopoint() { :; }
  123. eautoreconf
  124. fi
  125. }
  126. grub_do() {
  127. multibuild_foreach_variant run_in_build_dir "$@"
  128. }
  129. grub_do_once() {
  130. multibuild_for_best_variant run_in_build_dir "$@"
  131. }
  132. grub_configure() {
  133. local platform
  134. case ${MULTIBUILD_VARIANT} in
  135. efi*) platform=efi ;;
  136. xen*) platform=xen ;;
  137. guessed) ;;
  138. *) platform=${MULTIBUILD_VARIANT} ;;
  139. esac
  140. case ${MULTIBUILD_VARIANT} in
  141. *-32)
  142. if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
  143. local CTARGET=i386
  144. fi ;;
  145. *-64)
  146. if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
  147. local CTARGET=x86_64
  148. local -x TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
  149. local -x TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
  150. fi ;;
  151. esac
  152. local myeconfargs=(
  153. --disable-werror
  154. --program-prefix=
  155. --libdir="${EPREFIX}"/usr/lib
  156. --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
  157. $(use_enable debug mm-debug)
  158. $(use_enable device-mapper)
  159. $(use_enable mount grub-mount)
  160. $(use_enable nls)
  161. $(use_enable themes grub-themes)
  162. $(use_enable truetype grub-mkfont)
  163. $(use_enable libzfs)
  164. $(use sdl && use_enable debug grub-emu-sdl)
  165. ${platform:+--with-platform=}${platform}
  166. # Let configure detect this where supported
  167. $(usex efiemu '' '--disable-efiemu')
  168. )
  169. if use multislot; then
  170. myeconfargs+=( --program-transform-name="s,grub,grub2," )
  171. fi
  172. # Set up font symlinks
  173. ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
  174. if use themes; then
  175. ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
  176. fi
  177. local ECONF_SOURCE="${S}"
  178. econf "${myeconfargs[@]}"
  179. }
  180. src_configure() {
  181. # Bug 508758.
  182. replace-flags -O3 -O2
  183. # We don't want to leak flags onto boot code.
  184. export HOST_CCASFLAGS=${CCASFLAGS}
  185. export HOST_CFLAGS=${CFLAGS}
  186. export HOST_CPPFLAGS=${CPPFLAGS}
  187. export HOST_LDFLAGS=${LDFLAGS}
  188. unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
  189. use static && HOST_LDFLAGS+=" -static"
  190. tc-ld-disable-gold #439082 #466536 #526348
  191. export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
  192. unset LDFLAGS
  193. tc-export CC NM OBJCOPY RANLIB STRIP
  194. tc-export BUILD_CC # Bug 485592
  195. MULTIBUILD_VARIANTS=()
  196. local p
  197. for p in "${GRUB_ALL_PLATFORMS[@]}"; do
  198. use "grub_platforms_${p}" && MULTIBUILD_VARIANTS+=( "${p}" )
  199. done
  200. [[ ${#MULTIBUILD_VARIANTS[@]} -eq 0 ]] && MULTIBUILD_VARIANTS=( guessed )
  201. grub_do grub_configure
  202. }
  203. src_compile() {
  204. # Sandbox bug 404013.
  205. use libzfs && addpredict /etc/dfs:/dev/zfs
  206. grub_do emake
  207. use doc && grub_do_once emake -C docs html
  208. }
  209. src_test() {
  210. # The qemu dependency is a bit complex.
  211. # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
  212. grub_do emake check
  213. }
  214. src_install() {
  215. grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
  216. use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
  217. einstalldocs
  218. if use multislot; then
  219. mv "${ED%/}"/usr/share/info/grub{,2}.info || die
  220. fi
  221. insinto /etc/default
  222. newins "${FILESDIR}"/grub.default-3 grub
  223. }
  224. pkg_postinst() {
  225. elog "For information on how to configure GRUB2 please refer to the guide:"
  226. elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
  227. if has_version 'sys-boot/grub:0'; then
  228. elog "A migration guide for GRUB Legacy users is available:"
  229. elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
  230. fi
  231. if [[ -z ${REPLACING_VERSIONS} ]]; then
  232. elog
  233. elog "You may consider installing the following optional packages:"
  234. optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
  235. optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
  236. optfeature "Enable RAID device detection" sys-fs/mdadm
  237. fi
  238. }