/[gentoo-x86]/eclass/kernel-2.eclass
Gentoo

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.47 - (hide annotations) (download)
Wed Nov 24 16:36:38 2004 UTC (14 years, 7 months ago) by johnm
Branch: MAIN
Changes since 1.46: +113 -88 lines
Updating kernel-2 to properly honour strict patch levels with *.diff , adding linux-* in preparation for the 'Big Module Move of 2004'

1 vapier 1.35 # Copyright 1999-2004 Gentoo Foundation
2 johnm 1.13 # Distributed under the terms of the GNU General Public License v2
3 johnm 1.47 # $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.40 2004/07/11 20:38:24 spock Exp $
4 johnm 1.13
5 johnm 1.47 # kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel
6     # with back-compatibility for 2.4
7 johnm 1.3 #
8 johnm 1.47 # Author: John Mylchreest <johnm@gentoo.org>
9     # Copyright 2004 Gentoo Linux
10 johnm 1.3 #
11     # Please direct your bugs to the current eclass maintainer :)
12 johnm 1.47 # thatll be: johnm
13 johnm 1.1
14     # added functionality:
15     # unipatch - a flexible, singular method to extract, add and remove patches.
16    
17 johnm 1.47 # A Couple of env vars are available to effect behaviour of this eclass
18 johnm 1.1 # These are as follows:
19     #
20 johnm 1.47 # 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
24     # automatically set within the kernel Makefile
25     # K_NOUSENAME - if this is set then EXTRAVERSION will not include the
26     # first part of ${PN} in EXTRAVERSION
27     # K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
28     # ck-sources, ac-sources) it will use PR (ie: -r5)
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
35     # H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
36     # can be supported by the headers ebuild
37     # UNIPATCH_LIST - space delimetered list of patches to be applied to the
38     # kernel
39     # UNIPATCH_EXCLUDE - an additional var to support exlusion based completely
40     # on "<passedstring>*" and not "<passedno#>_*"
41     # - this should _NOT_ be used from the ebuild as this is
42     # reserved for end users passing excludes from the cli
43     # UNIPATCH_DOCS - space delimemeted list of docs to be installed to the
44     # doc dir
45     # UNIPATCH_STRICTORDER - if this is set places patches into directories of
46     # order, so they are applied in the order passed
47 johnm 1.1
48     ECLASS="kernel-2"
49 plasmaroo 1.33 INHERITED="$INHERITED $ECLASS"
50 johnm 1.13 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
51 johnm 1.1
52 johnm 1.30 # to prevent errors if theres no sources in /usr/src
53     # we set KV and re-set it later on as well.
54     [ -z "${KV}" ] && KV=${PV}
55    
56 johnm 1.1 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
57     LICENSE="GPL-2"
58 spock 1.37 IUSE="${IUSE} build doc"
59 johnm 1.1 SLOT="${KV}"
60    
61 johnm 1.18 # Grab kernel version from KV
62     KV_MAJOR=$(echo ${KV} | cut -d. -f1)
63     KV_MINOR=$(echo ${KV} | cut -d. -f2)
64 johnm 1.47 KV_PATCH=$(echo ${KV} | cut -d. -f3-)
65 johnm 1.18 KV_PATCH=${KV_PATCH/[-_]*/}
66    
67     # set LINUX_HOSTCFLAGS if not already set
68     [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
69    
70 johnm 1.47 #Eclass functions only from here onwards...
71 plasmaroo 1.33 #==============================================================
72     kernel_is() {
73     local RESULT
74     RESULT=1
75    
76     if [ -n "${1}" ]
77     then
78     [ "${1}" = "${KV_MAJOR}" ] && RESULT=0
79     fi
80    
81     if [ -n "${2}" ]
82     then
83     RESULT=1
84     [ "${2}" = "${KV_MINOR}" ] && RESULT=0
85     fi
86    
87     if [ -n "${3}" ]
88     then
89     RESULT=1
90     [ "${3}" = "${KV_PATCH}" ] && RESULT=0
91     fi
92     return ${RESULT}
93     }
94 johnm 1.18
95     kernel_is_2_4() {
96     [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
97     }
98    
99     kernel_is_2_6() {
100 johnm 1.47 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
101     return 0 || return 1
102 johnm 1.18 }
103    
104 plasmaroo 1.33 # Capture the sources type and set DEPENDs
105 johnm 1.1 if [ "${ETYPE}" == "sources" ]
106     then
107 johnm 1.47 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
108 johnm 1.1 DEPEND="!build? ( sys-apps/sed
109 spock 1.39 >=sys-devel/binutils-2.11.90.0.31 )
110 spock 1.40 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
111 johnm 1.1
112     RDEPEND="${DEPEND}
113     !build? ( >=sys-libs/ncurses-5.2
114     dev-lang/perl
115 johnm 1.6 sys-apps/module-init-tools
116 johnm 1.1 sys-devel/make )"
117 johnm 1.18
118 johnm 1.47 [ $(kernel_is_2_4) $? == 0 ] && \
119     PROVIDE="virtual/linux-sources" || \
120     PROVIDE="virtual/linux-sources virtual/alsa"
121 johnm 1.1
122     elif [ "${ETYPE}" == "headers" ]
123     then
124     PROVIDE="virtual/kernel virtual/os-headers"
125     else
126     eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\""
127     die
128     fi
129    
130     # Unpack functions
131     #==============================================================
132     unpack_2_4() {
133     cd ${S}
134     # this file is required for other things to build properly,
135     # so we autogenerate it
136     make mrproper || die "make mrproper died"
137     make include/linux/version.h || die "make include/linux/version.h failed"
138     echo ">>> version.h compiled successfully."
139     }
140    
141     universal_unpack() {
142 plasmaroo 1.33 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
143    
144     cd ${WORKDIR}
145     unpack linux-${OKV}.tar.bz2
146     if [ "${OKV}" != "${KV}" ]
147     then
148 johnm 1.47 mv linux-${OKV} linux-${KV} || \
149     die "Unable to move source tree to ${KV}."
150 plasmaroo 1.33 fi
151     cd ${S}
152 johnm 1.41
153     # change incorrect install path
154 johnm 1.47 [ -z "${K_NOFIXINSTALL_PATH}" ] && \
155     sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
156 plasmaroo 1.33
157 johnm 1.1 # remove all backup files
158     find . -iname "*~" -exec rm {} \; 2> /dev/null
159    
160     if [ -d "${S}/Documentation/DocBook" ]
161     then
162     cd ${S}/Documentation/DocBook
163 johnm 1.47 sed -i -e "s:db2:docbook2:g" Makefile
164 johnm 1.1 cd ${S}
165     fi
166     }
167    
168     unpack_set_extraversion() {
169     cd ${S}
170 johnm 1.47 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
171 johnm 1.1 }
172    
173     # Compile Functions
174     #==============================================================
175     compile_headers() {
176     local MY_ARCH
177    
178     MY_ARCH=${ARCH}
179     unset ${ARCH}
180     yes "" | make oldconfig
181     echo ">>> make oldconfig complete"
182     ARCH=${MY_ARCH}
183     }
184    
185 spock 1.37 compile_manpages() {
186     local MY_ARCH
187    
188 johnm 1.47 einfo "Making manpages..."
189 spock 1.37 MY_ARCH=${ARCH}
190     unset ARCH
191     make mandocs
192     ARCH=${MY_ARCH}
193     }
194    
195 johnm 1.1 # install functions
196     #==============================================================
197     install_universal() {
198     #fix silly permissions in tarball
199     cd ${WORKDIR}
200     chown -R root:root *
201     chmod -R a+r-w+X,u+w *
202     }
203    
204     install_headers() {
205     [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
206 johnm 1.13
207 johnm 1.1 cd ${S}
208     dodir /usr/include/linux
209 johnm 1.16 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
210 johnm 1.1 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
211     rm -rf ${D}/usr/include/linux/modules
212 johnm 1.13
213 johnm 1.1 dodir /usr/include/asm
214     cp -ax ${S}/include/asm/* ${D}/usr/include/asm
215 johnm 1.12
216     if [ $(kernel_is_2_6) $? == 0 ]
217     then
218     dodir /usr/include/asm-generic
219     cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic
220     fi
221 johnm 1.1 }
222    
223     install_sources() {
224 johnm 1.12 local doc
225     local docs
226 johnm 1.27 local file
227 johnm 1.1
228 johnm 1.12 cd ${S}
229     dodir /usr/src
230 johnm 1.47 echo ">>> Copying sources..."
231 johnm 1.27 file="$(find ${WORKDIR} -iname "docs" -type d)"
232     if [ -n "${file}" ]
233 johnm 1.12 then
234 johnm 1.27 for file in $(find ${file} -type f)
235 johnm 1.1 do
236 johnm 1.27 echo "${file/*docs\//}" >> ${S}/patches.txt
237 johnm 1.47 echo "=========================================" >> ${S}/patches.txt
238 johnm 1.27 cat ${file} >> ${S}/patches.txt
239 johnm 1.47 echo "=========================================" >> ${S}/patches.txt
240 johnm 1.12 echo "" >> ${S}/patches.txt
241 johnm 1.1 done
242 johnm 1.12 fi
243 johnm 1.1
244 johnm 1.12 if [ ! -f ${S}/patches.txt ]
245     then
246     # patches.txt is empty so lets use our ChangeLog
247 johnm 1.47 [ -f ${FILESDIR}/../ChangeLog ] && \
248     echo "Please check the ebuild ChangeLog for more details." \
249     > ${S}/patches.txt
250 johnm 1.12 fi
251    
252     for doc in ${UNIPATCH_DOCS}
253     do
254     [ -f ${doc} ] && docs="${docs} ${doc}"
255     done
256    
257     if [ -f ${S}/patches.txt ]; then
258     docs="${docs} ${S}/patches.txt"
259     fi
260 johnm 1.27
261 spock 1.40 if use doc && ! use arm && ! use s390; then
262 spock 1.37 install_manpages
263     fi
264    
265 johnm 1.12 dodoc ${docs}
266     mv ${WORKDIR}/linux* ${D}/usr/src
267 johnm 1.1 }
268    
269 spock 1.37 install_manpages() {
270     local MY_ARCH
271    
272 spock 1.39 ebegin "Installing manpages"
273 spock 1.37 MY_ARCH=${ARCH}
274     unset ARCH
275     sed -i -e "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
276     make installmandocs
277     eend $?
278     sed -i -e "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
279     ARCH=${MY_ARCH}
280     }
281    
282 johnm 1.1 # pkg_preinst functions
283     #==============================================================
284     preinst_headers() {
285 johnm 1.12 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux
286     [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm
287 johnm 1.1 }
288    
289     # pkg_postinst functions
290     #==============================================================
291     postinst_sources() {
292 johnm 1.34 if [ ! -h ${ROOT}usr/src/linux ]
293 johnm 1.1 then
294     ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux
295     fi
296    
297     # Don't forget to make directory for sysfs
298     [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
299    
300     echo
301     einfo "After installing a new kernel of any version, it is important"
302     einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
303     einfo "created (X.Y is the first 2 parts of your new kernel version)"
304     echo
305     einfo "For example, this kernel will require:"
306     einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
307     echo
308 johnm 1.2
309     # if K_EXTRAEINFO is set then lets display it now
310     if [ -n "${K_EXTRAEINFO}" ]
311     then
312     echo ${K_EXTRAEINFO} | fmt |
313     while read -s ELINE
314     do
315     einfo "${ELINE}"
316     done
317 iggy 1.8
318     echo
319 johnm 1.2 fi
320 iggy 1.7
321 johnm 1.47 # Show policy version, if this kernel has SELinux...
322     local secfile="${ROOT}usr/src/linux-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}/security/selinux/include/security.h"
323 mr_bones_ 1.38 if use selinux && [ -f "$secfile" ]
324 plasmaroo 1.33 then
325     local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
326     einfo "The SELinux policy version of this kernel is $polver."
327     echo
328     fi
329    
330 iggy 1.7 # if K_EXTRAEWARN is set then lets display it now
331     if [ -n "${K_EXTRAEWARN}" ]
332     then
333     echo ${K_EXTRAEWARN} | fmt |
334     while read -s ELINE
335     do
336 iggy 1.8 ewarn "${ELINE}"
337 iggy 1.7 done
338 iggy 1.8
339     echo
340 iggy 1.7 fi
341 johnm 1.1 }
342    
343 johnm 1.12 postinst_headers() {
344     echo
345     einfo "Kernel headers are usually only used when recompiling glibc."
346     einfo "Following the installation of newer headers it is advised that"
347     einfo "you re-merge glibc as follows:"
348     einfo "# emerge glibc"
349     einfo "Failure to do so will cause glibc to not make use of newer"
350     einfo "features present in the updated kernelheaders."
351     echo
352     }
353    
354     # pkg_setup functions
355     #==============================================================
356     setup_headers() {
357 johnm 1.47 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ \
358     -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ \
359     -e s/amd64/x86_64/)
360 johnm 1.12 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
361    
362     [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
363     for i in ${H_SUPPORTEDARCH}
364     do
365     [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
366     done
367    
368     if [ "${H_ACCEPT_ARCH}" != "yes" ]
369     then
370     echo
371     eerror "This version of ${PN} does not support ${ARCH}."
372     eerror "Please merge the appropriate sources, in most cases"
373     eerror "this will be ${ARCH}-headers."
374     die "incorrect headers"
375     fi
376     }
377    
378 johnm 1.1 # unipatch
379     #==============================================================
380     unipatch() {
381     local i
382     local x
383     local extention
384     local PIPE_CMD
385 johnm 1.19 local UNIPATCH_DROP
386 johnm 1.1 local KPATCH_DIR
387     local PATCH_DEPTH
388 johnm 1.2 local ELINE
389 johnm 1.16 local STRICT_COUNT
390 johnm 1.41 local PATCH_LEVEL
391 johnm 1.1
392     [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
393     [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
394    
395 johnm 1.41 # We're gonna need it when doing patches with a predefined patchlevel
396     shopt -s extglob
397    
398 johnm 1.47 # This function will unpack all passed tarballs, add any passed patches,
399     # and remove any passed patchnumbers
400 johnm 1.1 # usage can be either via an env var or by params
401 johnm 1.47 [ -n "${@}" ] && UNIPATCH_LIST="${@} ${UNIPATCH_LIST}"
402 johnm 1.1
403     #unpack any passed tarballs
404     for i in ${UNIPATCH_LIST}
405     do
406 johnm 1.9 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
407 johnm 1.1 then
408     extention=${i/*./}
409 johnm 1.41 extention=${extention/:*/}
410 johnm 1.1 case ${extention} in
411     tbz2) PIPE_CMD="tar -xvjf";;
412     bz2) PIPE_CMD="tar -xvjf";;
413     tgz) PIPE_CMD="tar -xvzf";;
414     gz) PIPE_CMD="tar -xvzf";;
415     *) eerror "Unrecognized tarball compression"
416     die "Unrecognized tarball compression";;
417     esac
418    
419 johnm 1.16 if [ -n "${UNIPATCH_STRICTORDER}" ]
420     then
421     STRICT_COUNT=$((${STRICT_COUNT} + 1))
422     mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
423 johnm 1.47 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ \
424     1>/dev/null
425 johnm 1.16 else
426 johnm 1.41 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
427 johnm 1.16 fi
428    
429 johnm 1.1 if [ $? == 0 ]
430     then
431     einfo "${i/*\//} unpacked"
432 johnm 1.47 [ -n "$(echo ${i} | grep ':')" ] && \
433     echo ">>> Strict patch levels not currently supported for tarballed patchsets"
434 johnm 1.1 else
435 johnm 1.41 eerror "Failed to unpack ${i/:*/}"
436 johnm 1.1 die "unable to unpack patch tarball"
437     fi
438 johnm 1.16 else
439 johnm 1.25 extention=${i/*./}
440 johnm 1.41 extention=${extention/:*/}
441 johnm 1.25 PIPE_CMD=""
442     case ${extention} in
443     bz2) PIPE_CMD="bzip2 -dc";;
444     patch) PIPE_CMD="cat";;
445     diff) PIPE_CMD="cat";;
446     gz|Z|z) PIPE_CMD="gzip -dc";;
447     ZIP|zip) PIPE_CMD="unzip -p";;
448 johnm 1.41 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
449 johnm 1.25 esac
450 johnm 1.41
451     PATCH_LEVEL=${i/*([^:])?(:)}
452     i=${i/:*/}
453 johnm 1.25 x=${i/*\//}
454     x=${x/\.${extention}/}
455    
456 johnm 1.29 if [ -n "${PIPE_CMD}" ]
457 johnm 1.25 then
458 johnm 1.29 if [ ! -r "${i}" ]
459     then
460     echo
461     eerror "FATAL: unable to locate:"
462     eerror "${i}"
463 johnm 1.47 eerror "for read-only. The file either has incorrect"
464     eerror "permissions or does not exist."
465 johnm 1.29 die Unable to locate ${i}
466     fi
467    
468     if [ -n "${UNIPATCH_STRICTORDER}" ]
469     then
470     STRICT_COUNT=$((${STRICT_COUNT} + 1))
471     mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
472 johnm 1.47 $(${PIPE_CMD} ${i} > \
473     ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
474 johnm 1.29 else
475 johnm 1.41 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
476 johnm 1.29 fi
477 johnm 1.25 fi
478 johnm 1.16 fi
479 johnm 1.1 done
480    
481     #populate KPATCH_DIRS so we know where to look to remove the excludes
482     x=${KPATCH_DIR}
483     KPATCH_DIR=""
484 johnm 1.43 LC_ALL="C"
485 johnm 1.25 for i in $(find ${x} -type d | sort -n)
486 johnm 1.1 do
487     KPATCH_DIR="${KPATCH_DIR} ${i}"
488     done
489    
490     #so now lets get rid of the patchno's we want to exclude
491 johnm 1.19 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
492     for i in ${UNIPATCH_DROP}
493 johnm 1.1 do
494 johnm 1.47 einfo "Excluding Patch #${i}"
495 johnm 1.1 for x in ${KPATCH_DIR}
496     do
497 tseng 1.36 rm -f ${x}/${i}* 2>/dev/null
498 johnm 1.1 done
499     done
500    
501     # and now, finally, we patch it :)
502     for x in ${KPATCH_DIR}
503     do
504 johnm 1.47 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
505 johnm 1.1 do
506 johnm 1.47 unset PATCH_DEPTH
507    
508 johnm 1.25 STDERR_T="${T}/${i/*\//}"
509 johnm 1.41 STDERR_T="${STDERR_T/.patch*/.err}"
510 johnm 1.47 STDERR_T="${STDERR_T/.diff*/.err}"
511 johnm 1.41
512 johnm 1.47 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
513     [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
514 johnm 1.41
515     if [ -z "${PATCH_DEPTH}" ]; then
516     PATCH_DEPTH=0
517     fi
518    
519     ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
520 johnm 1.1 while [ ${PATCH_DEPTH} -lt 5 ]
521     do
522 plasmaroo 1.33 echo "Attempting Dry-run:" >> ${STDERR_T}
523 johnm 1.25 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
524 johnm 1.47 echo "==========================================" >> ${STDERR_T}
525 johnm 1.26 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
526 johnm 1.1 then
527 johnm 1.25 echo "Attempting patch:" > ${STDERR_T}
528     echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
529 johnm 1.47 echo "======================================" >> ${STDERR_T}
530 johnm 1.26 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
531 johnm 1.1 then
532     eend 0
533 johnm 1.25 rm ${STDERR_T}
534 johnm 1.1 break
535     else
536     eend 1
537     eerror "Failed to apply patch ${i/*\//}"
538 johnm 1.47 eerror "Please attach ${STDERR_T} to any bug you post."
539 johnm 1.1 die "Failed to apply ${i/*\//}"
540     fi
541     else
542     PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
543     fi
544     done
545     if [ ${PATCH_DEPTH} -eq 5 ]
546     then
547     eend 1
548 johnm 1.47 eerror "Please attach ${STDERR_T} to any bug you post."
549 johnm 1.1 die "Unable to dry-run patch."
550     fi
551     done
552     done
553 johnm 1.43
554     # clean up KPATCH_DIR's - fixes bug #53610
555     for x in ${KPATCH_DIR}
556     do
557     rm -Rf ${x}
558     done
559 johnm 1.42 unset LC_ALL
560 johnm 1.1 }
561    
562     # custom functions
563     #==============================================================
564     detect_version() {
565     # this function will detect and set
566 johnm 1.47 # OKV: Original Kernel Version (2.6.0/2.6.0-test11)
567     # KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
568     # EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
569    
570     if [ -z "${OKV}" ]
571     then
572     OKV=${PV/_beta/-test}
573     OKV=${OKV/_rc/-rc}
574     OKV=${OKV/_pre*/}
575     OKV=${OKV/-r*/}
576     fi
577 johnm 1.1
578     KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
579     KV_MINOR=$(echo ${OKV} | cut -d. -f2)
580     KV_PATCH=$(echo ${OKV} | cut -d. -f3)
581 johnm 1.47 KV_PATCH=${KV_PATCH/[-_]*/}
582 johnm 1.1
583     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
584    
585     RELEASE=${PV/${OKV}/}
586     RELEASE=${RELEASE/_beta/}
587     RELEASE=${RELEASE/_rc/-rc}
588 plasmaroo 1.33 if [ $(kernel_is_2_4) $? == 0 ]
589     then
590     RELEASE=${RELEASE/_pre/-pre}
591     else
592 johnm 1.47 RELEASE=${RELEASE/_pre/-bk}
593 plasmaroo 1.33 fi
594 johnm 1.1 RELEASETYPE=${RELEASE//[0-9]/}
595    
596     EXTRAVERSION="${RELEASE}"
597 johnm 1.47
598 johnm 1.11 if [ -n "${K_PREPATCHED}" ]
599     then
600 johnm 1.21 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
601 johnm 1.11 else
602     [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
603 johnm 1.47 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
604 johnm 1.21 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
605 johnm 1.11 fi
606 johnm 1.47
607 johnm 1.21 KV=${OKV}${EXTRAVERSION}
608 johnm 1.47
609     # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the
610     # portage naming convention these cannot be supported, but the code here can
611     # handle it up until this point and theoretically thereafter.
612 johnm 1.1
613 plasmaroo 1.33 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
614 johnm 1.1 then
615 johnm 1.47 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && \
616     echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
617 johnm 1.1 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
618     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
619 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
620 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
621 johnm 1.1 fi
622    
623     if [ "${RELEASETYPE}" == "-bk" ]
624     then
625     OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
626     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
627     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
628 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
629 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
630 johnm 1.1 fi
631    
632     if [ "${RELEASETYPE}" == "-rc-bk" ]
633     then
634     OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
635     EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
636    
637     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
638     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
639 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
640 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
641 johnm 1.1 fi
642 johnm 1.47
643 johnm 1.2 S=${WORKDIR}/linux-${KV}
644 johnm 1.1 }
645    
646 johnm 1.28 detect_arch() {
647     # This function sets ARCH_URI and ARCH_PATCH
648     # with the neccessary info for the arch sepecific compatibility
649     # patchsets.
650    
651 johnm 1.31 local ALL_ARCH
652     local LOOP_ARCH
653     local COMPAT_URI
654 plasmaroo 1.33 local i
655    
656     # COMPAT_URI is the contents of ${ARCH}_URI
657     # ARCH_URI is the URI for all the ${ARCH}_URI patches
658     # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
659    
660     ARCH_URI=""
661     ARCH_PATCH=""
662     ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
663 johnm 1.31
664     for LOOP_ARCH in ${ALL_ARCH}
665     do
666     COMPAT_URI="${LOOP_ARCH}_URI"
667     COMPAT_URI="${!COMPAT_URI}"
668    
669 johnm 1.47 [ -n "${COMPAT_URI}" ] && \
670     ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
671 plasmaroo 1.33
672 johnm 1.47 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ]
673 plasmaroo 1.33 then
674     for i in ${COMPAT_URI}
675     do
676     ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
677     done
678     fi
679 johnm 1.31 done
680 johnm 1.28 }
681    
682    
683 johnm 1.1 # common functions
684     #==============================================================
685 plasmaroo 1.33 kernel-2_src_unpack() {
686 johnm 1.1 universal_unpack
687 johnm 1.47 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
688     unipatch "${UNIPATCH_LIST_DEFAULT}"
689 johnm 1.1 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
690     [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
691     }
692    
693 plasmaroo 1.33 kernel-2_src_compile() {
694 johnm 1.1 [ "${ETYPE}" == "headers" ] && compile_headers
695 johnm 1.47 [ "${ETYPE}" == "sources" ] && \
696     use doc && ! use arm && ! use s390 && compile_manpages
697 johnm 1.1 }
698    
699 plasmaroo 1.33 kernel-2_pkg_preinst() {
700 johnm 1.1 [ "${ETYPE}" == "headers" ] && preinst_headers
701     }
702    
703 plasmaroo 1.33 kernel-2_src_install() {
704 johnm 1.1 install_universal
705     [ "${ETYPE}" == "headers" ] && install_headers
706     [ "${ETYPE}" == "sources" ] && install_sources
707     }
708    
709 plasmaroo 1.33 kernel-2_pkg_postinst() {
710 johnm 1.12 [ "${ETYPE}" == "headers" ] && postinst_headers
711 johnm 1.1 [ "${ETYPE}" == "sources" ] && postinst_sources
712     }
713 johnm 1.12
714 plasmaroo 1.33 kernel-2_pkg_setup() {
715 johnm 1.12 [ "${ETYPE}" == "headers" ] && setup_headers
716 johnm 1.13
717 plasmaroo 1.33 # This is to fix some weird portage bug? in stable versions of portage.
718 johnm 1.47 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
719 johnm 1.12 }

  ViewVC Help
Powered by ViewVC 1.1.20