/[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.36
1# Copyright 1999-2004 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.36 2004/07/04 23:48:19 tseng Exp $
4
1# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel 5# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel
2# with back-compatibility for 2.4 6# with back-compatibility for 2.4
3# 7#
4# Author: John Mylchreest <johnm@gentoo.org> 8# Author: John Mylchreest <johnm@gentoo.org>
5# Copyright 2004 Gentoo Linux 9# Copyright 2004 Gentoo Linux
13# A Couple of env vars are available to effect usage of this eclass 17# A Couple of env vars are available to effect usage of this eclass
14# These are as follows: 18# These are as follows:
15# 19#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 20# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be 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 21# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION
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 22# 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
19# - and not use it as a true package revision 23# - 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 24# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages
21# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's 25# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
22 26
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild 27# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild
24 28
25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 29# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
30# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely on "<passedstring>*" and not "<passedno#>_*"
31# - this should _NOT_ be used from the ebuild as this is reserved for end users passing excludes from the cli
26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 32# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
33# UNIPATCH_STRICTORDER - if this is set places patches into directories of order, so they are applied in the order passed
27 34
28ECLASS="kernel-2" 35ECLASS="kernel-2"
36INHERITED="$INHERITED $ECLASS"
29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 37EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
38
39# to prevent errors if theres no sources in /usr/src
40# we set KV and re-set it later on as well.
41[ -z "${KV}" ] && KV=${PV}
30 42
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 43HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 44LICENSE="GPL-2"
33IUSE="${IUSE} build" 45IUSE="${IUSE} build"
34SLOT="${KV}" 46SLOT="${KV}"
35 47
48# Grab kernel version from KV
49KV_MAJOR=$(echo ${KV} | cut -d. -f1)
50KV_MINOR=$(echo ${KV} | cut -d. -f2)
51KV_PATCH=$(echo ${KV} | cut -d. -f3)
52KV_PATCH=${KV_PATCH/[-_]*/}
53
54# set LINUX_HOSTCFLAGS if not already set
55[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
56
57#Eclass functions only from here onwards...
58#==============================================================
59kernel_is() {
60 local RESULT
61 RESULT=1
62
63 if [ -n "${1}" ]
64 then
65 [ "${1}" = "${KV_MAJOR}" ] && RESULT=0
66 fi
67
68 if [ -n "${2}" ]
69 then
70 RESULT=1
71 [ "${2}" = "${KV_MINOR}" ] && RESULT=0
72 fi
73
74 if [ -n "${3}" ]
75 then
76 RESULT=1
77 [ "${3}" = "${KV_PATCH}" ] && RESULT=0
78 fi
79 return ${RESULT}
80}
81
82kernel_is_2_4() {
83 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
84}
85
86kernel_is_2_6() {
87 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
88}
89
36# capture the sources type and set depends 90# Capture the sources type and set DEPENDs
37if [ "${ETYPE}" == "sources" ] 91if [ "${ETYPE}" == "sources" ]
38then 92then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 93 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
40 DEPEND="!build? ( sys-apps/sed 94 DEPEND="!build? ( sys-apps/sed
41 >=sys-devel/binutils-2.11.90.0.31 )" 95 >=sys-devel/binutils-2.11.90.0.31 )"
43 RDEPEND="${DEPEND} 97 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 98 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 99 dev-lang/perl
46 sys-apps/module-init-tools 100 sys-apps/module-init-tools
47 sys-devel/make )" 101 sys-devel/make )"
48 102
49 PROVIDE="virtual/linux-sources virtual/alsa" 103 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" || PROVIDE="virtual/linux-sources virtual/alsa"
50 104
51elif [ "${ETYPE}" == "headers" ] 105elif [ "${ETYPE}" == "headers" ]
52then 106then
53 PROVIDE="virtual/kernel virtual/os-headers" 107 PROVIDE="virtual/kernel virtual/os-headers"
54else 108else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 109 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\""
56 die 110 die
57fi 111fi
58 112
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
80# Unpack functions 113# Unpack functions
81#============================================================== 114#==============================================================
82unpack_2_4() { 115unpack_2_4() {
83 cd ${S} 116 cd ${S}
84 # this file is required for other things to build properly, 117 # this file is required for other things to build properly,
87 make include/linux/version.h || die "make include/linux/version.h failed" 120 make include/linux/version.h || die "make include/linux/version.h failed"
88 echo ">>> version.h compiled successfully." 121 echo ">>> version.h compiled successfully."
89} 122}
90 123
91universal_unpack() { 124universal_unpack() {
125 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
126
127 cd ${WORKDIR}
128 unpack linux-${OKV}.tar.bz2
129 if [ "${OKV}" != "${KV}" ]
130 then
131 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
132 fi
133 cd ${S}
134
92 # remove all backup files 135 # remove all backup files
93 find . -iname "*~" -exec rm {} \; 2> /dev/null 136 find . -iname "*~" -exec rm {} \; 2> /dev/null
94 137
95 if [ -d "${S}/Documentation/DocBook" ] 138 if [ -d "${S}/Documentation/DocBook" ]
96 then 139 then
132 chmod -R a+r-w+X,u+w * 175 chmod -R a+r-w+X,u+w *
133} 176}
134 177
135install_headers() { 178install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 179 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 180
138
139 cd ${S} 181 cd ${S}
140 dodir /usr/include/linux 182 dodir /usr/include/linux
183 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 184 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
142 rm -rf ${D}/usr/include/linux/modules 185 rm -rf ${D}/usr/include/linux/modules
186
143 dodir /usr/include/asm 187 dodir /usr/include/asm
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 188 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145 189
146 if [ $(kernel_is_2_6) $? == 0 ] 190 if [ $(kernel_is_2_6) $? == 0 ]
147 then 191 then
151} 195}
152 196
153install_sources() { 197install_sources() {
154 local doc 198 local doc
155 local docs 199 local docs
200 local file
156 201
157 cd ${S} 202 cd ${S}
158 dodir /usr/src 203 dodir /usr/src
159 echo ">>> Copying sources..." 204 echo ">>> Copying sources..."
160 if [ -d "${WORKDIR}/${KV}/docs/" ] 205 file="$(find ${WORKDIR} -iname "docs" -type d)"
206 if [ -n "${file}" ]
161 then 207 then
162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 208 for file in $(find ${file} -type f)
163 do 209 do
164 echo "XX_${file}*" >> ${S}/patches.txt 210 echo "${file/*docs\//}" >> ${S}/patches.txt
211 echo "===================================================" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt 212 cat ${file} >> ${S}/patches.txt
213 echo "===================================================" >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt 214 echo "" >> ${S}/patches.txt
167 done 215 done
168 fi 216 fi
169 217
170 if [ ! -f ${S}/patches.txt ] 218 if [ ! -f ${S}/patches.txt ]
179 done 227 done
180 228
181 if [ -f ${S}/patches.txt ]; then 229 if [ -f ${S}/patches.txt ]; then
182 docs="${docs} ${S}/patches.txt" 230 docs="${docs} ${S}/patches.txt"
183 fi 231 fi
232
184 dodoc ${docs} 233 dodoc ${docs}
185 mv ${WORKDIR}/linux* ${D}/usr/src 234 mv ${WORKDIR}/linux* ${D}/usr/src
186} 235}
187 236
188# pkg_preinst functions 237# pkg_preinst functions
219 while read -s ELINE 268 while read -s ELINE
220 do 269 do
221 einfo "${ELINE}" 270 einfo "${ELINE}"
222 done 271 done
223 272
273 echo
274 fi
275
276 # Show policy version, if this kernel has SELinux...
277 local secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h"
278 if [ -n "`use selinux`" -a -f "$secfile" ]
279 then
280 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
281 einfo "The SELinux policy version of this kernel is $polver."
224 echo 282 echo
225 fi 283 fi
226 284
227 # if K_EXTRAEWARN is set then lets display it now 285 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 286 if [ -n "${K_EXTRAEWARN}" ]
275unipatch() { 333unipatch() {
276 local i 334 local i
277 local x 335 local x
278 local extention 336 local extention
279 local PIPE_CMD 337 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 338 local UNIPATCH_DROP
281 local KPATCH_DIR 339 local KPATCH_DIR
282 local PATCH_DEPTH 340 local PATCH_DEPTH
283 local ELINE 341 local ELINE
342 local STRICT_COUNT
284 343
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 344 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 345 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 346
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 347 # 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 348 # usage can be either via an env var or by params
349 # although due to the nature we pass this within this eclass
350 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 351 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
352 UNIPATCH_LIST="${@}"
291 353
292 #unpack any passed tarballs 354 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 355 for i in ${UNIPATCH_LIST}
294 do 356 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 357 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
302 gz) PIPE_CMD="tar -xvzf";; 364 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 365 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 366 die "Unrecognized tarball compression";;
305 esac 367 esac
306 368
369 if [ -n "${UNIPATCH_STRICTORDER}" ]
370 then
371 STRICT_COUNT=$((${STRICT_COUNT} + 1))
372 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
373 ${PIPE_CMD} ${i} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
374 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 375 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null
376 fi
377
308 if [ $? == 0 ] 378 if [ $? == 0 ]
309 then 379 then
310 einfo "${i/*\//} unpacked" 380 einfo "${i/*\//} unpacked"
311 else 381 else
312 eerror "Failed to unpack ${i}" 382 eerror "Failed to unpack ${i}"
313 die "unable to unpack patch tarball" 383 die "unable to unpack patch tarball"
314 fi 384 fi
315 385 else
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 386 extention=${i/*./}
387 PIPE_CMD=""
388 case ${extention} in
389 bz2) PIPE_CMD="bzip2 -dc";;
390 patch) PIPE_CMD="cat";;
391 diff) PIPE_CMD="cat";;
392 gz|Z|z) PIPE_CMD="gzip -dc";;
393 ZIP|zip) PIPE_CMD="unzip -p";;
394 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i}";;
395 esac
396 x=${i/*\//}
397 x=${x/\.${extention}/}
398
399 if [ -n "${PIPE_CMD}" ]
400 then
401 if [ ! -r "${i}" ]
402 then
403 echo
404 eerror "FATAL: unable to locate:"
405 eerror "${i}"
406 eerror "for read-only. The file either has incorrect permissions"
407 eerror "or does not exist."
408 die Unable to locate ${i}
409 fi
410
411 if [ -n "${UNIPATCH_STRICTORDER}" ]
412 then
413 STRICT_COUNT=$((${STRICT_COUNT} + 1))
414 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
415 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch)
416 else
417 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch)
418 fi
419 fi
317 fi 420 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 421 done
337 422
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 423 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 424 x=${KPATCH_DIR}
340 KPATCH_DIR="" 425 KPATCH_DIR=""
341 for i in $(find ${x} -type d) 426 for i in $(find ${x} -type d | sort -n)
342 do 427 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 428 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 429 done
345 430
346 #so now lets get rid of the patchno's we want to exclude 431 #so now lets get rid of the patchno's we want to exclude
432 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 433 for i in ${UNIPATCH_DROP}
348 do 434 do
349 for x in ${KPATCH_DIR} 435 for x in ${KPATCH_DIR}
350 do 436 do
351 rm ${x}/${i}_* 2>/dev/null 437 rm -f ${x}/${i}* 2>/dev/null
352 if [ $? == 0 ] 438 if [ $? == 0 ]
353 then 439 then
354 einfo "Excluding Patch #${i}" 440 einfo "Excluding Patch #${i}"
355 einfo "From: ${x/${WORKDIR}/}" 441 einfo "From: ${x/${WORKDIR}/}"
356 fi 442 fi
358 done 444 done
359 445
360 # and now, finally, we patch it :) 446 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 447 for x in ${KPATCH_DIR}
362 do 448 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 449 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -n)
364 do 450 do
365 451 STDERR_T="${T}/${i/*\//}"
366 452 STDERR_T="${STDERR_T/.patch/.err}"
453
367 PATCH_DEPTH=0 454 PATCH_DEPTH=0
368 ebegin "Applying ${i/*\//}" 455 ebegin "Applying ${i/*\//}"
369 while [ ${PATCH_DEPTH} -lt 5 ] 456 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 457 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 458 echo "Attempting Dry-run:" >> ${STDERR_T}
459 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
460 echo "=======================================================" >> ${STDERR_T}
461 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 462 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 463 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 464 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
465 echo "=======================================================" >> ${STDERR_T}
466 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 467 then
376 eend 0 468 eend 0
469 rm ${STDERR_T}
377 break 470 break
378 else 471 else
379 eend 1 472 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 473 eerror "Failed to apply patch ${i/*\//}"
474 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 475 die "Failed to apply ${i/*\//}"
382 fi 476 fi
383 else 477 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 478 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 479 fi
386 done 480 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 481 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 482 then
389 eend 1 483 eend 1
484 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 485 die "Unable to dry-run patch."
391 fi 486 fi
392
393
394 done 487 done
395 done 488 done
396} 489}
397 490
398# custom functions 491# custom functions
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 509 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 510
418 RELEASE=${PV/${OKV}/} 511 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 512 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 513 RELEASE=${RELEASE/_rc/-rc}
514 if [ $(kernel_is_2_4) $? == 0 ]
515 then
516 RELEASE=${RELEASE/_pre/-pre}
517 else
421 RELEASE=${RELEASE/_pre/-bk} 518 RELEASE=${RELEASE/_pre/-bk}
519 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 520 RELEASETYPE=${RELEASE//[0-9]/}
423 521
424 EXTRAVERSION="${RELEASE}" 522 EXTRAVERSION="${RELEASE}"
425 523
426 if [ -n "${K_PREPATCHED}" ] 524 if [ -n "${K_PREPATCHED}" ]
427 then 525 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 526 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 527 else
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 528 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 529 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 530 fi
531
433 KV=${OKV}${EXTRAVERSION} 532 KV=${OKV}${EXTRAVERSION}
434 fi
435 533
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 534 # -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 535 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 536 # and theoretically thereafter.
439 537
440 if [ "${RELEASETYPE}" == "-rc" ] 538 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 539 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 540 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 541 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" 542 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 543 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 544 KV=${PV/[-_]*/}${EXTRAVERSION}
447 fi 545 fi
448 546
449 if [ "${RELEASETYPE}" == "-bk" ] 547 if [ "${RELEASETYPE}" == "-bk" ]
450 then 548 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 549 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 550 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" 551 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}" 552 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} 553 KV=${PV/[-_]*/}${EXTRAVERSION}
456 fi 554 fi
457 555
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 556 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 557 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 558 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})" 559 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 560
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 561 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" 562 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}" 563 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} 564 KV=${PV/[-_]*/}${EXTRAVERSION}
467 fi 565 fi
468 566
469 S=${WORKDIR}/linux-${KV} 567 S=${WORKDIR}/linux-${KV}
470} 568}
471 569
570detect_arch() {
571 # This function sets ARCH_URI and ARCH_PATCH
572 # with the neccessary info for the arch sepecific compatibility
573 # patchsets.
574
575 local ALL_ARCH
576 local LOOP_ARCH
577 local COMPAT_URI
578 local i
579
580 # COMPAT_URI is the contents of ${ARCH}_URI
581 # ARCH_URI is the URI for all the ${ARCH}_URI patches
582 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
583
584 ARCH_URI=""
585 ARCH_PATCH=""
586 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
587
588 for LOOP_ARCH in ${ALL_ARCH}
589 do
590 COMPAT_URI="${LOOP_ARCH}_URI"
591 COMPAT_URI="${!COMPAT_URI}"
592
593 [ -n "${COMPAT_URI}" ] && ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
594
595 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ]
596 then
597 for i in ${COMPAT_URI}
598 do
599 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
600 done
601 fi
602 done
603}
604
472 605
473# common functions 606# common functions
474#============================================================== 607#==============================================================
475src_unpack() { 608kernel-2_src_unpack() {
476 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
477
478 cd ${WORKDIR}
479 unpack linux-${OKV}.tar.bz2
480 if [ "${OKV}" != "${KV}" ]
481 then
482 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
483 fi
484 cd ${S}
485
486 universal_unpack 609 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST} 610 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 611 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 612 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491} 613}
492 614
493src_compile() { 615kernel-2_src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 616 [ "${ETYPE}" == "headers" ] && compile_headers
495} 617}
496 618
497pkg_preinst() { 619kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 620 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 621}
500 622
501src_install() { 623kernel-2_src_install() {
502 install_universal 624 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 625 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 626 [ "${ETYPE}" == "sources" ] && install_sources
505} 627}
506 628
507pkg_postinst() { 629kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 630 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 631 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 632}
511 633
512pkg_setup() { 634kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 635 [ "${ETYPE}" == "headers" ] && setup_headers
636
637 # This is to fix some weird portage bug? in stable versions of portage.
638 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
514} 639}

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

  ViewVC Help
Powered by ViewVC 1.1.20