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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.71 - (hide annotations) (download)
Sun Jan 9 18:56:47 2005 UTC (14 years, 5 months ago) by johnm
Branch: MAIN
Changes since 1.70: +2 -2 lines
changing back to virtual. if this causes problems, then please look at changing the default virtual for that profile to module-init-tools

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

  ViewVC Help
Powered by ViewVC 1.1.20