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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.46 - (hide annotations) (download)
Tue Oct 19 19:51:12 2004 UTC (13 years, 11 months ago) by vapier
Branch: MAIN
Changes since 1.45: +6 -6 lines
'...' -> ' ...'

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

  ViewVC Help
Powered by ViewVC 1.1.20