| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-9999.ebuild,v 1.59 2012/03/18 06:41:10 floppym Exp $
|
| 4 |
|
| 5 |
EAPI=4
|
| 6 |
|
| 7 |
if [[ ${PV} == "9999" ]] ; then
|
| 8 |
EBZR_REPO_URI="http://bzr.savannah.gnu.org/r/grub/trunk/grub/"
|
| 9 |
LIVE_ECLASS="bzr"
|
| 10 |
SRC_URI=""
|
| 11 |
DO_AUTORECONF="true"
|
| 12 |
else
|
| 13 |
MY_P=${P/_/\~}
|
| 14 |
if [[ ${PV} == *_alpha* || ${PV} == *_beta* ]]; then
|
| 15 |
SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
|
| 16 |
else
|
| 17 |
SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.xz
|
| 18 |
mirror://gentoo/${MY_P}.tar.xz"
|
| 19 |
fi
|
| 20 |
# Masked until documentation guys consolidate the guide and approve
|
| 21 |
# it for usage.
|
| 22 |
#KEYWORDS="~amd64 ~mips ~x86"
|
| 23 |
S=${WORKDIR}/${MY_P}
|
| 24 |
fi
|
| 25 |
|
| 26 |
inherit eutils flag-o-matic pax-utils toolchain-funcs ${DO_AUTORECONF:+autotools} ${LIVE_ECLASS}
|
| 27 |
unset LIVE_ECLASS
|
| 28 |
|
| 29 |
DESCRIPTION="GNU GRUB boot loader"
|
| 30 |
HOMEPAGE="http://www.gnu.org/software/grub/"
|
| 31 |
|
| 32 |
LICENSE="GPL-3"
|
| 33 |
SLOT="2"
|
| 34 |
IUSE="custom-cflags debug device-mapper efiemu mount nls static sdl truetype libzfs"
|
| 35 |
|
| 36 |
GRUB_PLATFORMS=(
|
| 37 |
# everywhere:
|
| 38 |
emu
|
| 39 |
# mips only:
|
| 40 |
qemu-mips yeeloong
|
| 41 |
# amd64, x86, ppc, ppc64:
|
| 42 |
ieee1275
|
| 43 |
# amd64, x86:
|
| 44 |
coreboot multiboot efi-32 pc qemu
|
| 45 |
# amd64, ia64:
|
| 46 |
efi-64
|
| 47 |
)
|
| 48 |
IUSE+=" ${GRUB_PLATFORMS[@]/#/grub_platforms_}"
|
| 49 |
|
| 50 |
# os-prober: Used on runtime to detect other OSes
|
| 51 |
# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
|
| 52 |
RDEPEND="
|
| 53 |
dev-libs/libisoburn
|
| 54 |
dev-libs/lzo
|
| 55 |
sys-boot/os-prober
|
| 56 |
>=sys-libs/ncurses-5.2-r5
|
| 57 |
debug? (
|
| 58 |
sdl? ( media-libs/libsdl )
|
| 59 |
)
|
| 60 |
device-mapper? ( >=sys-fs/lvm2-2.02.45 )
|
| 61 |
libzfs? ( sys-fs/zfs )
|
| 62 |
mount? ( sys-fs/fuse )
|
| 63 |
truetype? ( media-libs/freetype >=media-fonts/unifont-5 )"
|
| 64 |
DEPEND="${RDEPEND}
|
| 65 |
>=dev-lang/python-2.5.2
|
| 66 |
sys-devel/flex
|
| 67 |
virtual/yacc
|
| 68 |
sys-apps/texinfo
|
| 69 |
"
|
| 70 |
RDEPEND+="
|
| 71 |
grub_platforms_efi-32? ( sys-boot/efibootmgr )
|
| 72 |
grub_platforms_efi-64? ( sys-boot/efibootmgr )
|
| 73 |
"
|
| 74 |
if [[ -n ${DO_AUTORECONF} ]] ; then
|
| 75 |
DEPEND+=" >=sys-devel/autogen-5.10 sys-apps/help2man"
|
| 76 |
else
|
| 77 |
DEPEND+=" app-arch/xz-utils"
|
| 78 |
fi
|
| 79 |
|
| 80 |
export STRIP_MASK="*/grub/*/*.{mod,img}"
|
| 81 |
|
| 82 |
QA_EXECSTACK="
|
| 83 |
usr/bin/grub*
|
| 84 |
usr/sbin/grub*
|
| 85 |
usr/lib*/grub/*/*.mod
|
| 86 |
usr/lib*/grub/*/kernel.exec
|
| 87 |
usr/lib*/grub/*/kernel.img
|
| 88 |
usr/lib*/grub/*/setjmp.module
|
| 89 |
"
|
| 90 |
|
| 91 |
QA_WX_LOAD="
|
| 92 |
usr/lib*/grub/*/kernel.exec
|
| 93 |
usr/lib*/grub/*/kernel.img
|
| 94 |
usr/lib*/grub/*/*.image
|
| 95 |
"
|
| 96 |
|
| 97 |
QA_PRESTRIPPED="
|
| 98 |
usr/lib.*/grub/.*/kernel.img
|
| 99 |
"
|
| 100 |
|
| 101 |
grub_run_phase() {
|
| 102 |
local phase=$1
|
| 103 |
local platform=$2
|
| 104 |
[[ -z ${phase} || -z ${platform} ]] && die "${FUNCNAME} [phase] [platform]"
|
| 105 |
|
| 106 |
[[ -d "${WORKDIR}/build-${platform}" ]] || \
|
| 107 |
{ mkdir "${WORKDIR}/build-${platform}" || die ; }
|
| 108 |
pushd "${WORKDIR}/build-${platform}" > /dev/null || die
|
| 109 |
|
| 110 |
echo ">>> Running ${phase} for platform \"${platform}\""
|
| 111 |
echo ">>> Working in: \"${WORKDIR}/build-${platform}\""
|
| 112 |
|
| 113 |
grub_${phase} ${platform}
|
| 114 |
|
| 115 |
popd > /dev/null || die
|
| 116 |
}
|
| 117 |
|
| 118 |
grub_src_configure() {
|
| 119 |
local platform=$1
|
| 120 |
local with_platform=
|
| 121 |
|
| 122 |
[[ -z ${platform} ]] && die "${FUNCNAME} [platform]"
|
| 123 |
|
| 124 |
# Used below for efi cross-building
|
| 125 |
tc-export CC NM OBJCOPY STRIP
|
| 126 |
|
| 127 |
estack_push CTARGET "${CTARGET}"
|
| 128 |
estack_push TARGET_CC "${TARGET_CC}"
|
| 129 |
estack_push TARGET_CFLAGS "${TARGET_CFLAGS}"
|
| 130 |
estack_push TARGET_CPPFLAGS "${TARGET_CPPFLAGS}"
|
| 131 |
|
| 132 |
case ${platform} in
|
| 133 |
efi-32)
|
| 134 |
if [[ ${CHOST} == x86_64* ]]; then
|
| 135 |
CTARGET="${CTARGET:-i386}"
|
| 136 |
TARGET_CC="${TARGET_CC:-${CC}}"
|
| 137 |
export TARGET_CC
|
| 138 |
fi
|
| 139 |
with_platform="--with-platform=efi"
|
| 140 |
;;
|
| 141 |
efi-64)
|
| 142 |
if [[ ${CHOST} == i?86* ]]; then
|
| 143 |
CTARGET="${CTARGET:-x86_64}"
|
| 144 |
TARGET_CC="${TARGET_CC:-${CC}}"
|
| 145 |
TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
|
| 146 |
TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
|
| 147 |
export TARGET_CC TARGET_CFLAGS TARGET_CPPFLAGS
|
| 148 |
fi
|
| 149 |
with_platform="--with-platform=efi"
|
| 150 |
;;
|
| 151 |
guessed) ;;
|
| 152 |
*) with_platform="--with-platform=${platform}" ;;
|
| 153 |
esac
|
| 154 |
|
| 155 |
ECONF_SOURCE="${S}" \
|
| 156 |
econf \
|
| 157 |
--disable-werror \
|
| 158 |
--program-prefix= \
|
| 159 |
--program-transform-name="s,grub,grub2," \
|
| 160 |
--with-grubdir=grub2 \
|
| 161 |
${with_platform} \
|
| 162 |
$(use_enable debug mm-debug) \
|
| 163 |
$(use_enable debug grub-emu-usb) \
|
| 164 |
$(use_enable device-mapper) \
|
| 165 |
$(use_enable efiemu) \
|
| 166 |
$(use_enable mount grub-mount) \
|
| 167 |
$(use_enable nls) \
|
| 168 |
$(use_enable truetype grub-mkfont) \
|
| 169 |
$(use_enable libzfs) \
|
| 170 |
$(use sdl && use_enable debug grub-emu-sdl)
|
| 171 |
|
| 172 |
estack_pop CTARGET CTARGET || die
|
| 173 |
estack_pop TARGET_CC TARGET_CC || die
|
| 174 |
estack_pop TARGET_CFLAGS TARGET_CFLAGS || die
|
| 175 |
estack_pop TARGET_CPPFLAGS TARGET_CPPFLAGS || die
|
| 176 |
}
|
| 177 |
|
| 178 |
grub_src_compile() {
|
| 179 |
default_src_compile
|
| 180 |
pax-mark -mpes "${grub_binaries[@]}"
|
| 181 |
}
|
| 182 |
|
| 183 |
grub_src_install() {
|
| 184 |
default_src_install
|
| 185 |
}
|
| 186 |
|
| 187 |
src_prepare() {
|
| 188 |
local i j
|
| 189 |
|
| 190 |
epatch_user
|
| 191 |
|
| 192 |
# autogen.sh does more than just run autotools
|
| 193 |
if [[ -n ${DO_AUTORECONF} ]] ; then
|
| 194 |
sed -i -e '/^autoreconf/s:^:set +e; e:' autogen.sh || die
|
| 195 |
(. ./autogen.sh) || die
|
| 196 |
fi
|
| 197 |
|
| 198 |
# install into the right dir for eselect #372735
|
| 199 |
sed -i \
|
| 200 |
-e '/^bashcompletiondir =/s:=.*:= $(datarootdir)/bash-completion:' \
|
| 201 |
util/bash-completion.d/Makefile.in || die
|
| 202 |
|
| 203 |
# get enabled platforms
|
| 204 |
GRUB_ENABLED_PLATFORMS=""
|
| 205 |
for i in ${GRUB_PLATFORMS[@]}; do
|
| 206 |
use grub_platforms_${i} && GRUB_ENABLED_PLATFORMS+=" ${i}"
|
| 207 |
done
|
| 208 |
[[ -z ${GRUB_ENABLED_PLATFORMS} ]] && GRUB_ENABLED_PLATFORMS="guessed"
|
| 209 |
elog "Going to build following platforms: ${GRUB_ENABLED_PLATFORMS}"
|
| 210 |
}
|
| 211 |
|
| 212 |
src_configure() {
|
| 213 |
local i
|
| 214 |
|
| 215 |
use custom-cflags || unset CFLAGS CPPFLAGS LDFLAGS
|
| 216 |
use libzfs && addpredict /etc/dfs
|
| 217 |
use static && append-ldflags -static
|
| 218 |
|
| 219 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 220 |
grub_run_phase ${FUNCNAME} ${i}
|
| 221 |
done
|
| 222 |
}
|
| 223 |
|
| 224 |
src_compile() {
|
| 225 |
# Used for pax marking in grub_src_compile
|
| 226 |
local grub_binaries=(
|
| 227 |
grub-editenv
|
| 228 |
grub-fstest
|
| 229 |
grub-menulst2cfg
|
| 230 |
grub-mkimage
|
| 231 |
grub-mklayout
|
| 232 |
grub-mkpasswd-pbkdf2
|
| 233 |
grub-mkrelpath
|
| 234 |
grub-script-check
|
| 235 |
grub-bios-setup
|
| 236 |
grub-ofpathname
|
| 237 |
grub-probe
|
| 238 |
grub-sparc64-setup
|
| 239 |
)
|
| 240 |
use mount && grub_binaries+=( grub-mount )
|
| 241 |
use truetype && grub_binaries+=( grub-mkfont )
|
| 242 |
|
| 243 |
local i
|
| 244 |
|
| 245 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 246 |
grub_run_phase ${FUNCNAME} ${i}
|
| 247 |
done
|
| 248 |
}
|
| 249 |
|
| 250 |
src_install() {
|
| 251 |
local i
|
| 252 |
|
| 253 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 254 |
grub_run_phase ${FUNCNAME} ${i}
|
| 255 |
done
|
| 256 |
|
| 257 |
mv "${ED}"usr/share/info/grub{,2}.info || die
|
| 258 |
|
| 259 |
# can't be in docs array as we use default_src_install in different builddir
|
| 260 |
dodoc AUTHORS ChangeLog NEWS README THANKS TODO
|
| 261 |
insinto /etc/default
|
| 262 |
newins "${FILESDIR}"/grub.default grub
|
| 263 |
}
|
| 264 |
|
| 265 |
pkg_postinst() {
|
| 266 |
# display the link to guide
|
| 267 |
elog "For information on how to configure grub-2 please refer to the guide:"
|
| 268 |
elog " http://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
|
| 269 |
}
|