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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.69 - (show annotations) (download)
Thu Jan 6 13:58:15 2005 UTC (14 years, 4 months ago) by johnm
Branch: MAIN
Changes since 1.68: +12 -8 lines
Fixed bugs: 75034 76849 74655

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.68 2005/01/01 03:37:23 eradicator 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 IUSE="${IUSE} build doc"
55 SLOT="${PVR}"
56
57 # set LINUX_HOSTCFLAGS if not already set
58 [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
59
60 #Eclass functions only from here onwards ...
61 #==============================================================
62 kernel_is() {
63 # And lets add a sanity check
64 [ -z "${KV_FULL}" ] && return 1
65
66 local RESULT operator test value
67 RESULT=0
68
69 operator="="
70 if [ "${1}" == "lt" ]
71 then
72 operator="-lt"
73 shift
74 elif [ "${1}" == "gt" ]
75 then
76 operator="-gt"
77 shift
78 elif [ "${1}" == "le" ]
79 then
80 operator="-le"
81 shift
82 elif [ "${1}" == "ge" ]
83 then
84 operator="-ge"
85 shift
86 fi
87
88 if [ -n "${1}" ]
89 then
90 value="${value}${1}"
91 test="${test}${KV_MAJOR}"
92 fi
93 if [ -n "${2}" ]
94 then
95 value="${value}${2}"
96 test="${test}${KV_MINOR}"
97 fi
98 if [ -n "${3}" ]
99 then
100 value="${value}${3}"
101 test="${test}${KV_PATCH}"
102 fi
103
104 [ ${test} ${operator} ${value} ] && return 0 || return 1
105 }
106
107
108 kernel_is_2_4() {
109 kernel_is 2 4
110 return $?
111 }
112
113 kernel_is_2_6() {
114 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
115 return 0 || return 1
116 }
117
118 kernel_header_destdir() {
119 [ "${CTARGET}" = "${CHOST}" ] \
120 && echo /usr/include \
121 || echo /usr/${CTARGET}/include
122 }
123
124 # Capture the sources type and set DEPENDs
125 if [ "${ETYPE}" == "sources" ]
126 then
127 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
128 DEPEND="!build? ( sys-apps/sed
129 >=sys-devel/binutils-2.11.90.0.31 )
130 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
131
132 RDEPEND="${DEPEND}
133 !build? ( >=sys-libs/ncurses-5.2
134 dev-lang/perl
135 sys-apps/module-init-tools
136 sys-devel/make )"
137
138 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" \
139 || PROVIDE="virtual/linux-sources virtual/alsa"
140
141 elif [ "${ETYPE}" == "headers" ]
142 then
143 PROVIDE="virtual/kernel virtual/os-headers"
144 else
145 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
146 die
147 fi
148
149 # Unpack functions
150 #==============================================================
151 unpack_2_4() {
152 cd ${S}
153 # this file is required for other things to build properly,
154 # so we autogenerate it
155 make mrproper || die "make mrproper died"
156 make include/linux/version.h || die "make include/linux/version.h failed"
157 echo ">>> version.h compiled successfully."
158 }
159
160 universal_unpack() {
161 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
162
163 cd ${WORKDIR}
164 unpack linux-${OKV}.tar.bz2
165 if [ "${OKV}" != "${KV_FULL}" ]
166 then
167 mv linux-${OKV} linux-${KV_FULL} \
168 || die "Unable to move source tree to ${KV_FULL}."
169 fi
170 cd ${S}
171
172 # change incorrect install path
173 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
174
175 # remove all backup files
176 find . -iname "*~" -exec rm {} \; 2> /dev/null
177
178 if [ -d "${S}/Documentation/DocBook" ]
179 then
180 cd ${S}/Documentation/DocBook
181 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
182 && mv Makefile.new Makefile
183 cd ${S}
184 fi
185 # fix a problem on ppc
186 use ppc && \
187 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
188 ${S}/arch/ppc/Makefile
189 }
190
191 unpack_set_extraversion() {
192 cd ${S}
193 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
194 }
195
196 # Compile Functions
197 #==============================================================
198 compile_headers() {
199 local MY_ARCH
200
201 MY_ARCH=${ARCH}
202 unset ${ARCH}
203 yes "" | make oldconfig
204 echo ">>> make oldconfig complete"
205 ARCH=${MY_ARCH}
206 }
207
208 compile_manpages() {
209 local MY_ARCH
210
211 einfo "Making manpages ..."
212 MY_ARCH=${ARCH}
213 unset ARCH
214 make mandocs
215 ARCH=${MY_ARCH}
216 }
217
218 # install functions
219 #==============================================================
220 install_universal() {
221 #fix silly permissions in tarball
222 cd ${WORKDIR}
223 chown -R root:root *
224 chmod -R a+r-w+X,u+w *
225 }
226
227 install_headers() {
228 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
229
230 local ddir=$(kernel_header_destdir)
231 cd ${S}
232 dodir ${ddir}/linux
233 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
234 cp -ax ${S}/include/linux/* ${D}/${ddir}/linux
235 rm -rf ${D}/${ddir}/linux/modules
236
237 dodir ${ddir}/asm
238 cp -ax ${S}/include/asm/* ${D}/${ddir}/asm
239
240 if [ $(kernel_is_2_6) $? == 0 ]
241 then
242 dodir ${ddir}/asm-generic
243 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic
244 fi
245 }
246
247 install_sources() {
248 local doc
249 local docs
250 local file
251
252 cd ${S}
253 dodir /usr/src
254 echo ">>> Copying sources ..."
255 file="$(find ${WORKDIR} -iname "docs" -type d)"
256 if [ -n "${file}" ]
257 then
258 for file in $(find ${file} -type f)
259 do
260 echo "${file/*docs\//}" >> ${S}/patches.txt
261 echo "===================================================" >> ${S}/patches.txt
262 cat ${file} >> ${S}/patches.txt
263 echo "===================================================" >> ${S}/patches.txt
264 echo "" >> ${S}/patches.txt
265 done
266 fi
267
268 if [ ! -f ${S}/patches.txt ]
269 then
270 # patches.txt is empty so lets use our ChangeLog
271 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
272 fi
273
274 for doc in ${UNIPATCH_DOCS}
275 do
276 [ -f ${doc} ] && docs="${docs} ${doc}"
277 done
278
279 if [ -f ${S}/patches.txt ]; then
280 docs="${docs} ${S}/patches.txt"
281 fi
282
283 if use doc && ! use arm && ! use s390; then
284 install_manpages
285 fi
286
287 dodoc ${docs}
288 mv ${WORKDIR}/linux* ${D}/usr/src
289 }
290
291 install_manpages() {
292 local MY_ARCH
293
294 ebegin "Installing manpages"
295 MY_ARCH=${ARCH}
296 unset ARCH
297 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
298 make installmandocs
299 eend $?
300 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
301 ARCH=${MY_ARCH}
302 }
303
304 # pkg_preinst functions
305 #==============================================================
306 preinst_headers() {
307 local ddir=$(kernel_header_destdir)
308 [[ -L ${ROOT}${ddir}/linux ]] && rm "${ROOT}"${ddir}/linux
309 [[ -L ${ROOT}${ddir}/asm ]] && rm "${ROOT}"${ddir}/asm
310 }
311
312 # pkg_postinst functions
313 #==============================================================
314 postinst_sources() {
315 if [ ! -h ${ROOT}usr/src/linux ]
316 then
317 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
318 fi
319
320 # Don't forget to make directory for sysfs
321 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
322
323 echo
324 einfo "After installing a new kernel of any version, it is important"
325 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
326 einfo "created (X.Y is the first 2 parts of your new kernel version)"
327 echo
328 einfo "For example, this kernel will require:"
329 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
330 echo
331
332 # if K_EXTRAEINFO is set then lets display it now
333 if [ -n "${K_EXTRAEINFO}" ]
334 then
335 echo ${K_EXTRAEINFO} | fmt |
336 while read -s ELINE
337 do
338 einfo "${ELINE}"
339 done
340
341 echo
342 fi
343
344 # Show policy version, if this kernel has SELinux ...
345 local secfile
346 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
347 if use selinux && [ -f "$secfile" ]
348 then
349 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
350 einfo "The SELinux policy version of this kernel is $polver."
351 echo
352 fi
353
354 # if K_EXTRAEWARN is set then lets display it now
355 if [ -n "${K_EXTRAEWARN}" ]
356 then
357 echo ${K_EXTRAEWARN} | fmt |
358 while read -s ELINE
359 do
360 ewarn "${ELINE}"
361 done
362
363 echo
364 fi
365 }
366
367 postinst_headers() {
368 echo
369 einfo "Kernel headers are usually only used when recompiling glibc."
370 einfo "Following the installation of newer headers it is advised that"
371 einfo "you re-merge glibc as follows:"
372 einfo "# emerge glibc"
373 einfo "Failure to do so will cause glibc to not make use of newer"
374 einfo "features present in the updated kernelheaders."
375 echo
376 }
377
378 # pkg_setup functions
379 #==============================================================
380 setup_headers() {
381 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ \
382 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
383 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
384 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64-multilib" ] && ARCH="sparc64"
385
386 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
387 for i in ${H_SUPPORTEDARCH}
388 do
389 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
390 done
391
392 if [ "${H_ACCEPT_ARCH}" != "yes" ]
393 then
394 echo
395 eerror "This version of ${PN} does not support ${ARCH}."
396 eerror "Please merge the appropriate sources, in most cases"
397 eerror "this will be ${ARCH}-headers."
398 die "incorrect headers"
399 fi
400 }
401
402 # unipatch
403 #==============================================================
404 unipatch() {
405 local i
406 local x
407 local extention
408 local PIPE_CMD
409 local UNIPATCH_DROP
410 local KPATCH_DIR
411 local PATCH_DEPTH
412 local ELINE
413 local STRICT_COUNT
414 local PATCH_LEVEL
415
416 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
417 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
418
419 # We're gonna need it when doing patches with a predefined patchlevel
420 shopt -s extglob
421
422 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
423 # usage can be either via an env var or by params
424 # although due to the nature we pass this within this eclass
425 # it shall be by param only.
426 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
427 UNIPATCH_LIST="${@}"
428
429 #unpack any passed tarballs
430 for i in ${UNIPATCH_LIST}
431 do
432 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
433 then
434 extention=${i/*./}
435 extention=${extention/:*/}
436 case ${extention} in
437 tbz2) PIPE_CMD="tar -xvjf";;
438 bz2) PIPE_CMD="tar -xvjf";;
439 tgz) PIPE_CMD="tar -xvzf";;
440 gz) PIPE_CMD="tar -xvzf";;
441 *) eerror "Unrecognized tarball compression"
442 die "Unrecognized tarball compression";;
443 esac
444
445 if [ -n "${UNIPATCH_STRICTORDER}" ]
446 then
447 STRICT_COUNT=$((${STRICT_COUNT} + 1))
448 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
449 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
450 else
451 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
452 fi
453
454 if [ $? == 0 ]
455 then
456 einfo "${i/*\//} unpacked"
457 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
458 else
459 eerror "Failed to unpack ${i/:*/}"
460 die "unable to unpack patch tarball"
461 fi
462 else
463 extention=${i/*./}
464 extention=${extention/:*/}
465 PIPE_CMD=""
466 case ${extention} in
467 bz2) PIPE_CMD="bzip2 -dc";;
468 patch) PIPE_CMD="cat";;
469 diff) PIPE_CMD="cat";;
470 gz|Z|z) PIPE_CMD="gzip -dc";;
471 ZIP|zip) PIPE_CMD="unzip -p";;
472 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
473 esac
474
475 PATCH_LEVEL=${i/*([^:])?(:)}
476 i=${i/:*/}
477 x=${i/*\//}
478 x=${x/\.${extention}/}
479
480 if [ -n "${PIPE_CMD}" ]
481 then
482 if [ ! -r "${i}" ]
483 then
484 echo
485 eerror "FATAL: unable to locate:"
486 eerror "${i}"
487 eerror "for read-only. The file either has incorrect permissions"
488 eerror "or does not exist."
489 die Unable to locate ${i}
490 fi
491
492 if [ -n "${UNIPATCH_STRICTORDER}" ]
493 then
494 STRICT_COUNT=$((${STRICT_COUNT} + 1))
495 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
496 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
497 else
498 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
499 fi
500 fi
501 fi
502 done
503
504 #populate KPATCH_DIRS so we know where to look to remove the excludes
505 x=${KPATCH_DIR}
506 KPATCH_DIR=""
507 LC_ALL="C"
508 for i in $(find ${x} -type d | sort -n)
509 do
510 KPATCH_DIR="${KPATCH_DIR} ${i}"
511 done
512
513 #so now lets get rid of the patchno's we want to exclude
514 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
515 for i in ${UNIPATCH_DROP}
516 do
517 ebegin "Excluding Patch #${i}"
518 for x in ${KPATCH_DIR}
519 do
520 rm -f ${x}/${i}* 2>/dev/null
521 done
522 eend $?
523 done
524
525 # and now, finally, we patch it :)
526 for x in ${KPATCH_DIR}
527 do
528 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
529 do
530 STDERR_T="${T}/${i/*\//}"
531 STDERR_T="${STDERR_T/.patch*/.err}"
532
533 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
534 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
535
536 if [ -z "${PATCH_DEPTH}" ]; then
537 PATCH_DEPTH=0
538 fi
539
540 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
541 while [ ${PATCH_DEPTH} -lt 5 ]
542 do
543 echo "Attempting Dry-run:" >> ${STDERR_T}
544 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
545 echo "=======================================================" >> ${STDERR_T}
546 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
547 then
548 echo "Attempting patch:" > ${STDERR_T}
549 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
550 echo "=======================================================" >> ${STDERR_T}
551 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
552 then
553 eend 0
554 rm ${STDERR_T}
555 break
556 else
557 eend 1
558 eerror "Failed to apply patch ${i/*\//}"
559 eerror "Please attach ${STDERR_T} to any bug you may post."
560 die "Failed to apply ${i/*\//}"
561 fi
562 else
563 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
564 fi
565 done
566 if [ ${PATCH_DEPTH} -eq 5 ]
567 then
568 eend 1
569 eerror "Please attach ${STDERR_T} to any bug you may post."
570 die "Unable to dry-run patch."
571 fi
572 done
573 done
574
575 # clean up KPATCH_DIR's - fixes bug #53610
576 for x in ${KPATCH_DIR}
577 do
578 rm -Rf ${x}
579 done
580 unset LC_ALL
581 }
582
583 # custom functions
584 #==============================================================
585 detect_version() {
586 # this function will detect and set
587 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
588 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
589 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
590
591 if [ -n "${KV_FULL}" ] ;
592 then
593 # we will set this for backwards compatibility.
594 KV=${KV_FULL}
595
596 # we know KV_FULL so lets stop here. but not without resetting S
597 S=${WORKDIR}/linux-${KV_FULL}
598 return
599 fi
600
601 OKV=${PV/_beta/-test}
602 OKV=${OKV/_rc/-rc}
603 OKV=${OKV/_p*/}
604 OKV=${OKV/-r*/}
605
606 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
607 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
608 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
609 KV_PATCH=${KV_PATCH/[-_]*/}
610
611 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
612
613 RELEASE=${PV/${OKV}/}
614 RELEASE=${RELEASE/_beta/}
615 RELEASE=${RELEASE/_rc/-rc}
616 if [ $(kernel_is_2_4) $? == 0 ]
617 then
618 RELEASE=${RELEASE/_pre/-pre}
619 else
620 RELEASE=${RELEASE/_pre/-bk}
621 fi
622 RELEASETYPE=${RELEASE//[0-9]/}
623 EXTRAVERSION="${RELEASE}"
624
625 if [ -n "${K_PREPATCHED}" ]
626 then
627 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
628 else
629 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
630 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
631 fi
632
633 KV_FULL=${OKV}${EXTRAVERSION}
634
635 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
636 # these cannot be supported, but the code here can handle it up until this point
637 # and theoretically thereafter.
638
639 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
640 then
641 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
642 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
643 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
644 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
645 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
646 fi
647
648 if [ "${RELEASETYPE}" == "-bk" ]
649 then
650 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
651 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
652 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
653 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
654 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
655 fi
656
657 if [ "${RELEASETYPE}" == "-rc-bk" ]
658 then
659 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
660 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
661
662 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
663 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
664 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
665 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
666 fi
667
668 S=${WORKDIR}/linux-${KV_FULL}
669 # we will set this for backwards compatibility.
670 KV=${KV_FULL}
671 }
672
673 detect_arch() {
674 # This function sets ARCH_URI and ARCH_PATCH
675 # with the neccessary info for the arch sepecific compatibility
676 # patchsets.
677
678 local ALL_ARCH
679 local LOOP_ARCH
680 local COMPAT_URI
681 local i
682
683 # COMPAT_URI is the contents of ${ARCH}_URI
684 # ARCH_URI is the URI for all the ${ARCH}_URI patches
685 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
686
687 ARCH_URI=""
688 ARCH_PATCH=""
689 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
690
691 for LOOP_ARCH in ${ALL_ARCH}
692 do
693 COMPAT_URI="${LOOP_ARCH}_URI"
694 COMPAT_URI="${!COMPAT_URI}"
695
696 [ -n "${COMPAT_URI}" ] && \
697 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
698
699 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
700 then
701 for i in ${COMPAT_URI}
702 do
703 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
704 done
705 fi
706 done
707 }
708
709
710 # common functions
711 #==============================================================
712 kernel-2_src_unpack() {
713 detect_version
714 universal_unpack
715
716 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
717 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
718
719 [ -z "${K_NOSETEXTRAVERSION}" ] && \
720 unpack_set_extraversion
721
722 kernel_is 2 4 && unpack_2_4
723 }
724
725 kernel-2_src_compile() {
726 [ "${ETYPE}" == "headers" ] && compile_headers
727 [ "${ETYPE}" == "sources" ] && \
728 use doc && ! use arm && ! use s390 && compile_manpages
729 }
730
731 kernel-2_pkg_preinst() {
732 [ "${ETYPE}" == "headers" ] && preinst_headers
733 }
734
735 kernel-2_src_install() {
736 install_universal
737 [ "${ETYPE}" == "headers" ] && install_headers
738 [ "${ETYPE}" == "sources" ] && install_sources
739 }
740
741 kernel-2_pkg_postinst() {
742 [ "${ETYPE}" == "headers" ] && postinst_headers
743 [ "${ETYPE}" == "sources" ] && postinst_sources
744 }
745
746 kernel-2_pkg_setup() {
747 [ "${ETYPE}" == "headers" ] && setup_headers
748
749 # This is to fix some weird portage bug? in stable versions of portage.
750 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
751 }
752
753

  ViewVC Help
Powered by ViewVC 1.1.20