/[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.32 Revision 1.33
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2004 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.32 2004/03/14 06:43:16 seemant Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.33 2004/04/16 18:14:00 plasmaroo Exp $
4 4
5# 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
6# with back-compatibility for 2.4 6# with back-compatibility for 2.4
7# 7#
8# Author: John Mylchreest <johnm@gentoo.org> 8# Author: John Mylchreest <johnm@gentoo.org>
31# - this should _NOT_ be used from the ebuild as this is reserved for end users passing excludes from the cli 31# - this should _NOT_ be used from the ebuild as this is reserved for end users passing excludes from the cli
32# 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 33# UNIPATCH_STRICTORDER - if this is set places patches into directories of order, so they are applied in the order passed
34 34
35ECLASS="kernel-2" 35ECLASS="kernel-2"
36INHERITED="$INHERITED $ECLASS"
36EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst 37EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
37 38
38# to prevent errors if theres no sources in /usr/src 39# to prevent errors if theres no sources in /usr/src
39# we set KV and re-set it later on as well. 40# we set KV and re-set it later on as well.
40[ -z "${KV}" ] && KV=${PV} 41[ -z "${KV}" ] && KV=${PV}
51KV_PATCH=${KV_PATCH/[-_]*/} 52KV_PATCH=${KV_PATCH/[-_]*/}
52 53
53# set LINUX_HOSTCFLAGS if not already set 54# set LINUX_HOSTCFLAGS if not already set
54[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 55[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
55 56
56
57#eclass functions only from here onwards. 57#Eclass functions only from here onwards...
58#============================================================== 58#==============================================================
59kernel_is() {
60 local RESULT
61 RESULT=1
62
63 if [ -n "${1}" ]
64 then
65 [ "${1}" = "${KV_MAJOR}" ] && RESULT=0
66 fi
67
68 if [ -n "${2}" ]
69 then
70 RESULT=1
71 [ "${2}" = "${KV_MINOR}" ] && RESULT=0
72 fi
73
74 if [ -n "${3}" ]
75 then
76 RESULT=1
77 [ "${3}" = "${KV_PATCH}" ] && RESULT=0
78 fi
79 return ${RESULT}
80}
81
59kernel_is_2_4() { 82kernel_is_2_4() {
60 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1 83 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
61} 84}
62 85
63kernel_is_2_6() { 86kernel_is_2_6() {
64 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1 87 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
65} 88}
66 89
67# capture the sources type and set depends 90# Capture the sources type and set DEPENDs
68if [ "${ETYPE}" == "sources" ] 91if [ "${ETYPE}" == "sources" ]
69then 92then
70 #kbd is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 93 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
71 DEPEND="!build? ( sys-apps/sed 94 DEPEND="!build? ( sys-apps/sed
72 >=sys-devel/binutils-2.11.90.0.31 )" 95 >=sys-devel/binutils-2.11.90.0.31 )
96 >=sys-kernel/config-kernel-0.3.3"
73 97
74 RDEPEND="${DEPEND} 98 RDEPEND="${DEPEND}
75 !build? ( >=sys-libs/ncurses-5.2 99 !build? ( >=sys-libs/ncurses-5.2
76 dev-lang/perl 100 dev-lang/perl
77 sys-apps/module-init-tools 101 sys-apps/module-init-tools
97 make include/linux/version.h || die "make include/linux/version.h failed" 121 make include/linux/version.h || die "make include/linux/version.h failed"
98 echo ">>> version.h compiled successfully." 122 echo ">>> version.h compiled successfully."
99} 123}
100 124
101universal_unpack() { 125universal_unpack() {
126 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
127
128 cd ${WORKDIR}
129 unpack linux-${OKV}.tar.bz2
130 if [ "${OKV}" != "${KV}" ]
131 then
132 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
133 fi
134 cd ${S}
135
102 # remove all backup files 136 # remove all backup files
103 find . -iname "*~" -exec rm {} \; 2> /dev/null 137 find . -iname "*~" -exec rm {} \; 2> /dev/null
104 138
105 if [ -d "${S}/Documentation/DocBook" ] 139 if [ -d "${S}/Documentation/DocBook" ]
106 then 140 then
209} 243}
210 244
211# pkg_postinst functions 245# pkg_postinst functions
212#============================================================== 246#==============================================================
213postinst_sources() { 247postinst_sources() {
248 if [ -x "${ROOT}/usr/bin/config-kernel" ]
249 then
250 ${ROOT}/usr/bin/config-kernel --eclass-symlink ${KV}
214 if [ ! -h ${ROOT}usr/src/linux ] 251 elif [ ! -h ${ROOT}usr/src/linux ]
215 then 252 then
216 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux 253 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux
217 fi 254 fi
218 255
219 # Don't forget to make directory for sysfs 256 # Don't forget to make directory for sysfs
235 while read -s ELINE 272 while read -s ELINE
236 do 273 do
237 einfo "${ELINE}" 274 einfo "${ELINE}"
238 done 275 done
239 276
277 echo
278 fi
279
280 # Show policy version, if this kernel has SELinux...
281 local secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h"
282 if [ -n "`use selinux`" -a -f "$secfile" ]
283 then
284 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
285 einfo "The SELinux policy version of this kernel is $polver."
240 echo 286 echo
241 fi 287 fi
242 288
243 # if K_EXTRAEWARN is set then lets display it now 289 # if K_EXTRAEWARN is set then lets display it now
244 if [ -n "${K_EXTRAEWARN}" ] 290 if [ -n "${K_EXTRAEWARN}" ]
411 457
412 PATCH_DEPTH=0 458 PATCH_DEPTH=0
413 ebegin "Applying ${i/*\//}" 459 ebegin "Applying ${i/*\//}"
414 while [ ${PATCH_DEPTH} -lt 5 ] 460 while [ ${PATCH_DEPTH} -lt 5 ]
415 do 461 do
416 echo "Attempting Dry-run:" > ${STDERR_T} 462 echo "Attempting Dry-run:" >> ${STDERR_T}
417 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T} 463 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
418 echo "=======================================================" >> ${STDERR_T} 464 echo "=======================================================" >> ${STDERR_T}
419 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ] 465 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
420 then 466 then
421 echo "Attempting patch:" > ${STDERR_T} 467 echo "Attempting patch:" > ${STDERR_T}
467 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 513 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
468 514
469 RELEASE=${PV/${OKV}/} 515 RELEASE=${PV/${OKV}/}
470 RELEASE=${RELEASE/_beta/} 516 RELEASE=${RELEASE/_beta/}
471 RELEASE=${RELEASE/_rc/-rc} 517 RELEASE=${RELEASE/_rc/-rc}
518 if [ $(kernel_is_2_4) $? == 0 ]
519 then
520 RELEASE=${RELEASE/_pre/-pre}
521 else
472 RELEASE=${RELEASE/_pre/-bk} 522 RELEASE=${RELEASE/_pre/-bk}
523 fi
473 RELEASETYPE=${RELEASE//[0-9]/} 524 RELEASETYPE=${RELEASE//[0-9]/}
474 525
475 EXTRAVERSION="${RELEASE}" 526 EXTRAVERSION="${RELEASE}"
476 527
477 if [ -n "${K_PREPATCHED}" ] 528 if [ -n "${K_PREPATCHED}" ]
486 537
487 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 538 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
488 # these cannot be supported, but the code here can handle it up until this point 539 # these cannot be supported, but the code here can handle it up until this point
489 # and theoretically thereafter. 540 # and theoretically thereafter.
490 541
491 if [ "${RELEASETYPE}" == "-rc" ] 542 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
492 then 543 then
493 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 544 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
494 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 545 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
495 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 546 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
496 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2" 547 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
518 fi 569 fi
519 570
520 S=${WORKDIR}/linux-${KV} 571 S=${WORKDIR}/linux-${KV}
521} 572}
522 573
523
524detect_arch() { 574detect_arch() {
525 # This function sets ARCH_URI and ARCH_PATCH 575 # This function sets ARCH_URI and ARCH_PATCH
526 # with the neccessary info for the arch sepecific compatibility 576 # with the neccessary info for the arch sepecific compatibility
527 # patchsets. 577 # patchsets.
528 578
529 local ALL_ARCH 579 local ALL_ARCH
530 local LOOP_ARCH 580 local LOOP_ARCH
531 local COMPAT_URI 581 local COMPAT_URI
582 local i
532 583
584 # COMPAT_URI is the contents of ${ARCH}_URI
585 # ARCH_URI is the URI for all the ${ARCH}_URI patches
586 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
587
588 ARCH_URI=""
589 ARCH_PATCH=""
533 ALL_ARCH="X86 PPC PCC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD" 590 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
591
534 for LOOP_ARCH in ${ALL_ARCH} 592 for LOOP_ARCH in ${ALL_ARCH}
535 do 593 do
536 COMPAT_URI="${LOOP_ARCH}_URI" 594 COMPAT_URI="${LOOP_ARCH}_URI"
537 COMPAT_URI="${!COMPAT_URI}" 595 COMPAT_URI="${!COMPAT_URI}"
538 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
539 596
540 [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ] && ARCH_PATCH="${DISTDIR}/${COMPAT_URI/*\//}" 597 [ -n "${COMPAT_URI}" ] && ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
598
599 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ]
600 then
601 for i in ${COMPAT_URI}
602 do
603 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
604 done
605 fi
541 done 606 done
542} 607}
543 608
544 609
545# common functions 610# common functions
546#============================================================== 611#==============================================================
547src_unpack() { 612kernel-2_src_unpack() {
548 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
549
550 cd ${WORKDIR}
551 unpack linux-${OKV}.tar.bz2
552 if [ "${OKV}" != "${KV}" ]
553 then
554 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
555 fi
556 cd ${S}
557
558 universal_unpack 613 universal_unpack
559 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}" 614 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
560 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 615 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
561 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 616 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
562} 617}
563 618
564src_compile() { 619kernel-2_src_compile() {
565 [ "${ETYPE}" == "headers" ] && compile_headers 620 [ "${ETYPE}" == "headers" ] && compile_headers
566} 621}
567 622
568pkg_preinst() { 623kernel-2_pkg_preinst() {
569 [ "${ETYPE}" == "headers" ] && preinst_headers 624 [ "${ETYPE}" == "headers" ] && preinst_headers
570} 625}
571 626
572src_install() { 627kernel-2_src_install() {
573 install_universal 628 install_universal
574 [ "${ETYPE}" == "headers" ] && install_headers 629 [ "${ETYPE}" == "headers" ] && install_headers
575 [ "${ETYPE}" == "sources" ] && install_sources 630 [ "${ETYPE}" == "sources" ] && install_sources
576} 631}
577 632
578pkg_postinst() { 633kernel-2_pkg_postinst() {
579 [ "${ETYPE}" == "headers" ] && postinst_headers 634 [ "${ETYPE}" == "headers" ] && postinst_headers
580 [ "${ETYPE}" == "sources" ] && postinst_sources 635 [ "${ETYPE}" == "sources" ] && postinst_sources
581} 636}
582 637
583pkg_setup() { 638kernel-2_pkg_setup() {
584 [ "${ETYPE}" == "headers" ] && setup_headers 639 [ "${ETYPE}" == "headers" ] && setup_headers
585 640
586 # this is to fix some weird portage bug? in stable versions of portage. 641 # This is to fix some weird portage bug? in stable versions of portage.
587 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..." 642 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
588} 643}

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20