/[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.38
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.38 2004/07/08 02:03:41 mr_bones_ 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 doc"
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
121 yes "" | make oldconfig 164 yes "" | make oldconfig
122 echo ">>> make oldconfig complete" 165 echo ">>> make oldconfig complete"
123 ARCH=${MY_ARCH} 166 ARCH=${MY_ARCH}
124} 167}
125 168
169compile_manpages() {
170 local MY_ARCH
171
172 einfo "Making manpages..."
173 MY_ARCH=${ARCH}
174 unset ARCH
175 make mandocs
176 ARCH=${MY_ARCH}
177}
178
126# install functions 179# install functions
127#============================================================== 180#==============================================================
128install_universal() { 181install_universal() {
129 #fix silly permissions in tarball 182 #fix silly permissions in tarball
130 cd ${WORKDIR} 183 cd ${WORKDIR}
132 chmod -R a+r-w+X,u+w * 185 chmod -R a+r-w+X,u+w *
133} 186}
134 187
135install_headers() { 188install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 189 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 190
138
139 cd ${S} 191 cd ${S}
140 dodir /usr/include/linux 192 dodir /usr/include/linux
193 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 194 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
142 rm -rf ${D}/usr/include/linux/modules 195 rm -rf ${D}/usr/include/linux/modules
196
143 dodir /usr/include/asm 197 dodir /usr/include/asm
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 198 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145 199
146 if [ $(kernel_is_2_6) $? == 0 ] 200 if [ $(kernel_is_2_6) $? == 0 ]
147 then 201 then
151} 205}
152 206
153install_sources() { 207install_sources() {
154 local doc 208 local doc
155 local docs 209 local docs
210 local file
156 211
157 cd ${S} 212 cd ${S}
158 dodir /usr/src 213 dodir /usr/src
159 echo ">>> Copying sources..." 214 echo ">>> Copying sources..."
160 if [ -d "${WORKDIR}/${KV}/docs/" ] 215 file="$(find ${WORKDIR} -iname "docs" -type d)"
216 if [ -n "${file}" ]
161 then 217 then
162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 218 for file in $(find ${file} -type f)
163 do 219 do
164 echo "XX_${file}*" >> ${S}/patches.txt 220 echo "${file/*docs\//}" >> ${S}/patches.txt
221 echo "===================================================" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt 222 cat ${file} >> ${S}/patches.txt
223 echo "===================================================" >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt 224 echo "" >> ${S}/patches.txt
167 done 225 done
168 fi 226 fi
169 227
170 if [ ! -f ${S}/patches.txt ] 228 if [ ! -f ${S}/patches.txt ]
179 done 237 done
180 238
181 if [ -f ${S}/patches.txt ]; then 239 if [ -f ${S}/patches.txt ]; then
182 docs="${docs} ${S}/patches.txt" 240 docs="${docs} ${S}/patches.txt"
183 fi 241 fi
242
243 if use doc; then
244 install_manpages
245 fi
246
184 dodoc ${docs} 247 dodoc ${docs}
185 mv ${WORKDIR}/linux* ${D}/usr/src 248 mv ${WORKDIR}/linux* ${D}/usr/src
249}
250
251install_manpages() {
252 local MY_ARCH
253
254 ebegin "Installing mapages"
255 MY_ARCH=${ARCH}
256 unset ARCH
257 sed -i -e "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
258 make installmandocs
259 eend $?
260 sed -i -e "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
261 ARCH=${MY_ARCH}
186} 262}
187 263
188# pkg_preinst functions 264# pkg_preinst functions
189#============================================================== 265#==============================================================
190preinst_headers() { 266preinst_headers() {
219 while read -s ELINE 295 while read -s ELINE
220 do 296 do
221 einfo "${ELINE}" 297 einfo "${ELINE}"
222 done 298 done
223 299
300 echo
301 fi
302
303 # Show policy version, if this kernel has SELinux...
304 local secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h"
305 if use selinux && [ -f "$secfile" ]
306 then
307 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
308 einfo "The SELinux policy version of this kernel is $polver."
224 echo 309 echo
225 fi 310 fi
226 311
227 # if K_EXTRAEWARN is set then lets display it now 312 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 313 if [ -n "${K_EXTRAEWARN}" ]
275unipatch() { 360unipatch() {
276 local i 361 local i
277 local x 362 local x
278 local extention 363 local extention
279 local PIPE_CMD 364 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 365 local UNIPATCH_DROP
281 local KPATCH_DIR 366 local KPATCH_DIR
282 local PATCH_DEPTH 367 local PATCH_DEPTH
283 local ELINE 368 local ELINE
369 local STRICT_COUNT
284 370
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 371 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 372 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 373
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 374 # 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 375 # usage can be either via an env var or by params
376 # although due to the nature we pass this within this eclass
377 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 378 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
379 UNIPATCH_LIST="${@}"
291 380
292 #unpack any passed tarballs 381 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 382 for i in ${UNIPATCH_LIST}
294 do 383 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 384 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
302 gz) PIPE_CMD="tar -xvzf";; 391 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 392 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 393 die "Unrecognized tarball compression";;
305 esac 394 esac
306 395
396 if [ -n "${UNIPATCH_STRICTORDER}" ]
397 then
398 STRICT_COUNT=$((${STRICT_COUNT} + 1))
399 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
400 ${PIPE_CMD} ${i} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
401 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 402 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null
403 fi
404
308 if [ $? == 0 ] 405 if [ $? == 0 ]
309 then 406 then
310 einfo "${i/*\//} unpacked" 407 einfo "${i/*\//} unpacked"
311 else 408 else
312 eerror "Failed to unpack ${i}" 409 eerror "Failed to unpack ${i}"
313 die "unable to unpack patch tarball" 410 die "unable to unpack patch tarball"
314 fi 411 fi
315 412 else
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 413 extention=${i/*./}
414 PIPE_CMD=""
415 case ${extention} in
416 bz2) PIPE_CMD="bzip2 -dc";;
417 patch) PIPE_CMD="cat";;
418 diff) PIPE_CMD="cat";;
419 gz|Z|z) PIPE_CMD="gzip -dc";;
420 ZIP|zip) PIPE_CMD="unzip -p";;
421 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i}";;
422 esac
423 x=${i/*\//}
424 x=${x/\.${extention}/}
425
426 if [ -n "${PIPE_CMD}" ]
427 then
428 if [ ! -r "${i}" ]
429 then
430 echo
431 eerror "FATAL: unable to locate:"
432 eerror "${i}"
433 eerror "for read-only. The file either has incorrect permissions"
434 eerror "or does not exist."
435 die Unable to locate ${i}
436 fi
437
438 if [ -n "${UNIPATCH_STRICTORDER}" ]
439 then
440 STRICT_COUNT=$((${STRICT_COUNT} + 1))
441 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
442 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch)
443 else
444 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch)
445 fi
446 fi
317 fi 447 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 448 done
337 449
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 450 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 451 x=${KPATCH_DIR}
340 KPATCH_DIR="" 452 KPATCH_DIR=""
341 for i in $(find ${x} -type d) 453 for i in $(find ${x} -type d | sort -n)
342 do 454 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 455 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 456 done
345 457
346 #so now lets get rid of the patchno's we want to exclude 458 #so now lets get rid of the patchno's we want to exclude
459 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 460 for i in ${UNIPATCH_DROP}
348 do 461 do
349 for x in ${KPATCH_DIR} 462 for x in ${KPATCH_DIR}
350 do 463 do
351 rm ${x}/${i}_* 2>/dev/null 464 rm -f ${x}/${i}* 2>/dev/null
352 if [ $? == 0 ] 465 if [ $? == 0 ]
353 then 466 then
354 einfo "Excluding Patch #${i}" 467 einfo "Excluding Patch #${i}"
355 einfo "From: ${x/${WORKDIR}/}" 468 einfo "From: ${x/${WORKDIR}/}"
356 fi 469 fi
358 done 471 done
359 472
360 # and now, finally, we patch it :) 473 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 474 for x in ${KPATCH_DIR}
362 do 475 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 476 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -n)
364 do 477 do
365 478 STDERR_T="${T}/${i/*\//}"
366 479 STDERR_T="${STDERR_T/.patch/.err}"
480
367 PATCH_DEPTH=0 481 PATCH_DEPTH=0
368 ebegin "Applying ${i/*\//}" 482 ebegin "Applying ${i/*\//}"
369 while [ ${PATCH_DEPTH} -lt 5 ] 483 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 484 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 485 echo "Attempting Dry-run:" >> ${STDERR_T}
486 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
487 echo "=======================================================" >> ${STDERR_T}
488 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 489 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 490 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 491 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
492 echo "=======================================================" >> ${STDERR_T}
493 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 494 then
376 eend 0 495 eend 0
496 rm ${STDERR_T}
377 break 497 break
378 else 498 else
379 eend 1 499 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 500 eerror "Failed to apply patch ${i/*\//}"
501 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 502 die "Failed to apply ${i/*\//}"
382 fi 503 fi
383 else 504 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 505 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 506 fi
386 done 507 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 508 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 509 then
389 eend 1 510 eend 1
511 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 512 die "Unable to dry-run patch."
391 fi 513 fi
392
393
394 done 514 done
395 done 515 done
396} 516}
397 517
398# custom functions 518# custom functions
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 536 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 537
418 RELEASE=${PV/${OKV}/} 538 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 539 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 540 RELEASE=${RELEASE/_rc/-rc}
541 if [ $(kernel_is_2_4) $? == 0 ]
542 then
543 RELEASE=${RELEASE/_pre/-pre}
544 else
421 RELEASE=${RELEASE/_pre/-bk} 545 RELEASE=${RELEASE/_pre/-bk}
546 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 547 RELEASETYPE=${RELEASE//[0-9]/}
423 548
424 EXTRAVERSION="${RELEASE}" 549 EXTRAVERSION="${RELEASE}"
425 550
426 if [ -n "${K_PREPATCHED}" ] 551 if [ -n "${K_PREPATCHED}" ]
427 then 552 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 553 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 554 else
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 555 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 556 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 557 fi
558
433 KV=${OKV}${EXTRAVERSION} 559 KV=${OKV}${EXTRAVERSION}
434 fi
435 560
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 561 # -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 562 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 563 # and theoretically thereafter.
439 564
440 if [ "${RELEASETYPE}" == "-rc" ] 565 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 566 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 567 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 568 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" 569 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 570 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 571 KV=${PV/[-_]*/}${EXTRAVERSION}
447 fi 572 fi
448 573
449 if [ "${RELEASETYPE}" == "-bk" ] 574 if [ "${RELEASETYPE}" == "-bk" ]
450 then 575 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 576 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 577 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" 578 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}" 579 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} 580 KV=${PV/[-_]*/}${EXTRAVERSION}
456 fi 581 fi
457 582
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 583 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 584 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 585 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})" 586 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 587
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 588 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" 589 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}" 590 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} 591 KV=${PV/[-_]*/}${EXTRAVERSION}
467 fi 592 fi
468 593
469 S=${WORKDIR}/linux-${KV} 594 S=${WORKDIR}/linux-${KV}
470} 595}
471 596
597detect_arch() {
598 # This function sets ARCH_URI and ARCH_PATCH
599 # with the neccessary info for the arch sepecific compatibility
600 # patchsets.
601
602 local ALL_ARCH
603 local LOOP_ARCH
604 local COMPAT_URI
605 local i
606
607 # COMPAT_URI is the contents of ${ARCH}_URI
608 # ARCH_URI is the URI for all the ${ARCH}_URI patches
609 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
610
611 ARCH_URI=""
612 ARCH_PATCH=""
613 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
614
615 for LOOP_ARCH in ${ALL_ARCH}
616 do
617 COMPAT_URI="${LOOP_ARCH}_URI"
618 COMPAT_URI="${!COMPAT_URI}"
619
620 [ -n "${COMPAT_URI}" ] && ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
621
622 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ]
623 then
624 for i in ${COMPAT_URI}
625 do
626 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
627 done
628 fi
629 done
630}
631
472 632
473# common functions 633# common functions
474#============================================================== 634#==============================================================
475src_unpack() { 635kernel-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 636 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST} 637 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 638 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 639 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491} 640}
492 641
493src_compile() { 642kernel-2_src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 643 [ "${ETYPE}" == "headers" ] && compile_headers
644 [ "${ETYPE}" == "sources" ] && use doc && compile_manpages
495} 645}
496 646
497pkg_preinst() { 647kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 648 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 649}
500 650
501src_install() { 651kernel-2_src_install() {
502 install_universal 652 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 653 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 654 [ "${ETYPE}" == "sources" ] && install_sources
505} 655}
506 656
507pkg_postinst() { 657kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 658 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 659 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 660}
511 661
512pkg_setup() { 662kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 663 [ "${ETYPE}" == "headers" ] && setup_headers
664
665 # This is to fix some weird portage bug? in stable versions of portage.
666 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
514} 667}

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

  ViewVC Help
Powered by ViewVC 1.1.20