/[gentoo-x86]/eclass/kernel-2.eclass
Gentoo

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.229 - (show annotations) (download)
Mon Apr 26 07:15:03 2010 UTC (9 years, 1 month ago) by robbat2
Branch: MAIN
Changes since 1.228: +46 -3 lines
Bug #266157: Deblob support for libre kernels.

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header$
4
5 # Description: kernel.eclass rewrite for a clean base regarding the 2.6
6 # series of kernel with back-compatibility for 2.4
7 #
8 # Original author: John Mylchreest <johnm@gentoo.org>
9 # Maintainer: kernel-misc@gentoo.org
10 #
11 # Please direct your bugs to the current eclass maintainer :)
12
13 # added functionality:
14 # unipatch - a flexible, singular method to extract, add and remove patches.
15
16 # A Couple of env vars are available to effect usage of this eclass
17 # These are as follows:
18 #
19 # K_USEPV - When setting the EXTRAVERSION variable, it should
20 # add PV to the end.
21 # this is useful for thigns like wolk. IE:
22 # EXTRAVERSION would be something like : -wolk-4.19-r1
23 # K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
24 # automatically set within the kernel Makefile
25 # K_NOUSENAME - if this is set then EXTRAVERSION will not include the
26 # first part of ${PN} in EXTRAVERSION
27 # K_NOUSEPR - if this is set then EXTRAVERSION will not include the
28 # anything based on ${PR}.
29 # K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
30 # ck-sources, ac-sources) it will use PR (ie: -r5) as
31 # the patchset version for
32 # and not use it as a true package revision
33 # K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
34 # postinst and can be used to carry additional postinst
35 # messages
36 # K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo
37 # K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo
38 # K_SYMLINK - if this is set, then forcably create symlink anyway
39 #
40 # K_DEFCONFIG - Allow specifying a different defconfig target.
41 # If length zero, defaults to "defconfig".
42 # K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
43 # combination of "base" and "extras"
44 # K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
45 # A value of "5" would apply genpatches-2.6.12-5 to
46 # my-sources-2.6.12.ebuild
47 # K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
48
49 # H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
50 # can be supported by the headers ebuild
51
52 # UNIPATCH_LIST - space delimetered list of patches to be applied to the
53 # kernel
54 # UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
55 # on "<passedstring>*" and not "<passedno#>_*"
56 # - this should _NOT_ be used from the ebuild as this is
57 # reserved for end users passing excludes from the cli
58 # UNIPATCH_DOCS - space delimemeted list of docs to be installed to
59 # the doc dir
60 # UNIPATCH_STRICTORDER - if this is set places patches into directories of
61 # order, so they are applied in the order passed
62
63 inherit eutils toolchain-funcs versionator multilib
64 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
65
66 # Added by Daniel Ostrow <dostrow@gentoo.org>
67 # This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
68 # I will remove it when I come up with something more reasonable.
69 [[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
70
71 export CTARGET=${CTARGET:-${CHOST}}
72 if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
73 export CTARGET=${CATEGORY/cross-}
74 fi
75
76 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
77 [[ -z ${LICENSE} ]] && \
78 LICENSE="GPL-2"
79
80 # No need to run scanelf/strip on kernel sources/headers (bug #134453).
81 RESTRICT="binchecks strip"
82
83 # set LINUX_HOSTCFLAGS if not already set
84 [[ -z ${LINUX_HOSTCFLAGS} ]] && \
85 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
86
87 # debugging functions
88 #==============================================================
89 # this function exists only to help debug kernel-2.eclass
90 # if you are adding new functionality in, put a call to it
91 # at the start of src_unpack, or during SRC_URI/dep generation.
92 debug-print-kernel2-variables() {
93 for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
94 RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
95 UNIPATCH_LIST S KERNEL_URI ; do
96 debug-print "${v}: ${!v}"
97 done
98 }
99
100 #Eclass functions only from here onwards ...
101 #==============================================================
102 handle_genpatches() {
103 local tarball
104 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
105
106 for i in ${K_WANT_GENPATCHES} ; do
107 tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
108 GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
109 UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
110 done
111 }
112
113 detect_version() {
114 # this function will detect and set
115 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
116 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
117 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
118
119 if [[ -n ${KV_FULL} ]]; then
120 # we will set this for backwards compatibility.
121 KV=${KV_FULL}
122
123 # we know KV_FULL so lets stop here. but not without resetting S
124 S=${WORKDIR}/linux-${KV_FULL}
125 return
126 fi
127
128 # CKV is used as a comparison kernel version, which is used when
129 # PV doesnt reflect the genuine kernel version.
130 # this gets set to the portage style versioning. ie:
131 # CKV=2.6.11_rc4
132 CKV=${CKV:-${PV}}
133 OKV=${OKV:-${CKV}}
134 OKV=${OKV/_beta/-test}
135 OKV=${OKV/_rc/-rc}
136 OKV=${OKV/-r*}
137 OKV=${OKV/_p*}
138
139 KV_MAJOR=$(get_version_component_range 1 ${OKV})
140 KV_MINOR=$(get_version_component_range 2 ${OKV})
141 KV_PATCH=$(get_version_component_range 3 ${OKV})
142
143 if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
144 KV_EXTRA=$(get_version_component_range 4- ${OKV})
145 KV_EXTRA=${KV_EXTRA/[-_]*}
146 else
147 KV_PATCH=$(get_version_component_range 3- ${OKV})
148 fi
149 KV_PATCH=${KV_PATCH/[-_]*}
150
151 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
152
153 RELEASE=${CKV/${OKV}}
154 RELEASE=${RELEASE/_beta}
155 RELEASE=${RELEASE/_rc/-rc}
156 RELEASE=${RELEASE/_pre/-pre}
157 kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
158 RELEASETYPE=${RELEASE//[0-9]}
159
160 # Now we know that RELEASE is the -rc/-git
161 # and RELEASETYPE is the same but with its numerics stripped
162 # we can work on better sorting EXTRAVERSION.
163 # first of all, we add the release
164 EXTRAVERSION="${RELEASE}"
165 debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
166 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
167
168 debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
169 if [[ -n "${K_NOUSEPR}" ]]; then
170 # Don't add anything based on PR to EXTRAVERSION
171 debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
172 elif [[ -n ${K_PREPATCHED} ]]; then
173 debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
174 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
175 elif [[ "${ETYPE}" = "sources" ]]; then
176 debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
177 # For some sources we want to use the PV in the extra version
178 # This is because upstream releases with a completely different
179 # versioning scheme.
180 case ${PN/-*} in
181 wolk) K_USEPV=1;;
182 vserver) K_USEPV=1;;
183 esac
184
185 [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
186 [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
187 [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
188 fi
189 debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
190
191 # The only messing around which should actually effect this is for KV_EXTRA
192 # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
193 # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
194 if [[ -n ${KV_EXTRA} ]]; then
195 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
196 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/patch-${CKV}.bz2
197 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.tar.bz2"
198 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
199 fi
200
201 # We need to set this using OKV, but we need to set it before we do any
202 # messing around with OKV based on RELEASETYPE
203 KV_FULL=${OKV}${EXTRAVERSION}
204
205 # we will set this for backwards compatibility.
206 S=${WORKDIR}/linux-${KV_FULL}
207 KV=${KV_FULL}
208
209 # -rc-git pulls can be achieved by specifying CKV
210 # for example:
211 # CKV="2.6.11_rc3_pre2"
212 # will pull:
213 # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
214
215 if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
216 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
217 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
218 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
219 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
220 fi
221
222 if [[ ${RELEASETYPE} == -git ]]; then
223 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${OKV}${RELEASE}.bz2
224 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
225 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
226 fi
227
228 if [[ ${RELEASETYPE} == -rc-git ]]; then
229 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
230 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
231 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
232 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
233 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
234 fi
235
236 debug-print-kernel2-variables
237
238 handle_genpatches
239 }
240
241 kernel_is() {
242 # ALL of these should be set before we can safely continue this function.
243 # some of the sources have in the past had only one set.
244 local v n=0
245 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
246 [[ $n -eq 1 ]] && detect_version
247 unset v n
248
249 # Now we can continue
250 local operator test value x=0 y=0 z=0
251
252 case ${1} in
253 lt) operator="-lt"; shift;;
254 gt) operator="-gt"; shift;;
255 le) operator="-le"; shift;;
256 ge) operator="-ge"; shift;;
257 eq) operator="-eq"; shift;;
258 *) operator="-eq";;
259 esac
260
261 for x in ${@}; do
262 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
263 value="${value}${x}"
264 z=$((${z} + 1))
265
266 case ${z} in
267 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
268 test="${test}${KV_MAJOR}";;
269 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
270 test="${test}${KV_MINOR}";;
271 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
272 test="${test}${KV_PATCH}";;
273 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
274 esac
275 done
276
277 [ ${test} ${operator} ${value} ] && return 0 || return 1
278 }
279
280 kernel_is_2_4() {
281 kernel_is 2 4
282 }
283
284 kernel_is_2_6() {
285 kernel_is 2 6 || kernel_is 2 5
286 }
287
288 # Capture the sources type and set DEPENDs
289 if [[ ${ETYPE} == sources ]]; then
290 DEPEND="!build? ( sys-apps/sed
291 >=sys-devel/binutils-2.11.90.0.31 )"
292 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
293 sys-devel/make )"
294 PDEPEND="!build? ( virtual/dev-manager )"
295
296 PROVIDE="virtual/linux-sources"
297 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
298
299 SLOT="${PVR}"
300 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
301 IUSE="symlink build"
302
303 # Bug #266157, deblob for libre support
304 if [[ -z ${KERNEL_DEBLOBBED} ]] ; then
305 if kernel_is ge 2 6 27 ; then
306 IUSE="${IUSE} deblob"
307 # Reflect that kernels contain firmware blobs unless otherwise
308 # stripped
309 LICENSE="${LICENSE} !deblob? ( freedist )"
310
311 # This to to avoid us triggering some QA warnings
312 DEBLOB_AVAILABLE=1
313
314 DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
315 DEBLOB_A="deblob-${DEBLOB_PV}"
316 DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
317 HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
318
319 KERNEL_URI="${KERNEL_URI}
320 deblob? (
321 ${DEBLOB_HOMEPAGE}/download/releases/LATEST-${DEBLOB_PV}.N/${DEBLOB_A}
322 )"
323 else
324 # We have no way to deblob older kernels, so just mark them as
325 # tainted with non-libre materials.
326 LICENSE="${LICENSE} freedist"
327 fi
328 fi
329
330 elif [[ ${ETYPE} == headers ]]; then
331 DESCRIPTION="Linux system headers"
332
333 # Since we should NOT honour KBUILD_OUTPUT in headers
334 # lets unset it here.
335 unset KBUILD_OUTPUT
336
337 if [[ ${CTARGET} = ${CHOST} ]]; then
338 DEPEND="!virtual/os-headers"
339 PROVIDE="virtual/os-headers"
340 SLOT="0"
341 else
342 SLOT="${CTARGET}"
343 fi
344 else
345 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
346 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
347 fi
348
349 # Cross-compile support functions
350 #==============================================================
351 kernel_header_destdir() {
352 [[ ${CTARGET} == ${CHOST} ]] \
353 && echo /usr/include \
354 || echo /usr/${CTARGET}/usr/include
355 }
356
357 cross_pre_c_headers() {
358 use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
359 }
360
361 env_setup_xmakeopts() {
362 # Kernel ARCH != portage ARCH
363 export KARCH=$(tc-arch-kernel)
364
365 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
366 # variables properly or bad things happen !
367 xmakeopts="ARCH=${KARCH}"
368 if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
369 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
370 elif type -p ${CHOST}-ar > /dev/null ; then
371 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
372 fi
373 export xmakeopts
374 }
375
376 # Unpack functions
377 #==============================================================
378 unpack_2_4() {
379 # this file is required for other things to build properly,
380 # so we autogenerate it
381 make -s mrproper ${xmakeopts} || die "make mrproper failed"
382 make -s symlinks ${xmakeopts} || die "make symlinks failed"
383 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
384 echo ">>> version.h compiled successfully."
385 }
386
387 unpack_2_6() {
388 # this file is required for other things to build properly, so we
389 # autogenerate it ... generate a .config to keep version.h build from
390 # spitting out an annoying warning
391 make -s mrproper ${xmakeopts} 2>/dev/null \
392 || die "make mrproper failed"
393
394 # quick fix for bug #132152 which triggers when it cannot include linux
395 # headers (ie, we have not installed it yet)
396 if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
397 touch .config
398 eerror "make defconfig failed."
399 eerror "assuming you dont have any headers installed yet and continuing"
400 epause 5
401 fi
402
403 make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
404 || die "make include/linux/version.h failed"
405 rm -f .config >/dev/null
406 }
407
408 universal_unpack() {
409 cd "${WORKDIR}"
410 unpack linux-${OKV}.tar.bz2
411 if [[ -d "linux" ]]; then
412 mv linux linux-${KV_FULL} \
413 || die "Unable to move source tree to ${KV_FULL}."
414 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
415 mv linux-${OKV} linux-${KV_FULL} \
416 || die "Unable to move source tree to ${KV_FULL}."
417 fi
418 cd "${S}"
419
420 # remove all backup files
421 find . -iname "*~" -exec rm {} \; 2> /dev/null
422
423 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
424 # only do this for kernel < 2.6.27 since this file does not exist in later
425 # kernels
426 if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]]
427 then
428 sed -i \
429 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
430 "${S}"/arch/ppc/Makefile
431 else
432 sed -i \
433 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
434 "${S}"/arch/powerpc/Makefile
435 fi
436 }
437
438 unpack_set_extraversion() {
439 cd "${S}"
440 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
441 cd "${OLDPWD}"
442 }
443
444 # Should be done after patches have been applied
445 # Otherwise patches that modify the same area of Makefile will fail
446 unpack_fix_install_path() {
447 cd "${S}"
448 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
449 }
450
451 # Compile Functions
452 #==============================================================
453 compile_headers() {
454 env_setup_xmakeopts
455
456 # if we couldnt obtain HOSTCFLAGS from the Makefile,
457 # then set it to something sane
458 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
459 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
460
461 if kernel_is 2 4; then
462 yes "" | make oldconfig ${xmakeopts}
463 echo ">>> make oldconfig complete"
464 make dep ${xmakeopts}
465 elif kernel_is 2 6; then
466 # 2.6.18 introduces headers_install which means we dont need any
467 # of this crap anymore :D
468 kernel_is ge 2 6 18 && return 0
469
470 # autoconf.h isnt generated unless it already exists. plus, we have
471 # no guarantee that any headers are installed on the system...
472 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
473 || touch include/linux/autoconf.h
474
475 # if K_DEFCONFIG isn't set, force to "defconfig"
476 # needed by mips
477 if [[ -z ${K_DEFCONFIG} ]]; then
478 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
479 case ${CTARGET} in
480 powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
481 powerpc*) K_DEFCONFIG="pmac32_defconfig";;
482 *) K_DEFCONFIG="defconfig";;
483 esac
484 else
485 K_DEFCONFIG="defconfig"
486 fi
487 fi
488
489 # if there arent any installed headers, then there also isnt an asm
490 # symlink in /usr/include/, and make defconfig will fail, so we have
491 # to force an include path with $S.
492 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
493 ln -sf asm-${KARCH} "${S}"/include/asm
494 cross_pre_c_headers && return 0
495
496 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
497 if compile_headers_tweak_config ; then
498 yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
499 fi
500 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
501 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
502 fi
503 }
504
505 compile_headers_tweak_config() {
506 # some targets can be very very picky, so let's finesse the
507 # .config based upon any info we may have
508 case ${CTARGET} in
509 sh*)
510 sed -i '/CONFIG_CPU_SH/d' .config
511 echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
512 return 0;;
513 esac
514
515 # no changes, so lets do nothing
516 return 1
517 }
518
519 # install functions
520 #==============================================================
521 install_universal() {
522 #fix silly permissions in tarball
523 cd "${WORKDIR}"
524 chown -R root:0 * >& /dev/null
525 chmod -R a+r-w+X,u+w *
526 cd ${OLDPWD}
527 }
528
529 install_headers() {
530 local ddir=$(kernel_header_destdir)
531
532 # 2.6.18 introduces headers_install which means we dont need any
533 # of this crap anymore :D
534 if kernel_is ge 2 6 18 ; then
535 env_setup_xmakeopts
536 emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
537
538 # let other packages install some of these headers
539 rm -rf "${D}"/${ddir}/sound #alsa-headers
540 rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
541 return 0
542 fi
543
544 # Do not use "linux/*" as that can cause problems with very long
545 # $S values where the cmdline to cp is too long
546 cd "${S}"
547 dodir ${ddir}/linux
548 cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
549 rm -rf "${D}"/${ddir}/linux/modules
550
551 # Handle multilib headers and crap
552 local multi_dirs="" multi_defs=""
553 case $(tc-arch-kernel) in
554 sparc64)
555 multi_dirs="sparc sparc64"
556 multi_defs="!__arch64__ __arch64__"
557 ;;
558 x86_64)
559 multi_dirs="i386 x86_64"
560 multi_defs="__i386__ __x86_64__"
561 ;;
562 ppc64)
563 multi_dirs="ppc ppc64"
564 multi_defs="!__powerpc64__ __powerpc64__"
565 ;;
566 s390x)
567 multi_dirs="s390 s390x"
568 multi_defs="!__s390x__ __s390x__"
569 ;;
570 arm)
571 dodir ${ddir}/asm
572 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
573 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
574 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
575 ;;
576 powerpc)
577 dodir ${ddir}/asm
578 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
579 if [[ -e "${S}"/include/asm-ppc ]] ; then
580 dodir ${ddir}/asm-ppc
581 cp -pPR "${S}"/include/asm-ppc/* "${D}"/${ddir}/asm-ppc
582 fi
583 ;;
584 *)
585 dodir ${ddir}/asm
586 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
587 ;;
588 esac
589 if [[ -n ${multi_dirs} ]] ; then
590 local d ml_inc=""
591 for d in ${multi_dirs} ; do
592 dodir ${ddir}/asm-${d}
593 cp -pPR "${S}"/include/asm-${d}/* "${D}"/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
594
595 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
596 multi_defs=${multi_defs#* }
597 done
598 create_ml_includes ${ddir}/asm ${ml_inc}
599 fi
600
601 if kernel_is 2 6; then
602 dodir ${ddir}/asm-generic
603 cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
604 fi
605
606 # clean up
607 find "${D}" -name '*.orig' -exec rm -f {} \;
608
609 cd ${OLDPWD}
610 }
611
612 install_sources() {
613 local file
614
615 cd "${S}"
616 dodir /usr/src
617 echo ">>> Copying sources ..."
618
619 file="$(find ${WORKDIR} -iname "docs" -type d)"
620 if [[ -n ${file} ]]; then
621 for file in $(find ${file} -type f); do
622 echo "${file//*docs\/}" >> "${S}"/patches.txt
623 echo "===================================================" >> "${S}"/patches.txt
624 cat ${file} >> "${S}"/patches.txt
625 echo "===================================================" >> "${S}"/patches.txt
626 echo "" >> "${S}"/patches.txt
627 done
628 fi
629
630 if [[ ! -f ${S}/patches.txt ]]; then
631 # patches.txt is empty so lets use our ChangeLog
632 [[ -f ${FILESDIR}/../ChangeLog ]] && \
633 echo "Please check the ebuild ChangeLog for more details." \
634 > "${S}"/patches.txt
635 fi
636
637 mv ${WORKDIR}/linux* "${D}"/usr/src
638 }
639
640 # pkg_preinst functions
641 #==============================================================
642 preinst_headers() {
643 local ddir=$(kernel_header_destdir)
644 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
645 [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
646 }
647
648 # pkg_postinst functions
649 #==============================================================
650 postinst_sources() {
651 local MAKELINK=0
652
653 # if we have USE=symlink, then force K_SYMLINK=1
654 use symlink && K_SYMLINK=1
655
656 # if we're using a deblobbed kernel, it's not supported
657 [[ $DEBLOB_AVAILABLE == "1" ]] && \
658 use deblob && \
659 K_SECURITY_UNSUPPORTED=1
660
661 # if we are to forcably symlink, delete it if it already exists first.
662 if [[ ${K_SYMLINK} > 0 ]]; then
663 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
664 MAKELINK=1
665 fi
666
667 # if the link doesnt exist, lets create it
668 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
669
670 if [[ ${MAKELINK} == 1 ]]; then
671 cd "${ROOT}"usr/src
672 ln -sf linux-${KV_FULL} linux
673 cd ${OLDPWD}
674 fi
675
676 # Don't forget to make directory for sysfs
677 [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
678
679 echo
680 elog "If you are upgrading from a previous kernel, you may be interested"
681 elog "in the following document:"
682 elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
683 echo
684
685 # if K_EXTRAEINFO is set then lets display it now
686 if [[ -n ${K_EXTRAEINFO} ]]; then
687 echo ${K_EXTRAEINFO} | fmt |
688 while read -s ELINE; do einfo "${ELINE}"; done
689 fi
690
691 # if K_EXTRAELOG is set then lets display it now
692 if [[ -n ${K_EXTRAELOG} ]]; then
693 echo ${K_EXTRAELOG} | fmt |
694 while read -s ELINE; do elog "${ELINE}"; done
695 fi
696
697 # if K_EXTRAEWARN is set then lets display it now
698 if [[ -n ${K_EXTRAEWARN} ]]; then
699 echo ${K_EXTRAEWARN} | fmt |
700 while read -s ELINE; do ewarn "${ELINE}"; done
701 fi
702
703 # optionally display security unsupported message
704 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
705 echo
706 ewarn "${PN} is UNSUPPORTED by Gentoo Security."
707 ewarn "This means that it is likely to be vulnerable to recent security issues."
708 ewarn "For specific information on why this kernel is unsupported, please read:"
709 ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
710 fi
711
712 # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
713 KV_MAJOR=$(get_version_component_range 1 ${OKV})
714 KV_MINOR=$(get_version_component_range 2 ${OKV})
715 KV_PATCH=$(get_version_component_range 3 ${OKV})
716 if [[ "$(tc-arch)" = "sparc" ]] \
717 && [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]]
718 then
719 echo
720 elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
721 elog "you now need to do"
722 elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
723 elog "instead of just"
724 elog " make"
725 elog "to compile the kernel. For more information please browse to"
726 elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
727 echo
728 fi
729 }
730
731 postinst_headers() {
732 elog "Kernel headers are usually only used when recompiling your system libc, as"
733 elog "such, following the installation of newer headers, it is advised that you"
734 elog "re-merge your system libc."
735 elog "Failure to do so will cause your system libc to not make use of newer"
736 elog "features present in the updated kernel headers."
737 }
738
739 # pkg_setup functions
740 #==============================================================
741 setup_headers() {
742 [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
743 for i in ${H_SUPPORTEDARCH}; do
744 [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
745 done
746
747 if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
748 echo
749 eerror "This version of ${PN} does not support $(tc-arch)."
750 eerror "Please merge the appropriate sources, in most cases"
751 eerror "(but not all) this will be called $(tc-arch)-headers."
752 die "Package unsupported for $(tc-arch)"
753 fi
754 }
755
756 # unipatch
757 #==============================================================
758 unipatch() {
759 local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
760 local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG extglob_bak
761
762 # set to a standard locale to ensure sorts are ordered properly.
763 myLC_ALL="${LC_ALL}"
764 myLANG="${LANG}"
765 LC_ALL="C"
766 LANG=""
767
768 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
769 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
770
771 # We're gonna need it when doing patches with a predefined patchlevel
772 extglob_bak=$(shopt -p extglob)
773 shopt -s extglob
774
775 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
776 # usage can be either via an env var or by params
777 # although due to the nature we pass this within this eclass
778 # it shall be by param only.
779 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
780 UNIPATCH_LIST="${@}"
781
782 #unpack any passed tarballs
783 for i in ${UNIPATCH_LIST}; do
784 if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
785 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
786 unset z
787 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
788 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
789 do z="${z}0";
790 done
791 PATCH_ORDER="${z}${STRICT_COUNT}"
792
793 mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
794 pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
795 unpack ${i##*/}
796 popd >/dev/null
797 else
798 pushd "${KPATCH_DIR}" >/dev/null
799 unpack ${i##*/}
800 popd >/dev/null
801 fi
802
803 [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
804 else
805 extention=${i/*./}
806 extention=${extention/:*/}
807 PIPE_CMD=""
808 case ${extention} in
809 bz2) PIPE_CMD="bzip2 -dc";;
810 patch) PIPE_CMD="cat";;
811 diff) PIPE_CMD="cat";;
812 gz|Z|z) PIPE_CMD="gzip -dc";;
813 ZIP|zip) PIPE_CMD="unzip -p";;
814 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
815 esac
816
817 PATCH_LEVEL=${i/*([^:])?(:)}
818 i=${i/:*/}
819 x=${i/*\//}
820 x=${x/\.${extention}/}
821
822 if [ -n "${PIPE_CMD}" ]; then
823 if [ ! -r "${i}" ]; then
824 echo
825 eerror "FATAL: unable to locate:"
826 eerror "${i}"
827 eerror "for read-only. The file either has incorrect permissions"
828 eerror "or does not exist."
829 die Unable to locate ${i}
830 fi
831
832 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
833 unset z
834 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
835 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
836 do z="${z}0";
837 done
838 PATCH_ORDER="${z}${STRICT_COUNT}"
839
840 mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
841 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL})
842 else
843 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
844 fi
845 fi
846 fi
847 done
848
849 #populate KPATCH_DIRS so we know where to look to remove the excludes
850 x=${KPATCH_DIR}
851 KPATCH_DIR=""
852 for i in $(find ${x} -type d | sort -n); do
853 KPATCH_DIR="${KPATCH_DIR} ${i}"
854 done
855
856 # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
857 # bug #272676
858 if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
859 if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
860 UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
861 echo
862 ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
863 ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
864 ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
865 echo
866 fi
867 fi
868
869 #so now lets get rid of the patchno's we want to exclude
870 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
871 for i in ${UNIPATCH_DROP}; do
872 ebegin "Excluding Patch #${i}"
873 for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
874 eend $?
875 done
876
877 # and now, finally, we patch it :)
878 for x in ${KPATCH_DIR}; do
879 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
880 STDERR_T="${T}/${i/*\//}"
881 STDERR_T="${STDERR_T/.patch*/.err}"
882
883 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
884 #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
885
886 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
887
888 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
889 while [ ${PATCH_DEPTH} -lt 5 ]; do
890 echo "Attempting Dry-run:" >> ${STDERR_T}
891 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
892 echo "=======================================================" >> ${STDERR_T}
893 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
894 echo "Attempting patch:" > ${STDERR_T}
895 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
896 echo "=======================================================" >> ${STDERR_T}
897 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
898 eend 0
899 rm ${STDERR_T}
900 break
901 else
902 eend 1
903 eerror "Failed to apply patch ${i/*\//}"
904 eerror "Please attach ${STDERR_T} to any bug you may post."
905 die "Failed to apply ${i/*\//}"
906 fi
907 else
908 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
909 fi
910 done
911 if [ ${PATCH_DEPTH} -eq 5 ]; then
912 eend 1
913 eerror "Please attach ${STDERR_T} to any bug you may post."
914 die "Unable to dry-run patch."
915 fi
916 done
917 done
918
919 # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which
920 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
921 # which is why I'm not taking too much time over this.
922 local tmp
923 for i in ${UNIPATCH_DOCS}; do
924 tmp="${tmp} ${i//*\/}"
925 cp -f ${i} "${T}"/
926 done
927 UNIPATCH_DOCS="${tmp}"
928
929 # clean up KPATCH_DIR's - fixes bug #53610
930 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
931
932 LC_ALL="${myLC_ALL}"
933 LANG="${myLANG}"
934 eval ${extglob_bak}
935 }
936
937 # getfilevar accepts 2 vars as follows:
938 # getfilevar <VARIABLE> <CONFIGFILE>
939 # pulled from linux-info
940
941 getfilevar() {
942 local workingdir basefname basedname xarch=$(tc-arch-kernel)
943
944 if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
945 echo -e "\n"
946 eerror "getfilevar requires 2 variables, with the second a valid file."
947 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
948 else
949 workingdir=${PWD}
950 basefname=$(basename ${2})
951 basedname=$(dirname ${2})
952 unset ARCH
953
954 cd ${basedname}
955 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
956 make ${BUILD_FIXES} -s -f - e 2>/dev/null
957 cd ${workingdir}
958
959 ARCH=${xarch}
960 fi
961 }
962
963 detect_arch() {
964 # This function sets ARCH_URI and ARCH_PATCH
965 # with the neccessary info for the arch sepecific compatibility
966 # patchsets.
967
968 local ALL_ARCH LOOP_ARCH COMPAT_URI i
969
970 # COMPAT_URI is the contents of ${ARCH}_URI
971 # ARCH_URI is the URI for all the ${ARCH}_URI patches
972 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
973
974 ARCH_URI=""
975 ARCH_PATCH=""
976 ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
977
978 for LOOP_ARCH in ${ALL_ARCH}; do
979 COMPAT_URI="${LOOP_ARCH}_URI"
980 COMPAT_URI="${!COMPAT_URI}"
981
982 [[ -n ${COMPAT_URI} ]] && \
983 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
984
985 if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
986 for i in ${COMPAT_URI}; do
987 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
988 done
989 fi
990 done
991 }
992
993 # sparc nastiness
994 #==============================================================
995 # This script generates the files in /usr/include/asm for sparc systems
996 # during installation of sys-kernel/linux-headers.
997 # Will no longer be needed when full 64 bit support is used on sparc64
998 # systems.
999 #
1000 # Shamefully ripped from Debian
1001 # ----------------------------------------------------------------------
1002
1003 # Idea borrowed from RedHat's kernel package
1004
1005 # This is gonna get replaced by something in multilib.eclass soon...
1006 # --eradicator
1007 generate_sparc_asm() {
1008 local name
1009
1010 cd $1 || die
1011 mkdir asm
1012
1013 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
1014 name="$(echo $h | tr a-z. A-Z_)"
1015 # common header
1016 echo "/* All asm/ files are generated and point to the corresponding
1017 * file in asm-sparc or asm-sparc64.
1018 */
1019
1020 #ifndef __SPARCSTUB__${name}__
1021 #define __SPARCSTUB__${name}__
1022 " > asm/${h}
1023
1024 # common for sparc and sparc64
1025 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
1026 echo "#ifdef __arch64__
1027 #include <asm-sparc64/$h>
1028 #else
1029 #include <asm-sparc/$h>
1030 #endif
1031 " >> asm/${h}
1032
1033 # sparc only
1034 elif [ -f asm-sparc/$h ]; then
1035 echo "#ifndef __arch64__
1036 #include <asm-sparc/$h>
1037 #endif
1038 " >> asm/${h}
1039
1040 # sparc64 only
1041 else
1042 echo "#ifdef __arch64__
1043 #include <asm-sparc64/$h>
1044 #endif
1045 " >> asm/${h}
1046 fi
1047
1048 # common footer
1049 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
1050 done
1051 return 0
1052 }
1053
1054 headers___fix() {
1055 # Voodoo to partially fix broken upstream headers.
1056 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1057 sed -i \
1058 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1059 -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
1060 -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
1061 -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
1062 -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
1063 "$@"
1064 }
1065
1066 # common functions
1067 #==============================================================
1068 kernel-2_src_unpack() {
1069 universal_unpack
1070 debug-print "Doing unipatch"
1071
1072 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
1073 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
1074
1075 debug-print "Doing premake"
1076
1077 # allow ebuilds to massage the source tree after patching but before
1078 # we run misc `make` functions below
1079 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
1080
1081 debug-print "Doing epatch_user"
1082 epatch_user
1083
1084 debug-print "Doing unpack_set_extraversion"
1085
1086 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
1087 unpack_fix_install_path
1088
1089 # Setup xmakeopts and cd into sourcetree.
1090 env_setup_xmakeopts
1091 cd "${S}"
1092
1093 # We dont need a version.h for anything other than headers
1094 # at least, I should hope we dont. If this causes problems
1095 # take out the if/fi block and inform me please.
1096 # unpack_2_6 should now be 2.6.17 safe anyways
1097 if [[ ${ETYPE} == headers ]]; then
1098 kernel_is 2 4 && unpack_2_4
1099 kernel_is 2 6 && unpack_2_6
1100 fi
1101
1102 if [[ $DEBLOB_AVAILABLE == "1" ]] && use deblob ; then
1103 cp "${DISTDIR}/${DEBLOB_A}" "${T}"
1104 chmod +x "${T}/${DEBLOB_A}"
1105 fi
1106 }
1107
1108 kernel-2_src_compile() {
1109 cd "${S}"
1110 [[ ${ETYPE} == headers ]] && compile_headers
1111
1112 if [[ $DEBLOB_AVAILABLE == "1" ]] && use deblob ; then
1113 echo ">>> Running deblob script ..."
1114 sh "${T}/${DEBLOB_A}" --force || \
1115 die "Deblob script failed to run!!!"
1116 fi
1117 }
1118
1119 kernel-2_pkg_preinst() {
1120 [[ ${ETYPE} == headers ]] && preinst_headers
1121 }
1122
1123 kernel-2_src_install() {
1124 install_universal
1125 [[ ${ETYPE} == headers ]] && install_headers
1126 [[ ${ETYPE} == sources ]] && install_sources
1127 }
1128
1129 kernel-2_pkg_postinst() {
1130 [[ ${ETYPE} == headers ]] && postinst_headers
1131 [[ ${ETYPE} == sources ]] && postinst_sources
1132 }
1133
1134 kernel-2_pkg_setup() {
1135 if kernel_is 2 4; then
1136 if [ "$( gcc-major-version )" -eq "4" ] ; then
1137 echo
1138 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1139 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1140 ewarn "newer kernel that supports gcc-4."
1141 echo
1142 ewarn "Also be aware that bugreports about gcc-4 not working"
1143 ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
1144 echo
1145 epause 10
1146 fi
1147 fi
1148
1149 ABI="${KERNEL_ABI}"
1150 [[ ${ETYPE} == headers ]] && setup_headers
1151 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1152 }

  ViewVC Help
Powered by ViewVC 1.1.20