| 1 |
# Copyright 1999-2011 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.44 2011/10/04 18:23:19 scarabeus 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 |
SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.xz
|
| 15 |
mirror://gentoo/${MY_P}.tar.xz"
|
| 16 |
S=${WORKDIR}/${MY_P}
|
| 17 |
fi
|
| 18 |
|
| 19 |
inherit mount-boot eutils flag-o-matic pax-utils toolchain-funcs ${DO_AUTORECONF:+autotools} ${LIVE_ECLASS}
|
| 20 |
unset LIVE_ECLASS
|
| 21 |
|
| 22 |
DESCRIPTION="GNU GRUB boot loader"
|
| 23 |
HOMEPAGE="http://www.gnu.org/software/grub/"
|
| 24 |
|
| 25 |
LICENSE="GPL-3"
|
| 26 |
SLOT="2"
|
| 27 |
[[ ${PV} != "9999" ]] && KEYWORDS="~amd64 ~mips ~x86"
|
| 28 |
IUSE="custom-cflags debug device-mapper efiemu nls static sdl truetype"
|
| 29 |
|
| 30 |
GRUB_PLATFORMS="coreboot efi-32 efi-64 emu ieee1275 multiboot pc qemu qemu-mips loongson"
|
| 31 |
# everywhere:
|
| 32 |
# emu
|
| 33 |
# mips only:
|
| 34 |
# qemu-mips, loongson
|
| 35 |
# amd64, x86, ppc, ppc64
|
| 36 |
# ieee1275
|
| 37 |
# amd64, x86
|
| 38 |
# coreboot, multiboot, efi-32, pc, qemu
|
| 39 |
# amd64
|
| 40 |
# efi-64
|
| 41 |
for i in ${GRUB_PLATFORMS}; do
|
| 42 |
IUSE+=" grub_platforms_${i}"
|
| 43 |
done
|
| 44 |
unset i
|
| 45 |
|
| 46 |
# os-prober: Used on runtime to detect other OSes
|
| 47 |
# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
|
| 48 |
RDEPEND="
|
| 49 |
dev-libs/libisoburn
|
| 50 |
dev-libs/lzo
|
| 51 |
sys-boot/os-prober
|
| 52 |
>=sys-libs/ncurses-5.2-r5
|
| 53 |
debug? (
|
| 54 |
sdl? ( media-libs/libsdl )
|
| 55 |
)
|
| 56 |
device-mapper? ( >=sys-fs/lvm2-2.02.45 )
|
| 57 |
truetype? ( media-libs/freetype >=media-fonts/unifont-5 )"
|
| 58 |
DEPEND="${RDEPEND}
|
| 59 |
>=dev-lang/python-2.5.2
|
| 60 |
sys-devel/flex
|
| 61 |
virtual/yacc
|
| 62 |
sys-apps/texinfo
|
| 63 |
"
|
| 64 |
if [[ -n ${DO_AUTORECONF} ]] ; then
|
| 65 |
DEPEND+=" >=sys-devel/autogen-5.10 sys-apps/help2man"
|
| 66 |
else
|
| 67 |
DEPEND+=" app-arch/xz-utils"
|
| 68 |
fi
|
| 69 |
|
| 70 |
export STRIP_MASK="*/grub*/*/*.{mod,img}"
|
| 71 |
QA_EXECSTACK="
|
| 72 |
lib64/grub2/*/setjmp.mod
|
| 73 |
lib64/grub2/*/kernel.img
|
| 74 |
sbin/grub2-probe
|
| 75 |
sbin/grub2-setup
|
| 76 |
sbin/grub2-mkdevicemap
|
| 77 |
bin/grub2-script-check
|
| 78 |
bin/grub2-fstest
|
| 79 |
bin/grub2-mklayout
|
| 80 |
bin/grub2-menulst2cfg
|
| 81 |
bin/grub2-mkrelpath
|
| 82 |
bin/grub2-mkpasswd-pbkdf2
|
| 83 |
bin/grub2-mkfont
|
| 84 |
bin/grub2-editenv
|
| 85 |
bin/grub2-mkimage
|
| 86 |
"
|
| 87 |
|
| 88 |
QA_WX_LOAD="
|
| 89 |
lib*/grub2/*/kernel.img
|
| 90 |
lib*/grub2/*/setjmp.mod
|
| 91 |
"
|
| 92 |
|
| 93 |
grub_run_phase() {
|
| 94 |
local phase=$1
|
| 95 |
local platform=$2
|
| 96 |
[[ -z ${phase} || -z ${platform} ]] && die "${FUNCNAME} [phase] [platform]"
|
| 97 |
|
| 98 |
[[ -d "${WORKDIR}/build-${platform}" ]] || \
|
| 99 |
{ mkdir "${WORKDIR}/build-${platform}" || die ; }
|
| 100 |
pushd "${WORKDIR}/build-${platform}" > /dev/null || die
|
| 101 |
|
| 102 |
echo ">>> Running ${phase} for platform \"${platform}\""
|
| 103 |
echo ">>> Working in: \"${WORKDIR}/build-${platform}\""
|
| 104 |
|
| 105 |
grub_${phase} ${platform}
|
| 106 |
|
| 107 |
popd > /dev/null || die
|
| 108 |
}
|
| 109 |
|
| 110 |
grub_src_configure() {
|
| 111 |
local platform=$1
|
| 112 |
local target
|
| 113 |
|
| 114 |
[[ -z ${platform} ]] && die "${FUNCNAME} [platform]"
|
| 115 |
|
| 116 |
# if we have no platform then --with-platform=guessed does not work
|
| 117 |
[[ ${platform} == "guessed" ]] && platform=""
|
| 118 |
|
| 119 |
# check if we have to specify the target (EFI)
|
| 120 |
# or just append correct --with-platform
|
| 121 |
if [[ -n ${platform} ]]; then
|
| 122 |
if [[ ${platform} == efi* ]]; then
|
| 123 |
# EFI platform hack
|
| 124 |
[[ ${platform/*-} == 32 ]] && target=i386
|
| 125 |
[[ ${platform/*-} == 64 ]] && target=x86_64
|
| 126 |
# program-prefix is required empty because otherwise it is equal to
|
| 127 |
# target variable, which we do not want at all
|
| 128 |
platform="
|
| 129 |
--with-platform=${platform/-*}
|
| 130 |
--target=${target}
|
| 131 |
--program-prefix=
|
| 132 |
"
|
| 133 |
else
|
| 134 |
platform=" --with-platform=${platform}"
|
| 135 |
fi
|
| 136 |
fi
|
| 137 |
|
| 138 |
ECONF_SOURCE="${WORKDIR}/${P}/" \
|
| 139 |
econf \
|
| 140 |
--disable-werror \
|
| 141 |
--sbindir=/sbin \
|
| 142 |
--bindir=/bin \
|
| 143 |
--libdir=/$(get_libdir) \
|
| 144 |
--program-transform-name=s,grub,grub2, \
|
| 145 |
$(use_enable debug mm-debug) \
|
| 146 |
$(use_enable debug grub-emu-usb) \
|
| 147 |
$(use_enable device-mapper) \
|
| 148 |
$(use_enable efiemu) \
|
| 149 |
$(use_enable nls) \
|
| 150 |
$(use_enable truetype grub-mkfont) \
|
| 151 |
$(use sdl && use_enable debug grub-emu-sdl) \
|
| 152 |
${platform}
|
| 153 |
}
|
| 154 |
|
| 155 |
grub_src_compile() {
|
| 156 |
default_src_compile
|
| 157 |
}
|
| 158 |
|
| 159 |
grub_src_install() {
|
| 160 |
default_src_install
|
| 161 |
}
|
| 162 |
|
| 163 |
src_prepare() {
|
| 164 |
local i j archs
|
| 165 |
|
| 166 |
epatch \
|
| 167 |
"${FILESDIR}/1.99-call_proper_grub_probe.patch"
|
| 168 |
|
| 169 |
epatch_user
|
| 170 |
|
| 171 |
# fix texinfo file name, as otherwise the grub2.info file will be
|
| 172 |
# useless
|
| 173 |
sed -i \
|
| 174 |
-e '/setfilename/s:grub.info:grub2.info:' \
|
| 175 |
-e 's:(grub):(grub2):' \
|
| 176 |
"${S}"/docs/grub.texi
|
| 177 |
|
| 178 |
# autogen.sh does more than just run autotools
|
| 179 |
if [[ -n ${DO_AUTORECONF} ]] ; then
|
| 180 |
sed -i -e '/^autoreconf/s:^:set +e; e:' autogen.sh || die
|
| 181 |
(. ./autogen.sh) || die
|
| 182 |
fi
|
| 183 |
|
| 184 |
# install into the right dir for eselect #372735
|
| 185 |
sed -i \
|
| 186 |
-e '/^bashcompletiondir =/s:=.*:= $(datarootdir)/bash-completion:' \
|
| 187 |
util/bash-completion.d/Makefile.in || die
|
| 188 |
|
| 189 |
# get enabled platforms
|
| 190 |
GRUB_ENABLED_PLATFORMS=""
|
| 191 |
for i in ${GRUB_PLATFORMS}; do
|
| 192 |
use grub_platforms_${i} && GRUB_ENABLED_PLATFORMS+=" ${i}"
|
| 193 |
done
|
| 194 |
[[ -z ${GRUB_ENABLED_PLATFORMS} ]] && GRUB_ENABLED_PLATFORMS="guessed"
|
| 195 |
elog "Going to build following platforms: ${GRUB_ENABLED_PLATFORMS}"
|
| 196 |
}
|
| 197 |
|
| 198 |
src_configure() {
|
| 199 |
local i
|
| 200 |
|
| 201 |
use custom-cflags || unset CFLAGS CPPFLAGS LDFLAGS
|
| 202 |
use static && append-ldflags -static
|
| 203 |
|
| 204 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 205 |
grub_run_phase ${FUNCNAME} ${i}
|
| 206 |
done
|
| 207 |
}
|
| 208 |
|
| 209 |
src_compile() {
|
| 210 |
local i
|
| 211 |
|
| 212 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 213 |
grub_run_phase ${FUNCNAME} ${i}
|
| 214 |
done
|
| 215 |
}
|
| 216 |
|
| 217 |
src_install() {
|
| 218 |
local i
|
| 219 |
|
| 220 |
for i in ${GRUB_ENABLED_PLATFORMS}; do
|
| 221 |
grub_run_phase ${FUNCNAME} ${i}
|
| 222 |
done
|
| 223 |
|
| 224 |
# slot all collisions with grub legacy
|
| 225 |
mv "${ED}"/usr/share/info/grub.info \
|
| 226 |
"${ED}"/usr/share/info/grub2.info || die
|
| 227 |
|
| 228 |
# Do pax marking
|
| 229 |
local PAX=(
|
| 230 |
"sbin/grub2-probe"
|
| 231 |
"sbin/grub2-setup"
|
| 232 |
"sbin/grub2-mkdevicemap"
|
| 233 |
"bin/grub2-script-check"
|
| 234 |
"bin/grub2-fstest"
|
| 235 |
"bin/grub2-mklayout"
|
| 236 |
"bin/grub2-menulst2cfg"
|
| 237 |
"bin/grub2-mkrelpath"
|
| 238 |
"bin/grub2-mkpasswd-pbkdf2"
|
| 239 |
"bin/grub2-editenv"
|
| 240 |
"bin/grub2-mkimage"
|
| 241 |
)
|
| 242 |
for e in ${PAX[@]}; do
|
| 243 |
pax-mark -mp "${ED}/${e}"
|
| 244 |
done
|
| 245 |
|
| 246 |
# can't be in docs array as we use default_src_install in different builddir
|
| 247 |
dodoc AUTHORS ChangeLog NEWS README THANKS TODO
|
| 248 |
insinto /etc/default
|
| 249 |
newins "${FILESDIR}"/grub.default grub
|
| 250 |
cat <<EOF >> "${ED}"/lib*/grub2/grub-mkconfig_lib
|
| 251 |
GRUB_DISTRIBUTOR="Gentoo"
|
| 252 |
EOF
|
| 253 |
|
| 254 |
elog
|
| 255 |
elog "To configure GRUB 2, check the defaults in /etc/default/grub and"
|
| 256 |
elog "then run 'emerge --config =${CATEGORY}/${PF}'."
|
| 257 |
|
| 258 |
# display the link to guide
|
| 259 |
show_doc_url
|
| 260 |
}
|
| 261 |
|
| 262 |
show_doc_url() {
|
| 263 |
elog
|
| 264 |
elog "For informations how to configure grub-2 please refer to the guide:"
|
| 265 |
elog " http://dev.gentoo.org/~scarabeus/grub-2-guide.xml"
|
| 266 |
}
|
| 267 |
|
| 268 |
setup_boot_dir() {
|
| 269 |
local dir=$1
|
| 270 |
local use_legacy='n'
|
| 271 |
|
| 272 |
# Make sure target directory exists
|
| 273 |
mkdir -p "${dir}"
|
| 274 |
|
| 275 |
if [[ -e ${dir/2/}/menu.lst ]] ; then
|
| 276 |
# Legacy config exists, ask user what to do
|
| 277 |
einfo "Found legacy GRUB configuration. Do you want to convert it"
|
| 278 |
einfo "instead of using autoconfig (y/N)?"
|
| 279 |
read use_legacy
|
| 280 |
|
| 281 |
use_legacy=${use_legacy,,[A-Z]}
|
| 282 |
fi
|
| 283 |
|
| 284 |
if [[ ${use_legacy} == y* ]] ; then
|
| 285 |
grub1_cfg=${dir/2/}/menu.lst
|
| 286 |
grub2_cfg=${dir}/grub.cfg
|
| 287 |
|
| 288 |
# GRUB legacy configuration exists. Use it instead of doing
|
| 289 |
# our normal autoconfigure.
|
| 290 |
#
|
| 291 |
|
| 292 |
einfo "Converting legacy config at '${grub1_cfg}' for use by GRUB2."
|
| 293 |
ebegin "Running: grub2-menulst2cfg '${grub1_cfg}' '${grub2_cfg}'"
|
| 294 |
grub2-menulst2cfg "${grub1_cfg}" "${grub2_cfg}" &> /dev/null
|
| 295 |
eend $?
|
| 296 |
|
| 297 |
ewarn
|
| 298 |
ewarn "Even though the conversion above succeeded, you are STRONGLY"
|
| 299 |
ewarn "URGED to upgrade to the new GRUB2 configuration format."
|
| 300 |
|
| 301 |
# Remind the user about the documentation
|
| 302 |
show_doc_url
|
| 303 |
else
|
| 304 |
# Run GRUB 2 autoconfiguration
|
| 305 |
einfo "Running GRUB 2 autoconfiguration."
|
| 306 |
ebegin "grub2-mkconfig -o '${dir}/grub.cfg'"
|
| 307 |
grub2-mkconfig -o "${dir}/grub.cfg" &> /dev/null
|
| 308 |
eend $?
|
| 309 |
fi
|
| 310 |
|
| 311 |
einfo
|
| 312 |
einfo "Remember to run grub2-install to activate GRUB2 as your default"
|
| 313 |
einfo "bootloader."
|
| 314 |
}
|
| 315 |
|
| 316 |
pkg_config() {
|
| 317 |
local dir
|
| 318 |
|
| 319 |
mount-boot_mount_boot_partition
|
| 320 |
|
| 321 |
einfo "Enter the directory where you want to setup grub2 ('${ROOT}boot/grub2/'):"
|
| 322 |
read dir
|
| 323 |
|
| 324 |
[[ -z ${dir} ]] && dir="${ROOT}"boot/grub2
|
| 325 |
|
| 326 |
setup_boot_dir "${dir}"
|
| 327 |
|
| 328 |
mount-boot_pkg_postinst
|
| 329 |
}
|