/[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.48 - (show annotations) (download)
Sun Jan 15 02:19:54 2012 UTC (2 years, 3 months ago) by floppym
Branch: MAIN
Changes since 1.47: +2 -5 lines
1.99-call_proper_grub_probe.patch has been applied upstream.

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

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.47 2011/11/18 00:04:29 vapier 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 # Masked until documentation guys consolidate the guide and approve
17 # it for usage.
18 #KEYWORDS="~amd64 ~mips ~x86"
19 S=${WORKDIR}/${MY_P}
20 fi
21
22 inherit mount-boot eutils flag-o-matic pax-utils toolchain-funcs ${DO_AUTORECONF:+autotools} ${LIVE_ECLASS}
23 unset LIVE_ECLASS
24
25 DESCRIPTION="GNU GRUB boot loader"
26 HOMEPAGE="http://www.gnu.org/software/grub/"
27
28 LICENSE="GPL-3"
29 SLOT="2"
30 IUSE="custom-cflags debug device-mapper efiemu nls static sdl truetype"
31
32 GRUB_PLATFORMS=(
33 # everywhere:
34 emu
35 # mips only:
36 qemu-mips yeeloong
37 # amd64, x86, ppc, ppc64:
38 ieee1275
39 # amd64, x86:
40 coreboot multiboot efi-32 pc qemu
41 # amd64:
42 efi-64
43 )
44 IUSE+=" ${GRUB_PLATFORMS[@]/#/grub_platforms_}"
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_user
167
168 # fix texinfo file name, as otherwise the grub2.info file will be
169 # useless
170 sed -i \
171 -e '/setfilename/s:grub.info:grub2.info:' \
172 -e 's:(grub):(grub2):' \
173 "${S}"/docs/grub.texi
174
175 # autogen.sh does more than just run autotools
176 if [[ -n ${DO_AUTORECONF} ]] ; then
177 sed -i -e '/^autoreconf/s:^:set +e; e:' autogen.sh || die
178 (. ./autogen.sh) || die
179 fi
180
181 # install into the right dir for eselect #372735
182 sed -i \
183 -e '/^bashcompletiondir =/s:=.*:= $(datarootdir)/bash-completion:' \
184 util/bash-completion.d/Makefile.in || die
185
186 # get enabled platforms
187 GRUB_ENABLED_PLATFORMS=""
188 for i in ${GRUB_PLATFORMS[@]}; do
189 use grub_platforms_${i} && GRUB_ENABLED_PLATFORMS+=" ${i}"
190 done
191 [[ -z ${GRUB_ENABLED_PLATFORMS} ]] && GRUB_ENABLED_PLATFORMS="guessed"
192 elog "Going to build following platforms: ${GRUB_ENABLED_PLATFORMS}"
193 }
194
195 src_configure() {
196 local i
197
198 use custom-cflags || unset CFLAGS CPPFLAGS LDFLAGS
199 use static && append-ldflags -static
200
201 for i in ${GRUB_ENABLED_PLATFORMS}; do
202 grub_run_phase ${FUNCNAME} ${i}
203 done
204 }
205
206 src_compile() {
207 local i
208
209 for i in ${GRUB_ENABLED_PLATFORMS}; do
210 grub_run_phase ${FUNCNAME} ${i}
211 done
212 }
213
214 src_install() {
215 local i
216
217 for i in ${GRUB_ENABLED_PLATFORMS}; do
218 grub_run_phase ${FUNCNAME} ${i}
219 done
220
221 # No need to move the info file with the live ebuild since we
222 # already changed the generated file name during the preparation
223 # phase.
224 if [[ ${PV} != "9999" ]]; then
225 # slot all collisions with grub legacy
226 mv "${ED}"/usr/share/info/grub.info \
227 "${ED}"/usr/share/info/grub2.info || die
228 fi
229
230 # Do pax marking
231 local PAX=(
232 "sbin/grub2-probe"
233 "sbin/grub2-setup"
234 "sbin/grub2-mkdevicemap"
235 "bin/grub2-script-check"
236 "bin/grub2-fstest"
237 "bin/grub2-mklayout"
238 "bin/grub2-menulst2cfg"
239 "bin/grub2-mkrelpath"
240 "bin/grub2-mkpasswd-pbkdf2"
241 "bin/grub2-editenv"
242 "bin/grub2-mkimage"
243 )
244 for e in ${PAX[@]}; do
245 pax-mark -mp "${ED}/${e}"
246 done
247
248 # can't be in docs array as we use default_src_install in different builddir
249 dodoc AUTHORS ChangeLog NEWS README THANKS TODO
250 insinto /etc/default
251 newins "${FILESDIR}"/grub.default grub
252 cat <<EOF >> "${ED}"/lib*/grub2/grub-mkconfig_lib
253 GRUB_DISTRIBUTOR="Gentoo"
254 EOF
255
256 elog
257 elog "To configure GRUB 2, check the defaults in /etc/default/grub and"
258 elog "then run 'emerge --config =${CATEGORY}/${PF}'."
259
260 # display the link to guide
261 show_doc_url
262 }
263
264 show_doc_url() {
265 elog
266 elog "For informations how to configure grub-2 please refer to the guide:"
267 elog " http://dev.gentoo.org/~scarabeus/grub-2-guide.xml"
268 }
269
270 setup_boot_dir() {
271 local dir=$1
272 local use_legacy='n'
273
274 # Make sure target directory exists
275 mkdir -p "${dir}"
276
277 if [[ -e ${dir/2/}/menu.lst ]] ; then
278 # Legacy config exists, ask user what to do
279 einfo "Found legacy GRUB configuration. Do you want to convert it"
280 einfo "instead of using autoconfig (y/N)?"
281 read use_legacy
282
283 use_legacy=${use_legacy,,[A-Z]}
284 fi
285
286 if [[ ${use_legacy} == y* ]] ; then
287 grub1_cfg=${dir/2/}/menu.lst
288 grub2_cfg=${dir}/grub.cfg
289
290 # GRUB legacy configuration exists. Use it instead of doing
291 # our normal autoconfigure.
292 #
293
294 einfo "Converting legacy config at '${grub1_cfg}' for use by GRUB2."
295 ebegin "Running: grub2-menulst2cfg '${grub1_cfg}' '${grub2_cfg}'"
296 grub2-menulst2cfg "${grub1_cfg}" "${grub2_cfg}" &> /dev/null
297 eend $?
298
299 ewarn
300 ewarn "Even though the conversion above succeeded, you are STRONGLY"
301 ewarn "URGED to upgrade to the new GRUB2 configuration format."
302
303 # Remind the user about the documentation
304 show_doc_url
305 else
306 # Run GRUB 2 autoconfiguration
307 einfo "Running GRUB 2 autoconfiguration."
308 ebegin "grub2-mkconfig -o '${dir}/grub.cfg'"
309 grub2-mkconfig -o "${dir}/grub.cfg" &> /dev/null
310 eend $?
311 fi
312
313 einfo
314 einfo "Remember to run grub2-install to activate GRUB2 as your default"
315 einfo "bootloader."
316 }
317
318 pkg_config() {
319 local dir
320
321 mount-boot_mount_boot_partition
322
323 einfo "Enter the directory where you want to setup grub2 ('${ROOT}boot/grub2/'):"
324 read dir
325
326 [[ -z ${dir} ]] && dir="${ROOT}"boot/grub2
327
328 setup_boot_dir "${dir}"
329
330 mount-boot_pkg_postinst
331 }

  ViewVC Help
Powered by ViewVC 1.1.20