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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.48 - (hide annotations) (download)
Thu Nov 25 15:41:06 2004 UTC (14 years, 5 months ago) by johnm
Branch: MAIN
Changes since 1.47: +13 -3 lines
Updating kernel-2.eclass so tat the detect_* functions are moved to pkg_setup. for older kernel ebuilds this shouldnt cause a problem. if it does, please add K_NODETECTVER='yes' to the ebuild before the inherit line.

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

  ViewVC Help
Powered by ViewVC 1.1.20