/[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.216 Revision 1.229
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2009 Gentoo Foundation
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.216 2008/11/13 23:50:55 mpagano Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.229 2010/04/26 07:15:03 robbat2 Exp $
4 4
5# Description: kernel.eclass rewrite for a clean base regarding the 2.6 5# Description: kernel.eclass rewrite for a clean base regarding the 2.6
6# series of kernel with back-compatibility for 2.4 6# series of kernel with back-compatibility for 2.4
7# 7#
8# Original author: John Mylchreest <johnm@gentoo.org> 8# Original author: John Mylchreest <johnm@gentoo.org>
72if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 72if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
73 export CTARGET=${CATEGORY/cross-} 73 export CTARGET=${CATEGORY/cross-}
74fi 74fi
75 75
76HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" 76HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
77[[ -z ${LICENSE} ]] && \
77LICENSE="GPL-2" 78 LICENSE="GPL-2"
78 79
79# No need to run scanelf/strip on kernel sources/headers (bug #134453). 80# No need to run scanelf/strip on kernel sources/headers (bug #134453).
80RESTRICT="binchecks strip" 81RESTRICT="binchecks strip"
81 82
82# set LINUX_HOSTCFLAGS if not already set 83# set LINUX_HOSTCFLAGS if not already set
87#============================================================== 88#==============================================================
88# this function exists only to help debug kernel-2.eclass 89# this function exists only to help debug kernel-2.eclass
89# if you are adding new functionality in, put a call to it 90# if you are adding new functionality in, put a call to it
90# at the start of src_unpack, or during SRC_URI/dep generation. 91# at the start of src_unpack, or during SRC_URI/dep generation.
91debug-print-kernel2-variables() { 92debug-print-kernel2-variables() {
92 debug-print "PVR: ${PVR}" 93 for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
93 debug-print "CKV: ${CKV}" 94 RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
94 debug-print "OKV: ${OKV}" 95 UNIPATCH_LIST S KERNEL_URI ; do
95 debug-print "KV: ${KV}" 96 debug-print "${v}: ${!v}"
96 debug-print "KV_FULL: ${KV_FULL}" 97 done
97 debug-print "RELEASETYPE: ${RELEASETYPE}"
98 debug-print "RELEASE: ${RELEASE}"
99 debug-print "UNIPATCH_LIST_DEFAULT: ${UNIPATCH_LIST_DEFAULT} "
100 debug-print "UNIPATCH_LIST_GENPATCHES: ${UNIPATCH_LIST_GENPATCHES} "
101 debug-print "UNIPATCH_LIST: ${UNIPATCH_LIST}"
102 debug-print "S: ${S}"
103 debug-print "KERNEL_URI: ${KERNEL_URI}"
104} 98}
105 99
106#Eclass functions only from here onwards ... 100#Eclass functions only from here onwards ...
107#============================================================== 101#==============================================================
108handle_genpatches() { 102handle_genpatches() {
109 local tarball 103 local tarball
110 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return -1 104 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
111 105
112 for i in ${K_WANT_GENPATCHES} ; do 106 for i in ${K_WANT_GENPATCHES} ; do
113 tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2" 107 tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
114 GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}" 108 GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
115 UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}" 109 UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
243 237
244 handle_genpatches 238 handle_genpatches
245} 239}
246 240
247kernel_is() { 241kernel_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
248 [[ -z ${OKV} ]] && detect_version 246 [[ $n -eq 1 ]] && detect_version
247 unset v n
248
249 # Now we can continue
249 local operator test value x=0 y=0 z=0 250 local operator test value x=0 y=0 z=0
250 251
251 case ${1} in 252 case ${1} in
252 lt) operator="-lt"; shift;; 253 lt) operator="-lt"; shift;;
253 gt) operator="-gt"; shift;; 254 gt) operator="-gt"; shift;;
287# Capture the sources type and set DEPENDs 288# Capture the sources type and set DEPENDs
288if [[ ${ETYPE} == sources ]]; then 289if [[ ${ETYPE} == sources ]]; then
289 DEPEND="!build? ( sys-apps/sed 290 DEPEND="!build? ( sys-apps/sed
290 >=sys-devel/binutils-2.11.90.0.31 )" 291 >=sys-devel/binutils-2.11.90.0.31 )"
291 RDEPEND="!build? ( >=sys-libs/ncurses-5.2 292 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
292 sys-devel/make ) 293 sys-devel/make )"
293 virtual/dev-manager" 294 PDEPEND="!build? ( virtual/dev-manager )"
294 295
295 PROVIDE="virtual/linux-sources" 296 PROVIDE="virtual/linux-sources"
296 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa" 297 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
297 298
298 SLOT="${PVR}" 299 SLOT="${PVR}"
299 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel" 300 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
300 IUSE="symlink build" 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
301elif [[ ${ETYPE} == headers ]]; then 330elif [[ ${ETYPE} == headers ]]; then
302 DESCRIPTION="Linux system headers" 331 DESCRIPTION="Linux system headers"
303 332
304 # Since we should NOT honour KBUILD_OUTPUT in headers 333 # Since we should NOT honour KBUILD_OUTPUT in headers
305 # lets unset it here. 334 # lets unset it here.
375 || die "make include/linux/version.h failed" 404 || die "make include/linux/version.h failed"
376 rm -f .config >/dev/null 405 rm -f .config >/dev/null
377} 406}
378 407
379universal_unpack() { 408universal_unpack() {
380 cd ${WORKDIR} 409 cd "${WORKDIR}"
381 unpack linux-${OKV}.tar.bz2 410 unpack linux-${OKV}.tar.bz2
382 if [[ -d "linux" ]]; then 411 if [[ -d "linux" ]]; then
383 mv linux linux-${KV_FULL} \ 412 mv linux linux-${KV_FULL} \
384 || die "Unable to move source tree to ${KV_FULL}." 413 || die "Unable to move source tree to ${KV_FULL}."
385 elif [[ "${OKV}" != "${KV_FULL}" ]]; then 414 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
489 518
490# install functions 519# install functions
491#============================================================== 520#==============================================================
492install_universal() { 521install_universal() {
493 #fix silly permissions in tarball 522 #fix silly permissions in tarball
494 cd ${WORKDIR} 523 cd "${WORKDIR}"
495 chown -R root:0 * 524 chown -R root:0 * >& /dev/null
496 chmod -R a+r-w+X,u+w * 525 chmod -R a+r-w+X,u+w *
497 cd ${OLDPWD} 526 cd ${OLDPWD}
498} 527}
499 528
500install_headers() { 529install_headers() {
544 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch 573 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
545 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc 574 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
546 ;; 575 ;;
547 powerpc) 576 powerpc)
548 dodir ${ddir}/asm 577 dodir ${ddir}/asm
549 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm 578 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
550 if [[ -e "${S}"/include/asm-ppc ]] ; then 579 if [[ -e "${S}"/include/asm-ppc ]] ; then
551 dodir ${ddir}/asm-ppc 580 dodir ${ddir}/asm-ppc
552 cp -pPR "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc 581 cp -pPR "${S}"/include/asm-ppc/* "${D}"/${ddir}/asm-ppc
553 fi 582 fi
554 ;; 583 ;;
555 *) 584 *)
556 dodir ${ddir}/asm 585 dodir ${ddir}/asm
557 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm 586 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
558 ;; 587 ;;
559 esac 588 esac
560 if [[ -n ${multi_dirs} ]] ; then 589 if [[ -n ${multi_dirs} ]] ; then
561 local d ml_inc="" 590 local d ml_inc=""
562 for d in ${multi_dirs} ; do 591 for d in ${multi_dirs} ; do
563 dodir ${ddir}/asm-${d} 592 dodir ${ddir}/asm-${d}
564 cp -pPR "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed" 593 cp -pPR "${S}"/include/asm-${d}/* "${D}"/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
565 594
566 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}" 595 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
567 multi_defs=${multi_defs#* } 596 multi_defs=${multi_defs#* }
568 done 597 done
569 create_ml_includes ${ddir}/asm ${ml_inc} 598 create_ml_includes ${ddir}/asm ${ml_inc}
570 fi 599 fi
571 600
572 if kernel_is 2 6; then 601 if kernel_is 2 6; then
573 dodir ${ddir}/asm-generic 602 dodir ${ddir}/asm-generic
574 cp -pPR "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic 603 cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
575 fi 604 fi
576 605
577 # clean up 606 # clean up
578 find "${D}" -name '*.orig' -exec rm -f {} \; 607 find "${D}" -name '*.orig' -exec rm -f {} \;
579 608
603 [[ -f ${FILESDIR}/../ChangeLog ]] && \ 632 [[ -f ${FILESDIR}/../ChangeLog ]] && \
604 echo "Please check the ebuild ChangeLog for more details." \ 633 echo "Please check the ebuild ChangeLog for more details." \
605 > "${S}"/patches.txt 634 > "${S}"/patches.txt
606 fi 635 fi
607 636
608 mv ${WORKDIR}/linux* ${D}/usr/src 637 mv ${WORKDIR}/linux* "${D}"/usr/src
609} 638}
610 639
611# pkg_preinst functions 640# pkg_preinst functions
612#============================================================== 641#==============================================================
613preinst_headers() { 642preinst_headers() {
622 local MAKELINK=0 651 local MAKELINK=0
623 652
624 # if we have USE=symlink, then force K_SYMLINK=1 653 # if we have USE=symlink, then force K_SYMLINK=1
625 use symlink && K_SYMLINK=1 654 use symlink && K_SYMLINK=1
626 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
627 # if we are to forcably symlink, delete it if it already exists first. 661 # if we are to forcably symlink, delete it if it already exists first.
628 if [[ ${K_SYMLINK} > 0 ]]; then 662 if [[ ${K_SYMLINK} > 0 ]]; then
629 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux 663 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
630 MAKELINK=1 664 MAKELINK=1
631 fi 665 fi
632 666
633 # if the link doesnt exist, lets create it 667 # if the link doesnt exist, lets create it
634 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 668 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
635 669
636 if [[ ${MAKELINK} == 1 ]]; then 670 if [[ ${MAKELINK} == 1 ]]; then
637 cd ${ROOT}usr/src 671 cd "${ROOT}"usr/src
638 ln -sf linux-${KV_FULL} linux 672 ln -sf linux-${KV_FULL} linux
639 cd ${OLDPWD} 673 cd ${OLDPWD}
640 fi 674 fi
641 675
642 # Don't forget to make directory for sysfs 676 # Don't forget to make directory for sysfs
816 x=${KPATCH_DIR} 850 x=${KPATCH_DIR}
817 KPATCH_DIR="" 851 KPATCH_DIR=""
818 for i in $(find ${x} -type d | sort -n); do 852 for i in $(find ${x} -type d | sort -n); do
819 KPATCH_DIR="${KPATCH_DIR} ${i}" 853 KPATCH_DIR="${KPATCH_DIR} ${i}"
820 done 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
821 868
822 #so now lets get rid of the patchno's we want to exclude 869 #so now lets get rid of the patchno's we want to exclude
823 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}" 870 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
824 for i in ${UNIPATCH_DROP}; do 871 for i in ${UNIPATCH_DROP}; do
825 ebegin "Excluding Patch #${i}" 872 ebegin "Excluding Patch #${i}"
873 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite, 920 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
874 # which is why I'm not taking too much time over this. 921 # which is why I'm not taking too much time over this.
875 local tmp 922 local tmp
876 for i in ${UNIPATCH_DOCS}; do 923 for i in ${UNIPATCH_DOCS}; do
877 tmp="${tmp} ${i//*\/}" 924 tmp="${tmp} ${i//*\/}"
878 cp -f ${i} ${T}/ 925 cp -f ${i} "${T}"/
879 done 926 done
880 UNIPATCH_DOCS="${tmp}" 927 UNIPATCH_DOCS="${tmp}"
881 928
882 # clean up KPATCH_DIR's - fixes bug #53610 929 # clean up KPATCH_DIR's - fixes bug #53610
883 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done 930 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
1029 1076
1030 # allow ebuilds to massage the source tree after patching but before 1077 # allow ebuilds to massage the source tree after patching but before
1031 # we run misc `make` functions below 1078 # we run misc `make` functions below
1032 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake 1079 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
1033 1080
1081 debug-print "Doing epatch_user"
1082 epatch_user
1083
1034 debug-print "Doing unpack_set_extraversion" 1084 debug-print "Doing unpack_set_extraversion"
1035 1085
1036 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 1086 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
1037 unpack_fix_install_path 1087 unpack_fix_install_path
1038 1088
1046 # unpack_2_6 should now be 2.6.17 safe anyways 1096 # unpack_2_6 should now be 2.6.17 safe anyways
1047 if [[ ${ETYPE} == headers ]]; then 1097 if [[ ${ETYPE} == headers ]]; then
1048 kernel_is 2 4 && unpack_2_4 1098 kernel_is 2 4 && unpack_2_4
1049 kernel_is 2 6 && unpack_2_6 1099 kernel_is 2 6 && unpack_2_6
1050 fi 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
1051} 1106}
1052 1107
1053kernel-2_src_compile() { 1108kernel-2_src_compile() {
1054 cd "${S}" 1109 cd "${S}"
1055 [[ ${ETYPE} == headers ]] && compile_headers 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
1056} 1117}
1057 1118
1058kernel-2_pkg_preinst() { 1119kernel-2_pkg_preinst() {
1059 [[ ${ETYPE} == headers ]] && preinst_headers 1120 [[ ${ETYPE} == headers ]] && preinst_headers
1060} 1121}

Legend:
Removed from v.1.216  
changed lines
  Added in v.1.229

  ViewVC Help
Powered by ViewVC 1.1.20