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

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

  ViewVC Help
Powered by ViewVC 1.1.20