/[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.12 Revision 1.90
1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.90 2005/02/07 11:15:18 johnm Exp $
4
1# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel 5# Description: kernel.eclass rewrite for a clean base regarding the 2.6
2# with back-compatibility for 2.4 6# series of kernel with back-compatibility for 2.4
3# 7#
4# Author: John Mylchreest <johnm@gentoo.org> 8# Maintainer: John Mylchreest <johnm@gentoo.org>
5# Copyright 2004 Gentoo Linux
6# 9#
7# Please direct your bugs to the current eclass maintainer :) 10# Please direct your bugs to the current eclass maintainer :)
8# thatll be: johnm
9 11
10# added functionality: 12# added functionality:
11# unipatch - a flexible, singular method to extract, add and remove patches. 13# unipatch - a flexible, singular method to extract, add and remove patches.
12 14
13# A Couple of env vars are available to effect usage of this eclass 15# A Couple of env vars are available to effect usage of this eclass
14# These are as follows: 16# These are as follows:
15# 17#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 18# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
19# automatically set within the kernel Makefile
17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION 20# K_NOUSENAME - if this is set then EXTRAVERSION will not include the
18# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, ck-sources, ac-sources) it will use PR (ie: -r5) as the patchset version for EXTRAVERSION 21# first part of ${PN} in EXTRAVERSION
22# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
23# ck-sources, ac-sources) it will use PR (ie: -r5) as
24# the patchset version for
19# - and not use it as a true package revision 25# - and not use it as a true package revision
20# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages 26# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
27# postinst and can be used to carry additional postinst
28# messages
21# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's 29# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
30# K_SYMLINK - if this is set, then forcably create symlink anyway
22 31
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild 32# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
33# can be supported by the headers ebuild
24 34
25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 35# UNIPATCH_LIST - space delimetered list of patches to be applied to the
36# kernel
37# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
38# on "<passedstring>*" and not "<passedno#>_*"
39# - this should _NOT_ be used from the ebuild as this is
40# reserved for end users passing excludes from the cli
26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 41# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
42# the doc dir
43# UNIPATCH_STRICTORDER - if this is set places patches into directories of
44# order, so they are applied in the order passed
27 45
46inherit toolchain-funcs versionator multilib
28ECLASS="kernel-2" 47ECLASS="kernel-2"
48INHERITED="$INHERITED $ECLASS"
29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 49EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
30 50
51export CTARGET=${CTARGET:-${CHOST}}
52if [[ ${CTARGET} == ${CHOST} ]] ; then
53 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
54 export CTARGET=${CATEGORY/cross-}
55 fi
56fi
57
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 58HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 59LICENSE="GPL-2"
33IUSE="${IUSE} build"
34SLOT="${KV}"
35 60
61# set LINUX_HOSTCFLAGS if not already set
62[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
63
64#Eclass functions only from here onwards ...
65#==============================================================
66kernel_is() {
67 # And lets add a sanity check
68 [ -z "${KV_FULL}" ] && return 1
69
70 local RESULT operator test value i len
71 RESULT=0
72
73 operator="="
74 if [ "${1}" == "lt" ]
75 then
76 operator="-lt"
77 shift
78 elif [ "${1}" == "gt" ]
79 then
80 operator="-gt"
81 shift
82 elif [ "${1}" == "le" ]
83 then
84 operator="-le"
85 shift
86 elif [ "${1}" == "ge" ]
87 then
88 operator="-ge"
89 shift
90 fi
91
92 if [ -n "${1}" ]
93 then
94 value="${value}${1}"
95 test="${test}${KV_MAJOR}"
96 fi
97 if [ -n "${2}" ]
98 then
99 len=$[ 3 - ${#2} ]
100 for((i=0; i<$len; i++)); do
101 value="${value}0"
102 done
103 value="${value}${2}"
104
105 len=$[ 3 - ${#KV_MINOR} ]
106 for((i=0; i<$len; i++)); do
107 test="${test}0"
108 done
109 test="${test}${KV_MINOR}"
110 fi
111 if [ -n "${3}" ]
112 then
113 len=$[ 3 - ${#3} ]
114 for((i=0; i<$len; i++)); do
115 value="${value}0"
116 done
117 value="${value}${3}"
118
119 len=$[ 3 - ${#KV_PATCH} ]
120 for((i=0; i<$len; i++)); do
121 test="${test}0"
122 done
123 test="${test}${KV_PATCH}"
124 fi
125
126 [ ${test} ${operator} ${value} ] && return 0 || return 1
127}
128
129
130kernel_is_2_4() {
131 kernel_is 2 4
132 return $?
133}
134
135kernel_is_2_6() {
136 kernel_is 2 6 || kernel_is 2 5
137 return $?
138}
139
140kernel_header_destdir() {
141 [[ ${CTARGET} == ${CHOST} ]] \
142 && echo /usr/include \
143 || echo /usr/${CTARGET}/include
144}
145
36# capture the sources type and set depends 146# Capture the sources type and set DEPENDs
37if [ "${ETYPE}" == "sources" ] 147if [ "${ETYPE}" == "sources" ]
38then 148then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 149 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
40 DEPEND="!build? ( sys-apps/sed 150 DEPEND="!build? ( sys-apps/sed
41 >=sys-devel/binutils-2.11.90.0.31 )" 151 >=sys-devel/binutils-2.11.90.0.31 )
42 152 doc? ( app-text/docbook-sgml-utils )"
43 RDEPEND="${DEPEND} 153 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 154 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 155 dev-lang/perl
46 sys-apps/module-init-tools 156 virtual/modutils
47 sys-devel/make )" 157 sys-devel/make )"
48 158
49 PROVIDE="virtual/linux-sources virtual/alsa" 159 PROVIDE="virtual/linux-sources"
50 160 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
161
162 SLOT="${PVR}"
163 DESCRIPTION="Sources for the Linux kernel"
164 IUSE="${IUSE} symlink build doc"
51elif [ "${ETYPE}" == "headers" ] 165elif [ "${ETYPE}" == "headers" ]
52then 166then
167 DESCRIPTION="Linux system headers"
168 IUSE="${IUSE}"
169
170 if [[ ${CTARGET} = ${CHOST} ]]
171 then
172 DEPEND="!virtual/os-headers"
53 PROVIDE="virtual/kernel virtual/os-headers" 173 PROVIDE="virtual/kernel virtual/os-headers"
174 SLOT="0"
175 else
176 SLOT="${CTARGET}"
177 fi
54else 178else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 179 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
56 die 180 die
57fi 181fi
58
59# Grab kernel version from KV
60KV_MAJOR=$(echo ${KV} | cut -d. -f1)
61KV_MINOR=$(echo ${KV} | cut -d. -f2)
62KV_PATCH=$(echo ${KV} | cut -d. -f3)
63KV_PATCH=${KV_PATCH/[-_]*/}
64
65# set LINUX_HOSTCFLAGS if not already set
66[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
67
68
69#eclass functions only from here onwards.
70#==============================================================
71kernel_is_2_4() {
72 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
73}
74
75kernel_is_2_6() {
76 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
77}
78
79 182
80# Unpack functions 183# Unpack functions
81#============================================================== 184#==============================================================
82unpack_2_4() { 185unpack_2_4() {
83 cd ${S} 186 cd ${S}
84 # this file is required for other things to build properly, 187 # this file is required for other things to build properly,
85 # so we autogenerate it 188 # so we autogenerate it
86 make mrproper || die "make mrproper died" 189 make mrproper || die "make mrproper died"
87 make include/linux/version.h || die "make include/linux/version.h failed" 190 make include/linux/version.h || die "make include/linux/version.h failed"
88 echo ">>> version.h compiled successfully." 191 echo ">>> version.h compiled successfully."
89} 192}
90 193
91universal_unpack() { 194universal_unpack() {
195 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
196
197 cd ${WORKDIR}
198 unpack linux-${OKV}.tar.bz2
199 if [ "${OKV}" != "${KV_FULL}" ]
200 then
201 mv linux-${OKV} linux-${KV_FULL} \
202 || die "Unable to move source tree to ${KV_FULL}."
203 fi
204 cd ${S}
205
206 # change incorrect install path
207 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
208
92 # remove all backup files 209 # remove all backup files
93 find . -iname "*~" -exec rm {} \; 2> /dev/null 210 find . -iname "*~" -exec rm {} \; 2> /dev/null
94 211
95 if [ -d "${S}/Documentation/DocBook" ] 212 if [ -d "${S}/Documentation/DocBook" ]
96 then 213 then
97 cd ${S}/Documentation/DocBook 214 cd ${S}/Documentation/DocBook
98 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \ 215 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
99 && mv Makefile.new Makefile 216 && mv Makefile.new Makefile
100 cd ${S} 217 cd ${S}
101 fi 218 fi
219 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
220 use ppc && \
221 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
222 ${S}/arch/ppc/Makefile
102} 223}
103 224
104unpack_set_extraversion() { 225unpack_set_extraversion() {
105 # Gentoo Linux uses /boot, so fix 'make install' to work properly and fix EXTRAVERSION
106 cd ${S} 226 cd ${S}
107 mv Makefile Makefile.orig
108 sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
109 -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \ 227 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
110 Makefile.orig > Makefile
111 rm Makefile.orig
112} 228}
113 229
114# Compile Functions 230# Compile Functions
115#============================================================== 231#==============================================================
116compile_headers() { 232compile_headers() {
117 local MY_ARCH 233 # if we couldnt obtain HOSTCFLAGS from the Makefile,
118 234 # then set it to something sane
119 MY_ARCH=${ARCH} 235 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS ${S}/Makefile)
120 unset ${ARCH} 236 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
237
238 # Kernel ARCH != portage ARCH
239 local KARCH=$(tc-arch-kernel)
240
241 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
242 # variables properly or bad things happen !
243 local xmakeopts="ARCH=${KARCH}"
244 if [[ ${CTARGET} != ${CHOST} ]] ; then
245 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
246 elif type -p ${CHOST}-ar ; then
247 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
248 fi
249
250 if kernel_is 2 4 ; then
121 yes "" | make oldconfig 251 yes "" | make oldconfig ${xmakeopts}
122 echo ">>> make oldconfig complete" 252 echo ">>> make oldconfig complete"
123 ARCH=${MY_ARCH} 253 use sparc && make dep ${xmakeopts}
254
255 elif kernel_is 2 6 ; then
256 # autoconf.h isnt generated unless it already exists. plus, we have
257 # no guarantee that any headers are installed on the system...
258 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
259 || touch include/linux/autoconf.h
260
261 # if there arent any installed headers, then there also isnt an asm
262 # symlink in /usr/include/, and make defconfig will fail, so we have
263 # to force an include path with $S.
264 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
265 ln -sf asm-${KARCH} "${S}"/include/asm
266 make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed"
267 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
268 fi
269}
270
271compile_manpages() {
272 einfo "Making manpages ..."
273 env -u ARCH make mandocs
124} 274}
125 275
126# install functions 276# install functions
127#============================================================== 277#==============================================================
128install_universal() { 278install_universal() {
131 chown -R root:root * 281 chown -R root:root *
132 chmod -R a+r-w+X,u+w * 282 chmod -R a+r-w+X,u+w *
133} 283}
134 284
135install_headers() { 285install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 286 local ddir=$(kernel_header_destdir)
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
138 287
139 cd ${S} 288 cd ${S}
140 dodir /usr/include/linux 289 dodir ${ddir}/linux
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 290 cp -ax ${S}/include/linux/* ${D}/${ddir}/linux
142 rm -rf ${D}/usr/include/linux/modules 291 rm -rf ${D}/${ddir}/linux/modules
143 dodir /usr/include/asm 292 dodir ${ddir}/asm
293
294 if [[ $(tc-arch-kernel) == "sparc64" ]] ; then
295 rm -Rf ${D}/${ddir}/asm
296 dodir ${ddir}/asm-sparc
297 dodir ${ddir}/asm-sparc64
298 cp -ax ${S}/include/asm-sparc/* ${D}/usr/include/asm-sparc
299 cp -ax ${S}/include/asm-sparc64/* ${D}/usr/include/asm-sparc64
300 #generate_sparc_asm ${D}/usr/include
301 create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64
302 elif [[ $(tc-arch-kernel) == "x86_64" ]] ; then
303 rm -Rf ${D}/${ddir}/asm
304 dodir ${ddir}/asm-i386
305 dodir ${ddir}/asm-x86_64
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 306 cp -ax ${S}/include/asm-i386/* ${D}/usr/include/asm-i386
145 307 cp -ax ${S}/include/asm-x86_64/* ${D}/usr/include/asm-x86_64
146 if [ $(kernel_is_2_6) $? == 0 ] 308 #/bin/sh ${FILESDIR}/generate-asm-amd64 ${D}/usr/include
147 then 309 create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64
148 dodir /usr/include/asm-generic 310 else
311 cp -ax ${S}/include/asm/* ${D}/${ddir}/asm
312 fi
313
314 if kernel_is 2 6 ; then
315 dodir ${ddir}/asm-generic
149 cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic 316 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic
150 fi 317 fi
151} 318}
152 319
153install_sources() { 320install_sources() {
154 local doc 321 local doc
155 local docs 322 local docs
323 local file
156 324
157 cd ${S} 325 cd ${S}
158 dodir /usr/src 326 dodir /usr/src
159 echo ">>> Copying sources..." 327 echo ">>> Copying sources ..."
160 if [ -d "${WORKDIR}/${KV}/docs/" ] 328 file="$(find ${WORKDIR} -iname "docs" -type d)"
329 if [ -n "${file}" ]
161 then 330 then
162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 331 for file in $(find ${file} -type f)
163 do 332 do
164 echo "XX_${file}*" >> ${S}/patches.txt 333 echo "${file/*docs\//}" >> ${S}/patches.txt
334 echo "===================================================" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt 335 cat ${file} >> ${S}/patches.txt
336 echo "===================================================" >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt 337 echo "" >> ${S}/patches.txt
167 done 338 done
168 fi 339 fi
169 340
170 if [ ! -f ${S}/patches.txt ] 341 if [ ! -f ${S}/patches.txt ]
179 done 350 done
180 351
181 if [ -f ${S}/patches.txt ]; then 352 if [ -f ${S}/patches.txt ]; then
182 docs="${docs} ${S}/patches.txt" 353 docs="${docs} ${S}/patches.txt"
183 fi 354 fi
355
356 if use doc && ! use arm && ! use s390; then
357 install_manpages
358 fi
359
184 dodoc ${docs} 360 dodoc ${docs}
185 mv ${WORKDIR}/linux* ${D}/usr/src 361 mv ${WORKDIR}/linux* ${D}/usr/src
362}
363
364install_manpages() {
365 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
366 ebegin "Installing manpages"
367 env -u ARCH make installmandocs
368 eend $?
369 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
186} 370}
187 371
188# pkg_preinst functions 372# pkg_preinst functions
189#============================================================== 373#==============================================================
190preinst_headers() { 374preinst_headers() {
191 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux 375 local ddir=$(kernel_header_destdir)
192 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm 376 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
377 [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
193} 378}
194 379
195# pkg_postinst functions 380# pkg_postinst functions
196#============================================================== 381#==============================================================
197postinst_sources() { 382postinst_sources() {
198 if [ ! -h ${ROOT}usr/src/linux ] 383 local MAKELINK=0
199 then 384
385 # if we have USE=symlink, then force K_SYMLINK=1
386 use symlink && K_SYMLINK=1
387
388 # if we are to forcably symlink, delete it if it already exists first.
389 if [[ -n ${K_SYMLINK} ]] ; then
200 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux 390 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
391 MAKELINK=1
392 fi
393
394 # if the link doesnt exist, lets create it
395 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
396
397 if [[ ${MAKELINK} == 1 ]]
398 then
399 cd ${ROOT}usr/src
400 ln -sf linux-${KV_FULL} linux
401 cd ${OLDPWD}
201 fi 402 fi
202 403
203 # Don't forget to make directory for sysfs 404 # Don't forget to make directory for sysfs
204 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys 405 [ ! -d "${ROOT}/sys" -a kernel_is_2_6 ] && mkdir /sys
205 406
206 echo 407 echo
207 einfo "After installing a new kernel of any version, it is important" 408 einfo "After installing a new kernel of any version, it is important"
208 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y" 409 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
209 einfo "created (X.Y is the first 2 parts of your new kernel version)" 410 einfo "created (X.Y is the first 2 parts of your new kernel version)"
210 echo 411 echo
211 einfo "For example, this kernel will require:" 412 einfo "For example, this kernel will require:"
212 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" 413 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
213 echo 414 echo
214 415
215 # if K_EXTRAEINFO is set then lets display it now 416 # if K_EXTRAEINFO is set then lets display it now
216 if [ -n "${K_EXTRAEINFO}" ] 417 if [[ -n ${K_EXTRAEINFO} ]] ; then
217 then
218 echo ${K_EXTRAEINFO} | fmt | 418 echo ${K_EXTRAEINFO} | fmt |
219 while read -s ELINE 419 while read -s ELINE ; do
220 do
221 einfo "${ELINE}" 420 einfo "${ELINE}"
222 done 421 done
223 422
423 echo
424 fi
425
426 # Show policy version, if this kernel has SELinux ...
427 local secfile
428 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
429 if use selinux && [ -f "$secfile" ]
430 then
431 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
432 einfo "The SELinux policy version of this kernel is $polver."
224 echo 433 echo
225 fi 434 fi
226 435
227 # if K_EXTRAEWARN is set then lets display it now 436 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 437 if [ -n "${K_EXTRAEWARN}" ]
236 echo 445 echo
237 fi 446 fi
238} 447}
239 448
240postinst_headers() { 449postinst_headers() {
241 echo
242 einfo "Kernel headers are usually only used when recompiling glibc." 450 einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation"
243 einfo "Following the installation of newer headers it is advised that" 451 einfo "of newer headers, it is advised that you re-merge glibc as follows:"
244 einfo "you re-merge glibc as follows:"
245 einfo "# emerge glibc" 452 einfo "emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer" 453 einfo "Failure to do so will cause glibc to not make use of newer features present in the updated kernel"
247 einfo "features present in the updated kernelheaders." 454 einfo "headers."
248 echo
249} 455}
250 456
251# pkg_setup functions 457# pkg_setup functions
252#============================================================== 458#==============================================================
253setup_headers() { 459setup_headers() {
254 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
255 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
256
257 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}" 460 [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
258 for i in ${H_SUPPORTEDARCH} 461 for i in ${H_SUPPORTEDARCH} ; do
259 do
260 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes" 462 [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
261 done 463 done
262 464
263 if [ "${H_ACCEPT_ARCH}" != "yes" ] 465 if [[ ${H_ACCEPT_ARCH} != "yes" ]] ; then
264 then
265 echo 466 echo
266 eerror "This version of ${PN} does not support ${ARCH}." 467 eerror "This version of ${PN} does not support ${ARCH}."
267 eerror "Please merge the appropriate sources, in most cases" 468 eerror "Please merge the appropriate sources, in most cases"
268 eerror "this will be ${ARCH}-headers." 469 eerror "(but not all) this will be called ${ARCH}-headers."
269 die "incorrect headers" 470 die "Package unsupported for ${ARCH}"
270 fi 471 fi
271} 472}
272 473
273# unipatch 474# unipatch
274#============================================================== 475#==============================================================
275unipatch() { 476unipatch() {
276 local i 477 local i
277 local x 478 local x
278 local extention 479 local extention
279 local PIPE_CMD 480 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 481 local UNIPATCH_DROP
281 local KPATCH_DIR 482 local KPATCH_DIR
282 local PATCH_DEPTH 483 local PATCH_DEPTH
283 local ELINE 484 local ELINE
485 local STRICT_COUNT
486 local PATCH_LEVEL
487 local myLC_ALL
488
489 # set to a standard locale to ensure sorts are ordered properly.
490 myLC_ALL="${LC_ALL}"
491 LC_ALL="C"
284 492
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 493 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 494 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 495
496 # We're gonna need it when doing patches with a predefined patchlevel
497 shopt -s extglob
498
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 499 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
289 # usage can be either via an env var or by params 500 # usage can be either via an env var or by params
501 # although due to the nature we pass this within this eclass
502 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 503 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
504 UNIPATCH_LIST="${@}"
291 505
292 #unpack any passed tarballs 506 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 507 for i in ${UNIPATCH_LIST}
294 do 508 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 509 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
296 then 510 then
297 extention=${i/*./} 511 extention=${i/*./}
512 extention=${extention/:*/}
298 case ${extention} in 513 case ${extention} in
299 tbz2) PIPE_CMD="tar -xvjf";; 514 tbz2) PIPE_CMD="tar -xvjf";;
300 bz2) PIPE_CMD="tar -xvjf";; 515 bz2) PIPE_CMD="tar -xvjf";;
301 tgz) PIPE_CMD="tar -xvzf";; 516 tgz) PIPE_CMD="tar -xvzf";;
302 gz) PIPE_CMD="tar -xvzf";; 517 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 518 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 519 die "Unrecognized tarball compression";;
305 esac 520 esac
306 521
522 if [ -n "${UNIPATCH_STRICTORDER}" ]
523 then
524 STRICT_COUNT=$((${STRICT_COUNT} + 1))
525 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
526 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
527 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 528 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
529 fi
530
308 if [ $? == 0 ] 531 if [ $? == 0 ]
309 then 532 then
310 einfo "${i/*\//} unpacked" 533 einfo "${i/*\//} unpacked"
534 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
311 else 535 else
312 eerror "Failed to unpack ${i}" 536 eerror "Failed to unpack ${i/:*/}"
313 die "unable to unpack patch tarball" 537 die "unable to unpack patch tarball"
314 fi 538 fi
539 else
540 extention=${i/*./}
541 extention=${extention/:*/}
542 PIPE_CMD=""
543 case ${extention} in
544 bz2) PIPE_CMD="bzip2 -dc";;
545 patch) PIPE_CMD="cat";;
546 diff) PIPE_CMD="cat";;
547 gz|Z|z) PIPE_CMD="gzip -dc";;
548 ZIP|zip) PIPE_CMD="unzip -p";;
549 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
550 esac
315 551
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 552 PATCH_LEVEL=${i/*([^:])?(:)}
553 i=${i/:*/}
554 x=${i/*\//}
555 x=${x/\.${extention}/}
556
557 if [ -n "${PIPE_CMD}" ]
558 then
559 if [ ! -r "${i}" ]
560 then
561 echo
562 eerror "FATAL: unable to locate:"
563 eerror "${i}"
564 eerror "for read-only. The file either has incorrect permissions"
565 eerror "or does not exist."
566 die Unable to locate ${i}
567 fi
568
569 if [ -n "${UNIPATCH_STRICTORDER}" ]
570 then
571 STRICT_COUNT=$((${STRICT_COUNT} + 1))
572 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
573 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
574 else
575 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
576 fi
577 fi
317 fi 578 fi
318 done
319
320 #so now everything is unpacked, lets work out whats to be dropped and whats to be included.
321 for i in ${UNIPATCH_LIST}
322 do
323 extention=${i/*./}
324 PIPE_CMD=""
325 case ${extention} in
326 bz2) PIPE_CMD="bzip2 -dc";;
327 patch) PIPE_CMD="cat";;
328 diff) PIPE_CMD="cat";;
329 gz|Z|z) PIPE_CMD="gzip -dc";;
330 ZIP|zip) PIPE_CMD="unzip -p";;
331 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";;
332 esac
333 x=${i/*\//}
334 x=${x/\.${extention}/}
335 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch
336 done 579 done
337 580
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 581 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 582 x=${KPATCH_DIR}
340 KPATCH_DIR="" 583 KPATCH_DIR=""
341 for i in $(find ${x} -type d) 584 for i in $(find ${x} -type d | sort -n)
342 do 585 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 586 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 587 done
345 588
346 #so now lets get rid of the patchno's we want to exclude 589 #so now lets get rid of the patchno's we want to exclude
590 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 591 for i in ${UNIPATCH_DROP}
348 do 592 do
593 ebegin "Excluding Patch #${i}"
349 for x in ${KPATCH_DIR} 594 for x in ${KPATCH_DIR}
350 do 595 do
351 rm ${x}/${i}_* 2>/dev/null 596 rm -f ${x}/${i}* 2>/dev/null
352 if [ $? == 0 ]
353 then
354 einfo "Excluding Patch #${i}"
355 einfo "From: ${x/${WORKDIR}/}"
356 fi
357 done 597 done
598 eend $?
358 done 599 done
359 600
360 # and now, finally, we patch it :) 601 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 602 for x in ${KPATCH_DIR}
362 do 603 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 604 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
364 do 605 do
606 STDERR_T="${T}/${i/*\//}"
607 STDERR_T="${STDERR_T/.patch*/.err}"
365 608
609 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
610 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
366 611
612 if [ -z "${PATCH_DEPTH}" ]; then
367 PATCH_DEPTH=0 613 PATCH_DEPTH=0
614 fi
615
368 ebegin "Applying ${i/*\//}" 616 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
369 while [ ${PATCH_DEPTH} -lt 5 ] 617 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 618 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 619 echo "Attempting Dry-run:" >> ${STDERR_T}
620 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
621 echo "=======================================================" >> ${STDERR_T}
622 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 623 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 624 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 625 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
626 echo "=======================================================" >> ${STDERR_T}
627 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 628 then
376 eend 0 629 eend 0
630 rm ${STDERR_T}
377 break 631 break
378 else 632 else
379 eend 1 633 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 634 eerror "Failed to apply patch ${i/*\//}"
635 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 636 die "Failed to apply ${i/*\//}"
382 fi 637 fi
383 else 638 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 639 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 640 fi
386 done 641 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 642 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 643 then
389 eend 1 644 eend 1
645 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 646 die "Unable to dry-run patch."
391 fi 647 fi
392
393
394 done 648 done
395 done 649 done
396}
397 650
398# custom functions 651 # clean up KPATCH_DIR's - fixes bug #53610
399#============================================================== 652 for x in ${KPATCH_DIR}
653 do
654 rm -Rf ${x}
655 done
656
657 LC_ALL="${myLC_ALL}"
658}
659
660# getfilevar accepts 2 vars as follows:
661# getfilevar <VARIABLE> <CONFIGFILE>
662# pulled from linux-info
663
664getfilevar() {
665local ERROR workingdir basefname basedname xarch
666 ERROR=0
667
668 [ -z "${1}" ] && ERROR=1
669 [ ! -f "${2}" ] && ERROR=1
670
671 if [ "${ERROR}" = 1 ]
672 then
673 ebeep
674 echo -e "\n"
675 eerror "getfilevar requires 2 variables, with the second a valid file."
676 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
677 else
678 workingdir=${PWD}
679 basefname=$(basename ${2})
680 basedname=$(dirname ${2})
681 xarch=$(tc-arch-kernel)
682 unset ARCH
683
684 cd ${basedname}
685 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
686 make ${BUILD_FIXES} -f - e 2>/dev/null
687 cd ${workingdir}
688
689 ARCH=${xarch}
690 fi
691}
692
400detect_version() { 693detect_version() {
401 # this function will detect and set 694 # this function will detect and set
402 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 695 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
403 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) 696 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
404 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 697 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
405 698
699 if [ -n "${KV_FULL}" ] ;
700 then
701 # we will set this for backwards compatibility.
702 KV=${KV_FULL}
703
704 # we know KV_FULL so lets stop here. but not without resetting S
705 S=${WORKDIR}/linux-${KV_FULL}
706 return
707 fi
708
709 CKV=${CKV:-${PV}}
710 if [ -z "${OKV}" ]
711 then
406 OKV=${PV/_beta/-test} 712 OKV=${CKV/_beta/-test}
407 OKV=${OKV/_rc/-rc} 713 OKV=${OKV/_rc/-rc}
408 OKV=${OKV/_pre*/} 714 OKV=${OKV/_p*/}
409 OKV=${OKV/-r*/} 715 OKV=${OKV/-r*/}
410 716 fi
411 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 717
412 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 718 KV_MAJOR=$(get_version_component_range 1 ${OKV})
413 KV_PATCH=$(echo ${OKV} | cut -d. -f3) 719 KV_MINOR=$(get_version_component_range 2 ${OKV})
720 KV_PATCH=$(get_version_component_range 3- ${OKV})
414 KV_PATCH=${KV_PATCH/[-_]*/} 721 KV_PATCH=${KV_PATCH/[-_]*/}
415 722
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 723 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 724
418 RELEASE=${PV/${OKV}/} 725 RELEASE=${CKV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 726 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 727 RELEASE=${RELEASE/_rc/-rc}
728 if [ $(kernel_is_2_4) $? == 0 ]
729 then
730 RELEASE=${RELEASE/_pre/-pre}
731 else
421 RELEASE=${RELEASE/_pre/-bk} 732 RELEASE=${RELEASE/_pre/-bk}
733 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 734 RELEASETYPE=${RELEASE//[0-9]/}
423
424 EXTRAVERSION="${RELEASE}" 735 EXTRAVERSION="${RELEASE}"
425 736
426 if [ -n "${K_PREPATCHED}" ] 737 if [ -n "${K_PREPATCHED}" ]
427 then 738 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 739 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 740 elif [ ${ETYPE} != "headers" ]
741 then
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 742 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
743 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
744 [ "${PN/-*/}" == "vserver" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 745 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 746 fi
747
433 KV=${OKV}${EXTRAVERSION} 748 KV_FULL=${OKV}${EXTRAVERSION}
434 fi 749
435
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 750 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
437 # these cannot be supported, but the code here can handle it up until this point 751 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 752 # and theoretically thereafter.
439 753
440 if [ "${RELEASETYPE}" == "-rc" ] 754 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 755 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 756 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
443 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 757 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
444 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 758 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 759 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 760 KV_FULL=${CKV/[-_]*/}${EXTRAVERSION}
447 fi 761 fi
448 762
449 if [ "${RELEASETYPE}" == "-bk" ] 763 if [ "${RELEASETYPE}" == "-bk" ]
450 then 764 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 765 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
452 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 766 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
453 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 767 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
454 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 768 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
455 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 769 KV_FULL=${CKV/[-_]*/}${EXTRAVERSION}
456 fi 770 fi
457 771
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 772 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 773 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 774 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
461 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})" 775 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 776
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 777 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
464 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 778 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
465 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 779 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
466 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 780 KV_FULL=${CKV/[-_]*/}${EXTRAVERSION}
467 fi 781 fi
468 782
469 S=${WORKDIR}/linux-${KV} 783 S=${WORKDIR}/linux-${KV_FULL}
784 # we will set this for backwards compatibility.
785 KV=${KV_FULL}
470} 786}
471 787
788detect_arch() {
789 # This function sets ARCH_URI and ARCH_PATCH
790 # with the neccessary info for the arch sepecific compatibility
791 # patchsets.
792
793 local ALL_ARCH
794 local LOOP_ARCH
795 local COMPAT_URI
796 local i
797
798 # COMPAT_URI is the contents of ${ARCH}_URI
799 # ARCH_URI is the URI for all the ${ARCH}_URI patches
800 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
801
802 ARCH_URI=""
803 ARCH_PATCH=""
804 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390 SH"
805
806 for LOOP_ARCH in ${ALL_ARCH}
807 do
808 COMPAT_URI="${LOOP_ARCH}_URI"
809 COMPAT_URI="${!COMPAT_URI}"
810
811 [[ -n ${COMPAT_URI} ]] && \
812 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
813
814 if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]
815 then
816 for i in ${COMPAT_URI}
817 do
818 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
819 done
820 fi
821 done
822}
823
824# sparc nastiness
825#==============================================================
826# This script generates the files in /usr/include/asm for sparc systems
827# during installation of sys-kernel/linux-headers.
828# Will no longer be needed when full 64 bit support is used on sparc64
829# systems.
830#
831# Shamefully ripped from Debian
832# ----------------------------------------------------------------------
833
834# Idea borrowed from RedHat's kernel package
835
836# This is gonna get replaced by something in multilib.eclass soon...
837# --eradicator
838generate_sparc_asm() {
839 local name
840
841 cd $1 || die
842 mkdir asm
843
844 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
845 name="$(echo $h | tr a-z. A-Z_)"
846 # common header
847 echo "/* All asm/ files are generated and point to the corresponding
848 * file in asm-sparc or asm-sparc64.
849 */
850
851#ifndef __SPARCSTUB__${name}__
852#define __SPARCSTUB__${name}__
853" > asm/${h}
854
855 # common for sparc and sparc64
856 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
857 echo "#ifdef __arch64__
858#include <asm-sparc64/$h>
859#else
860#include <asm-sparc/$h>
861#endif
862" >> asm/${h}
863
864 # sparc only
865 elif [ -f asm-sparc/$h ]; then
866echo "#ifndef __arch64__
867#include <asm-sparc/$h>
868#endif
869" >> asm/${h}
870
871 # sparc64 only
872 else
873echo "#ifdef __arch64__
874#include <asm-sparc64/$h>
875#endif
876" >> asm/${h}
877 fi
878
879 # common footer
880 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
881 done
882 return 0
883}
884
885headers___fix() {
886 # Voodoo to partially fix broken upstream headers.
887 # Issues with this function should go to plasmaroo.
888 sed -i \
889 -e "s/\([ "$'\t'"]\)u8\([ "$'\t'"]\)/\1__u8\2/g;" \
890 -e "s/\([ "$'\t'"]\)u16\([ "$'\t'"]\)/\1__u16\2/g;" \
891 -e "s/\([ "$'\t'"]\)u32\([ "$'\t'"]\)/\1__u32\2/g;" \
892 -e "s/\([ "$'\t'"]\)u64\([ "$'\t'"]\)/\1__u64\2/g;" \
893 -e "s/\([ "$'\t'"]\)s64\([ "$'\t'"]\)/\1__s64\2/g;" \
894 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \
895 -e 's/\([(, ]\)\(u\|s\)64\([, )]\)/\1__\264\3/g' \
896 "$@"
897}
472 898
473# common functions 899# common functions
474#============================================================== 900#==============================================================
475src_unpack() { 901kernel-2_src_unpack() {
476 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 902 detect_version
903 universal_unpack
477 904
478 cd ${WORKDIR} 905 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
479 unpack linux-${OKV}.tar.bz2 906 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
480 if [ "${OKV}" != "${KV}" ] 907
481 then 908 [ -z "${K_NOSETEXTRAVERSION}" ] && \
482 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}." 909 unpack_set_extraversion
483 fi 910
911 kernel_is 2 4 && unpack_2_4
912}
913
914kernel-2_src_compile() {
484 cd ${S} 915 cd ${S}
485
486 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST}
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491}
492
493src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 916 [ "${ETYPE}" == "headers" ] && compile_headers
917 [ "${ETYPE}" == "sources" ] && \
918 use doc && ! use arm && ! use s390 && compile_manpages
495} 919}
496 920
497pkg_preinst() { 921kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 922 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 923}
500 924
501src_install() { 925kernel-2_src_install() {
502 install_universal 926 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 927 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 928 [ "${ETYPE}" == "sources" ] && install_sources
505} 929}
506 930
507pkg_postinst() { 931kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 932 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 933 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 934}
511 935
512pkg_setup() { 936kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 937 [ "${ETYPE}" == "headers" ] && setup_headers
938
939 # This is to fix some weird portage bug? in stable versions of portage.
940 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
514} 941}

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.90

  ViewVC Help
Powered by ViewVC 1.1.20