/[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.88
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.88 2005/01/31 19:14:55 plasmaroo 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() {
383 local MAKELINK=0
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
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
198 if [ ! -h ${ROOT}usr/src/linux ] 395 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
199 then 396
397 [[ ${MAKELINK} == 1 ]] && \
200 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux 398 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
201 fi
202 399
203 # Don't forget to make directory for sysfs 400 # Don't forget to make directory for sysfs
204 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys 401 [ ! -d "${ROOT}/sys" -a kernel_is_2_6 ] && mkdir /sys
205 402
206 echo 403 echo
207 einfo "After installing a new kernel of any version, it is important" 404 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" 405 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)" 406 einfo "created (X.Y is the first 2 parts of your new kernel version)"
210 echo 407 echo
211 einfo "For example, this kernel will require:" 408 einfo "For example, this kernel will require:"
212 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" 409 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
213 echo 410 echo
214 411
215 # if K_EXTRAEINFO is set then lets display it now 412 # if K_EXTRAEINFO is set then lets display it now
216 if [ -n "${K_EXTRAEINFO}" ] 413 if [[ -n ${K_EXTRAEINFO} ]] ; then
217 then
218 echo ${K_EXTRAEINFO} | fmt | 414 echo ${K_EXTRAEINFO} | fmt |
219 while read -s ELINE 415 while read -s ELINE ; do
220 do
221 einfo "${ELINE}" 416 einfo "${ELINE}"
222 done 417 done
223 418
419 echo
420 fi
421
422 # Show policy version, if this kernel has SELinux ...
423 local secfile
424 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
425 if use selinux && [ -f "$secfile" ]
426 then
427 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
428 einfo "The SELinux policy version of this kernel is $polver."
224 echo 429 echo
225 fi 430 fi
226 431
227 # if K_EXTRAEWARN is set then lets display it now 432 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 433 if [ -n "${K_EXTRAEWARN}" ]
236 echo 441 echo
237 fi 442 fi
238} 443}
239 444
240postinst_headers() { 445postinst_headers() {
241 echo
242 einfo "Kernel headers are usually only used when recompiling glibc." 446 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" 447 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" 448 einfo "emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer" 449 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." 450 einfo "headers."
248 echo
249} 451}
250 452
251# pkg_setup functions 453# pkg_setup functions
252#============================================================== 454#==============================================================
253setup_headers() { 455setup_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/-*/}" 456 [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
258 for i in ${H_SUPPORTEDARCH} 457 for i in ${H_SUPPORTEDARCH} ; do
259 do
260 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes" 458 [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
261 done 459 done
262 460
263 if [ "${H_ACCEPT_ARCH}" != "yes" ] 461 if [[ ${H_ACCEPT_ARCH} != "yes" ]] ; then
264 then
265 echo 462 echo
266 eerror "This version of ${PN} does not support ${ARCH}." 463 eerror "This version of ${PN} does not support ${ARCH}."
267 eerror "Please merge the appropriate sources, in most cases" 464 eerror "Please merge the appropriate sources, in most cases"
268 eerror "this will be ${ARCH}-headers." 465 eerror "(but not all) this will be called ${ARCH}-headers."
269 die "incorrect headers" 466 die "Package unsupported for ${ARCH}"
270 fi 467 fi
271} 468}
272 469
273# unipatch 470# unipatch
274#============================================================== 471#==============================================================
275unipatch() { 472unipatch() {
276 local i 473 local i
277 local x 474 local x
278 local extention 475 local extention
279 local PIPE_CMD 476 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 477 local UNIPATCH_DROP
281 local KPATCH_DIR 478 local KPATCH_DIR
282 local PATCH_DEPTH 479 local PATCH_DEPTH
283 local ELINE 480 local ELINE
481 local STRICT_COUNT
482 local PATCH_LEVEL
483 local myLC_ALL
484
485 # set to a standard locale to ensure sorts are ordered properly.
486 myLC_ALL="${LC_ALL}"
487 LC_ALL="C"
284 488
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 489 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 490 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 491
492 # We're gonna need it when doing patches with a predefined patchlevel
493 shopt -s extglob
494
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 495 # 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 496 # usage can be either via an env var or by params
497 # although due to the nature we pass this within this eclass
498 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 499 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
500 UNIPATCH_LIST="${@}"
291 501
292 #unpack any passed tarballs 502 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 503 for i in ${UNIPATCH_LIST}
294 do 504 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 505 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
296 then 506 then
297 extention=${i/*./} 507 extention=${i/*./}
508 extention=${extention/:*/}
298 case ${extention} in 509 case ${extention} in
299 tbz2) PIPE_CMD="tar -xvjf";; 510 tbz2) PIPE_CMD="tar -xvjf";;
300 bz2) PIPE_CMD="tar -xvjf";; 511 bz2) PIPE_CMD="tar -xvjf";;
301 tgz) PIPE_CMD="tar -xvzf";; 512 tgz) PIPE_CMD="tar -xvzf";;
302 gz) PIPE_CMD="tar -xvzf";; 513 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 514 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 515 die "Unrecognized tarball compression";;
305 esac 516 esac
306 517
518 if [ -n "${UNIPATCH_STRICTORDER}" ]
519 then
520 STRICT_COUNT=$((${STRICT_COUNT} + 1))
521 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
522 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
523 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 524 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
525 fi
526
308 if [ $? == 0 ] 527 if [ $? == 0 ]
309 then 528 then
310 einfo "${i/*\//} unpacked" 529 einfo "${i/*\//} unpacked"
530 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
311 else 531 else
312 eerror "Failed to unpack ${i}" 532 eerror "Failed to unpack ${i/:*/}"
313 die "unable to unpack patch tarball" 533 die "unable to unpack patch tarball"
314 fi 534 fi
535 else
536 extention=${i/*./}
537 extention=${extention/:*/}
538 PIPE_CMD=""
539 case ${extention} in
540 bz2) PIPE_CMD="bzip2 -dc";;
541 patch) PIPE_CMD="cat";;
542 diff) PIPE_CMD="cat";;
543 gz|Z|z) PIPE_CMD="gzip -dc";;
544 ZIP|zip) PIPE_CMD="unzip -p";;
545 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
546 esac
315 547
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 548 PATCH_LEVEL=${i/*([^:])?(:)}
549 i=${i/:*/}
550 x=${i/*\//}
551 x=${x/\.${extention}/}
552
553 if [ -n "${PIPE_CMD}" ]
554 then
555 if [ ! -r "${i}" ]
556 then
557 echo
558 eerror "FATAL: unable to locate:"
559 eerror "${i}"
560 eerror "for read-only. The file either has incorrect permissions"
561 eerror "or does not exist."
562 die Unable to locate ${i}
563 fi
564
565 if [ -n "${UNIPATCH_STRICTORDER}" ]
566 then
567 STRICT_COUNT=$((${STRICT_COUNT} + 1))
568 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
569 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
570 else
571 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
572 fi
573 fi
317 fi 574 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 575 done
337 576
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 577 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 578 x=${KPATCH_DIR}
340 KPATCH_DIR="" 579 KPATCH_DIR=""
341 for i in $(find ${x} -type d) 580 for i in $(find ${x} -type d | sort -n)
342 do 581 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 582 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 583 done
345 584
346 #so now lets get rid of the patchno's we want to exclude 585 #so now lets get rid of the patchno's we want to exclude
586 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 587 for i in ${UNIPATCH_DROP}
348 do 588 do
589 ebegin "Excluding Patch #${i}"
349 for x in ${KPATCH_DIR} 590 for x in ${KPATCH_DIR}
350 do 591 do
351 rm ${x}/${i}_* 2>/dev/null 592 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 593 done
594 eend $?
358 done 595 done
359 596
360 # and now, finally, we patch it :) 597 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 598 for x in ${KPATCH_DIR}
362 do 599 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 600 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
364 do 601 do
602 STDERR_T="${T}/${i/*\//}"
603 STDERR_T="${STDERR_T/.patch*/.err}"
365 604
605 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
606 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
366 607
608 if [ -z "${PATCH_DEPTH}" ]; then
367 PATCH_DEPTH=0 609 PATCH_DEPTH=0
610 fi
611
368 ebegin "Applying ${i/*\//}" 612 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
369 while [ ${PATCH_DEPTH} -lt 5 ] 613 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 614 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 615 echo "Attempting Dry-run:" >> ${STDERR_T}
616 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
617 echo "=======================================================" >> ${STDERR_T}
618 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 619 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 620 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 621 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
622 echo "=======================================================" >> ${STDERR_T}
623 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 624 then
376 eend 0 625 eend 0
626 rm ${STDERR_T}
377 break 627 break
378 else 628 else
379 eend 1 629 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 630 eerror "Failed to apply patch ${i/*\//}"
631 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 632 die "Failed to apply ${i/*\//}"
382 fi 633 fi
383 else 634 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 635 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 636 fi
386 done 637 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 638 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 639 then
389 eend 1 640 eend 1
641 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 642 die "Unable to dry-run patch."
391 fi 643 fi
392
393
394 done 644 done
395 done 645 done
396}
397 646
398# custom functions 647 # clean up KPATCH_DIR's - fixes bug #53610
399#============================================================== 648 for x in ${KPATCH_DIR}
649 do
650 rm -Rf ${x}
651 done
652
653 LC_ALL="${myLC_ALL}"
654}
655
656# getfilevar accepts 2 vars as follows:
657# getfilevar <VARIABLE> <CONFIGFILE>
658# pulled from linux-info
659
660getfilevar() {
661local ERROR workingdir basefname basedname xarch
662 ERROR=0
663
664 [ -z "${1}" ] && ERROR=1
665 [ ! -f "${2}" ] && ERROR=1
666
667 if [ "${ERROR}" = 1 ]
668 then
669 ebeep
670 echo -e "\n"
671 eerror "getfilevar requires 2 variables, with the second a valid file."
672 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
673 else
674 workingdir=${PWD}
675 basefname=$(basename ${2})
676 basedname=$(dirname ${2})
677 xarch=$(tc-arch-kernel)
678 unset ARCH
679
680 cd ${basedname}
681 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
682 make ${BUILD_FIXES} -f - e 2>/dev/null
683 cd ${workingdir}
684
685 ARCH=${xarch}
686 fi
687}
688
400detect_version() { 689detect_version() {
401 # this function will detect and set 690 # this function will detect and set
402 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 691 # - 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) 692 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
404 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 693 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
405 694
695 if [ -n "${KV_FULL}" ] ;
696 then
697 # we will set this for backwards compatibility.
698 KV=${KV_FULL}
699
700 # we know KV_FULL so lets stop here. but not without resetting S
701 S=${WORKDIR}/linux-${KV_FULL}
702 return
703 fi
704
705 if [ -z "${OKV}" ]
706 then
406 OKV=${PV/_beta/-test} 707 OKV=${PV/_beta/-test}
407 OKV=${OKV/_rc/-rc} 708 OKV=${OKV/_rc/-rc}
408 OKV=${OKV/_pre*/} 709 OKV=${OKV/_p*/}
409 OKV=${OKV/-r*/} 710 OKV=${OKV/-r*/}
410 711 fi
411 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 712
412 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 713 KV_MAJOR=$(get_version_component_range 1 ${OKV})
413 KV_PATCH=$(echo ${OKV} | cut -d. -f3) 714 KV_MINOR=$(get_version_component_range 2 ${OKV})
715 KV_PATCH=$(get_version_component_range 3- ${OKV})
414 KV_PATCH=${KV_PATCH/[-_]*/} 716 KV_PATCH=${KV_PATCH/[-_]*/}
415 717
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 718 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 719
418 RELEASE=${PV/${OKV}/} 720 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 721 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 722 RELEASE=${RELEASE/_rc/-rc}
723 if [ $(kernel_is_2_4) $? == 0 ]
724 then
725 RELEASE=${RELEASE/_pre/-pre}
726 else
421 RELEASE=${RELEASE/_pre/-bk} 727 RELEASE=${RELEASE/_pre/-bk}
728 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 729 RELEASETYPE=${RELEASE//[0-9]/}
423
424 EXTRAVERSION="${RELEASE}" 730 EXTRAVERSION="${RELEASE}"
425 731
426 if [ -n "${K_PREPATCHED}" ] 732 if [ -n "${K_PREPATCHED}" ]
427 then 733 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 734 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 735 elif [ ${ETYPE} != "headers" ]
736 then
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 737 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
738 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
739 [ "${PN/-*/}" == "vserver" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 740 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 741 fi
742
433 KV=${OKV}${EXTRAVERSION} 743 KV_FULL=${OKV}${EXTRAVERSION}
434 fi 744
435
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 745 # -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 746 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 747 # and theoretically thereafter.
439 748
440 if [ "${RELEASETYPE}" == "-rc" ] 749 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 750 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 751 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 752 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
444 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 753 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 754 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 755 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
447 fi 756 fi
448 757
449 if [ "${RELEASETYPE}" == "-bk" ] 758 if [ "${RELEASETYPE}" == "-bk" ]
450 then 759 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 760 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 761 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" 762 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}" 763 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} 764 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
456 fi 765 fi
457 766
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 767 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 768 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 769 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})" 770 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 771
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 772 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" 773 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}" 774 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} 775 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
467 fi 776 fi
468 777
469 S=${WORKDIR}/linux-${KV} 778 S=${WORKDIR}/linux-${KV_FULL}
779 # we will set this for backwards compatibility.
780 KV=${KV_FULL}
470} 781}
471 782
783detect_arch() {
784 # This function sets ARCH_URI and ARCH_PATCH
785 # with the neccessary info for the arch sepecific compatibility
786 # patchsets.
787
788 local ALL_ARCH
789 local LOOP_ARCH
790 local COMPAT_URI
791 local i
792
793 # COMPAT_URI is the contents of ${ARCH}_URI
794 # ARCH_URI is the URI for all the ${ARCH}_URI patches
795 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
796
797 ARCH_URI=""
798 ARCH_PATCH=""
799 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390 SH"
800
801 for LOOP_ARCH in ${ALL_ARCH}
802 do
803 COMPAT_URI="${LOOP_ARCH}_URI"
804 COMPAT_URI="${!COMPAT_URI}"
805
806 [[ -n ${COMPAT_URI} ]] && \
807 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
808
809 if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]
810 then
811 for i in ${COMPAT_URI}
812 do
813 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
814 done
815 fi
816 done
817}
818
819# sparc nastiness
820#==============================================================
821# This script generates the files in /usr/include/asm for sparc systems
822# during installation of sys-kernel/linux-headers.
823# Will no longer be needed when full 64 bit support is used on sparc64
824# systems.
825#
826# Shamefully ripped from Debian
827# ----------------------------------------------------------------------
828
829# Idea borrowed from RedHat's kernel package
830
831# This is gonna get replaced by something in multilib.eclass soon...
832# --eradicator
833generate_sparc_asm() {
834 local name
835
836 cd $1 || die
837 mkdir asm
838
839 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
840 name="$(echo $h | tr a-z. A-Z_)"
841 # common header
842 echo "/* All asm/ files are generated and point to the corresponding
843 * file in asm-sparc or asm-sparc64.
844 */
845
846#ifndef __SPARCSTUB__${name}__
847#define __SPARCSTUB__${name}__
848" > asm/${h}
849
850 # common for sparc and sparc64
851 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
852 echo "#ifdef __arch64__
853#include <asm-sparc64/$h>
854#else
855#include <asm-sparc/$h>
856#endif
857" >> asm/${h}
858
859 # sparc only
860 elif [ -f asm-sparc/$h ]; then
861echo "#ifndef __arch64__
862#include <asm-sparc/$h>
863#endif
864" >> asm/${h}
865
866 # sparc64 only
867 else
868echo "#ifdef __arch64__
869#include <asm-sparc64/$h>
870#endif
871" >> asm/${h}
872 fi
873
874 # common footer
875 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
876 done
877 return 0
878}
879
880headers___fix()
881{
882 # Voodoo to partially fix broken upstream headers.
883 # Issues with this function should go to plasmaroo.
884 sed -i \
885 -e "s/\([ "$'\t'"]\)u8\([ "$'\t'"]\)/\1__u8\2/g;" \
886 -e "s/\([ "$'\t'"]\)u16\([ "$'\t'"]\)/\1__u16\2/g;" \
887 -e "s/\([ "$'\t'"]\)u32\([ "$'\t'"]\)/\1__u32\2/g;" \
888 -e "s/\([ "$'\t'"]\)u64\([ "$'\t'"]\)/\1__u64\2/g;" \
889 -e "s/\([ "$'\t'"]\)s64\([ "$'\t'"]\)/\1__s64\2/g;" \
890 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \
891 -e 's/\([(, ]\)\(u\|s\)64\([, )]\)/\1__\264\3/g' \
892 "$@"
893}
472 894
473# common functions 895# common functions
474#============================================================== 896#==============================================================
475src_unpack() { 897kernel-2_src_unpack() {
476 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 898 detect_version
899 universal_unpack
477 900
478 cd ${WORKDIR} 901 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
479 unpack linux-${OKV}.tar.bz2 902 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
480 if [ "${OKV}" != "${KV}" ] 903
481 then 904 [ -z "${K_NOSETEXTRAVERSION}" ] && \
482 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}." 905 unpack_set_extraversion
483 fi 906
907 kernel_is 2 4 && unpack_2_4
908}
909
910kernel-2_src_compile() {
484 cd ${S} 911 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 912 [ "${ETYPE}" == "headers" ] && compile_headers
913 [ "${ETYPE}" == "sources" ] && \
914 use doc && ! use arm && ! use s390 && compile_manpages
495} 915}
496 916
497pkg_preinst() { 917kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 918 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 919}
500 920
501src_install() { 921kernel-2_src_install() {
502 install_universal 922 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 923 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 924 [ "${ETYPE}" == "sources" ] && install_sources
505} 925}
506 926
507pkg_postinst() { 927kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 928 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 929 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 930}
511 931
512pkg_setup() { 932kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 933 [ "${ETYPE}" == "headers" ] && setup_headers
934
935 # This is to fix some weird portage bug? in stable versions of portage.
936 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
514} 937}

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

  ViewVC Help
Powered by ViewVC 1.1.20