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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.52 - (hide annotations) (download)
Fri Nov 26 01:49:05 2004 UTC (14 years, 6 months ago) by johnm
Branch: MAIN
Changes since 1.51: +0 -7 lines
cleaning up pkg_setup.

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

  ViewVC Help
Powered by ViewVC 1.1.20