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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.58 - (hide annotations) (download)
Mon Nov 29 13:44:31 2004 UTC (14 years, 6 months ago) by johnm
Branch: MAIN
Changes since 1.57: +1 -7 lines
Removing obsolete checks for KV_*

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.58 # $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.57 SLOT="${PV}"
54 johnm 1.1
55 johnm 1.18 # set LINUX_HOSTCFLAGS if not already set
56     [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
57    
58 johnm 1.54 #Eclass functions only from here onwards ...
59 plasmaroo 1.33 #==============================================================
60     kernel_is() {
61     local RESULT
62     RESULT=1
63    
64     if [ -n "${1}" ]
65     then
66     [ "${1}" = "${KV_MAJOR}" ] && RESULT=0
67     fi
68    
69     if [ -n "${2}" ]
70     then
71     RESULT=1
72     [ "${2}" = "${KV_MINOR}" ] && RESULT=0
73     fi
74    
75     if [ -n "${3}" ]
76     then
77     RESULT=1
78     [ "${3}" = "${KV_PATCH}" ] && RESULT=0
79     fi
80     return ${RESULT}
81     }
82 johnm 1.18
83     kernel_is_2_4() {
84 johnm 1.56 kernel_is 2 4
85     return $?
86 johnm 1.18 }
87    
88     kernel_is_2_6() {
89 johnm 1.55 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
90     return 0 || return 1
91 johnm 1.18 }
92    
93 plasmaroo 1.33 # Capture the sources type and set DEPENDs
94 johnm 1.1 if [ "${ETYPE}" == "sources" ]
95     then
96 johnm 1.55 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
97 johnm 1.1 DEPEND="!build? ( sys-apps/sed
98 johnm 1.55 >=sys-devel/binutils-2.11.90.0.31 )
99     doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
100 johnm 1.1
101     RDEPEND="${DEPEND}
102 johnm 1.55 !build? ( >=sys-libs/ncurses-5.2
103     dev-lang/perl
104     sys-apps/module-init-tools
105     sys-devel/make )"
106 johnm 1.18
107 johnm 1.55 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" \
108     || PROVIDE="virtual/linux-sources virtual/alsa"
109 johnm 1.1
110     elif [ "${ETYPE}" == "headers" ]
111     then
112     PROVIDE="virtual/kernel virtual/os-headers"
113     else
114 johnm 1.55 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
115 johnm 1.1 die
116     fi
117    
118     # Unpack functions
119     #==============================================================
120     unpack_2_4() {
121     cd ${S}
122     # this file is required for other things to build properly,
123     # so we autogenerate it
124     make mrproper || die "make mrproper died"
125     make include/linux/version.h || die "make include/linux/version.h failed"
126     echo ">>> version.h compiled successfully."
127     }
128    
129     universal_unpack() {
130 plasmaroo 1.33 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
131    
132     cd ${WORKDIR}
133     unpack linux-${OKV}.tar.bz2
134 johnm 1.55 if [ "${OKV}" != "${KV_FULL}" ]
135 plasmaroo 1.33 then
136 johnm 1.55 mv linux-${OKV} linux-${KV_FULL} \
137     || die "Unable to move source tree to ${KV_FULL}."
138 dsd 1.49 fi
139 plasmaroo 1.33 cd ${S}
140 johnm 1.54
141 johnm 1.41 # change incorrect install path
142 johnm 1.55 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
143    
144 johnm 1.1 # remove all backup files
145     find . -iname "*~" -exec rm {} \; 2> /dev/null
146    
147     if [ -d "${S}/Documentation/DocBook" ]
148     then
149     cd ${S}/Documentation/DocBook
150 johnm 1.54 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
151     && mv Makefile.new Makefile
152 johnm 1.1 cd ${S}
153     fi
154     }
155    
156     unpack_set_extraversion() {
157     cd ${S}
158 johnm 1.55 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
159 johnm 1.1 }
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 johnm 1.54 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 johnm 1.54 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 johnm 1.54 echo "===================================================" >> ${S}/patches.txt
226 johnm 1.27 cat ${file} >> ${S}/patches.txt
227 johnm 1.54 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 johnm 1.54 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
236 johnm 1.12 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 johnm 1.55 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
262 spock 1.37 make installmandocs
263     eend $?
264 johnm 1.55 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
265 spock 1.37 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 johnm 1.55 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
281 johnm 1.1 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 johnm 1.54 # Show policy version, if this kernel has SELinux ...
308 johnm 1.55 local secfile
309     secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
310 mr_bones_ 1.38 if use selinux && [ -f "$secfile" ]
311 plasmaroo 1.33 then
312     local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
313     einfo "The SELinux policy version of this kernel is $polver."
314     echo
315     fi
316    
317 iggy 1.7 # if K_EXTRAEWARN is set then lets display it now
318     if [ -n "${K_EXTRAEWARN}" ]
319     then
320     echo ${K_EXTRAEWARN} | fmt |
321     while read -s ELINE
322     do
323 iggy 1.8 ewarn "${ELINE}"
324 iggy 1.7 done
325 iggy 1.8
326     echo
327 iggy 1.7 fi
328 johnm 1.1 }
329    
330 johnm 1.12 postinst_headers() {
331     echo
332     einfo "Kernel headers are usually only used when recompiling glibc."
333     einfo "Following the installation of newer headers it is advised that"
334     einfo "you re-merge glibc as follows:"
335     einfo "# emerge glibc"
336     einfo "Failure to do so will cause glibc to not make use of newer"
337 johnm 1.54 einfo "features present in the updated kernelheaders."
338 johnm 1.12 echo
339     }
340    
341     # pkg_setup functions
342     #==============================================================
343     setup_headers() {
344 johnm 1.55 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ \
345     -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
346 johnm 1.12 [ "$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.54 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
385 johnm 1.1 # usage can be either via an env var or by params
386 johnm 1.54 # 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.54 ${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.54 [ -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 johnm 1.54 eerror "for read-only. The file either has incorrect permissions"
450     eerror "or does not exist."
451 johnm 1.29 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.54 $(${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.43 LC_ALL="C"
470 johnm 1.25 for i in $(find ${x} -type d | sort -n)
471 johnm 1.1 do
472     KPATCH_DIR="${KPATCH_DIR} ${i}"
473     done
474    
475     #so now lets get rid of the patchno's we want to exclude
476 johnm 1.19 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
477     for i in ${UNIPATCH_DROP}
478 johnm 1.1 do
479 johnm 1.55 ebegin "Excluding Patch #${i}"
480 johnm 1.1 for x in ${KPATCH_DIR}
481     do
482 tseng 1.36 rm -f ${x}/${i}* 2>/dev/null
483 johnm 1.1 done
484 johnm 1.55 eend $?
485 johnm 1.1 done
486    
487     # and now, finally, we patch it :)
488     for x in ${KPATCH_DIR}
489     do
490 johnm 1.47 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
491 johnm 1.1 do
492 johnm 1.25 STDERR_T="${T}/${i/*\//}"
493 johnm 1.41 STDERR_T="${STDERR_T/.patch*/.err}"
494    
495 johnm 1.54 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
496     [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
497 johnm 1.41
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 johnm 1.54 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 johnm 1.54 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.54 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.54 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 johnm 1.54 # - 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 johnm 1.55 if [ -n "${KV_FULL}" ] ;
554     then
555     # we will set this for backwards compatibility.
556     KV=${KV_FULL}
557    
558     # we know KV_FULL so lets stop here. but not without resetting S
559     S=${WORKDIR}/linux-${KV_FULL}
560     return
561     fi
562    
563 johnm 1.54 OKV=${PV/_beta/-test}
564     OKV=${OKV/_rc/-rc}
565     OKV=${OKV/_pre*/}
566     OKV=${OKV/-r*/}
567 johnm 1.1
568     KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
569     KV_MINOR=$(echo ${OKV} | cut -d. -f2)
570 johnm 1.51 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
571 johnm 1.54 KV_PATCH=${KV_PATCH/[-_]*/}
572 johnm 1.1
573     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
574    
575     RELEASE=${PV/${OKV}/}
576     RELEASE=${RELEASE/_beta/}
577     RELEASE=${RELEASE/_rc/-rc}
578 plasmaroo 1.33 if [ $(kernel_is_2_4) $? == 0 ]
579     then
580     RELEASE=${RELEASE/_pre/-pre}
581     else
582 johnm 1.54 RELEASE=${RELEASE/_pre/-bk}
583 plasmaroo 1.33 fi
584 johnm 1.1 RELEASETYPE=${RELEASE//[0-9]/}
585     EXTRAVERSION="${RELEASE}"
586 johnm 1.54
587 johnm 1.11 if [ -n "${K_PREPATCHED}" ]
588     then
589 johnm 1.21 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
590 johnm 1.11 else
591     [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
592 johnm 1.55 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
593 johnm 1.11 fi
594 johnm 1.54
595 johnm 1.55 KV_FULL=${OKV}${EXTRAVERSION}
596 johnm 1.54
597     # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
598     # these cannot be supported, but the code here can handle it up until this point
599     # and theoretically thereafter.
600 johnm 1.1
601 plasmaroo 1.33 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
602 johnm 1.1 then
603 johnm 1.54 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
604 johnm 1.1 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
605     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
606 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
607 johnm 1.55 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
608 johnm 1.1 fi
609    
610     if [ "${RELEASETYPE}" == "-bk" ]
611     then
612     OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
613     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
614     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
615 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
616 johnm 1.55 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
617 johnm 1.1 fi
618    
619     if [ "${RELEASETYPE}" == "-rc-bk" ]
620     then
621     OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
622     EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
623    
624     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
625     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
626 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
627 johnm 1.55 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
628 johnm 1.1 fi
629 johnm 1.54
630 johnm 1.55 S=${WORKDIR}/linux-${KV_FULL}
631     # we will set this for backwards compatibility.
632     KV=${KV_FULL}
633 johnm 1.1 }
634    
635 johnm 1.28 detect_arch() {
636     # This function sets ARCH_URI and ARCH_PATCH
637     # with the neccessary info for the arch sepecific compatibility
638     # patchsets.
639    
640 johnm 1.31 local ALL_ARCH
641     local LOOP_ARCH
642     local COMPAT_URI
643 plasmaroo 1.33 local i
644    
645     # COMPAT_URI is the contents of ${ARCH}_URI
646     # ARCH_URI is the URI for all the ${ARCH}_URI patches
647     # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
648    
649     ARCH_URI=""
650     ARCH_PATCH=""
651     ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
652 johnm 1.31
653     for LOOP_ARCH in ${ALL_ARCH}
654     do
655     COMPAT_URI="${LOOP_ARCH}_URI"
656     COMPAT_URI="${!COMPAT_URI}"
657    
658 johnm 1.55 [ -n "${COMPAT_URI}" ] && \
659     ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
660 plasmaroo 1.33
661 johnm 1.54 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
662 plasmaroo 1.33 then
663     for i in ${COMPAT_URI}
664     do
665     ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
666     done
667     fi
668 johnm 1.31 done
669 johnm 1.28 }
670    
671    
672 johnm 1.1 # common functions
673     #==============================================================
674 plasmaroo 1.33 kernel-2_src_unpack() {
675 johnm 1.1 universal_unpack
676 johnm 1.56
677     [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
678     unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
679    
680     [ -z "${K_NOSETEXTRAVERSION}" ] && \
681     unpack_set_extraversion
682    
683     kernel_is 2 4 && unpack_2_4
684 johnm 1.1 }
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