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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.32 - (hide annotations) (download)
Sun Mar 14 06:43:16 2004 UTC (15 years, 3 months ago) by seemant
Branch: MAIN
Changes since 1.31: +2 -2 lines
console-tools->kbd

1 johnm 1.13 # Copyright 1999-2004 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 seemant 1.32 # $Header: /home/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.31 2004/02/18 22:33:29 johnm 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 johnm 1.13 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
37 johnm 1.1
38 johnm 1.30 # to prevent errors if theres no sources in /usr/src
39     # we set KV and re-set it later on as well.
40     [ -z "${KV}" ] && KV=${PV}
41    
42 johnm 1.1 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
43     LICENSE="GPL-2"
44     IUSE="${IUSE} build"
45     SLOT="${KV}"
46    
47 johnm 1.18 # Grab kernel version from KV
48     KV_MAJOR=$(echo ${KV} | cut -d. -f1)
49     KV_MINOR=$(echo ${KV} | cut -d. -f2)
50     KV_PATCH=$(echo ${KV} | cut -d. -f3)
51     KV_PATCH=${KV_PATCH/[-_]*/}
52    
53     # set LINUX_HOSTCFLAGS if not already set
54     [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
55    
56    
57     #eclass functions only from here onwards.
58     #==============================================================
59     kernel_is_2_4() {
60     [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
61     }
62    
63     kernel_is_2_6() {
64     [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
65     }
66    
67 johnm 1.1 # capture the sources type and set depends
68     if [ "${ETYPE}" == "sources" ]
69     then
70 seemant 1.32 #kbd is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
71 johnm 1.1 DEPEND="!build? ( sys-apps/sed
72     >=sys-devel/binutils-2.11.90.0.31 )"
73    
74     RDEPEND="${DEPEND}
75     !build? ( >=sys-libs/ncurses-5.2
76     dev-lang/perl
77 johnm 1.6 sys-apps/module-init-tools
78 johnm 1.1 sys-devel/make )"
79 johnm 1.18
80 johnm 1.17 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" || PROVIDE="virtual/linux-sources virtual/alsa"
81 johnm 1.1
82     elif [ "${ETYPE}" == "headers" ]
83     then
84     PROVIDE="virtual/kernel virtual/os-headers"
85     else
86     eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\""
87     die
88     fi
89    
90     # Unpack functions
91     #==============================================================
92     unpack_2_4() {
93     cd ${S}
94     # this file is required for other things to build properly,
95     # so we autogenerate it
96     make mrproper || die "make mrproper died"
97     make include/linux/version.h || die "make include/linux/version.h failed"
98     echo ">>> version.h compiled successfully."
99     }
100    
101     universal_unpack() {
102     # remove all backup files
103     find . -iname "*~" -exec rm {} \; 2> /dev/null
104    
105     if [ -d "${S}/Documentation/DocBook" ]
106     then
107     cd ${S}/Documentation/DocBook
108     sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
109     && mv Makefile.new Makefile
110     cd ${S}
111     fi
112     }
113    
114     unpack_set_extraversion() {
115     # Gentoo Linux uses /boot, so fix 'make install' to work properly and fix EXTRAVERSION
116     cd ${S}
117     mv Makefile Makefile.orig
118     sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
119     -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \
120     Makefile.orig > Makefile
121     rm Makefile.orig
122     }
123    
124     # Compile Functions
125     #==============================================================
126     compile_headers() {
127     local MY_ARCH
128    
129     MY_ARCH=${ARCH}
130     unset ${ARCH}
131     yes "" | make oldconfig
132     echo ">>> make oldconfig complete"
133     ARCH=${MY_ARCH}
134     }
135    
136     # install functions
137     #==============================================================
138     install_universal() {
139     #fix silly permissions in tarball
140     cd ${WORKDIR}
141     chown -R root:root *
142     chmod -R a+r-w+X,u+w *
143     }
144    
145     install_headers() {
146     [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
147 johnm 1.13
148 johnm 1.1 cd ${S}
149     dodir /usr/include/linux
150 johnm 1.16 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
151 johnm 1.1 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
152     rm -rf ${D}/usr/include/linux/modules
153 johnm 1.13
154 johnm 1.1 dodir /usr/include/asm
155     cp -ax ${S}/include/asm/* ${D}/usr/include/asm
156 johnm 1.12
157     if [ $(kernel_is_2_6) $? == 0 ]
158     then
159     dodir /usr/include/asm-generic
160     cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic
161     fi
162 johnm 1.1 }
163    
164     install_sources() {
165 johnm 1.12 local doc
166     local docs
167 johnm 1.27 local file
168 johnm 1.1
169 johnm 1.12 cd ${S}
170     dodir /usr/src
171     echo ">>> Copying sources..."
172 johnm 1.27 file="$(find ${WORKDIR} -iname "docs" -type d)"
173     if [ -n "${file}" ]
174 johnm 1.12 then
175 johnm 1.27 for file in $(find ${file} -type f)
176 johnm 1.1 do
177 johnm 1.27 echo "${file/*docs\//}" >> ${S}/patches.txt
178     echo "===================================================" >> ${S}/patches.txt
179     cat ${file} >> ${S}/patches.txt
180     echo "===================================================" >> ${S}/patches.txt
181 johnm 1.12 echo "" >> ${S}/patches.txt
182 johnm 1.1 done
183 johnm 1.12 fi
184 johnm 1.1
185 johnm 1.12 if [ ! -f ${S}/patches.txt ]
186     then
187     # patches.txt is empty so lets use our ChangeLog
188     [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
189     fi
190    
191     for doc in ${UNIPATCH_DOCS}
192     do
193     [ -f ${doc} ] && docs="${docs} ${doc}"
194     done
195    
196     if [ -f ${S}/patches.txt ]; then
197     docs="${docs} ${S}/patches.txt"
198     fi
199 johnm 1.27
200 johnm 1.12 dodoc ${docs}
201     mv ${WORKDIR}/linux* ${D}/usr/src
202 johnm 1.1 }
203    
204     # pkg_preinst functions
205     #==============================================================
206     preinst_headers() {
207 johnm 1.12 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux
208     [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm
209 johnm 1.1 }
210    
211     # pkg_postinst functions
212     #==============================================================
213     postinst_sources() {
214     if [ ! -h ${ROOT}usr/src/linux ]
215     then
216     ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux
217     fi
218    
219     # Don't forget to make directory for sysfs
220     [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
221    
222     echo
223     einfo "After installing a new kernel of any version, it is important"
224     einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
225     einfo "created (X.Y is the first 2 parts of your new kernel version)"
226     echo
227     einfo "For example, this kernel will require:"
228     einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
229     echo
230 johnm 1.2
231     # if K_EXTRAEINFO is set then lets display it now
232     if [ -n "${K_EXTRAEINFO}" ]
233     then
234     echo ${K_EXTRAEINFO} | fmt |
235     while read -s ELINE
236     do
237     einfo "${ELINE}"
238     done
239 iggy 1.8
240     echo
241 johnm 1.2 fi
242 iggy 1.7
243     # if K_EXTRAEWARN is set then lets display it now
244     if [ -n "${K_EXTRAEWARN}" ]
245     then
246     echo ${K_EXTRAEWARN} | fmt |
247     while read -s ELINE
248     do
249 iggy 1.8 ewarn "${ELINE}"
250 iggy 1.7 done
251 iggy 1.8
252     echo
253 iggy 1.7 fi
254 johnm 1.1 }
255    
256 johnm 1.12 postinst_headers() {
257     echo
258     einfo "Kernel headers are usually only used when recompiling glibc."
259     einfo "Following the installation of newer headers it is advised that"
260     einfo "you re-merge glibc as follows:"
261     einfo "# emerge glibc"
262     einfo "Failure to do so will cause glibc to not make use of newer"
263     einfo "features present in the updated kernelheaders."
264     echo
265     }
266    
267     # pkg_setup functions
268     #==============================================================
269     setup_headers() {
270     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/)
271     [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
272    
273     [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
274     for i in ${H_SUPPORTEDARCH}
275     do
276     [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
277     done
278    
279     if [ "${H_ACCEPT_ARCH}" != "yes" ]
280     then
281     echo
282     eerror "This version of ${PN} does not support ${ARCH}."
283     eerror "Please merge the appropriate sources, in most cases"
284     eerror "this will be ${ARCH}-headers."
285     die "incorrect headers"
286     fi
287     }
288    
289 johnm 1.1 # unipatch
290     #==============================================================
291     unipatch() {
292     local i
293     local x
294     local extention
295     local PIPE_CMD
296 johnm 1.19 local UNIPATCH_DROP
297 johnm 1.1 local KPATCH_DIR
298     local PATCH_DEPTH
299 johnm 1.2 local ELINE
300 johnm 1.16 local STRICT_COUNT
301 johnm 1.1
302     [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
303     [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
304    
305     # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
306     # usage can be either via an env var or by params
307 johnm 1.25 # although due to the nature we pass this within this eclass
308     # it shall be by param only.
309     # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
310     UNIPATCH_LIST="${@}"
311 johnm 1.1
312     #unpack any passed tarballs
313     for i in ${UNIPATCH_LIST}
314     do
315 johnm 1.9 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
316 johnm 1.1 then
317     extention=${i/*./}
318     case ${extention} in
319     tbz2) PIPE_CMD="tar -xvjf";;
320     bz2) PIPE_CMD="tar -xvjf";;
321     tgz) PIPE_CMD="tar -xvzf";;
322     gz) PIPE_CMD="tar -xvzf";;
323     *) eerror "Unrecognized tarball compression"
324     die "Unrecognized tarball compression";;
325     esac
326    
327 johnm 1.16 if [ -n "${UNIPATCH_STRICTORDER}" ]
328     then
329     STRICT_COUNT=$((${STRICT_COUNT} + 1))
330     mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
331     ${PIPE_CMD} ${i} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
332     else
333     ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null
334     fi
335    
336 johnm 1.1 if [ $? == 0 ]
337     then
338     einfo "${i/*\//} unpacked"
339     else
340     eerror "Failed to unpack ${i}"
341     die "unable to unpack patch tarball"
342     fi
343 johnm 1.16 else
344 johnm 1.25 extention=${i/*./}
345     PIPE_CMD=""
346     case ${extention} in
347     bz2) PIPE_CMD="bzip2 -dc";;
348     patch) PIPE_CMD="cat";;
349     diff) PIPE_CMD="cat";;
350     gz|Z|z) PIPE_CMD="gzip -dc";;
351     ZIP|zip) PIPE_CMD="unzip -p";;
352     *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i}";;
353     esac
354     x=${i/*\//}
355     x=${x/\.${extention}/}
356    
357 johnm 1.29 if [ -n "${PIPE_CMD}" ]
358 johnm 1.25 then
359 johnm 1.29 if [ ! -r "${i}" ]
360     then
361     echo
362     eerror "FATAL: unable to locate:"
363     eerror "${i}"
364     eerror "for read-only. The file either has incorrect permissions"
365     eerror "or does not exist."
366     die Unable to locate ${i}
367     fi
368    
369     if [ -n "${UNIPATCH_STRICTORDER}" ]
370     then
371     STRICT_COUNT=$((${STRICT_COUNT} + 1))
372     mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
373     $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch)
374     else
375     $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch)
376     fi
377 johnm 1.25 fi
378 johnm 1.16 fi
379 johnm 1.1 done
380    
381     #populate KPATCH_DIRS so we know where to look to remove the excludes
382     x=${KPATCH_DIR}
383     KPATCH_DIR=""
384 johnm 1.25 for i in $(find ${x} -type d | sort -n)
385 johnm 1.1 do
386     KPATCH_DIR="${KPATCH_DIR} ${i}"
387     done
388    
389     #so now lets get rid of the patchno's we want to exclude
390 johnm 1.19 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
391     for i in ${UNIPATCH_DROP}
392 johnm 1.1 do
393     for x in ${KPATCH_DIR}
394     do
395 johnm 1.19 rm ${x}/${i}* 2>/dev/null
396 johnm 1.1 if [ $? == 0 ]
397     then
398     einfo "Excluding Patch #${i}"
399     einfo "From: ${x/${WORKDIR}/}"
400     fi
401     done
402     done
403    
404     # and now, finally, we patch it :)
405     for x in ${KPATCH_DIR}
406     do
407 johnm 1.25 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -n)
408 johnm 1.1 do
409 johnm 1.25 STDERR_T="${T}/${i/*\//}"
410     STDERR_T="${STDERR_T/.patch/.err}"
411    
412 johnm 1.1 PATCH_DEPTH=0
413     ebegin "Applying ${i/*\//}"
414     while [ ${PATCH_DEPTH} -lt 5 ]
415     do
416 johnm 1.25 echo "Attempting Dry-run:" > ${STDERR_T}
417     echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
418     echo "=======================================================" >> ${STDERR_T}
419 johnm 1.26 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
420 johnm 1.1 then
421 johnm 1.25 echo "Attempting patch:" > ${STDERR_T}
422     echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
423     echo "=======================================================" >> ${STDERR_T}
424 johnm 1.26 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
425 johnm 1.1 then
426     eend 0
427 johnm 1.25 rm ${STDERR_T}
428 johnm 1.1 break
429     else
430     eend 1
431     eerror "Failed to apply patch ${i/*\//}"
432 johnm 1.25 eerror "Please attach ${STDERR_T} to any bug you may post."
433 johnm 1.1 die "Failed to apply ${i/*\//}"
434     fi
435     else
436     PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
437     fi
438     done
439     if [ ${PATCH_DEPTH} -eq 5 ]
440     then
441     eend 1
442 johnm 1.25 eerror "Please attach ${STDERR_T} to any bug you may post."
443 johnm 1.1 die "Unable to dry-run patch."
444     fi
445     done
446     done
447     }
448    
449     # custom functions
450     #==============================================================
451     detect_version() {
452     # this function will detect and set
453     # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
454     # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
455     # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
456    
457     OKV=${PV/_beta/-test}
458     OKV=${OKV/_rc/-rc}
459     OKV=${OKV/_pre*/}
460     OKV=${OKV/-r*/}
461    
462     KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
463     KV_MINOR=$(echo ${OKV} | cut -d. -f2)
464     KV_PATCH=$(echo ${OKV} | cut -d. -f3)
465     KV_PATCH=${KV_PATCH/[-_]*/}
466    
467     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
468    
469     RELEASE=${PV/${OKV}/}
470     RELEASE=${RELEASE/_beta/}
471     RELEASE=${RELEASE/_rc/-rc}
472     RELEASE=${RELEASE/_pre/-bk}
473     RELEASETYPE=${RELEASE//[0-9]/}
474    
475     EXTRAVERSION="${RELEASE}"
476    
477 johnm 1.11 if [ -n "${K_PREPATCHED}" ]
478     then
479 johnm 1.21 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
480 johnm 1.11 else
481     [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
482 johnm 1.21 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
483 johnm 1.11 fi
484 johnm 1.1
485 johnm 1.21 KV=${OKV}${EXTRAVERSION}
486    
487 johnm 1.1 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
488     # these cannot be supported, but the code here can handle it up until this point
489     # and theoretically thereafter.
490    
491     if [ "${RELEASETYPE}" == "-rc" ]
492     then
493     OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
494     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
495     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
496 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
497 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
498 johnm 1.1 fi
499    
500     if [ "${RELEASETYPE}" == "-bk" ]
501     then
502     OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
503     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
504     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
505 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
506 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
507 johnm 1.1 fi
508    
509     if [ "${RELEASETYPE}" == "-rc-bk" ]
510     then
511     OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
512     EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
513    
514     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
515     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
516 johnm 1.25 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
517 johnm 1.21 KV=${PV/[-_]*/}${EXTRAVERSION}
518 johnm 1.1 fi
519 johnm 1.2
520     S=${WORKDIR}/linux-${KV}
521 johnm 1.1 }
522    
523    
524 johnm 1.28 detect_arch() {
525     # This function sets ARCH_URI and ARCH_PATCH
526     # with the neccessary info for the arch sepecific compatibility
527     # patchsets.
528    
529 johnm 1.31 local ALL_ARCH
530     local LOOP_ARCH
531     local COMPAT_URI
532    
533     ALL_ARCH="X86 PPC PCC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD"
534     for LOOP_ARCH in ${ALL_ARCH}
535     do
536     COMPAT_URI="${LOOP_ARCH}_URI"
537     COMPAT_URI="${!COMPAT_URI}"
538     ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
539    
540     [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ] && ARCH_PATCH="${DISTDIR}/${COMPAT_URI/*\//}"
541     done
542 johnm 1.28 }
543    
544    
545 johnm 1.1 # common functions
546     #==============================================================
547     src_unpack() {
548     [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
549    
550     cd ${WORKDIR}
551     unpack linux-${OKV}.tar.bz2
552 johnm 1.5 if [ "${OKV}" != "${KV}" ]
553     then
554     mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
555     fi
556 johnm 1.1 cd ${S}
557    
558     universal_unpack
559 johnm 1.25 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
560 johnm 1.1 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
561     [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
562     }
563    
564     src_compile() {
565     [ "${ETYPE}" == "headers" ] && compile_headers
566     }
567    
568     pkg_preinst() {
569     [ "${ETYPE}" == "headers" ] && preinst_headers
570     }
571    
572     src_install() {
573     install_universal
574     [ "${ETYPE}" == "headers" ] && install_headers
575     [ "${ETYPE}" == "sources" ] && install_sources
576     }
577    
578     pkg_postinst() {
579 johnm 1.12 [ "${ETYPE}" == "headers" ] && postinst_headers
580 johnm 1.1 [ "${ETYPE}" == "sources" ] && postinst_sources
581     }
582 johnm 1.12
583     pkg_setup() {
584     [ "${ETYPE}" == "headers" ] && setup_headers
585 johnm 1.13
586     # this is to fix some weird portage bug? in stable versions of portage.
587 johnm 1.15 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
588 johnm 1.12 }

  ViewVC Help
Powered by ViewVC 1.1.20