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

Diff of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.12 Revision 1.21
1# Copyright 1999-2004 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.21 2004/01/26 09:06:27 johnm Exp $
4
1# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel 5# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel
2# with back-compatibility for 2.4 6# with back-compatibility for 2.4
3# 7#
4# Author: John Mylchreest <johnm@gentoo.org> 8# Author: John Mylchreest <johnm@gentoo.org>
5# Copyright 2004 Gentoo Linux 9# Copyright 2004 Gentoo Linux
13# A Couple of env vars are available to effect usage of this eclass 17# A Couple of env vars are available to effect usage of this eclass
14# These are as follows: 18# These are as follows:
15# 19#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 20# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile
17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION 21# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION
18# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, ck-sources, ac-sources) it will use PR (ie: -r5) as the patchset version for EXTRAVERSION 22# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, ck-sources, ac-sources) it will use PR (ie: -r5) as the patchset version for
19# - and not use it as a true package revision 23# - and not use it as a true package revision
20# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages 24# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages
21# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's 25# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
22 26
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild 27# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild
24 28
25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 29# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
30# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely on "<passedstring>*" and not "<passedno#>_*"
31 - this should _NOT_ be used from the ebuild as this is reserved for end users passing excludes from the cli
26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 32# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
33# UNIPATCH_STRICTORDER - if this is set places patches into directories of order, so they are applied in the order passed
27 34
28ECLASS="kernel-2" 35ECLASS="kernel-2"
29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 36EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
30 37
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 38HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 39LICENSE="GPL-2"
33IUSE="${IUSE} build" 40IUSE="${IUSE} build"
34SLOT="${KV}" 41SLOT="${KV}"
42
43# Grab kernel version from KV
44KV_MAJOR=$(echo ${KV} | cut -d. -f1)
45KV_MINOR=$(echo ${KV} | cut -d. -f2)
46KV_PATCH=$(echo ${KV} | cut -d. -f3)
47KV_PATCH=${KV_PATCH/[-_]*/}
48
49# set LINUX_HOSTCFLAGS if not already set
50[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
51
52
53#eclass functions only from here onwards.
54#==============================================================
55kernel_is_2_4() {
56 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
57}
58
59kernel_is_2_6() {
60 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
61}
35 62
36# capture the sources type and set depends 63# capture the sources type and set depends
37if [ "${ETYPE}" == "sources" ] 64if [ "${ETYPE}" == "sources" ]
38then 65then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 66 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
43 RDEPEND="${DEPEND} 70 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 71 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 72 dev-lang/perl
46 sys-apps/module-init-tools 73 sys-apps/module-init-tools
47 sys-devel/make )" 74 sys-devel/make )"
48 75
49 PROVIDE="virtual/linux-sources virtual/alsa" 76 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" || PROVIDE="virtual/linux-sources virtual/alsa"
50 77
51elif [ "${ETYPE}" == "headers" ] 78elif [ "${ETYPE}" == "headers" ]
52then 79then
53 PROVIDE="virtual/kernel virtual/os-headers" 80 PROVIDE="virtual/kernel virtual/os-headers"
54else 81else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 82 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\""
56 die 83 die
57fi 84fi
58
59# Grab kernel version from KV
60KV_MAJOR=$(echo ${KV} | cut -d. -f1)
61KV_MINOR=$(echo ${KV} | cut -d. -f2)
62KV_PATCH=$(echo ${KV} | cut -d. -f3)
63KV_PATCH=${KV_PATCH/[-_]*/}
64
65# set LINUX_HOSTCFLAGS if not already set
66[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
67
68
69#eclass functions only from here onwards.
70#==============================================================
71kernel_is_2_4() {
72 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
73}
74
75kernel_is_2_6() {
76 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
77}
78
79 85
80# Unpack functions 86# Unpack functions
81#============================================================== 87#==============================================================
82unpack_2_4() { 88unpack_2_4() {
83 cd ${S} 89 cd ${S}
132 chmod -R a+r-w+X,u+w * 138 chmod -R a+r-w+X,u+w *
133} 139}
134 140
135install_headers() { 141install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 142 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 143
138
139 cd ${S} 144 cd ${S}
140 dodir /usr/include/linux 145 dodir /usr/include/linux
146 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 147 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
142 rm -rf ${D}/usr/include/linux/modules 148 rm -rf ${D}/usr/include/linux/modules
149
143 dodir /usr/include/asm 150 dodir /usr/include/asm
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 151 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145 152
146 if [ $(kernel_is_2_6) $? == 0 ] 153 if [ $(kernel_is_2_6) $? == 0 ]
147 then 154 then
275unipatch() { 282unipatch() {
276 local i 283 local i
277 local x 284 local x
278 local extention 285 local extention
279 local PIPE_CMD 286 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 287 local UNIPATCH_DROP
281 local KPATCH_DIR 288 local KPATCH_DIR
282 local PATCH_DEPTH 289 local PATCH_DEPTH
283 local ELINE 290 local ELINE
291 local STRICT_COUNT
284 292
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 293 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 294 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 295
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 296 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
302 gz) PIPE_CMD="tar -xvzf";; 310 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 311 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 312 die "Unrecognized tarball compression";;
305 esac 313 esac
306 314
315 if [ -n "${UNIPATCH_STRICTORDER}" ]
316 then
317 STRICT_COUNT=$((${STRICT_COUNT} + 1))
318 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
319 ${PIPE_CMD} ${i} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
320 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 321 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null
322 fi
323
308 if [ $? == 0 ] 324 if [ $? == 0 ]
309 then 325 then
310 einfo "${i/*\//} unpacked" 326 einfo "${i/*\//} unpacked"
311 else 327 else
312 eerror "Failed to unpack ${i}" 328 eerror "Failed to unpack ${i}"
326 bz2) PIPE_CMD="bzip2 -dc";; 342 bz2) PIPE_CMD="bzip2 -dc";;
327 patch) PIPE_CMD="cat";; 343 patch) PIPE_CMD="cat";;
328 diff) PIPE_CMD="cat";; 344 diff) PIPE_CMD="cat";;
329 gz|Z|z) PIPE_CMD="gzip -dc";; 345 gz|Z|z) PIPE_CMD="gzip -dc";;
330 ZIP|zip) PIPE_CMD="unzip -p";; 346 ZIP|zip) PIPE_CMD="unzip -p";;
331 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";; 347 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i}";;
332 esac 348 esac
333 x=${i/*\//} 349 x=${i/*\//}
334 x=${x/\.${extention}/} 350 x=${x/\.${extention}/}
351
352 if [ -n "${UNIPATCH_STRICTORDER}" -a -n "${PIPE_CMD}" ]
353 then
354 STRICT_COUNT=$((${STRICT_COUNT} + 1))
355 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
356 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch)
357 else
335 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch 358 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch)
359 fi
336 done 360 done
337 361
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 362 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 363 x=${KPATCH_DIR}
340 KPATCH_DIR="" 364 KPATCH_DIR=""
342 do 366 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 367 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 368 done
345 369
346 #so now lets get rid of the patchno's we want to exclude 370 #so now lets get rid of the patchno's we want to exclude
371 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 372 for i in ${UNIPATCH_DROP}
348 do 373 do
349 for x in ${KPATCH_DIR} 374 for x in ${KPATCH_DIR}
350 do 375 do
351 rm ${x}/${i}_* 2>/dev/null 376 rm ${x}/${i}* 2>/dev/null
352 if [ $? == 0 ] 377 if [ $? == 0 ]
353 then 378 then
354 einfo "Excluding Patch #${i}" 379 einfo "Excluding Patch #${i}"
355 einfo "From: ${x/${WORKDIR}/}" 380 einfo "From: ${x/${WORKDIR}/}"
356 fi 381 fi
360 # and now, finally, we patch it :) 385 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 386 for x in ${KPATCH_DIR}
362 do 387 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 388 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u)
364 do 389 do
365
366
367 PATCH_DEPTH=0 390 PATCH_DEPTH=0
368 ebegin "Applying ${i/*\//}" 391 ebegin "Applying ${i/*\//}"
369 while [ ${PATCH_DEPTH} -lt 5 ] 392 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 393 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 394 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null)
423 446
424 EXTRAVERSION="${RELEASE}" 447 EXTRAVERSION="${RELEASE}"
425 448
426 if [ -n "${K_PREPATCHED}" ] 449 if [ -n "${K_PREPATCHED}" ]
427 then 450 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 451 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 452 else
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 453 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 454 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 455 fi
456
433 KV=${OKV}${EXTRAVERSION} 457 KV=${OKV}${EXTRAVERSION}
434 fi
435 458
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 459 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
437 # these cannot be supported, but the code here can handle it up until this point 460 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 461 # and theoretically thereafter.
439 462
441 then 464 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 465 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
443 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 466 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
444 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 467 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 468 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 469 KV=${PV/[-_]*/}${EXTRAVERSION}
447 fi 470 fi
448 471
449 if [ "${RELEASETYPE}" == "-bk" ] 472 if [ "${RELEASETYPE}" == "-bk" ]
450 then 473 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 474 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
452 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 475 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
453 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 476 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
454 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 477 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
455 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 478 KV=${PV/[-_]*/}${EXTRAVERSION}
456 fi 479 fi
457 480
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 481 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 482 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 483 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
461 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})" 484 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 485
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 486 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
464 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 487 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
465 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 488 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
466 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 489 KV=${PV/[-_]*/}${EXTRAVERSION}
467 fi 490 fi
468 491
469 S=${WORKDIR}/linux-${KV} 492 S=${WORKDIR}/linux-${KV}
470} 493}
471 494
509 [ "${ETYPE}" == "sources" ] && postinst_sources 532 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 533}
511 534
512pkg_setup() { 535pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 536 [ "${ETYPE}" == "headers" ] && setup_headers
537
538 # this is to fix some weird portage bug? in stable versions of portage.
539 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
514} 540}

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20