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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (hide annotations) (download)
Fri Nov 26 15:06:17 2004 UTC (13 years, 5 months ago) by johnm
Branch: MAIN
Changes since 1.54: +81 -65 lines
Changing all KV calls to KV_FULL to stop portage conflicts. currently still setting KV to stop breakages

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

  ViewVC Help
Powered by ViewVC 1.1.20