/[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.47 - (hide annotations) (download)
Fri Nov 18 00:04:29 2011 UTC (3 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.46: +18 -18 lines
Simplify GRUB_PLATFORMS handling, and move masking here.

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

1 vapier 1.27 # Copyright 1999-2011 Gentoo Foundation
2 vapier 1.1 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.47 # $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-9999.ebuild,v 1.46 2011/11/11 13:42:09 flameeyes 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 scarabeus 1.39 epatch \
167     "${FILESDIR}/1.99-call_proper_grub_probe.patch"
168    
169 vapier 1.15 epatch_user
170 vapier 1.7
171 flameeyes 1.45 # 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 vapier 1.7 # autogen.sh does more than just run autotools
179 flameeyes 1.45 if [[ -n ${DO_AUTORECONF} ]] ; then
180 vapier 1.33 sed -i -e '/^autoreconf/s:^:set +e; e:' autogen.sh || die
181 vapier 1.17 (. ./autogen.sh) || die
182     fi
183 vapier 1.34
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 scarabeus 1.37
189     # get enabled platforms
190     GRUB_ENABLED_PLATFORMS=""
191 vapier 1.47 for i in ${GRUB_PLATFORMS[@]}; do
192 scarabeus 1.37 use grub_platforms_${i} && GRUB_ENABLED_PLATFORMS+=" ${i}"
193     done
194     [[ -z ${GRUB_ENABLED_PLATFORMS} ]] && GRUB_ENABLED_PLATFORMS="guessed"
195 scarabeus 1.44 elog "Going to build following platforms: ${GRUB_ENABLED_PLATFORMS}"
196 vapier 1.6 }
197    
198 vapier 1.33 src_configure() {
199 scarabeus 1.37 local i
200    
201 vapier 1.1 use custom-cflags || unset CFLAGS CPPFLAGS LDFLAGS
202     use static && append-ldflags -static
203    
204 scarabeus 1.37 for i in ${GRUB_ENABLED_PLATFORMS}; do
205     grub_run_phase ${FUNCNAME} ${i}
206     done
207 vapier 1.33 }
208    
209     src_compile() {
210 scarabeus 1.37 local i
211    
212     for i in ${GRUB_ENABLED_PLATFORMS}; do
213     grub_run_phase ${FUNCNAME} ${i}
214     done
215 vapier 1.1 }
216    
217     src_install() {
218 scarabeus 1.37 local i
219    
220     for i in ${GRUB_ENABLED_PLATFORMS}; do
221     grub_run_phase ${FUNCNAME} ${i}
222     done
223    
224 flameeyes 1.46 # No need to move the info file with the live ebuild since we
225     # already changed the generated file name during the preparation
226     # phase.
227     if [[ ${PV} != "9999" ]]; then
228     # slot all collisions with grub legacy
229     mv "${ED}"/usr/share/info/grub.info \
230     "${ED}"/usr/share/info/grub2.info || die
231     fi
232 scarabeus 1.37
233 alexxy 1.40 # Do pax marking
234     local PAX=(
235     "sbin/grub2-probe"
236     "sbin/grub2-setup"
237     "sbin/grub2-mkdevicemap"
238     "bin/grub2-script-check"
239     "bin/grub2-fstest"
240     "bin/grub2-mklayout"
241     "bin/grub2-menulst2cfg"
242     "bin/grub2-mkrelpath"
243     "bin/grub2-mkpasswd-pbkdf2"
244     "bin/grub2-editenv"
245     "bin/grub2-mkimage"
246     )
247     for e in ${PAX[@]}; do
248 scarabeus 1.43 pax-mark -mp "${ED}/${e}"
249 alexxy 1.40 done
250    
251 scarabeus 1.43 # can't be in docs array as we use default_src_install in different builddir
252 vapier 1.1 dodoc AUTHORS ChangeLog NEWS README THANKS TODO
253 scarabeus 1.37 insinto /etc/default
254     newins "${FILESDIR}"/grub.default grub
255     cat <<EOF >> "${ED}"/lib*/grub2/grub-mkconfig_lib
256 vapier 1.6 GRUB_DISTRIBUTOR="Gentoo"
257 scarabeus 1.37 EOF
258 scarabeus 1.42
259 scarabeus 1.44 elog
260     elog "To configure GRUB 2, check the defaults in /etc/default/grub and"
261     elog "then run 'emerge --config =${CATEGORY}/${PF}'."
262    
263     # display the link to guide
264     show_doc_url
265     }
266    
267     show_doc_url() {
268     elog
269     elog "For informations how to configure grub-2 please refer to the guide:"
270     elog " http://dev.gentoo.org/~scarabeus/grub-2-guide.xml"
271 vapier 1.3 }
272    
273     setup_boot_dir() {
274 scarabeus 1.37 local dir=$1
275 scarabeus 1.44 local use_legacy='n'
276 scarabeus 1.37
277 scarabeus 1.43 # Make sure target directory exists
278     mkdir -p "${dir}"
279    
280 scarabeus 1.44 if [[ -e ${dir/2/}/menu.lst ]] ; then
281     # Legacy config exists, ask user what to do
282     einfo "Found legacy GRUB configuration. Do you want to convert it"
283     einfo "instead of using autoconfig (y/N)?"
284     read use_legacy
285    
286     use_legacy=${use_legacy,,[A-Z]}
287     fi
288    
289     if [[ ${use_legacy} == y* ]] ; then
290     grub1_cfg=${dir/2/}/menu.lst
291     grub2_cfg=${dir}/grub.cfg
292    
293     # GRUB legacy configuration exists. Use it instead of doing
294     # our normal autoconfigure.
295     #
296    
297     einfo "Converting legacy config at '${grub1_cfg}' for use by GRUB2."
298     ebegin "Running: grub2-menulst2cfg '${grub1_cfg}' '${grub2_cfg}'"
299     grub2-menulst2cfg "${grub1_cfg}" "${grub2_cfg}" &> /dev/null
300     eend $?
301    
302     ewarn
303     ewarn "Even though the conversion above succeeded, you are STRONGLY"
304     ewarn "URGED to upgrade to the new GRUB2 configuration format."
305 scarabeus 1.37
306 scarabeus 1.44 # Remind the user about the documentation
307     show_doc_url
308 scarabeus 1.37 else
309 scarabeus 1.44 # Run GRUB 2 autoconfiguration
310     einfo "Running GRUB 2 autoconfiguration."
311     ebegin "grub2-mkconfig -o '${dir}/grub.cfg'"
312     grub2-mkconfig -o "${dir}/grub.cfg" &> /dev/null
313     eend $?
314 vapier 1.3 fi
315    
316 scarabeus 1.44 einfo
317     einfo "Remember to run grub2-install to activate GRUB2 as your default"
318     einfo "bootloader."
319 vapier 1.1 }
320    
321 scarabeus 1.42 pkg_config() {
322     local dir
323    
324 vapier 1.28 mount-boot_mount_boot_partition
325 vapier 1.27
326 scarabeus 1.42 einfo "Enter the directory where you want to setup grub2 ('${ROOT}boot/grub2/'):"
327     read dir
328    
329     [[ -z ${dir} ]] && dir="${ROOT}"boot/grub2
330    
331     setup_boot_dir "${dir}"
332 vapier 1.28
333     mount-boot_pkg_postinst
334 vapier 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20