/[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.260 Revision 1.274
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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.260 2011/08/29 01:28:10 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.274 2011/12/28 13:38:05 psomas 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>
81if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 81if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
82 export CTARGET=${CATEGORY/cross-} 82 export CTARGET=${CATEGORY/cross-}
83fi 83fi
84 84
85HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" 85HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
86[[ -z ${LICENSE} ]] && \
87 LICENSE="GPL-2" 86: ${LICENSE:="GPL-2"}
88 87
89# This is the latest KV_PATCH of the deblob tool available from the 88# This is the latest KV_PATCH of the deblob tool available from the
90# libre-sources upstream. If you bump this, you MUST regenerate the Manifests 89# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
91# for ALL kernel-2 consumer packages where deblob is available. 90# for ALL kernel-2 consumer packages where deblob is available.
92[[ -z ${DEBLOB_MAX_VERSION} ]] && DEBLOB_MAX_VERSION=38 91: ${DEBLOB_MAX_VERSION:=38}
93 92
94# No need to run scanelf/strip on kernel sources/headers (bug #134453). 93# No need to run scanelf/strip on kernel sources/headers (bug #134453).
95RESTRICT="binchecks strip" 94RESTRICT="binchecks strip"
96 95
97# set LINUX_HOSTCFLAGS if not already set 96# set LINUX_HOSTCFLAGS if not already set
98[[ -z ${LINUX_HOSTCFLAGS} ]] && \
99 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 97: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
100 98
101# debugging functions 99# debugging functions
102#============================================================== 100#==============================================================
103# this function exists only to help debug kernel-2.eclass 101# this function exists only to help debug kernel-2.eclass
104# if you are adding new functionality in, put a call to it 102# if you are adding new functionality in, put a call to it
116handle_genpatches() { 114handle_genpatches() {
117 local tarball 115 local tarball
118 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1 116 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
119 117
120 debug-print "Inside handle_genpatches" 118 debug-print "Inside handle_genpatches"
121 local oldifs=${IFS}
122 export IFS="."
123 local OKV_ARRAY=( $OKV ) 119 local OKV_ARRAY
124 export IFS=${oldifs} 120 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
125 121
126 # for > 3.0 kernels, handle genpatches tarball name 122 # for > 3.0 kernels, handle genpatches tarball name
127 # genpatches for 3.0 and 3.0.1 might be named 123 # genpatches for 3.0 and 3.0.1 might be named
128 # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2 124 # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2
129 # respectively. Handle this. 125 # respectively. Handle this.
148 # this function will detect and set 144 # this function will detect and set
149 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 145 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
150 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) 146 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
151 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 147 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
152 148
153 if [[ -n ${KV_FULL} ]]; then 149 # We've already run, so nothing to do here.
154 # we will set this for backwards compatibility. 150 [[ -n ${KV_FULL} ]] && return 0
155 KV=${KV_FULL}
156
157 # we know KV_FULL so lets stop here. but not without resetting S
158 S=${WORKDIR}/linux-${KV_FULL}
159 return
160 fi
161 151
162 # CKV is used as a comparison kernel version, which is used when 152 # CKV is used as a comparison kernel version, which is used when
163 # PV doesnt reflect the genuine kernel version. 153 # PV doesnt reflect the genuine kernel version.
164 # this gets set to the portage style versioning. ie: 154 # this gets set to the portage style versioning. ie:
165 # CKV=2.6.11_rc4 155 # CKV=2.6.11_rc4
170 OKV=${OKV/-r*} 160 OKV=${OKV/-r*}
171 OKV=${OKV/_p*} 161 OKV=${OKV/_p*}
172 162
173 KV_MAJOR=$(get_version_component_range 1 ${OKV}) 163 KV_MAJOR=$(get_version_component_range 1 ${OKV})
174 # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1) 164 # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
175 local oldifs=${IFS}
176 export IFS="."
177 local OKV_ARRAY=( $OKV ) 165 local OKV_ARRAY
178 export IFS=${oldifs} 166 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
179 167
180 # if KV_MAJOR >= 3, then we have no more KV_MINOR 168 # if KV_MAJOR >= 3, then we have no more KV_MINOR
181 #if [[ ${KV_MAJOR} -lt 3 ]]; then 169 #if [[ ${KV_MAJOR} -lt 3 ]]; then
182 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then 170 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
183 KV_MINOR=$(get_version_component_range 2 ${OKV}) 171 KV_MINOR=$(get_version_component_range 2 ${OKV})
229 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}" 217 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
230 [[ -n "${K_LONGTERM}" ]] && 218 [[ -n "${K_LONGTERM}" ]] &&
231 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}" 219 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
232 else 220 else
233 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0" 221 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
234 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}" 222 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
223 if [[ ${KV_MAJOR} -ge 3 ]]; then
224 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
225 else
226 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
227 fi
228
235 [[ -n "${K_LONGTERM}" ]] && 229 [[ -n "${K_LONGTERM}" ]] &&
230 #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
236 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 231 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
237 fi 232 fi
238 233
239 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}" 234 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
240 235
382 debug-print-kernel2-variables 377 debug-print-kernel2-variables
383 378
384 handle_genpatches 379 handle_genpatches
385} 380}
386 381
382# Note: duplicated in linux-info.eclass
387kernel_is() { 383kernel_is() {
388 # ALL of these should be set before we can safely continue this function. 384 # ALL of these should be set before we can safely continue this function.
389 # some of the sources have in the past had only one set. 385 # some of the sources have in the past had only one set.
390 local v n=0 386 local v n=0
391 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done 387 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
392 [[ $n -eq 1 ]] && detect_version 388 [[ $n -eq 1 ]] && detect_version
393 unset v n 389 unset v n
394 390
395 # Now we can continue 391 # Now we can continue
396 local operator test value x=0 y=0 z=0 392 local operator test value
397 393
398 case ${1} in 394 case ${1#-} in
399 lt) operator="-lt"; shift;; 395 lt) operator="-lt"; shift;;
400 gt) operator="-gt"; shift;; 396 gt) operator="-gt"; shift;;
401 le) operator="-le"; shift;; 397 le) operator="-le"; shift;;
402 ge) operator="-ge"; shift;; 398 ge) operator="-ge"; shift;;
403 eq) operator="-eq"; shift;; 399 eq) operator="-eq"; shift;;
404 *) operator="-eq";; 400 *) operator="-eq";;
405 esac 401 esac
406
407 for x in ${@}; do
408 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
409 value="${value}${x}"
410 z=$((${z} + 1))
411
412 case ${z} in
413 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
414 test="${test}${KV_MAJOR}";;
415 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
416 test="${test}${KV_MINOR}";;
417 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
418 test="${test}${KV_PATCH}";;
419 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 402 [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
420 esac
421 done
422 403
423 [ ${test} ${operator} ${value} ] && return 0 || return 1 404 : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
405 : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
406 [ ${test} ${operator} ${value} ]
424} 407}
425 408
426kernel_is_2_4() { 409kernel_is_2_4() {
427 kernel_is 2 4 410 kernel_is 2 4
428} 411}
495 478
496 # Since we should NOT honour KBUILD_OUTPUT in headers 479 # Since we should NOT honour KBUILD_OUTPUT in headers
497 # lets unset it here. 480 # lets unset it here.
498 unset KBUILD_OUTPUT 481 unset KBUILD_OUTPUT
499 482
500 if [[ ${CTARGET} = ${CHOST} ]]; then
501 SLOT="0" 483 SLOT="0"
502 else
503 SLOT="${CTARGET}"
504 fi
505else 484else
506 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 485 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
507 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 486 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
508fi 487fi
509 488
567} 546}
568 547
569universal_unpack() { 548universal_unpack() {
570 debug-print "Inside universal_unpack" 549 debug-print "Inside universal_unpack"
571 550
572 local oldifs=${IFS}
573 export IFS="."
574 local OKV_ARRAY=( $OKV ) 551 local OKV_ARRAY
575 export IFS=${oldifs} 552 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
576 553
577 cd "${WORKDIR}" 554 cd "${WORKDIR}"
578 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then 555 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
579 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2 556 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2
580 else 557 else
1127 done 1104 done
1128 fi 1105 fi
1129 done 1106 done
1130} 1107}
1131 1108
1132# sparc nastiness
1133#==============================================================
1134# This script generates the files in /usr/include/asm for sparc systems
1135# during installation of sys-kernel/linux-headers.
1136# Will no longer be needed when full 64 bit support is used on sparc64
1137# systems.
1138#
1139# Shamefully ripped from Debian
1140# ----------------------------------------------------------------------
1141
1142# Idea borrowed from RedHat's kernel package
1143
1144# This is gonna get replaced by something in multilib.eclass soon...
1145# --eradicator
1146generate_sparc_asm() {
1147 local name
1148
1149 cd $1 || die
1150 mkdir asm
1151
1152 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
1153 name="$(echo $h | tr a-z. A-Z_)"
1154 # common header
1155 echo "/* All asm/ files are generated and point to the corresponding
1156 * file in asm-sparc or asm-sparc64.
1157 */
1158
1159#ifndef __SPARCSTUB__${name}__
1160#define __SPARCSTUB__${name}__
1161" > asm/${h}
1162
1163 # common for sparc and sparc64
1164 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
1165 echo "#ifdef __arch64__
1166#include <asm-sparc64/$h>
1167#else
1168#include <asm-sparc/$h>
1169#endif
1170" >> asm/${h}
1171
1172 # sparc only
1173 elif [ -f asm-sparc/$h ]; then
1174echo "#ifndef __arch64__
1175#include <asm-sparc/$h>
1176#endif
1177" >> asm/${h}
1178
1179 # sparc64 only
1180 else
1181echo "#ifdef __arch64__
1182#include <asm-sparc64/$h>
1183#endif
1184" >> asm/${h}
1185 fi
1186
1187 # common footer
1188 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
1189 done
1190 return 0
1191}
1192
1193headers___fix() { 1109headers___fix() {
1194 # Voodoo to partially fix broken upstream headers. 1110 # Voodoo to partially fix broken upstream headers.
1195 # note: do not put inline/asm/volatile together (breaks "inline asm volatile") 1111 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1196 sed -i \ 1112 sed -i \
1197 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \ 1113 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1278 [[ ${ETYPE} == sources ]] && postinst_sources 1194 [[ ${ETYPE} == sources ]] && postinst_sources
1279} 1195}
1280 1196
1281kernel-2_pkg_setup() { 1197kernel-2_pkg_setup() {
1282 if kernel_is 2 4; then 1198 if kernel_is 2 4; then
1283 if [ "$( gcc-major-version )" -eq "4" ] ; then 1199 if [[ $(gcc-major-version) -ge 4 ]] ; then
1284 echo 1200 echo
1285 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!" 1201 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1286 ewarn "Either switch to another gcc-version (via gcc-config) or use a" 1202 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1287 ewarn "newer kernel that supports gcc-4." 1203 ewarn "newer kernel that supports gcc-4."
1288 echo 1204 echo
1297 [[ ${ETYPE} == headers ]] && setup_headers 1213 [[ ${ETYPE} == headers ]] && setup_headers
1298 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." 1214 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1299} 1215}
1300 1216
1301kernel-2_pkg_postrm() { 1217kernel-2_pkg_postrm() {
1218 # This warning only makes sense for kernel sources.
1219 [[ ${ETYPE} == headers ]] && return 0
1220
1221 # If there isn't anything left behind, then don't complain.
1222 [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
1302 echo 1223 echo
1303 ewarn "Note: Even though you have successfully unmerged " 1224 ewarn "Note: Even though you have successfully unmerged "
1304 ewarn "your kernel package, directories in kernel source location: " 1225 ewarn "your kernel package, directories in kernel source location: "
1305 ewarn "${ROOT}usr/src/linux-${KV_FULL}" 1226 ewarn "${ROOT}usr/src/linux-${KV_FULL}"
1306 ewarn "with modified files will remain behind. By design, package managers" 1227 ewarn "with modified files will remain behind. By design, package managers"
1307 ewarn "will not remove these modified files and the directories they reside in." 1228 ewarn "will not remove these modified files and the directories they reside in."
1308 echo 1229 echo
1309} 1230}
1310

Legend:
Removed from v.1.260  
changed lines
  Added in v.1.274

  ViewVC Help
Powered by ViewVC 1.1.20