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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.67 - (hide annotations) (download)
Wed Dec 29 08:37:07 2004 UTC (14 years, 5 months ago) by johnm
Branch: MAIN
Changes since 1.66: +4 -1 lines
Adding sanity check

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

  ViewVC Help
Powered by ViewVC 1.1.20