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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.73 - (show annotations) (download)
Tue Jan 11 15:26:03 2005 UTC (14 years, 4 months ago) by johnm
Branch: MAIN
Changes since 1.72: +8 -4 lines
added wolk fix

1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.71 2005/01/09 18:56:47 johnm Exp $
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 # Maintainer: John Mylchreest <johnm@gentoo.org>
9 # Copyright 2004 Gentoo Linux
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_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
20 # automatically set within the kernel Makefile
21 # K_NOUSENAME - if this is set then EXTRAVERSION will not include the
22 # first part of ${PN} in EXTRAVERSION
23 # K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
24 # ck-sources, ac-sources) it will use PR (ie: -r5) as
25 # the patchset version for
26 # - and not use it as a true package revision
27 # K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
28 # postinst and can be used to carry additional postinst
29 # messages
30 # K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
31
32 # H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
33 # can be supported by the headers ebuild
34
35 # UNIPATCH_LIST - space delimetered list of patches to be applied to the
36 # kernel
37 # UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
38 # on "<passedstring>*" and not "<passedno#>_*"
39 # - this should _NOT_ be used from the ebuild as this is
40 # reserved for end users passing excludes from the cli
41 # UNIPATCH_DOCS - space delimemeted list of docs to be installed to
42 # the doc dir
43 # UNIPATCH_STRICTORDER - if this is set places patches into directories of
44 # order, so they are applied in the order passed
45
46 ECLASS="kernel-2"
47 INHERITED="$INHERITED $ECLASS"
48 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
49
50 export CTARGET="${CTARGET:-${CHOST}}"
51
52 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
53 LICENSE="GPL-2"
54
55 # set LINUX_HOSTCFLAGS if not already set
56 [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
57
58 #Eclass functions only from here onwards ...
59 #==============================================================
60 kernel_is() {
61 # And lets add a sanity check
62 [ -z "${KV_FULL}" ] && return 1
63
64 local RESULT operator test value i len
65 RESULT=0
66
67 operator="="
68 if [ "${1}" == "lt" ]
69 then
70 operator="-lt"
71 shift
72 elif [ "${1}" == "gt" ]
73 then
74 operator="-gt"
75 shift
76 elif [ "${1}" == "le" ]
77 then
78 operator="-le"
79 shift
80 elif [ "${1}" == "ge" ]
81 then
82 operator="-ge"
83 shift
84 fi
85
86 if [ -n "${1}" ]
87 then
88 value="${value}${1}"
89 test="${test}${KV_MAJOR}"
90 fi
91 if [ -n "${2}" ]
92 then
93 len=$[ 3 - ${#2} ]
94 for((i=0; i<$len; i++)); do
95 value="${value}0"
96 done
97 value="${value}${2}"
98
99 len=$[ 3 - ${#KV_MINOR} ]
100 for((i=0; i<$len; i++)); do
101 test="${test}0"
102 done
103 test="${test}${KV_MINOR}"
104 fi
105 if [ -n "${3}" ]
106 then
107 len=$[ 3 - ${#3} ]
108 for((i=0; i<$len; i++)); do
109 value="${value}0"
110 done
111 value="${value}${3}"
112
113 len=$[ 3 - ${#KV_PATCH} ]
114 for((i=0; i<$len; i++)); do
115 test="${test}0"
116 done
117 test="${test}${KV_PATCH}"
118 fi
119
120 [ ${test} ${operator} ${value} ] && return 0 || return 1
121 }
122
123
124 kernel_is_2_4() {
125 kernel_is 2 4
126 return $?
127 }
128
129 kernel_is_2_6() {
130 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
131 return 0 || return 1
132 }
133
134 kernel_header_destdir() {
135 [ "${CTARGET}" = "${CHOST}" ] \
136 && echo /usr/include \
137 || echo /usr/${CTARGET}/include
138 }
139
140 # Capture the sources type and set DEPENDs
141 if [ "${ETYPE}" == "sources" ]
142 then
143 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
144 DEPEND="!build? ( sys-apps/sed
145 >=sys-devel/binutils-2.11.90.0.31 )
146 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
147
148 RDEPEND="${DEPEND}
149 !build? ( >=sys-libs/ncurses-5.2
150 dev-lang/perl
151 virtual/modutils
152 sys-devel/make )"
153
154 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" \
155 || PROVIDE="virtual/linux-sources virtual/alsa"
156
157 SLOT="${PVR}"
158 DESCRIPTION="Sources for the Linux kernel"
159 IUSE="${IUSE} build doc"
160 elif [ "${ETYPE}" == "headers" ]
161 then
162 DESCRIPTION="Linux system headers"
163 IUSE="${IUSE}"
164
165 if [[ ${CTARGET} = ${CHOST} ]]
166 then
167 DEPEND="!virtual/os-headers"
168 PROVIDE="virtual/kernel virtual/os-headers"
169 SLOT="0"
170 else
171 SLOT="${CTARGET}"
172 fi
173 else
174 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
175 die
176 fi
177
178 # Unpack functions
179 #==============================================================
180 unpack_2_4() {
181 cd ${S}
182 # this file is required for other things to build properly,
183 # so we autogenerate it
184 make mrproper || die "make mrproper died"
185 make include/linux/version.h || die "make include/linux/version.h failed"
186 echo ">>> version.h compiled successfully."
187 }
188
189 universal_unpack() {
190 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
191
192 cd ${WORKDIR}
193 unpack linux-${OKV}.tar.bz2
194 if [ "${OKV}" != "${KV_FULL}" ]
195 then
196 mv linux-${OKV} linux-${KV_FULL} \
197 || die "Unable to move source tree to ${KV_FULL}."
198 fi
199 cd ${S}
200
201 # change incorrect install path
202 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
203
204 # remove all backup files
205 find . -iname "*~" -exec rm {} \; 2> /dev/null
206
207 if [ -d "${S}/Documentation/DocBook" ]
208 then
209 cd ${S}/Documentation/DocBook
210 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
211 && mv Makefile.new Makefile
212 cd ${S}
213 fi
214 # fix a problem on ppc
215 use ppc && \
216 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
217 ${S}/arch/ppc/Makefile
218 }
219
220 unpack_set_extraversion() {
221 cd ${S}
222 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
223 }
224
225 # Compile Functions
226 #==============================================================
227 compile_headers() {
228 local extra_makeopts=
229 local HOSTCFLAGS=
230 unset ARCH
231
232 if kernel_is 2 4
233 then
234 yes "" | make oldconfig
235 echo ">>> make oldconfig complete"
236 use sparc && make dep
237 elif kernel_is 2 6
238 then
239 # autoconf.h isnt generated unless it already exists. plus, we have
240 # no guarantee that any headers are installed on the system...
241 [ -f "${ROOT}"/usr/include/linux/autoconf.h ] \
242 || touch include/linux/autoconf.h
243
244 # When cross-compiling, we need to set the CROSS_COMPILE var properly
245 if [[ ${CTARGET} != ${CHOST} ]] ; then
246 extra_makeopts="CROSS_COMPILE=${CTARGET}-"
247 elif type -p ${CHOST}-ar ; then
248 extra_makeopts="CROSS_COMPILE=${CHOST}-"
249 fi
250
251 # if there arent any installed headers, then there also isnt an asm
252 # symlink in /usr/include/, and make defconfig will fail, so we have
253 # to force an include path with $S.
254 local HOSTCFLAGS="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I${S}/include/"
255 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
256 make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "defconfig failed"
257 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "prepare failed"
258 fi
259 }
260
261 compile_manpages() {
262 local MY_ARCH
263
264 einfo "Making manpages ..."
265 MY_ARCH=${ARCH}
266 unset ARCH
267 make mandocs
268 ARCH=${MY_ARCH}
269 }
270
271 # install functions
272 #==============================================================
273 install_universal() {
274 #fix silly permissions in tarball
275 cd ${WORKDIR}
276 chown -R root:root *
277 chmod -R a+r-w+X,u+w *
278 }
279
280 install_headers() {
281 local ddir=$(kernel_header_destdir)
282
283 cd ${S}
284 dodir ${ddir}/linux
285 cp -ax ${S}/include/linux/* ${D}/${ddir}/linux
286 rm -rf ${D}/${ddir}/linux/modules
287 dodir ${ddir}/asm
288
289 if [ "${PROFILE_ARCH}" = "sparc64" -o "${PROFILE_ARCH}" = "sparc64-multilib" ] ; then
290 rm -Rf ${ddir}/asm
291 dodir ${ddir}/asm-sparc
292 dodir ${ddir}/asm-sparc64
293 cp -ax ${S}/include/asm-sparc/* ${D}/usr/include/asm-sparc
294 cp -ax ${S}/include/asm-sparc64/* ${D}/usr/include/asm-sparc64
295 generate_sparc_asm ${D}/usr/include
296 else
297 cp -ax ${S}/include/asm/* ${D}/${ddir}/asm
298 fi
299
300 if kernel_is 2 6
301 then
302 dodir ${ddir}/asm-generic
303 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic
304
305
306 fi
307 }
308
309 install_sources() {
310 local doc
311 local docs
312 local file
313
314 cd ${S}
315 dodir /usr/src
316 echo ">>> Copying sources ..."
317 file="$(find ${WORKDIR} -iname "docs" -type d)"
318 if [ -n "${file}" ]
319 then
320 for file in $(find ${file} -type f)
321 do
322 echo "${file/*docs\//}" >> ${S}/patches.txt
323 echo "===================================================" >> ${S}/patches.txt
324 cat ${file} >> ${S}/patches.txt
325 echo "===================================================" >> ${S}/patches.txt
326 echo "" >> ${S}/patches.txt
327 done
328 fi
329
330 if [ ! -f ${S}/patches.txt ]
331 then
332 # patches.txt is empty so lets use our ChangeLog
333 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
334 fi
335
336 for doc in ${UNIPATCH_DOCS}
337 do
338 [ -f ${doc} ] && docs="${docs} ${doc}"
339 done
340
341 if [ -f ${S}/patches.txt ]; then
342 docs="${docs} ${S}/patches.txt"
343 fi
344
345 if use doc && ! use arm && ! use s390; then
346 install_manpages
347 fi
348
349 dodoc ${docs}
350 mv ${WORKDIR}/linux* ${D}/usr/src
351 }
352
353 install_manpages() {
354 local MY_ARCH
355
356 ebegin "Installing manpages"
357 MY_ARCH=${ARCH}
358 unset ARCH
359 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
360 make installmandocs
361 eend $?
362 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
363 ARCH=${MY_ARCH}
364 }
365
366 # pkg_preinst functions
367 #==============================================================
368 preinst_headers() {
369 local ddir=$(kernel_header_destdir)
370 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
371 [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
372 }
373
374 # pkg_postinst functions
375 #==============================================================
376 postinst_sources() {
377 if [ ! -h ${ROOT}usr/src/linux ]
378 then
379 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
380 fi
381
382 # Don't forget to make directory for sysfs
383 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
384
385 echo
386 einfo "After installing a new kernel of any version, it is important"
387 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
388 einfo "created (X.Y is the first 2 parts of your new kernel version)"
389 echo
390 einfo "For example, this kernel will require:"
391 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
392 echo
393
394 # if K_EXTRAEINFO is set then lets display it now
395 if [ -n "${K_EXTRAEINFO}" ]
396 then
397 echo ${K_EXTRAEINFO} | fmt |
398 while read -s ELINE
399 do
400 einfo "${ELINE}"
401 done
402
403 echo
404 fi
405
406 # Show policy version, if this kernel has SELinux ...
407 local secfile
408 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
409 if use selinux && [ -f "$secfile" ]
410 then
411 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
412 einfo "The SELinux policy version of this kernel is $polver."
413 echo
414 fi
415
416 # if K_EXTRAEWARN is set then lets display it now
417 if [ -n "${K_EXTRAEWARN}" ]
418 then
419 echo ${K_EXTRAEWARN} | fmt |
420 while read -s ELINE
421 do
422 ewarn "${ELINE}"
423 done
424
425 echo
426 fi
427 }
428
429 postinst_headers() {
430 einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation"
431 einfo "of newer headers, it is advised that you re-merge glibc as follows:"
432 einfo "emerge glibc"
433 einfo "Failure to do so will cause glibc to not make use of newer features present in the updated kernel"
434 einfo "headers."
435 }
436
437 # pkg_setup functions
438 #==============================================================
439 setup_headers() {
440 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
441 for i in ${H_SUPPORTEDARCH}
442 do
443 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
444 done
445
446 if [ "${H_ACCEPT_ARCH}" != "yes" ]
447 then
448 echo
449 eerror "This version of ${PN} does not support ${ARCH}."
450 eerror "Please merge the appropriate sources, in most cases"
451 eerror "(but not all) this will be called ${ARCH}-headers."
452 die "Package unsupported for ${ARCH}"
453 fi
454 }
455
456 # unipatch
457 #==============================================================
458 unipatch() {
459 local i
460 local x
461 local extention
462 local PIPE_CMD
463 local UNIPATCH_DROP
464 local KPATCH_DIR
465 local PATCH_DEPTH
466 local ELINE
467 local STRICT_COUNT
468 local PATCH_LEVEL
469
470 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
471 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
472
473 # We're gonna need it when doing patches with a predefined patchlevel
474 shopt -s extglob
475
476 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
477 # usage can be either via an env var or by params
478 # although due to the nature we pass this within this eclass
479 # it shall be by param only.
480 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
481 UNIPATCH_LIST="${@}"
482
483 #unpack any passed tarballs
484 for i in ${UNIPATCH_LIST}
485 do
486 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
487 then
488 extention=${i/*./}
489 extention=${extention/:*/}
490 case ${extention} in
491 tbz2) PIPE_CMD="tar -xvjf";;
492 bz2) PIPE_CMD="tar -xvjf";;
493 tgz) PIPE_CMD="tar -xvzf";;
494 gz) PIPE_CMD="tar -xvzf";;
495 *) eerror "Unrecognized tarball compression"
496 die "Unrecognized tarball compression";;
497 esac
498
499 if [ -n "${UNIPATCH_STRICTORDER}" ]
500 then
501 STRICT_COUNT=$((${STRICT_COUNT} + 1))
502 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
503 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
504 else
505 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
506 fi
507
508 if [ $? == 0 ]
509 then
510 einfo "${i/*\//} unpacked"
511 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
512 else
513 eerror "Failed to unpack ${i/:*/}"
514 die "unable to unpack patch tarball"
515 fi
516 else
517 extention=${i/*./}
518 extention=${extention/:*/}
519 PIPE_CMD=""
520 case ${extention} in
521 bz2) PIPE_CMD="bzip2 -dc";;
522 patch) PIPE_CMD="cat";;
523 diff) PIPE_CMD="cat";;
524 gz|Z|z) PIPE_CMD="gzip -dc";;
525 ZIP|zip) PIPE_CMD="unzip -p";;
526 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
527 esac
528
529 PATCH_LEVEL=${i/*([^:])?(:)}
530 i=${i/:*/}
531 x=${i/*\//}
532 x=${x/\.${extention}/}
533
534 if [ -n "${PIPE_CMD}" ]
535 then
536 if [ ! -r "${i}" ]
537 then
538 echo
539 eerror "FATAL: unable to locate:"
540 eerror "${i}"
541 eerror "for read-only. The file either has incorrect permissions"
542 eerror "or does not exist."
543 die Unable to locate ${i}
544 fi
545
546 if [ -n "${UNIPATCH_STRICTORDER}" ]
547 then
548 STRICT_COUNT=$((${STRICT_COUNT} + 1))
549 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
550 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
551 else
552 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
553 fi
554 fi
555 fi
556 done
557
558 #populate KPATCH_DIRS so we know where to look to remove the excludes
559 x=${KPATCH_DIR}
560 KPATCH_DIR=""
561 LC_ALL="C"
562 for i in $(find ${x} -type d | sort -n)
563 do
564 KPATCH_DIR="${KPATCH_DIR} ${i}"
565 done
566
567 #so now lets get rid of the patchno's we want to exclude
568 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
569 for i in ${UNIPATCH_DROP}
570 do
571 ebegin "Excluding Patch #${i}"
572 for x in ${KPATCH_DIR}
573 do
574 rm -f ${x}/${i}* 2>/dev/null
575 done
576 eend $?
577 done
578
579 # and now, finally, we patch it :)
580 for x in ${KPATCH_DIR}
581 do
582 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
583 do
584 STDERR_T="${T}/${i/*\//}"
585 STDERR_T="${STDERR_T/.patch*/.err}"
586
587 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
588 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
589
590 if [ -z "${PATCH_DEPTH}" ]; then
591 PATCH_DEPTH=0
592 fi
593
594 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
595 while [ ${PATCH_DEPTH} -lt 5 ]
596 do
597 echo "Attempting Dry-run:" >> ${STDERR_T}
598 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
599 echo "=======================================================" >> ${STDERR_T}
600 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
601 then
602 echo "Attempting patch:" > ${STDERR_T}
603 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
604 echo "=======================================================" >> ${STDERR_T}
605 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
606 then
607 eend 0
608 rm ${STDERR_T}
609 break
610 else
611 eend 1
612 eerror "Failed to apply patch ${i/*\//}"
613 eerror "Please attach ${STDERR_T} to any bug you may post."
614 die "Failed to apply ${i/*\//}"
615 fi
616 else
617 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
618 fi
619 done
620 if [ ${PATCH_DEPTH} -eq 5 ]
621 then
622 eend 1
623 eerror "Please attach ${STDERR_T} to any bug you may post."
624 die "Unable to dry-run patch."
625 fi
626 done
627 done
628
629 # clean up KPATCH_DIR's - fixes bug #53610
630 for x in ${KPATCH_DIR}
631 do
632 rm -Rf ${x}
633 done
634 unset LC_ALL
635 }
636
637 # custom functions
638 #==============================================================
639 detect_version() {
640 # this function will detect and set
641 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
642 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
643 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
644
645 if [ -n "${KV_FULL}" ] ;
646 then
647 # we will set this for backwards compatibility.
648 KV=${KV_FULL}
649
650 # we know KV_FULL so lets stop here. but not without resetting S
651 S=${WORKDIR}/linux-${KV_FULL}
652 return
653 fi
654
655 if [ -z "${OKV}" ]
656 then
657 OKV=${PV/_beta/-test}
658 OKV=${OKV/_rc/-rc}
659 OKV=${OKV/_p*/}
660 OKV=${OKV/-r*/}
661 fi
662
663 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
664 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
665 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
666 KV_PATCH=${KV_PATCH/[-_]*/}
667
668 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
669
670 RELEASE=${PV/${OKV}/}
671 RELEASE=${RELEASE/_beta/}
672 RELEASE=${RELEASE/_rc/-rc}
673 if [ $(kernel_is_2_4) $? == 0 ]
674 then
675 RELEASE=${RELEASE/_pre/-pre}
676 else
677 RELEASE=${RELEASE/_pre/-bk}
678 fi
679 RELEASETYPE=${RELEASE//[0-9]/}
680 EXTRAVERSION="${RELEASE}"
681
682 if [ -n "${K_PREPATCHED}" ]
683 then
684 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
685 elif [ ${ETYPE} != "headers" ]
686 then
687 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
688 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
689 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
690 fi
691
692 KV_FULL=${OKV}${EXTRAVERSION}
693
694 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
695 # these cannot be supported, but the code here can handle it up until this point
696 # and theoretically thereafter.
697
698 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
699 then
700 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
701 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
702 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
703 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
704 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
705 fi
706
707 if [ "${RELEASETYPE}" == "-bk" ]
708 then
709 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
710 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
711 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
712 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
713 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
714 fi
715
716 if [ "${RELEASETYPE}" == "-rc-bk" ]
717 then
718 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
719 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
720
721 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
722 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
723 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
724 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
725 fi
726
727 S=${WORKDIR}/linux-${KV_FULL}
728 # we will set this for backwards compatibility.
729 KV=${KV_FULL}
730 }
731
732 detect_arch() {
733 # This function sets ARCH_URI and ARCH_PATCH
734 # with the neccessary info for the arch sepecific compatibility
735 # patchsets.
736
737 local ALL_ARCH
738 local LOOP_ARCH
739 local COMPAT_URI
740 local i
741
742 # COMPAT_URI is the contents of ${ARCH}_URI
743 # ARCH_URI is the URI for all the ${ARCH}_URI patches
744 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
745
746 ARCH_URI=""
747 ARCH_PATCH=""
748 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
749
750 for LOOP_ARCH in ${ALL_ARCH}
751 do
752 COMPAT_URI="${LOOP_ARCH}_URI"
753 COMPAT_URI="${!COMPAT_URI}"
754
755 [ -n "${COMPAT_URI}" ] && \
756 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
757
758 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
759 then
760 for i in ${COMPAT_URI}
761 do
762 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
763 done
764 fi
765 done
766 }
767
768 # sparc nastiness
769 #==============================================================
770 # This script generates the files in /usr/include/asm for sparc systems
771 # during installation of sys-kernel/linux-headers.
772 # Will no longer be needed when full 64 bit support is used on sparc64
773 # systems.
774 #
775 # Shamefully ripped from Debian
776 # ----------------------------------------------------------------------
777
778 # Idea borrowed from RedHat's kernel package
779
780 generate_sparc_asm() {
781 local name
782
783 cd $1 || die
784 mkdir asm
785
786 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
787 name="$(echo $h | tr a-z. A-Z_)"
788 # common header
789 echo "/* All asm/ files are generated and point to the corresponding
790 * file in asm-sparc or asm-sparc64.
791 */
792
793 #ifndef __SPARCSTUB__${name}__
794 #define __SPARCSTUB__${name}__
795 " > asm/${h}
796
797 # common for sparc and sparc64
798 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
799 echo "#ifdef __arch64__
800 #include <asm-sparc64/$h>
801 #else
802 #include <asm-sparc/$h>
803 #endif
804 " >> asm/${h}
805
806 # sparc only
807 elif [ -f asm-sparc/$h ]; then
808 echo "#ifndef __arch64__
809 #include <asm-sparc/$h>
810 #endif
811 " >> asm/${h}
812
813 # sparc64 only
814 else
815 echo "#ifdef __arch64__
816 #include <asm-sparc64/$h>
817 #endif
818 " >> asm/${h}
819 fi
820
821 # common footer
822 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
823 done
824 return 0
825 }
826
827 headers___fix() {
828 sed -i \
829 -e "s/\([ "$'\t'"]\)u8\([ "$'\t'"]\)/\1__u8\2/g;" \
830 -e "s/\([ "$'\t'"]\)u16\([ "$'\t'"]\)/\1__u16\2/g;" \
831 -e "s/\([ "$'\t'"]\)u32\([ "$'\t'"]\)/\1__u32\2/g;" \
832 -e "s/\([ "$'\t'"]\)u64\([ "$'\t'"]\)/\1__u64\2/g;" \
833 "$@"
834 }
835
836 # common functions
837 #==============================================================
838 kernel-2_src_unpack() {
839 detect_version
840 universal_unpack
841
842 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
843 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
844
845 [ -z "${K_NOSETEXTRAVERSION}" ] && \
846 unpack_set_extraversion
847
848 kernel_is 2 4 && unpack_2_4
849 }
850
851 kernel-2_src_compile() {
852 detect_version
853 cd ${S}
854 [ "${ETYPE}" == "headers" ] && compile_headers
855 [ "${ETYPE}" == "sources" ] && \
856 use doc && ! use arm && ! use s390 && compile_manpages
857 }
858
859 kernel-2_pkg_preinst() {
860 detect_version
861 [ "${ETYPE}" == "headers" ] && preinst_headers
862 }
863
864 kernel-2_src_install() {
865 detect_version
866 install_universal
867 [ "${ETYPE}" == "headers" ] && install_headers
868 [ "${ETYPE}" == "sources" ] && install_sources
869 }
870
871 kernel-2_pkg_postinst() {
872 detect_version
873 [ "${ETYPE}" == "headers" ] && postinst_headers
874 [ "${ETYPE}" == "sources" ] && postinst_sources
875 }
876
877 kernel-2_pkg_setup() {
878 detect_version
879 [ "${ETYPE}" == "headers" ] && setup_headers
880
881 # This is to fix some weird portage bug? in stable versions of portage.
882 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
883 }
884
885

  ViewVC Help
Powered by ViewVC 1.1.20