/[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.221 Revision 1.234
1# Copyright 1999-2009 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.221 2009/10/20 19:17:59 zmedico Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.234 2010/05/20 23:11:48 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>
43# combination of "base" and "extras" 43# combination of "base" and "extras"
44# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply. 44# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
45# A value of "5" would apply genpatches-2.6.12-5 to 45# A value of "5" would apply genpatches-2.6.12-5 to
46# my-sources-2.6.12.ebuild 46# my-sources-2.6.12.ebuild
47# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security 47# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
48# K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob
49# code. If empty, will be set to "1" if deblobbing is
50# possible. Test ONLY for "1".
51# K_PREDEBLOBBED - This kernel was already deblobbed elsewhere.
52# If false, either optional deblobbing will be available
53# or the license will note the inclusion of freedist
54# code.
48 55
49# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which 56# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
50# can be supported by the headers ebuild 57# can be supported by the headers ebuild
51 58
52# UNIPATCH_LIST - space delimetered list of patches to be applied to the 59# UNIPATCH_LIST - space delimetered list of patches to be applied to the
72if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 79if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
73 export CTARGET=${CATEGORY/cross-} 80 export CTARGET=${CATEGORY/cross-}
74fi 81fi
75 82
76HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" 83HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
84[[ -z ${LICENSE} ]] && \
77LICENSE="GPL-2" 85 LICENSE="GPL-2"
86
87# This is the latest KV_PATCH of the deblob tool available from the
88# libre-sources upstream.
89[[ -z ${DEBLOB_MAX_VERSION} ]] && DEBLOB_MAX_VERSION=33
78 90
79# No need to run scanelf/strip on kernel sources/headers (bug #134453). 91# No need to run scanelf/strip on kernel sources/headers (bug #134453).
80RESTRICT="binchecks strip" 92RESTRICT="binchecks strip"
81 93
82# set LINUX_HOSTCFLAGS if not already set 94# set LINUX_HOSTCFLAGS if not already set
87#============================================================== 99#==============================================================
88# this function exists only to help debug kernel-2.eclass 100# this function exists only to help debug kernel-2.eclass
89# if you are adding new functionality in, put a call to it 101# 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. 102# at the start of src_unpack, or during SRC_URI/dep generation.
91debug-print-kernel2-variables() { 103debug-print-kernel2-variables() {
92 debug-print "PVR: ${PVR}" 104 for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
93 debug-print "CKV: ${CKV}" 105 RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
94 debug-print "OKV: ${OKV}" 106 UNIPATCH_LIST S KERNEL_URI ; do
95 debug-print "KV: ${KV}" 107 debug-print "${v}: ${!v}"
96 debug-print "KV_FULL: ${KV_FULL}" 108 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} 109}
105 110
106#Eclass functions only from here onwards ... 111#Eclass functions only from here onwards ...
107#============================================================== 112#==============================================================
108handle_genpatches() { 113handle_genpatches() {
151 KV_EXTRA=${KV_EXTRA/[-_]*} 156 KV_EXTRA=${KV_EXTRA/[-_]*}
152 else 157 else
153 KV_PATCH=$(get_version_component_range 3- ${OKV}) 158 KV_PATCH=$(get_version_component_range 3- ${OKV})
154 fi 159 fi
155 KV_PATCH=${KV_PATCH/[-_]*} 160 KV_PATCH=${KV_PATCH/[-_]*}
161
162 local v n=0 missing
163 for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
164 [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
165 done
166 [[ $n -eq 1 ]] && \
167 eerror "Missing variables: ${missing}" && \
168 die "Failed to extract kernel version (try explicit CKV in ebuild)!"
169 unset v n missing
156 170
157 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 171 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
158 172
159 RELEASE=${CKV/${OKV}} 173 RELEASE=${CKV/${OKV}}
160 RELEASE=${RELEASE/_beta} 174 RELEASE=${RELEASE/_beta}
161 RELEASE=${RELEASE/_rc/-rc} 175 RELEASE=${RELEASE/_rc/-rc}
162 RELEASE=${RELEASE/_pre/-pre} 176 RELEASE=${RELEASE/_pre/-pre}
177 # We cannot trivally call kernel_is here, because it calls us to detect the
178 # version
163 kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git} 179 #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
180 [ $(($KV_MAJOR * 1000 + $KV_MINOR)) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
164 RELEASETYPE=${RELEASE//[0-9]} 181 RELEASETYPE=${RELEASE//[0-9]}
165 182
166 # Now we know that RELEASE is the -rc/-git 183 # Now we know that RELEASE is the -rc/-git
167 # and RELEASETYPE is the same but with its numerics stripped 184 # and RELEASETYPE is the same but with its numerics stripped
168 # we can work on better sorting EXTRAVERSION. 185 # we can work on better sorting EXTRAVERSION.
243 260
244 handle_genpatches 261 handle_genpatches
245} 262}
246 263
247kernel_is() { 264kernel_is() {
265 # ALL of these should be set before we can safely continue this function.
266 # some of the sources have in the past had only one set.
267 local v n=0
268 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
248 [[ -z ${OKV} ]] && detect_version 269 [[ $n -eq 1 ]] && detect_version
270 unset v n
271
272 # Now we can continue
249 local operator test value x=0 y=0 z=0 273 local operator test value x=0 y=0 z=0
250 274
251 case ${1} in 275 case ${1} in
252 lt) operator="-lt"; shift;; 276 lt) operator="-lt"; shift;;
253 gt) operator="-gt"; shift;; 277 gt) operator="-gt"; shift;;
288if [[ ${ETYPE} == sources ]]; then 312if [[ ${ETYPE} == sources ]]; then
289 DEPEND="!build? ( sys-apps/sed 313 DEPEND="!build? ( sys-apps/sed
290 >=sys-devel/binutils-2.11.90.0.31 )" 314 >=sys-devel/binutils-2.11.90.0.31 )"
291 RDEPEND="!build? ( >=sys-libs/ncurses-5.2 315 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
292 sys-devel/make )" 316 sys-devel/make )"
293 PDEPEND="virtual/dev-manager" 317 PDEPEND="!build? ( virtual/dev-manager )"
294 318
295 PROVIDE="virtual/linux-sources" 319 PROVIDE="virtual/linux-sources"
296 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa" 320 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
297 321
298 SLOT="${PVR}" 322 SLOT="${PVR}"
299 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel" 323 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
300 IUSE="symlink build" 324 IUSE="symlink build"
325
326 # Bug #266157, deblob for libre support
327 if [[ -z ${K_PREDEBLOBBED} ]] ; then
328 if [[ -z ${K_DEBLOB_AVAILABLE} ]] ; then
329 kernel_is ge 2 6 27 && \
330 kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
331 K_DEBLOB_AVAILABLE=1
332 fi
333 if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
334 IUSE="${IUSE} deblob"
335 # Reflect that kernels contain firmware blobs unless otherwise
336 # stripped
337 LICENSE="${LICENSE} !deblob? ( freedist )"
338
339 DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
340 DEBLOB_A="deblob-${DEBLOB_PV}"
341 DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
342 HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
343
344 KERNEL_URI="${KERNEL_URI}
345 deblob? (
346 ${DEBLOB_HOMEPAGE}/download/releases/LATEST-${DEBLOB_PV}.N/${DEBLOB_A}
347 )"
348 else
349 # We have no way to deblob older kernels, so just mark them as
350 # tainted with non-libre materials.
351 LICENSE="${LICENSE} freedist"
352 fi
353 fi
354
301elif [[ ${ETYPE} == headers ]]; then 355elif [[ ${ETYPE} == headers ]]; then
302 DESCRIPTION="Linux system headers" 356 DESCRIPTION="Linux system headers"
303 357
304 # Since we should NOT honour KBUILD_OUTPUT in headers 358 # Since we should NOT honour KBUILD_OUTPUT in headers
305 # lets unset it here. 359 # lets unset it here.
375 || die "make include/linux/version.h failed" 429 || die "make include/linux/version.h failed"
376 rm -f .config >/dev/null 430 rm -f .config >/dev/null
377} 431}
378 432
379universal_unpack() { 433universal_unpack() {
380 cd ${WORKDIR} 434 cd "${WORKDIR}"
381 unpack linux-${OKV}.tar.bz2 435 unpack linux-${OKV}.tar.bz2
382 if [[ -d "linux" ]]; then 436 if [[ -d "linux" ]]; then
383 mv linux linux-${KV_FULL} \ 437 mv linux linux-${KV_FULL} \
384 || die "Unable to move source tree to ${KV_FULL}." 438 || die "Unable to move source tree to ${KV_FULL}."
385 elif [[ "${OKV}" != "${KV_FULL}" ]]; then 439 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
489 543
490# install functions 544# install functions
491#============================================================== 545#==============================================================
492install_universal() { 546install_universal() {
493 #fix silly permissions in tarball 547 #fix silly permissions in tarball
494 cd ${WORKDIR} 548 cd "${WORKDIR}"
495 chown -R root:0 * >& /dev/null 549 chown -R root:0 * >& /dev/null
496 chmod -R a+r-w+X,u+w * 550 chmod -R a+r-w+X,u+w *
497 cd ${OLDPWD} 551 cd ${OLDPWD}
498} 552}
499 553
544 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch 598 [[ ! -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 599 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
546 ;; 600 ;;
547 powerpc) 601 powerpc)
548 dodir ${ddir}/asm 602 dodir ${ddir}/asm
549 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm 603 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
550 if [[ -e "${S}"/include/asm-ppc ]] ; then 604 if [[ -e "${S}"/include/asm-ppc ]] ; then
551 dodir ${ddir}/asm-ppc 605 dodir ${ddir}/asm-ppc
552 cp -pPR "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc 606 cp -pPR "${S}"/include/asm-ppc/* "${D}"/${ddir}/asm-ppc
553 fi 607 fi
554 ;; 608 ;;
555 *) 609 *)
556 dodir ${ddir}/asm 610 dodir ${ddir}/asm
557 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm 611 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
558 ;; 612 ;;
559 esac 613 esac
560 if [[ -n ${multi_dirs} ]] ; then 614 if [[ -n ${multi_dirs} ]] ; then
561 local d ml_inc="" 615 local d ml_inc=""
562 for d in ${multi_dirs} ; do 616 for d in ${multi_dirs} ; do
563 dodir ${ddir}/asm-${d} 617 dodir ${ddir}/asm-${d}
564 cp -pPR "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed" 618 cp -pPR "${S}"/include/asm-${d}/* "${D}"/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
565 619
566 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}" 620 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
567 multi_defs=${multi_defs#* } 621 multi_defs=${multi_defs#* }
568 done 622 done
569 create_ml_includes ${ddir}/asm ${ml_inc} 623 create_ml_includes ${ddir}/asm ${ml_inc}
570 fi 624 fi
571 625
572 if kernel_is 2 6; then 626 if kernel_is 2 6; then
573 dodir ${ddir}/asm-generic 627 dodir ${ddir}/asm-generic
574 cp -pPR "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic 628 cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
575 fi 629 fi
576 630
577 # clean up 631 # clean up
578 find "${D}" -name '*.orig' -exec rm -f {} \; 632 find "${D}" -name '*.orig' -exec rm -f {} \;
579 633
603 [[ -f ${FILESDIR}/../ChangeLog ]] && \ 657 [[ -f ${FILESDIR}/../ChangeLog ]] && \
604 echo "Please check the ebuild ChangeLog for more details." \ 658 echo "Please check the ebuild ChangeLog for more details." \
605 > "${S}"/patches.txt 659 > "${S}"/patches.txt
606 fi 660 fi
607 661
608 mv ${WORKDIR}/linux* ${D}/usr/src 662 mv ${WORKDIR}/linux* "${D}"/usr/src
609} 663}
610 664
611# pkg_preinst functions 665# pkg_preinst functions
612#============================================================== 666#==============================================================
613preinst_headers() { 667preinst_headers() {
622 local MAKELINK=0 676 local MAKELINK=0
623 677
624 # if we have USE=symlink, then force K_SYMLINK=1 678 # if we have USE=symlink, then force K_SYMLINK=1
625 use symlink && K_SYMLINK=1 679 use symlink && K_SYMLINK=1
626 680
681 # if we're using a deblobbed kernel, it's not supported
682 [[ $K_DEBLOB_AVAILABLE == 1 ]] && \
683 use deblob && \
684 K_SECURITY_UNSUPPORTED=deblob
685
627 # if we are to forcably symlink, delete it if it already exists first. 686 # if we are to forcably symlink, delete it if it already exists first.
628 if [[ ${K_SYMLINK} > 0 ]]; then 687 if [[ ${K_SYMLINK} > 0 ]]; then
629 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux 688 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
630 MAKELINK=1 689 MAKELINK=1
631 fi 690 fi
632 691
633 # if the link doesnt exist, lets create it 692 # if the link doesnt exist, lets create it
634 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 693 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
635 694
636 if [[ ${MAKELINK} == 1 ]]; then 695 if [[ ${MAKELINK} == 1 ]]; then
637 cd ${ROOT}usr/src 696 cd "${ROOT}"usr/src
638 ln -sf linux-${KV_FULL} linux 697 ln -sf linux-${KV_FULL} linux
639 cd ${OLDPWD} 698 cd ${OLDPWD}
640 fi 699 fi
641 700
642 # Don't forget to make directory for sysfs 701 # Don't forget to make directory for sysfs
665 echo ${K_EXTRAEWARN} | fmt | 724 echo ${K_EXTRAEWARN} | fmt |
666 while read -s ELINE; do ewarn "${ELINE}"; done 725 while read -s ELINE; do ewarn "${ELINE}"; done
667 fi 726 fi
668 727
669 # optionally display security unsupported message 728 # optionally display security unsupported message
729 # Start with why
730 if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
731 ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security."
732 elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
733 ewarn "${PN} is UNSUPPORTED by Gentoo Security."
734 fi
735 # And now the general message.
670 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then 736 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
671 echo
672 ewarn "${PN} is UNSUPPORTED by Gentoo Security."
673 ewarn "This means that it is likely to be vulnerable to recent security issues." 737 ewarn "This means that it is likely to be vulnerable to recent security issues."
674 ewarn "For specific information on why this kernel is unsupported, please read:" 738 ewarn "For specific information on why this kernel is unsupported, please read:"
675 ewarn "http://www.gentoo.org/proj/en/security/kernel.xml" 739 ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
676 fi 740 fi
677 741
886 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite, 950 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
887 # which is why I'm not taking too much time over this. 951 # which is why I'm not taking too much time over this.
888 local tmp 952 local tmp
889 for i in ${UNIPATCH_DOCS}; do 953 for i in ${UNIPATCH_DOCS}; do
890 tmp="${tmp} ${i//*\/}" 954 tmp="${tmp} ${i//*\/}"
891 cp -f ${i} ${T}/ 955 cp -f ${i} "${T}"/
892 done 956 done
893 UNIPATCH_DOCS="${tmp}" 957 UNIPATCH_DOCS="${tmp}"
894 958
895 # clean up KPATCH_DIR's - fixes bug #53610 959 # clean up KPATCH_DIR's - fixes bug #53610
896 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done 960 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
1042 1106
1043 # allow ebuilds to massage the source tree after patching but before 1107 # allow ebuilds to massage the source tree after patching but before
1044 # we run misc `make` functions below 1108 # we run misc `make` functions below
1045 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake 1109 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
1046 1110
1111 debug-print "Doing epatch_user"
1112 epatch_user
1113
1047 debug-print "Doing unpack_set_extraversion" 1114 debug-print "Doing unpack_set_extraversion"
1048 1115
1049 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 1116 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
1050 unpack_fix_install_path 1117 unpack_fix_install_path
1051 1118
1059 # unpack_2_6 should now be 2.6.17 safe anyways 1126 # unpack_2_6 should now be 2.6.17 safe anyways
1060 if [[ ${ETYPE} == headers ]]; then 1127 if [[ ${ETYPE} == headers ]]; then
1061 kernel_is 2 4 && unpack_2_4 1128 kernel_is 2 4 && unpack_2_4
1062 kernel_is 2 6 && unpack_2_6 1129 kernel_is 2 6 && unpack_2_6
1063 fi 1130 fi
1131
1132 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1133 cp "${DISTDIR}/${DEBLOB_A}" "${T}"
1134 chmod +x "${T}/${DEBLOB_A}"
1135 fi
1064} 1136}
1065 1137
1066kernel-2_src_compile() { 1138kernel-2_src_compile() {
1067 cd "${S}" 1139 cd "${S}"
1068 [[ ${ETYPE} == headers ]] && compile_headers 1140 [[ ${ETYPE} == headers ]] && compile_headers
1141
1142 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1143 echo ">>> Running deblob script ..."
1144 sh "${T}/${DEBLOB_A}" --force || \
1145 die "Deblob script failed to run!!!"
1146 fi
1069} 1147}
1070 1148
1071kernel-2_pkg_preinst() { 1149kernel-2_pkg_preinst() {
1072 [[ ${ETYPE} == headers ]] && preinst_headers 1150 [[ ${ETYPE} == headers ]] && preinst_headers
1073} 1151}

Legend:
Removed from v.1.221  
changed lines
  Added in v.1.234

  ViewVC Help
Powered by ViewVC 1.1.20