/[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 - (hide annotations) (download)
Sun Jan 15 02:19:54 2012 UTC (2 years, 11 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 floppym 1.48 # Copyright 1999-2012 Gentoo Foundation
2 vapier 1.1 # Distributed under the terms of the GNU General Public License v2
3 floppym 1.48 # $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-9999.ebuild,v 1.47 2011/11/18 00:04:29 vapier Exp $
4 vapier 1.21
5 scarabeus 1.37 EAPI=4
6 vapier 1.1
7     if [[ ${PV} == "9999" ]] ; then
8 vapier 1.29 EBZR_REPO_URI="http://bzr.savannah.gnu.org/r/grub/trunk/grub/"
9 flameeyes 1.45 LIVE_ECLASS="bzr"
10 vapier 1.2 SRC_URI=""
11 flameeyes 1.45 DO_AUTORECONF="true"
12 vapier 1.2 else
13 scarabeus 1.37 MY_P=${P/_/\~}
14     SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.xz
15     mirror://gentoo/${MY_P}.tar.xz"
16 vapier 1.47 # Masked until documentation guys consolidate the guide and approve
17     # it for usage.
18     #KEYWORDS="~amd64 ~mips ~x86"
19 scarabeus 1.37 S=${WORKDIR}/${MY_P}
20 vapier 1.1 fi
21    
22 flameeyes 1.45 inherit mount-boot eutils flag-o-matic pax-utils toolchain-funcs ${DO_AUTORECONF:+autotools} ${LIVE_ECLASS}
23 scarabeus 1.37 unset LIVE_ECLASS
24    
25 vapier 1.32 DESCRIPTION="GNU GRUB boot loader"
26 vapier 1.1 HOMEPAGE="http://www.gnu.org/software/grub/"
27    
28 vapier 1.4 LICENSE="GPL-3"
29 scarabeus 1.37 SLOT="2"
30 scarabeus 1.38 IUSE="custom-cflags debug device-mapper efiemu nls static sdl truetype"
31 scarabeus 1.37
32 vapier 1.47 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 scarabeus 1.37
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 vapier 1.18 dev-libs/lzo
51 scarabeus 1.37 sys-boot/os-prober
52     >=sys-libs/ncurses-5.2-r5
53 vapier 1.32 debug? (
54     sdl? ( media-libs/libsdl )
55     )
56     device-mapper? ( >=sys-fs/lvm2-2.02.45 )
57 vapier 1.24 truetype? ( media-libs/freetype >=media-fonts/unifont-5 )"
58 vapier 1.9 DEPEND="${RDEPEND}
59 mattst88 1.35 >=dev-lang/python-2.5.2
60 scarabeus 1.37 sys-devel/flex
61 vapier 1.36 virtual/yacc
62 flameeyes 1.45 sys-apps/texinfo
63 scarabeus 1.37 "
64 flameeyes 1.45 if [[ -n ${DO_AUTORECONF} ]] ; then
65 scarabeus 1.37 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 scarabeus 1.41 QA_WX_LOAD="
89     lib*/grub2/*/kernel.img
90     lib*/grub2/*/setjmp.mod
91     "
92    
93 scarabeus 1.37 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 vapier 1.1
105 scarabeus 1.37 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 scarabeus 1.38 $(use_enable debug mm-debug) \
146     $(use_enable debug grub-emu-usb) \
147 scarabeus 1.37 $(use_enable device-mapper) \
148 scarabeus 1.38 $(use_enable efiemu) \
149     $(use_enable nls) \
150 scarabeus 1.37 $(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 vapier 1.1
163 vapier 1.33 src_prepare() {
164 scarabeus 1.37 local i j archs
165    
166 vapier 1.15 epatch_user
167 vapier 1.7
168 flameeyes 1.45 # 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 vapier 1.7 # autogen.sh does more than just run autotools
176 flameeyes 1.45 if [[ -n ${DO_AUTORECONF} ]] ; then
177 vapier 1.33 sed -i -e '/^autoreconf/s:^:set +e; e:' autogen.sh || die
178 vapier 1.17 (. ./autogen.sh) || die
179     fi
180 vapier 1.34
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 scarabeus 1.37
186     # get enabled platforms
187     GRUB_ENABLED_PLATFORMS=""
188 vapier 1.47 for i in ${GRUB_PLATFORMS[@]}; do
189 scarabeus 1.37 use grub_platforms_${i} && GRUB_ENABLED_PLATFORMS+=" ${i}"
190     done
191     [[ -z ${GRUB_ENABLED_PLATFORMS} ]] && GRUB_ENABLED_PLATFORMS="guessed"
192 scarabeus 1.44 elog "Going to build following platforms: ${GRUB_ENABLED_PLATFORMS}"
193 vapier 1.6 }
194    
195 vapier 1.33 src_configure() {
196 scarabeus 1.37 local i
197    
198 vapier 1.1 use custom-cflags || unset CFLAGS CPPFLAGS LDFLAGS
199     use static && append-ldflags -static
200    
201 scarabeus 1.37 for i in ${GRUB_ENABLED_PLATFORMS}; do
202     grub_run_phase ${FUNCNAME} ${i}
203     done
204 vapier 1.33 }
205    
206     src_compile() {
207 scarabeus 1.37 local i
208    
209     for i in ${GRUB_ENABLED_PLATFORMS}; do
210     grub_run_phase ${FUNCNAME} ${i}
211     done
212 vapier 1.1 }
213    
214     src_install() {
215 scarabeus 1.37 local i
216    
217     for i in ${GRUB_ENABLED_PLATFORMS}; do
218     grub_run_phase ${FUNCNAME} ${i}
219     done
220    
221 flameeyes 1.46 # 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 scarabeus 1.37
230 alexxy 1.40 # 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 scarabeus 1.43 pax-mark -mp "${ED}/${e}"
246 alexxy 1.40 done
247    
248 scarabeus 1.43 # can't be in docs array as we use default_src_install in different builddir
249 vapier 1.1 dodoc AUTHORS ChangeLog NEWS README THANKS TODO
250 scarabeus 1.37 insinto /etc/default
251     newins "${FILESDIR}"/grub.default grub
252     cat <<EOF >> "${ED}"/lib*/grub2/grub-mkconfig_lib
253 vapier 1.6 GRUB_DISTRIBUTOR="Gentoo"
254 scarabeus 1.37 EOF
255 scarabeus 1.42
256 scarabeus 1.44 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 vapier 1.3 }
269    
270     setup_boot_dir() {
271 scarabeus 1.37 local dir=$1
272 scarabeus 1.44 local use_legacy='n'
273 scarabeus 1.37
274 scarabeus 1.43 # Make sure target directory exists
275     mkdir -p "${dir}"
276    
277 scarabeus 1.44 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 scarabeus 1.37
303 scarabeus 1.44 # Remind the user about the documentation
304     show_doc_url
305 scarabeus 1.37 else
306 scarabeus 1.44 # 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 vapier 1.3 fi
312    
313 scarabeus 1.44 einfo
314     einfo "Remember to run grub2-install to activate GRUB2 as your default"
315     einfo "bootloader."
316 vapier 1.1 }
317    
318 scarabeus 1.42 pkg_config() {
319     local dir
320    
321 vapier 1.28 mount-boot_mount_boot_partition
322 vapier 1.27
323 scarabeus 1.42 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 vapier 1.28
330     mount-boot_pkg_postinst
331 vapier 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20