/[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.53 Revision 1.54
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.53 2004/11/26 02:08:27 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.54 2004/11/26 09:55:44 johnm Exp $
4 4
5# 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
6# with back-compatibility for 2.4 6# series of kernel with back-compatibility for 2.4
7# 7#
8# Author: John Mylchreest <johnm@gentoo.org> 8# Maintainer: John Mylchreest <johnm@gentoo.org>
9# Copyright 2004 Gentoo Linux 9# Copyright 2004 Gentoo Linux
10# 10#
11# Please direct your bugs to the current eclass maintainer :) 11# Please direct your bugs to the current eclass maintainer :)
12# thatll be: johnm
13 12
14# added functionality: 13# added functionality:
15# unipatch - a flexible, singular method to extract, add and remove patches. 14# unipatch - a flexible, singular method to extract, add and remove patches.
16 15
17# A Couple of env vars are available to effect behaviour of this eclass 16# A Couple of env vars are available to effect usage of this eclass
18# These are as follows: 17# These are as follows:
19# 18#
20# K_NOFIXINSTALL_PATH - some patches (wolk for example) dont like INSTALL_PATH
21# being fixed prior to patching. therefore having this
22# option set disables the command to change this.
23# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be 19# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile
24# automatically set within the kernel Makefile
25# K_NOUSENAME - if this is set then EXTRAVERSION will not include the 20# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION
26# first part of ${PN} in EXTRAVERSION 21# 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
27# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, 22# - and not use it as a true package revision
28# ck-sources, ac-sources) it will use PR (ie: -r5) 23# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages
29# as the patchset version and not use it as a true
30# package revision
31# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
32# postinst and can be used to carry additional postinst
33# messages
34# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's 24# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
35# K_NODETECTVER - Dont try to detect_version in pkg_setup. we will 25
36# specify KV, OKV and EXTRAVERSION ourselves.
37# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which 26# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild
38# can be supported by the headers ebuild 27
39# UNIPATCH_LIST - space delimetered list of patches to be applied to the 28# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
40# kernel
41# UNIPATCH_EXCLUDE - an additional var to support exlusion based completely 29# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely on "<passedstring>*" and not "<passedno#>_*"
42# on "<passedstring>*" and not "<passedno#>_*" 30# - this should _NOT_ be used from the ebuild as this is reserved for end users passing excludes from the cli
43# - this should _NOT_ be used from the ebuild as this is
44# reserved for end users passing excludes from the cli
45# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the 31# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
46# doc dir
47# UNIPATCH_STRICTORDER - if this is set places patches into directories of 32# UNIPATCH_STRICTORDER - if this is set places patches into directories of order, so they are applied in the order passed
48# order, so they are applied in the order passed
49 33
50ECLASS="kernel-2" 34ECLASS="kernel-2"
51INHERITED="$INHERITED $ECLASS" 35INHERITED="$INHERITED $ECLASS"
52EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst 36EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
53 37
67KV_PATCH=${KV_PATCH/[-_]*/} 51KV_PATCH=${KV_PATCH/[-_]*/}
68 52
69# set LINUX_HOSTCFLAGS if not already set 53# set LINUX_HOSTCFLAGS if not already set
70[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 54[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
71 55
72#Eclass functions only from here onwards... 56#Eclass functions only from here onwards ...
73#============================================================== 57#==============================================================
74kernel_is() { 58kernel_is() {
75 local RESULT 59 local RESULT
76 RESULT=1 60 RESULT=1
77 61
97kernel_is_2_4() { 81kernel_is_2_4() {
98 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1 82 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
99} 83}
100 84
101kernel_is_2_6() { 85kernel_is_2_6() {
102 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \ 86 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
103 return 0 || return 1
104} 87}
105 88
106# Capture the sources type and set DEPENDs 89# Capture the sources type and set DEPENDs
107if [ "${ETYPE}" == "sources" ] 90if [ "${ETYPE}" == "sources" ]
108then 91then
109 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 92 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
110 DEPEND="!build? ( sys-apps/sed 93 DEPEND="!build? ( sys-apps/sed
111 >=sys-devel/binutils-2.11.90.0.31 ) 94 >=sys-devel/binutils-2.11.90.0.31 )
112 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )" 95 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
113 96
114 RDEPEND="${DEPEND} 97 RDEPEND="${DEPEND}
115 !build? ( >=sys-libs/ncurses-5.2 98 !build? ( >=sys-libs/ncurses-5.2
116 dev-lang/perl 99 dev-lang/perl
117 sys-apps/module-init-tools 100 sys-apps/module-init-tools
118 sys-devel/make )" 101 sys-devel/make )"
119 102
120 [ $(kernel_is_2_4) $? == 0 ] && \ 103 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" || PROVIDE="virtual/linux-sources virtual/alsa"
121 PROVIDE="virtual/linux-sources" || \
122 PROVIDE="virtual/linux-sources virtual/alsa"
123 104
124elif [ "${ETYPE}" == "headers" ] 105elif [ "${ETYPE}" == "headers" ]
125then 106then
126 PROVIDE="virtual/kernel virtual/os-headers" 107 PROVIDE="virtual/kernel virtual/os-headers"
127else 108else
142 123
143universal_unpack() { 124universal_unpack() {
144 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 125 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
145 126
146 cd ${WORKDIR} 127 cd ${WORKDIR}
147
148 unpack linux-${OKV}.tar.bz2 128 unpack linux-${OKV}.tar.bz2
149 if [ "${OKV}" != "${KV}" ] 129 if [ "${OKV}" != "${KV}" ]
150 then 130 then
151 mv linux-${OKV} linux-${KV} || \ 131 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
152 die "Unable to move source tree to ${KV}."
153 fi 132 fi
154
155 cd ${S} 133 cd ${S}
134
156 # change incorrect install path 135 # change incorrect install path
157 [ -z "${K_NOFIXINSTALL_PATH}" ] && \ 136 mv Makefile Makefile.orig
158 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile 137 sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
138 Makefile.orig > Makefile
139 rm Makefile.orig
159 140
160 # remove all backup files 141 # remove all backup files
161 find . -iname "*~" -exec rm {} \; 2> /dev/null 142 find . -iname "*~" -exec rm {} \; 2> /dev/null
162 143
163 if [ -d "${S}/Documentation/DocBook" ] 144 if [ -d "${S}/Documentation/DocBook" ]
164 then 145 then
165 cd ${S}/Documentation/DocBook 146 cd ${S}/Documentation/DocBook
166 sed -i -e "s:db2:docbook2:g" Makefile 147 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
148 && mv Makefile.new Makefile
167 cd ${S} 149 cd ${S}
168 fi 150 fi
169} 151}
170 152
171unpack_set_extraversion() { 153unpack_set_extraversion() {
154 # Gentoo Linux uses /boot, so fix 'make install' to work properly and fix EXTRAVERSION
172 cd ${S} 155 cd ${S}
156 mv Makefile Makefile.orig
173 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile 157 sed -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \
158 Makefile.orig > Makefile
159 rm Makefile.orig
174} 160}
175 161
176# Compile Functions 162# Compile Functions
177#============================================================== 163#==============================================================
178compile_headers() { 164compile_headers() {
186} 172}
187 173
188compile_manpages() { 174compile_manpages() {
189 local MY_ARCH 175 local MY_ARCH
190 176
191 einfo "Making manpages..." 177 einfo "Making manpages ..."
192 MY_ARCH=${ARCH} 178 MY_ARCH=${ARCH}
193 unset ARCH 179 unset ARCH
194 make mandocs 180 make mandocs
195 ARCH=${MY_ARCH} 181 ARCH=${MY_ARCH}
196} 182}
228 local docs 214 local docs
229 local file 215 local file
230 216
231 cd ${S} 217 cd ${S}
232 dodir /usr/src 218 dodir /usr/src
233 echo ">>> Copying sources..." 219 echo ">>> Copying sources ..."
234 file="$(find ${WORKDIR} -iname "docs" -type d)" 220 file="$(find ${WORKDIR} -iname "docs" -type d)"
235 if [ -n "${file}" ] 221 if [ -n "${file}" ]
236 then 222 then
237 for file in $(find ${file} -type f) 223 for file in $(find ${file} -type f)
238 do 224 do
239 echo "${file/*docs\//}" >> ${S}/patches.txt 225 echo "${file/*docs\//}" >> ${S}/patches.txt
240 echo "=========================================" >> ${S}/patches.txt 226 echo "===================================================" >> ${S}/patches.txt
241 cat ${file} >> ${S}/patches.txt 227 cat ${file} >> ${S}/patches.txt
242 echo "=========================================" >> ${S}/patches.txt 228 echo "===================================================" >> ${S}/patches.txt
243 echo "" >> ${S}/patches.txt 229 echo "" >> ${S}/patches.txt
244 done 230 done
245 fi 231 fi
246 232
247 if [ ! -f ${S}/patches.txt ] 233 if [ ! -f ${S}/patches.txt ]
248 then 234 then
249 # patches.txt is empty so lets use our ChangeLog 235 # patches.txt is empty so lets use our ChangeLog
250 [ -f ${FILESDIR}/../ChangeLog ] && \ 236 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
251 echo "Please check the ebuild ChangeLog for more details." \
252 > ${S}/patches.txt
253 fi 237 fi
254 238
255 for doc in ${UNIPATCH_DOCS} 239 for doc in ${UNIPATCH_DOCS}
256 do 240 do
257 [ -f ${doc} ] && docs="${docs} ${doc}" 241 [ -f ${doc} ] && docs="${docs} ${doc}"
319 done 303 done
320 304
321 echo 305 echo
322 fi 306 fi
323 307
324 # Show policy version, if this kernel has SELinux... 308 # Show policy version, if this kernel has SELinux ...
325 local secfile
326 secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h" 309 local secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h"
327 if use selinux && [ -f "$secfile" ] 310 if use selinux && [ -f "$secfile" ]
328 then 311 then
329 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile) 312 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
330 einfo "The SELinux policy version of this kernel is $polver." 313 einfo "The SELinux policy version of this kernel is $polver."
331 echo 314 echo
349 einfo "Kernel headers are usually only used when recompiling glibc." 332 einfo "Kernel headers are usually only used when recompiling glibc."
350 einfo "Following the installation of newer headers it is advised that" 333 einfo "Following the installation of newer headers it is advised that"
351 einfo "you re-merge glibc as follows:" 334 einfo "you re-merge glibc as follows:"
352 einfo "# emerge glibc" 335 einfo "# emerge glibc"
353 einfo "Failure to do so will cause glibc to not make use of newer" 336 einfo "Failure to do so will cause glibc to not make use of newer"
354 einfo "features present in the updated kernel headers." 337 einfo "features present in the updated kernelheaders."
355 echo 338 echo
356} 339}
357 340
358# pkg_setup functions 341# pkg_setup functions
359#============================================================== 342#==============================================================
360setup_headers() { 343setup_headers() {
361 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ \ 344 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/)
362 -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ \
363 -e s/amd64/x86_64/)
364 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64" 345 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
365 346
366 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}" 347 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
367 for i in ${H_SUPPORTEDARCH} 348 for i in ${H_SUPPORTEDARCH}
368 do 349 do
397 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 378 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
398 379
399 # We're gonna need it when doing patches with a predefined patchlevel 380 # We're gonna need it when doing patches with a predefined patchlevel
400 shopt -s extglob 381 shopt -s extglob
401 382
402 # This function will unpack all passed tarballs, add any passed patches, 383 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
403 # and remove any passed patchnumbers
404 # usage can be either via an env var or by params 384 # usage can be either via an env var or by params
405 [ -n "${@}" ] && UNIPATCH_LIST="${@} ${UNIPATCH_LIST}" 385 # although due to the nature we pass this within this eclass
386 # it shall be by param only.
387 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
388 UNIPATCH_LIST="${@}"
406 389
407 #unpack any passed tarballs 390 #unpack any passed tarballs
408 for i in ${UNIPATCH_LIST} 391 for i in ${UNIPATCH_LIST}
409 do 392 do
410 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 393 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
422 405
423 if [ -n "${UNIPATCH_STRICTORDER}" ] 406 if [ -n "${UNIPATCH_STRICTORDER}" ]
424 then 407 then
425 STRICT_COUNT=$((${STRICT_COUNT} + 1)) 408 STRICT_COUNT=$((${STRICT_COUNT} + 1))
426 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/ 409 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
427 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ \ 410 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
428 1>/dev/null
429 else 411 else
430 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null 412 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
431 fi 413 fi
432 414
433 if [ $? == 0 ] 415 if [ $? == 0 ]
434 then 416 then
435 einfo "${i/*\//} unpacked" 417 einfo "${i/*\//} unpacked"
436 [ -n "$(echo ${i} | grep ':')" ] && \
437 echo ">>> Strict patch levels not currently supported for tarballed patchsets" 418 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
438 else 419 else
439 eerror "Failed to unpack ${i/:*/}" 420 eerror "Failed to unpack ${i/:*/}"
440 die "unable to unpack patch tarball" 421 die "unable to unpack patch tarball"
441 fi 422 fi
442 else 423 else
462 if [ ! -r "${i}" ] 443 if [ ! -r "${i}" ]
463 then 444 then
464 echo 445 echo
465 eerror "FATAL: unable to locate:" 446 eerror "FATAL: unable to locate:"
466 eerror "${i}" 447 eerror "${i}"
467 eerror "for read-only. The file either has incorrect" 448 eerror "for read-only. The file either has incorrect permissions"
468 eerror "permissions or does not exist." 449 eerror "or does not exist."
469 die Unable to locate ${i} 450 die Unable to locate ${i}
470 fi 451 fi
471 452
472 if [ -n "${UNIPATCH_STRICTORDER}" ] 453 if [ -n "${UNIPATCH_STRICTORDER}" ]
473 then 454 then
474 STRICT_COUNT=$((${STRICT_COUNT} + 1)) 455 STRICT_COUNT=$((${STRICT_COUNT} + 1))
475 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/ 456 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
476 $(${PIPE_CMD} ${i} > \
477 ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL}) 457 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
478 else 458 else
479 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) 459 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
480 fi 460 fi
481 fi 461 fi
482 fi 462 fi
493 473
494 #so now lets get rid of the patchno's we want to exclude 474 #so now lets get rid of the patchno's we want to exclude
495 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}" 475 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
496 for i in ${UNIPATCH_DROP} 476 for i in ${UNIPATCH_DROP}
497 do 477 do
498 einfo "Excluding Patch #${i}"
499 for x in ${KPATCH_DIR} 478 for x in ${KPATCH_DIR}
500 do 479 do
501 rm -f ${x}/${i}* 2>/dev/null 480 rm -f ${x}/${i}* 2>/dev/null
481 if [ $? == 0 ]
482 then
483 einfo "Excluding Patch #${i}"
484 einfo "From: ${x/${WORKDIR}/}"
485 fi
502 done 486 done
503 done 487 done
504 488
505 # and now, finally, we patch it :) 489 # and now, finally, we patch it :)
506 for x in ${KPATCH_DIR} 490 for x in ${KPATCH_DIR}
507 do 491 do
508 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n) 492 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
509 do 493 do
510 unset PATCH_DEPTH
511
512 STDERR_T="${T}/${i/*\//}" 494 STDERR_T="${T}/${i/*\//}"
513 STDERR_T="${STDERR_T/.patch*/.err}" 495 STDERR_T="${STDERR_T/.patch*/.err}"
514 STDERR_T="${STDERR_T/.diff*/.err}"
515 496
516 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/} 497 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
517 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/} 498 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
518 499
519 if [ -z "${PATCH_DEPTH}" ]; then 500 if [ -z "${PATCH_DEPTH}" ]; then
520 PATCH_DEPTH=0 501 PATCH_DEPTH=0
521 fi 502 fi
522 503
523 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)" 504 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
524 while [ ${PATCH_DEPTH} -lt 5 ] 505 while [ ${PATCH_DEPTH} -lt 5 ]
525 do 506 do
526 echo "Attempting Dry-run:" >> ${STDERR_T} 507 echo "Attempting Dry-run:" >> ${STDERR_T}
527 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T} 508 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
528 echo "==========================================" >> ${STDERR_T} 509 echo "=======================================================" >> ${STDERR_T}
529 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ] 510 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
530 then 511 then
531 echo "Attempting patch:" > ${STDERR_T} 512 echo "Attempting patch:" > ${STDERR_T}
532 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T} 513 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
533 echo "======================================" >> ${STDERR_T} 514 echo "=======================================================" >> ${STDERR_T}
534 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ] 515 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
535 then 516 then
536 eend 0 517 eend 0
537 rm ${STDERR_T} 518 rm ${STDERR_T}
538 break 519 break
539 else 520 else
540 eend 1 521 eend 1
541 eerror "Failed to apply patch ${i/*\//}" 522 eerror "Failed to apply patch ${i/*\//}"
542 eerror "Please attach ${STDERR_T} to any bug you post." 523 eerror "Please attach ${STDERR_T} to any bug you may post."
543 die "Failed to apply ${i/*\//}" 524 die "Failed to apply ${i/*\//}"
544 fi 525 fi
545 else 526 else
546 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 527 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
547 fi 528 fi
548 done 529 done
549 if [ ${PATCH_DEPTH} -eq 5 ] 530 if [ ${PATCH_DEPTH} -eq 5 ]
550 then 531 then
551 eend 1 532 eend 1
552 eerror "Please attach ${STDERR_T} to any bug you post." 533 eerror "Please attach ${STDERR_T} to any bug you may post."
553 die "Unable to dry-run patch." 534 die "Unable to dry-run patch."
554 fi 535 fi
555 done 536 done
556 done 537 done
557 538
565 546
566# custom functions 547# custom functions
567#============================================================== 548#==============================================================
568detect_version() { 549detect_version() {
569 # this function will detect and set 550 # this function will detect and set
570 # OKV: Original Kernel Version (2.6.0/2.6.0-test11) 551 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
571 # KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) 552 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
572 # EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 553 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
573 554
574 # if ${DETECTED} is still set then we must know about all this other stuff
575 # too, so lets just reset S and be done with it
576 if [ -n "${DETECTED}" ];
577 then
578 # set S properly again shall we?
579 S=${WORKDIR}/linux-${KV}
580 return
581 fi
582
583 if [ -z "${OKV}" ];
584 then
585 OKV=${PV/_beta/-test} 555 OKV=${PV/_beta/-test}
586 OKV=${OKV/_rc/-rc} 556 OKV=${OKV/_rc/-rc}
587 OKV=${OKV/_pre*/} 557 OKV=${OKV/_pre*/}
588 OKV=${OKV/-r*/} 558 OKV=${OKV/-r*/}
589 fi
590 559
591 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 560 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
592 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 561 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
593 KV_PATCH=$(echo ${OKV} | cut -d. -f3-) 562 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
594 KV_PATCH=${KV_PATCH/[-_]*/} 563 KV_PATCH=${KV_PATCH/[-_]*/}
595 564
596 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 565 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
597 566
598 RELEASE=${PV/${OKV}/} 567 RELEASE=${PV/${OKV}/}
599 RELEASE=${RELEASE/_beta/} 568 RELEASE=${RELEASE/_beta/}
600 RELEASE=${RELEASE/_rc/-rc} 569 RELEASE=${RELEASE/_rc/-rc}
601 if [ $(kernel_is_2_4) $? == 0 ] 570 if [ $(kernel_is_2_4) $? == 0 ]
602 then 571 then
603 RELEASE=${RELEASE/_pre/-pre} 572 RELEASE=${RELEASE/_pre/-pre}
604 else 573 else
605 RELEASE=${RELEASE/_pre/-bk} 574 RELEASE=${RELEASE/_pre/-bk}
606 fi 575 fi
607 RELEASETYPE=${RELEASE//[0-9]/} 576 RELEASETYPE=${RELEASE//[0-9]/}
577
608 EXTRAVERSION="${RELEASE}" 578 EXTRAVERSION="${RELEASE}"
609 579
610 if [ -n "${K_PREPATCHED}" ] 580 if [ -n "${K_PREPATCHED}" ]
611 then 581 then
612 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}" 582 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
613 else 583 else
614 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 584 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
615 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
616 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 585 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
617 fi 586 fi
618 587
588 KV=${OKV}${EXTRAVERSION}
589
619 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the 590 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
620 # portage naming convention these cannot be supported, but the code here can 591 # these cannot be supported, but the code here can handle it up until this point
621 # handle it up until this point and theoretically thereafter. 592 # and theoretically thereafter.
622 593
623 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ] 594 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
624 then 595 then
625 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && \ 596 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
626 echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
627 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 597 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
628 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 598 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
629 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2" 599 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
630 KV=${PV/[-_]*/}${EXTRAVERSION} 600 KV=${PV/[-_]*/}${EXTRAVERSION}
631 fi 601 fi
647 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 617 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
648 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 618 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
649 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2" 619 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
650 KV=${PV/[-_]*/}${EXTRAVERSION} 620 KV=${PV/[-_]*/}${EXTRAVERSION}
651 fi 621 fi
652 622
653 S=${WORKDIR}/linux-${KV} 623 S=${WORKDIR}/linux-${KV}
654 DETECTED="yes"
655} 624}
656 625
657detect_arch() { 626detect_arch() {
658 # This function sets ARCH_URI and ARCH_PATCH 627 # This function sets ARCH_URI and ARCH_PATCH
659 # with the neccessary info for the arch sepecific compatibility 628 # with the neccessary info for the arch sepecific compatibility
675 for LOOP_ARCH in ${ALL_ARCH} 644 for LOOP_ARCH in ${ALL_ARCH}
676 do 645 do
677 COMPAT_URI="${LOOP_ARCH}_URI" 646 COMPAT_URI="${LOOP_ARCH}_URI"
678 COMPAT_URI="${!COMPAT_URI}" 647 COMPAT_URI="${!COMPAT_URI}"
679 648
680 [ -n "${COMPAT_URI}" ] && \ 649 [ -n "${COMPAT_URI}" ] && ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
681 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
682 650
683 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ] 651 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
684 then 652 then
685 for i in ${COMPAT_URI} 653 for i in ${COMPAT_URI}
686 do 654 do
687 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}" 655 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
688 done 656 done
693 661
694# common functions 662# common functions
695#============================================================== 663#==============================================================
696kernel-2_src_unpack() { 664kernel-2_src_unpack() {
697 universal_unpack 665 universal_unpack
698 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \ 666 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
699 unipatch "${UNIPATCH_LIST_DEFAULT}"
700 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 667 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
701 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 668 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
702} 669}
703 670
704kernel-2_src_compile() { 671kernel-2_src_compile() {
705 [ "${ETYPE}" == "headers" ] && compile_headers 672 [ "${ETYPE}" == "headers" ] && compile_headers
706 [ "${ETYPE}" == "sources" ] && \
707 use doc && ! use arm && ! use s390 && compile_manpages 673 [ "${ETYPE}" == "sources" ] && use doc && ! use arm && ! use s390 && compile_manpages
708} 674}
709 675
710kernel-2_pkg_preinst() { 676kernel-2_pkg_preinst() {
711 [ "${ETYPE}" == "headers" ] && preinst_headers 677 [ "${ETYPE}" == "headers" ] && preinst_headers
712} 678}
722 [ "${ETYPE}" == "sources" ] && postinst_sources 688 [ "${ETYPE}" == "sources" ] && postinst_sources
723} 689}
724 690
725kernel-2_pkg_setup() { 691kernel-2_pkg_setup() {
726 [ "${ETYPE}" == "headers" ] && setup_headers 692 [ "${ETYPE}" == "headers" ] && setup_headers
693
694 # This is to fix some weird portage bug? in stable versions of portage.
695 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
727} 696}
697
698

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

  ViewVC Help
Powered by ViewVC 1.1.20