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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.66 - (hide annotations) (download)
Wed Dec 29 00:06:53 2004 UTC (14 years, 4 months ago) by dsd
Branch: MAIN
Changes since 1.65: +1 -4 lines
Remove call to nonexistant get_version

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

  ViewVC Help
Powered by ViewVC 1.1.20