/[gentoo-x86]/sys-boot/grub/grub-9999.ebuild
Gentoo

Contents of /sys-boot/grub/grub-9999.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.44 - (show annotations) (download)
Tue Oct 4 18:23:19 2011 UTC (2 years, 10 months ago) by scarabeus
Branch: MAIN
Changes since 1.43: +50 -27 lines
Include option to prompt for grub1 configuration. Thanks to Robert Trace rtrace{at}farcaster.org for the patch.

(Portage version: 2.2.0_alpha60/cvs/Linux x86_64)

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

  ViewVC Help
Powered by ViewVC 1.1.20