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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.41 - (hide annotations) (download)
Sun Aug 22 11:38:02 2004 UTC (10 years, 2 months ago) by johnm
Branch: MAIN
Changes since 1.40: +34 -14 lines
added support for strict patch level for patch files. no support for tarballs as yet. moved the sed for INSTALL_PATCH to universal_unpack

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

  ViewVC Help
Powered by ViewVC 1.1.20