/[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.271
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.271 2011/12/08 19:39:44 vapier 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.
170 OKV=${OKV/-r*} 166 OKV=${OKV/-r*}
171 OKV=${OKV/_p*} 167 OKV=${OKV/_p*}
172 168
173 KV_MAJOR=$(get_version_component_range 1 ${OKV}) 169 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) 170 # 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 ) 171 local OKV_ARRAY
178 export IFS=${oldifs} 172 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
179 173
180 # if KV_MAJOR >= 3, then we have no more KV_MINOR 174 # if KV_MAJOR >= 3, then we have no more KV_MINOR
181 #if [[ ${KV_MAJOR} -lt 3 ]]; then 175 #if [[ ${KV_MAJOR} -lt 3 ]]; then
182 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then 176 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
183 KV_MINOR=$(get_version_component_range 2 ${OKV}) 177 KV_MINOR=$(get_version_component_range 2 ${OKV})
229 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}" 223 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
230 [[ -n "${K_LONGTERM}" ]] && 224 [[ -n "${K_LONGTERM}" ]] &&
231 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}" 225 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
232 else 226 else
233 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0" 227 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
234 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}" 228 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
229 if [[ ${KV_MAJOR} -ge 3 ]]; then
230 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
231 else
232 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
233 fi
234
235 [[ -n "${K_LONGTERM}" ]] && 235 [[ -n "${K_LONGTERM}" ]] &&
236 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
236 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 237 #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
237 fi 238 fi
238 239
239 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}" 240 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
240 241
241 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then 242 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
391 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done 392 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
392 [[ $n -eq 1 ]] && detect_version 393 [[ $n -eq 1 ]] && detect_version
393 unset v n 394 unset v n
394 395
395 # Now we can continue 396 # Now we can continue
396 local operator test value x=0 y=0 z=0 397 local operator test value
397 398
398 case ${1} in 399 case $1 in
399 lt) operator="-lt"; shift;; 400 lt) operator="-lt"; shift;;
400 gt) operator="-gt"; shift;; 401 gt) operator="-gt"; shift;;
401 le) operator="-le"; shift;; 402 le) operator="-le"; shift;;
402 ge) operator="-ge"; shift;; 403 ge) operator="-ge"; shift;;
403 eq) operator="-eq"; shift;; 404 eq) operator="-eq"; shift;;
404 *) operator="-eq";; 405 *) operator="-eq";;
405 esac 406 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.";; 407 [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
420 esac
421 done
422 408
423 [ ${test} ${operator} ${value} ] && return 0 || return 1 409 : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
410 : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
411 [ ${test} ${operator} ${value} ]
424} 412}
425 413
426kernel_is_2_4() { 414kernel_is_2_4() {
427 kernel_is 2 4 415 kernel_is 2 4
428} 416}
495 483
496 # Since we should NOT honour KBUILD_OUTPUT in headers 484 # Since we should NOT honour KBUILD_OUTPUT in headers
497 # lets unset it here. 485 # lets unset it here.
498 unset KBUILD_OUTPUT 486 unset KBUILD_OUTPUT
499 487
500 if [[ ${CTARGET} = ${CHOST} ]]; then
501 SLOT="0" 488 SLOT="0"
502 else
503 SLOT="${CTARGET}"
504 fi
505else 489else
506 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 490 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
507 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 491 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
508fi 492fi
509 493
567} 551}
568 552
569universal_unpack() { 553universal_unpack() {
570 debug-print "Inside universal_unpack" 554 debug-print "Inside universal_unpack"
571 555
572 local oldifs=${IFS}
573 export IFS="."
574 local OKV_ARRAY=( $OKV ) 556 local OKV_ARRAY
575 export IFS=${oldifs} 557 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
576 558
577 cd "${WORKDIR}" 559 cd "${WORKDIR}"
578 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then 560 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
579 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2 561 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2
580 else 562 else
1127 done 1109 done
1128 fi 1110 fi
1129 done 1111 done
1130} 1112}
1131 1113
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() { 1114headers___fix() {
1194 # Voodoo to partially fix broken upstream headers. 1115 # Voodoo to partially fix broken upstream headers.
1195 # note: do not put inline/asm/volatile together (breaks "inline asm volatile") 1116 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1196 sed -i \ 1117 sed -i \
1197 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \ 1118 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1278 [[ ${ETYPE} == sources ]] && postinst_sources 1199 [[ ${ETYPE} == sources ]] && postinst_sources
1279} 1200}
1280 1201
1281kernel-2_pkg_setup() { 1202kernel-2_pkg_setup() {
1282 if kernel_is 2 4; then 1203 if kernel_is 2 4; then
1283 if [ "$( gcc-major-version )" -eq "4" ] ; then 1204 if [[ $(gcc-major-version) -ge 4 ]] ; then
1284 echo 1205 echo
1285 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!" 1206 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" 1207 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1287 ewarn "newer kernel that supports gcc-4." 1208 ewarn "newer kernel that supports gcc-4."
1288 echo 1209 echo
1297 [[ ${ETYPE} == headers ]] && setup_headers 1218 [[ ${ETYPE} == headers ]] && setup_headers
1298 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." 1219 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1299} 1220}
1300 1221
1301kernel-2_pkg_postrm() { 1222kernel-2_pkg_postrm() {
1223 # This warning only makes sense for kernel sources.
1224 [[ ${ETYPE} == headers ]] && return 0
1225
1226 # If there isn't anything left behind, then don't complain.
1227 [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
1302 echo 1228 echo
1303 ewarn "Note: Even though you have successfully unmerged " 1229 ewarn "Note: Even though you have successfully unmerged "
1304 ewarn "your kernel package, directories in kernel source location: " 1230 ewarn "your kernel package, directories in kernel source location: "
1305 ewarn "${ROOT}usr/src/linux-${KV_FULL}" 1231 ewarn "${ROOT}usr/src/linux-${KV_FULL}"
1306 ewarn "with modified files will remain behind. By design, package managers" 1232 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." 1233 ewarn "will not remove these modified files and the directories they reside in."
1308 echo 1234 echo
1309} 1235}
1310

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

  ViewVC Help
Powered by ViewVC 1.1.20