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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.240 - (hide annotations) (download)
Tue Aug 3 18:31:08 2010 UTC (8 years, 10 months ago) by robbat2
Branch: MAIN
Changes since 1.239: +10 -2 lines
Bug #331013: avoid "make test" in kernel sources ebuilds.

1 vapier 1.218 # Copyright 1999-2009 Gentoo Foundation
2 johnm 1.13 # Distributed under the terms of the GNU General Public License v2
3 robbat2 1.240 # $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.239 2010/08/03 17:22:13 robbat2 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 phreak 1.206 # Original author: John Mylchreest <johnm@gentoo.org>
9     # Maintainer: kernel-misc@gentoo.org
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.93 # K_USEPV - When setting the EXTRAVERSION variable, it should
20     # add PV to the end.
21     # this is useful for thigns like wolk. IE:
22     # EXTRAVERSION would be something like : -wolk-4.19-r1
23 johnm 1.55 # K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
24     # automatically set within the kernel Makefile
25     # K_NOUSENAME - if this is set then EXTRAVERSION will not include the
26     # first part of ${PN} in EXTRAVERSION
27 robbat2 1.163 # K_NOUSEPR - if this is set then EXTRAVERSION will not include the
28     # anything based on ${PR}.
29 lu_zero 1.62 # K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
30     # ck-sources, ac-sources) it will use PR (ie: -r5) as
31     # the patchset version for
32 johnm 1.93 # and not use it as a true package revision
33 johnm 1.55 # K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
34 lu_zero 1.62 # postinst and can be used to carry additional postinst
35 johnm 1.55 # messages
36 zlin 1.208 # K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo
37     # K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo
38 johnm 1.107 # K_SYMLINK - if this is set, then forcably create symlink anyway
39 plasmaroo 1.105 #
40 johnm 1.108 # K_DEFCONFIG - Allow specifying a different defconfig target.
41     # If length zero, defaults to "defconfig".
42 dsd 1.126 # K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
43     # combination of "base" and "extras"
44     # K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
45     # A value of "5" would apply genpatches-2.6.12-5 to
46     # my-sources-2.6.12.ebuild
47 dsd 1.200 # K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
48 robbat2 1.230 # K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob
49     # code. If empty, will be set to "1" if deblobbing is
50     # possible. Test ONLY for "1".
51     # K_PREDEBLOBBED - This kernel was already deblobbed elsewhere.
52     # If false, either optional deblobbing will be available
53     # or the license will note the inclusion of freedist
54     # code.
55 johnm 1.55
56     # H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
57     # can be supported by the headers ebuild
58    
59     # UNIPATCH_LIST - space delimetered list of patches to be applied to the
60     # kernel
61     # UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
62     # on "<passedstring>*" and not "<passedno#>_*"
63 lu_zero 1.62 # - this should _NOT_ be used from the ebuild as this is
64 johnm 1.55 # reserved for end users passing excludes from the cli
65 lu_zero 1.62 # UNIPATCH_DOCS - space delimemeted list of docs to be installed to
66 johnm 1.55 # the doc dir
67 lu_zero 1.62 # UNIPATCH_STRICTORDER - if this is set places patches into directories of
68 johnm 1.55 # order, so they are applied in the order passed
69 johnm 1.1
70 phreak 1.192 inherit eutils toolchain-funcs versionator multilib
71 robbat2 1.240 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst
72 johnm 1.1
73 dostrow 1.132 # Added by Daniel Ostrow <dostrow@gentoo.org>
74     # This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
75     # I will remove it when I come up with something more reasonable.
76 vapier 1.189 [[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
77 dostrow 1.132
78 vapier 1.75 export CTARGET=${CTARGET:-${CHOST}}
79 hollow 1.96 if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
80 hollow 1.95 export CTARGET=${CATEGORY/cross-}
81 vapier 1.75 fi
82 vapier 1.60
83 phreak 1.181 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
84 robbat2 1.225 [[ -z ${LICENSE} ]] && \
85 robbat2 1.229 LICENSE="GPL-2"
86 johnm 1.1
87 robbat2 1.231 # This is the latest KV_PATCH of the deblob tool available from the
88     # libre-sources upstream.
89 robbat2 1.239 [[ -z ${DEBLOB_MAX_VERSION} ]] && DEBLOB_MAX_VERSION=35
90 robbat2 1.231
91 brix 1.178 # No need to run scanelf/strip on kernel sources/headers (bug #134453).
92     RESTRICT="binchecks strip"
93    
94 johnm 1.18 # set LINUX_HOSTCFLAGS if not already set
95 vapier 1.136 [[ -z ${LINUX_HOSTCFLAGS} ]] && \
96 johnm 1.93 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
97 johnm 1.18
98 robbat2 1.163 # debugging functions
99     #==============================================================
100     # this function exists only to help debug kernel-2.eclass
101     # if you are adding new functionality in, put a call to it
102     # at the start of src_unpack, or during SRC_URI/dep generation.
103     debug-print-kernel2-variables() {
104 robbat2 1.228 for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
105     RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
106     UNIPATCH_LIST S KERNEL_URI ; do
107     debug-print "${v}: ${!v}"
108     done
109 robbat2 1.163 }
110    
111 johnm 1.54 #Eclass functions only from here onwards ...
112 plasmaroo 1.33 #==============================================================
113 dsd 1.126 handle_genpatches() {
114     local tarball
115 vapier 1.218 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
116 dsd 1.126
117     for i in ${K_WANT_GENPATCHES} ; do
118     tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
119     GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
120     UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
121     done
122     }
123    
124 johnm 1.117 detect_version() {
125     # this function will detect and set
126     # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
127     # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
128     # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
129    
130     if [[ -n ${KV_FULL} ]]; then
131     # we will set this for backwards compatibility.
132     KV=${KV_FULL}
133    
134     # we know KV_FULL so lets stop here. but not without resetting S
135     S=${WORKDIR}/linux-${KV_FULL}
136     return
137     fi
138    
139     # CKV is used as a comparison kernel version, which is used when
140     # PV doesnt reflect the genuine kernel version.
141     # this gets set to the portage style versioning. ie:
142     # CKV=2.6.11_rc4
143     CKV=${CKV:-${PV}}
144     OKV=${OKV:-${CKV}}
145     OKV=${OKV/_beta/-test}
146     OKV=${OKV/_rc/-rc}
147     OKV=${OKV/-r*}
148     OKV=${OKV/_p*}
149    
150     KV_MAJOR=$(get_version_component_range 1 ${OKV})
151     KV_MINOR=$(get_version_component_range 2 ${OKV})
152     KV_PATCH=$(get_version_component_range 3 ${OKV})
153    
154     if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
155     KV_EXTRA=$(get_version_component_range 4- ${OKV})
156     KV_EXTRA=${KV_EXTRA/[-_]*}
157     else
158     KV_PATCH=$(get_version_component_range 3- ${OKV})
159     fi
160     KV_PATCH=${KV_PATCH/[-_]*}
161 robbat2 1.234
162     local v n=0 missing
163     for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
164     [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
165     done
166     [[ $n -eq 1 ]] && \
167     eerror "Missing variables: ${missing}" && \
168     die "Failed to extract kernel version (try explicit CKV in ebuild)!"
169     unset v n missing
170 johnm 1.117
171     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
172    
173     RELEASE=${CKV/${OKV}}
174     RELEASE=${RELEASE/_beta}
175     RELEASE=${RELEASE/_rc/-rc}
176     RELEASE=${RELEASE/_pre/-pre}
177 robbat2 1.234 # We cannot trivally call kernel_is here, because it calls us to detect the
178     # version
179     #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
180     [ $(($KV_MAJOR * 1000 + $KV_MINOR)) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
181 johnm 1.117 RELEASETYPE=${RELEASE//[0-9]}
182    
183 gregkh 1.156 # Now we know that RELEASE is the -rc/-git
184 johnm 1.117 # and RELEASETYPE is the same but with its numerics stripped
185     # we can work on better sorting EXTRAVERSION.
186     # first of all, we add the release
187     EXTRAVERSION="${RELEASE}"
188 robbat2 1.163 debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
189 johnm 1.117 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
190    
191 robbat2 1.163 debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
192     if [[ -n "${K_NOUSEPR}" ]]; then
193     # Don't add anything based on PR to EXTRAVERSION
194     debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
195     elif [[ -n ${K_PREPATCHED} ]]; then
196     debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
197 johnm 1.117 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
198     elif [[ "${ETYPE}" = "sources" ]]; then
199 robbat2 1.163 debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
200 johnm 1.117 # For some sources we want to use the PV in the extra version
201     # This is because upstream releases with a completely different
202     # versioning scheme.
203     case ${PN/-*} in
204     wolk) K_USEPV=1;;
205     vserver) K_USEPV=1;;
206     esac
207    
208 robbat2 1.163 [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
209     [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
210     [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
211 johnm 1.117 fi
212 robbat2 1.163 debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
213 johnm 1.117
214 johnm 1.120 # The only messing around which should actually effect this is for KV_EXTRA
215     # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
216     # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
217     if [[ -n ${KV_EXTRA} ]]; then
218     OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
219     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/patch-${CKV}.bz2
220     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.tar.bz2"
221     UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
222     fi
223 swegener 1.135
224 johnm 1.118 # We need to set this using OKV, but we need to set it before we do any
225     # messing around with OKV based on RELEASETYPE
226     KV_FULL=${OKV}${EXTRAVERSION}
227    
228     # we will set this for backwards compatibility.
229     S=${WORKDIR}/linux-${KV_FULL}
230     KV=${KV_FULL}
231    
232 gregkh 1.156 # -rc-git pulls can be achieved by specifying CKV
233 johnm 1.117 # for example:
234     # CKV="2.6.11_rc3_pre2"
235     # will pull:
236 gregkh 1.156 # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
237 johnm 1.117
238     if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
239     OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
240     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
241     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
242     UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
243     fi
244    
245 gregkh 1.156 if [[ ${RELEASETYPE} == -git ]]; then
246 johnm 1.117 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${OKV}${RELEASE}.bz2
247     mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
248     UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
249     fi
250    
251 gregkh 1.156 if [[ ${RELEASETYPE} == -rc-git ]]; then
252 johnm 1.117 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
253     KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
254 gregkh 1.156 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
255 johnm 1.117 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
256 gregkh 1.156 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
257 johnm 1.117 fi
258 dsd 1.126
259 swegener 1.165 debug-print-kernel2-variables
260 robbat2 1.163
261 dsd 1.126 handle_genpatches
262 johnm 1.117 }
263    
264 plasmaroo 1.33 kernel_is() {
265 robbat2 1.226 # ALL of these should be set before we can safely continue this function.
266     # some of the sources have in the past had only one set.
267     local v n=0
268     for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
269     [[ $n -eq 1 ]] && detect_version
270     unset v n
271    
272     # Now we can continue
273 johnm 1.93 local operator test value x=0 y=0 z=0
274 johnm 1.67
275 johnm 1.93 case ${1} in
276     lt) operator="-lt"; shift;;
277     gt) operator="-gt"; shift;;
278     le) operator="-le"; shift;;
279     ge) operator="-ge"; shift;;
280     eq) operator="-eq"; shift;;
281     *) operator="-eq";;
282     esac
283    
284     for x in ${@}; do
285     for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
286     value="${value}${x}"
287     z=$((${z} + 1))
288 swegener 1.135
289 johnm 1.93 case ${z} in
290     1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
291     test="${test}${KV_MAJOR}";;
292     2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
293     test="${test}${KV_MINOR}";;
294     3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
295     test="${test}${KV_PATCH}";;
296     *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
297     esac
298     done
299 johnm 1.69
300 johnm 1.93 [ ${test} ${operator} ${value} ] && return 0 || return 1
301 plasmaroo 1.33 }
302 johnm 1.18
303     kernel_is_2_4() {
304 johnm 1.56 kernel_is 2 4
305 johnm 1.18 }
306    
307     kernel_is_2_6() {
308 johnm 1.78 kernel_is 2 6 || kernel_is 2 5
309 johnm 1.18 }
310    
311 plasmaroo 1.33 # Capture the sources type and set DEPENDs
312 hollow 1.95 if [[ ${ETYPE} == sources ]]; then
313 johnm 1.1 DEPEND="!build? ( sys-apps/sed
314 dsd 1.183 >=sys-devel/binutils-2.11.90.0.31 )"
315 johnm 1.147 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
316 zmedico 1.221 sys-devel/make )"
317 robbat2 1.222 PDEPEND="!build? ( virtual/dev-manager )"
318 lu_zero 1.62
319 johnm 1.78 PROVIDE="virtual/linux-sources"
320     kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
321 johnm 1.147
322 johnm 1.72 SLOT="${PVR}"
323 johnm 1.147 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
324 dsd 1.183 IUSE="symlink build"
325 robbat2 1.229
326     # Bug #266157, deblob for libre support
327 robbat2 1.230 if [[ -z ${K_PREDEBLOBBED} ]] ; then
328 robbat2 1.231 if [[ -z ${K_DEBLOB_AVAILABLE} ]] ; then
329     kernel_is ge 2 6 27 && \
330     kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
331     K_DEBLOB_AVAILABLE=1
332     fi
333     if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
334 robbat2 1.229 IUSE="${IUSE} deblob"
335     # Reflect that kernels contain firmware blobs unless otherwise
336     # stripped
337     LICENSE="${LICENSE} !deblob? ( freedist )"
338    
339     DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
340     DEBLOB_A="deblob-${DEBLOB_PV}"
341 robbat2 1.239 DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
342 robbat2 1.229 DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
343 robbat2 1.239 DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
344     if ! has "${EAPI:-0}" 0 1 ; then
345     DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
346     else
347     DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
348     fi
349     DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
350 robbat2 1.229 HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
351    
352     KERNEL_URI="${KERNEL_URI}
353     deblob? (
354 robbat2 1.239 ${DEBLOB_URI}
355     ${DEBLOB_CHECK_URI}
356 robbat2 1.229 )"
357     else
358     # We have no way to deblob older kernels, so just mark them as
359     # tainted with non-libre materials.
360     LICENSE="${LICENSE} freedist"
361     fi
362     fi
363    
364 hollow 1.95 elif [[ ${ETYPE} == headers ]]; then
365 johnm 1.72 DESCRIPTION="Linux system headers"
366 swegener 1.135
367 johnm 1.174 # Since we should NOT honour KBUILD_OUTPUT in headers
368     # lets unset it here.
369     unset KBUILD_OUTPUT
370    
371 hollow 1.95 if [[ ${CTARGET} = ${CHOST} ]]; then
372 johnm 1.72 DEPEND="!virtual/os-headers"
373 vapier 1.137 PROVIDE="virtual/os-headers"
374 johnm 1.72 SLOT="0"
375     else
376     SLOT="${CTARGET}"
377     fi
378 johnm 1.1 else
379 johnm 1.55 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
380 johnm 1.93 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
381 johnm 1.1 fi
382    
383 vapier 1.153 # Cross-compile support functions
384 johnm 1.1 #==============================================================
385 vapier 1.153 kernel_header_destdir() {
386     [[ ${CTARGET} == ${CHOST} ]] \
387     && echo /usr/include \
388 vapier 1.168 || echo /usr/${CTARGET}/usr/include
389 vapier 1.153 }
390    
391     cross_pre_c_headers() {
392 kugelfang 1.187 use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
393 vapier 1.153 }
394    
395     env_setup_xmakeopts() {
396 johnm 1.117 # Kernel ARCH != portage ARCH
397 vapier 1.153 export KARCH=$(tc-arch-kernel)
398 johnm 1.117
399 vapier 1.136 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
400     # variables properly or bad things happen !
401 vapier 1.153 xmakeopts="ARCH=${KARCH}"
402     if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
403 vapier 1.136 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
404 vapier 1.151 elif type -p ${CHOST}-ar > /dev/null ; then
405 vapier 1.136 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
406     fi
407 vapier 1.153 export xmakeopts
408     }
409    
410     # Unpack functions
411     #==============================================================
412     unpack_2_4() {
413 lu_zero 1.62 # this file is required for other things to build properly,
414 johnm 1.1 # so we autogenerate it
415 vapier 1.145 make -s mrproper ${xmakeopts} || die "make mrproper failed"
416     make -s symlinks ${xmakeopts} || die "make symlinks failed"
417     make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
418 johnm 1.1 echo ">>> version.h compiled successfully."
419     }
420    
421 vapier 1.153 unpack_2_6() {
422     # this file is required for other things to build properly, so we
423 johnm 1.172 # autogenerate it ... generate a .config to keep version.h build from
424 vapier 1.153 # spitting out an annoying warning
425 johnm 1.177 make -s mrproper ${xmakeopts} 2>/dev/null \
426     || die "make mrproper failed"
427    
428     # quick fix for bug #132152 which triggers when it cannot include linux
429     # headers (ie, we have not installed it yet)
430 vapier 1.188 if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
431 johnm 1.177 touch .config
432     eerror "make defconfig failed."
433     eerror "assuming you dont have any headers installed yet and continuing"
434     epause 5
435     fi
436    
437     make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
438     || die "make include/linux/version.h failed"
439 swegener 1.179 rm -f .config >/dev/null
440 vapier 1.153 }
441    
442 johnm 1.1 universal_unpack() {
443 mpagano 1.223 cd "${WORKDIR}"
444 plasmaroo 1.33 unpack linux-${OKV}.tar.bz2
445 johnm 1.175 if [[ -d "linux" ]]; then
446     mv linux linux-${KV_FULL} \
447     || die "Unable to move source tree to ${KV_FULL}."
448     elif [[ "${OKV}" != "${KV_FULL}" ]]; then
449 hollow 1.98 mv linux-${OKV} linux-${KV_FULL} \
450 johnm 1.55 || die "Unable to move source tree to ${KV_FULL}."
451 hollow 1.98 fi
452 vapier 1.136 cd "${S}"
453 lu_zero 1.62
454 johnm 1.1 # remove all backup files
455     find . -iname "*~" -exec rm {} \; 2> /dev/null
456    
457 johnm 1.78 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
458 mpagano 1.215 # only do this for kernel < 2.6.27 since this file does not exist in later
459     # kernels
460     if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]]
461     then
462     sed -i \
463     -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
464     "${S}"/arch/ppc/Makefile
465 mpagano 1.216 else
466     sed -i \
467     -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
468     "${S}"/arch/powerpc/Makefile
469 mpagano 1.215 fi
470 johnm 1.1 }
471    
472     unpack_set_extraversion() {
473 vapier 1.136 cd "${S}"
474 dsd 1.104 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
475 vapier 1.185 cd "${OLDPWD}"
476 johnm 1.1 }
477    
478 dsd 1.104 # Should be done after patches have been applied
479     # Otherwise patches that modify the same area of Makefile will fail
480     unpack_fix_install_path() {
481 vapier 1.136 cd "${S}"
482 dsd 1.104 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
483     }
484    
485 johnm 1.1 # Compile Functions
486     #==============================================================
487     compile_headers() {
488 vapier 1.153 env_setup_xmakeopts
489    
490 swegener 1.135 # if we couldnt obtain HOSTCFLAGS from the Makefile,
491 vapier 1.75 # then set it to something sane
492 vapier 1.136 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
493 vapier 1.75 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
494    
495 johnm 1.93 if kernel_is 2 4; then
496 vapier 1.75 yes "" | make oldconfig ${xmakeopts}
497 johnm 1.72 echo ">>> make oldconfig complete"
498 vapier 1.152 make dep ${xmakeopts}
499 hollow 1.95 elif kernel_is 2 6; then
500 vapier 1.193 # 2.6.18 introduces headers_install which means we dont need any
501     # of this crap anymore :D
502     kernel_is ge 2 6 18 && return 0
503    
504 johnm 1.72 # autoconf.h isnt generated unless it already exists. plus, we have
505     # no guarantee that any headers are installed on the system...
506 vapier 1.75 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
507 johnm 1.72 || touch include/linux/autoconf.h
508    
509 plasmaroo 1.105 # if K_DEFCONFIG isn't set, force to "defconfig"
510     # needed by mips
511     if [[ -z ${K_DEFCONFIG} ]]; then
512 dostrow 1.194 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
513     case ${CTARGET} in
514     powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
515     powerpc*) K_DEFCONFIG="pmac32_defconfig";;
516     *) K_DEFCONFIG="defconfig";;
517     esac
518     else
519     K_DEFCONFIG="defconfig"
520     fi
521 plasmaroo 1.105 fi
522    
523 johnm 1.72 # if there arent any installed headers, then there also isnt an asm
524     # symlink in /usr/include/, and make defconfig will fail, so we have
525     # to force an include path with $S.
526 vapier 1.75 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
527     ln -sf asm-${KARCH} "${S}"/include/asm
528 vapier 1.153 cross_pre_c_headers && return 0
529    
530 vapier 1.170 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
531     if compile_headers_tweak_config ; then
532     yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
533     fi
534 vapier 1.75 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
535 eradicator 1.100 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
536 johnm 1.72 fi
537 johnm 1.1 }
538    
539 vapier 1.170 compile_headers_tweak_config() {
540     # some targets can be very very picky, so let's finesse the
541     # .config based upon any info we may have
542     case ${CTARGET} in
543     sh*)
544     sed -i '/CONFIG_CPU_SH/d' .config
545     echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
546     return 0;;
547     esac
548    
549     # no changes, so lets do nothing
550     return 1
551     }
552    
553 johnm 1.1 # install functions
554     #==============================================================
555     install_universal() {
556     #fix silly permissions in tarball
557 mpagano 1.223 cd "${WORKDIR}"
558 vapier 1.217 chown -R root:0 * >& /dev/null
559 johnm 1.1 chmod -R a+r-w+X,u+w *
560 johnm 1.93 cd ${OLDPWD}
561 johnm 1.1 }
562    
563     install_headers() {
564 vapier 1.195 local ddir=$(kernel_header_destdir)
565    
566 vapier 1.193 # 2.6.18 introduces headers_install which means we dont need any
567     # of this crap anymore :D
568     if kernel_is ge 2 6 18 ; then
569     env_setup_xmakeopts
570 vapier 1.195 emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
571 vapier 1.196
572     # let other packages install some of these headers
573     rm -rf "${D}"/${ddir}/sound #alsa-headers
574     rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
575 vapier 1.193 return 0
576     fi
577    
578 vapier 1.198 # Do not use "linux/*" as that can cause problems with very long
579     # $S values where the cmdline to cp is too long
580 vapier 1.136 cd "${S}"
581 vapier 1.60 dodir ${ddir}/linux
582 vapier 1.198 cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
583     rm -rf "${D}"/${ddir}/linux/modules
584 lu_zero 1.62
585 vapier 1.137 # Handle multilib headers and crap
586     local multi_dirs="" multi_defs=""
587 eradicator 1.99 case $(tc-arch-kernel) in
588     sparc64)
589 vapier 1.137 multi_dirs="sparc sparc64"
590     multi_defs="!__arch64__ __arch64__"
591 eradicator 1.99 ;;
592     x86_64)
593 vapier 1.137 multi_dirs="i386 x86_64"
594     multi_defs="__i386__ __x86_64__"
595 eradicator 1.99 ;;
596 dostrow 1.131 ppc64)
597 vapier 1.137 multi_dirs="ppc ppc64"
598     multi_defs="!__powerpc64__ __powerpc64__"
599     ;;
600     s390x)
601     multi_dirs="s390 s390x"
602     multi_defs="!__s390x__ __s390x__"
603 dostrow 1.131 ;;
604 vapier 1.114 arm)
605     dodir ${ddir}/asm
606 flameeyes 1.176 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
607 vapier 1.139 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
608     [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
609 vapier 1.114 ;;
610 dostrow 1.155 powerpc)
611     dodir ${ddir}/asm
612 mpagano 1.223 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
613 dostrow 1.155 if [[ -e "${S}"/include/asm-ppc ]] ; then
614     dodir ${ddir}/asm-ppc
615 mpagano 1.223 cp -pPR "${S}"/include/asm-ppc/* "${D}"/${ddir}/asm-ppc
616 dostrow 1.155 fi
617 swegener 1.159 ;;
618 eradicator 1.99 *)
619     dodir ${ddir}/asm
620 mpagano 1.223 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
621 eradicator 1.99 ;;
622     esac
623 vapier 1.137 if [[ -n ${multi_dirs} ]] ; then
624     local d ml_inc=""
625     for d in ${multi_dirs} ; do
626     dodir ${ddir}/asm-${d}
627 mpagano 1.223 cp -pPR "${S}"/include/asm-${d}/* "${D}"/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
628 vapier 1.137
629     ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
630     multi_defs=${multi_defs#* }
631     done
632 swegener 1.140 create_ml_includes ${ddir}/asm ${ml_inc}
633 vapier 1.137 fi
634 eradicator 1.76
635 johnm 1.93 if kernel_is 2 6; then
636 vapier 1.60 dodir ${ddir}/asm-generic
637 mpagano 1.223 cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
638 johnm 1.12 fi
639 eradicator 1.99
640 vapier 1.103 # clean up
641     find "${D}" -name '*.orig' -exec rm -f {} \;
642    
643 johnm 1.93 cd ${OLDPWD}
644 johnm 1.1 }
645    
646     install_sources() {
647 dsd 1.183 local file
648 johnm 1.1
649 vapier 1.136 cd "${S}"
650 johnm 1.12 dodir /usr/src
651 johnm 1.54 echo ">>> Copying sources ..."
652 johnm 1.93
653 johnm 1.27 file="$(find ${WORKDIR} -iname "docs" -type d)"
654 johnm 1.93 if [[ -n ${file} ]]; then
655     for file in $(find ${file} -type f); do
656 vapier 1.136 echo "${file//*docs\/}" >> "${S}"/patches.txt
657     echo "===================================================" >> "${S}"/patches.txt
658     cat ${file} >> "${S}"/patches.txt
659     echo "===================================================" >> "${S}"/patches.txt
660     echo "" >> "${S}"/patches.txt
661 johnm 1.1 done
662 johnm 1.12 fi
663 johnm 1.1
664 johnm 1.93 if [[ ! -f ${S}/patches.txt ]]; then
665 johnm 1.12 # patches.txt is empty so lets use our ChangeLog
666 johnm 1.93 [[ -f ${FILESDIR}/../ChangeLog ]] && \
667     echo "Please check the ebuild ChangeLog for more details." \
668 vapier 1.136 > "${S}"/patches.txt
669 johnm 1.12 fi
670    
671 mpagano 1.223 mv ${WORKDIR}/linux* "${D}"/usr/src
672 johnm 1.1 }
673    
674     # pkg_preinst functions
675     #==============================================================
676     preinst_headers() {
677 vapier 1.60 local ddir=$(kernel_header_destdir)
678 johnm 1.72 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
679     [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
680 johnm 1.1 }
681    
682     # pkg_postinst functions
683     #==============================================================
684     postinst_sources() {
685 vapier 1.80 local MAKELINK=0
686 swegener 1.135
687 johnm 1.84 # if we have USE=symlink, then force K_SYMLINK=1
688     use symlink && K_SYMLINK=1
689    
690 robbat2 1.229 # if we're using a deblobbed kernel, it's not supported
691 robbat2 1.230 [[ $K_DEBLOB_AVAILABLE == 1 ]] && \
692 robbat2 1.229 use deblob && \
693 robbat2 1.232 K_SECURITY_UNSUPPORTED=deblob
694 robbat2 1.229
695 johnm 1.78 # if we are to forcably symlink, delete it if it already exists first.
696 johnm 1.166 if [[ ${K_SYMLINK} > 0 ]]; then
697 vapier 1.80 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
698 johnm 1.78 MAKELINK=1
699     fi
700 swegener 1.135
701 johnm 1.78 # if the link doesnt exist, lets create it
702 vapier 1.80 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
703 swegener 1.135
704 johnm 1.93 if [[ ${MAKELINK} == 1 ]]; then
705 mpagano 1.223 cd "${ROOT}"usr/src
706 johnm 1.89 ln -sf linux-${KV_FULL} linux
707     cd ${OLDPWD}
708     fi
709 johnm 1.1
710     # Don't forget to make directory for sysfs
711 johnm 1.111 [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
712 johnm 1.1
713     echo
714 zlin 1.208 elog "If you are upgrading from a previous kernel, you may be interested"
715 mpagano 1.213 elog "in the following document:"
716 zlin 1.208 elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
717 r3pek 1.113 echo
718 lu_zero 1.62
719 johnm 1.2 # if K_EXTRAEINFO is set then lets display it now
720 hollow 1.95 if [[ -n ${K_EXTRAEINFO} ]]; then
721 johnm 1.2 echo ${K_EXTRAEINFO} | fmt |
722 hollow 1.95 while read -s ELINE; do einfo "${ELINE}"; done
723 plasmaroo 1.33 fi
724    
725 zlin 1.208 # if K_EXTRAELOG is set then lets display it now
726     if [[ -n ${K_EXTRAELOG} ]]; then
727     echo ${K_EXTRAELOG} | fmt |
728     while read -s ELINE; do elog "${ELINE}"; done
729     fi
730    
731 iggy 1.7 # if K_EXTRAEWARN is set then lets display it now
732 hollow 1.95 if [[ -n ${K_EXTRAEWARN} ]]; then
733 iggy 1.7 echo ${K_EXTRAEWARN} | fmt |
734 hollow 1.95 while read -s ELINE; do ewarn "${ELINE}"; done
735 iggy 1.7 fi
736 dsd 1.200
737     # optionally display security unsupported message
738 robbat2 1.232 # Start with why
739     if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
740 ulm 1.233 ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security."
741 robbat2 1.232 elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
742     ewarn "${PN} is UNSUPPORTED by Gentoo Security."
743     fi
744     # And now the general message.
745 dsd 1.200 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
746     ewarn "This means that it is likely to be vulnerable to recent security issues."
747     ewarn "For specific information on why this kernel is unsupported, please read:"
748     ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
749     fi
750 bluebird 1.214
751     # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
752     KV_MAJOR=$(get_version_component_range 1 ${OKV})
753     KV_MINOR=$(get_version_component_range 2 ${OKV})
754     KV_PATCH=$(get_version_component_range 3 ${OKV})
755     if [[ "$(tc-arch)" = "sparc" ]] \
756     && [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]]
757     then
758     echo
759     elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
760     elog "you now need to do"
761     elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
762     elog "instead of just"
763     elog " make"
764     elog "to compile the kernel. For more information please browse to"
765     elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
766     echo
767     fi
768 johnm 1.1 }
769    
770 johnm 1.12 # pkg_setup functions
771     #==============================================================
772     setup_headers() {
773 vapier 1.86 [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
774 hollow 1.95 for i in ${H_SUPPORTEDARCH}; do
775 vapier 1.87 [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
776 johnm 1.12 done
777 lu_zero 1.62
778 johnm 1.93 if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
779 johnm 1.12 echo
780 vapier 1.106 eerror "This version of ${PN} does not support $(tc-arch)."
781 johnm 1.12 eerror "Please merge the appropriate sources, in most cases"
782 vapier 1.106 eerror "(but not all) this will be called $(tc-arch)-headers."
783     die "Package unsupported for $(tc-arch)"
784 johnm 1.12 fi
785     }
786    
787 johnm 1.1 # unipatch
788     #==============================================================
789     unipatch() {
790 johnm 1.108 local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
791 mpagano 1.238 local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
792 swegener 1.135
793 johnm 1.78 # set to a standard locale to ensure sorts are ordered properly.
794     myLC_ALL="${LC_ALL}"
795 johnm 1.122 myLANG="${LANG}"
796 johnm 1.78 LC_ALL="C"
797 johnm 1.122 LANG=""
798 johnm 1.1
799     [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
800     [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
801    
802 johnm 1.41 # We're gonna need it when doing patches with a predefined patchlevel
803 mpagano 1.238 eshopts_push -s extglob
804 johnm 1.41
805 johnm 1.54 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
806 johnm 1.1 # usage can be either via an env var or by params
807 johnm 1.54 # although due to the nature we pass this within this eclass
808     # it shall be by param only.
809     # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
810     UNIPATCH_LIST="${@}"
811 johnm 1.1
812     #unpack any passed tarballs
813 hollow 1.95 for i in ${UNIPATCH_LIST}; do
814 vapier 1.210 if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
815 hollow 1.95 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
816 johnm 1.110 unset z
817 johnm 1.121 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
818 johnm 1.108 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
819     do z="${z}0";
820     done
821 r3pek 1.112 PATCH_ORDER="${z}${STRICT_COUNT}"
822 johnm 1.108
823 vapier 1.210 mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
824     pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
825     unpack ${i##*/}
826     popd >/dev/null
827 johnm 1.16 else
828 vapier 1.210 pushd "${KPATCH_DIR}" >/dev/null
829     unpack ${i##*/}
830     popd >/dev/null
831 johnm 1.16 fi
832    
833 vapier 1.210 [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
834 johnm 1.16 else
835 johnm 1.25 extention=${i/*./}
836 johnm 1.41 extention=${extention/:*/}
837 johnm 1.25 PIPE_CMD=""
838     case ${extention} in
839 vapier 1.236 xz) PIPE_CMD="xz -dc";;
840     lzma) PIPE_CMD="lzma -dc";;
841 johnm 1.25 bz2) PIPE_CMD="bzip2 -dc";;
842     patch) PIPE_CMD="cat";;
843     diff) PIPE_CMD="cat";;
844     gz|Z|z) PIPE_CMD="gzip -dc";;
845     ZIP|zip) PIPE_CMD="unzip -p";;
846 johnm 1.41 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
847 johnm 1.25 esac
848 johnm 1.41
849     PATCH_LEVEL=${i/*([^:])?(:)}
850     i=${i/:*/}
851 johnm 1.25 x=${i/*\//}
852     x=${x/\.${extention}/}
853 lu_zero 1.62
854 hollow 1.95 if [ -n "${PIPE_CMD}" ]; then
855     if [ ! -r "${i}" ]; then
856 johnm 1.29 echo
857     eerror "FATAL: unable to locate:"
858     eerror "${i}"
859 johnm 1.54 eerror "for read-only. The file either has incorrect permissions"
860     eerror "or does not exist."
861 johnm 1.29 die Unable to locate ${i}
862     fi
863 lu_zero 1.62
864 hollow 1.95 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
865 johnm 1.110 unset z
866 johnm 1.121 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
867 johnm 1.108 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
868     do z="${z}0";
869     done
870 r3pek 1.112 PATCH_ORDER="${z}${STRICT_COUNT}"
871 johnm 1.108
872 r3pek 1.112 mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
873     $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL})
874 johnm 1.29 else
875 johnm 1.41 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
876 johnm 1.29 fi
877 johnm 1.25 fi
878 johnm 1.16 fi
879 johnm 1.1 done
880    
881     #populate KPATCH_DIRS so we know where to look to remove the excludes
882     x=${KPATCH_DIR}
883     KPATCH_DIR=""
884 hollow 1.95 for i in $(find ${x} -type d | sort -n); do
885 johnm 1.1 KPATCH_DIR="${KPATCH_DIR} ${i}"
886     done
887    
888 mpagano 1.219 # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
889     # bug #272676
890 maekke 1.220 if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
891 mpagano 1.219 if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
892     UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
893     echo
894     ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
895     ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
896     ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
897     echo
898     fi
899     fi
900    
901 johnm 1.1 #so now lets get rid of the patchno's we want to exclude
902 johnm 1.19 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
903 hollow 1.95 for i in ${UNIPATCH_DROP}; do
904 johnm 1.55 ebegin "Excluding Patch #${i}"
905 hollow 1.95 for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
906 johnm 1.55 eend $?
907 johnm 1.1 done
908    
909     # and now, finally, we patch it :)
910 hollow 1.95 for x in ${KPATCH_DIR}; do
911     for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
912 johnm 1.25 STDERR_T="${T}/${i/*\//}"
913 johnm 1.41 STDERR_T="${STDERR_T/.patch*/.err}"
914    
915 lu_zero 1.62 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
916 r3pek 1.112 #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
917 johnm 1.41
918 hollow 1.96 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
919 johnm 1.41
920     ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
921 hollow 1.95 while [ ${PATCH_DEPTH} -lt 5 ]; do
922 plasmaroo 1.33 echo "Attempting Dry-run:" >> ${STDERR_T}
923 robbat2 1.204 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
924 johnm 1.54 echo "=======================================================" >> ${STDERR_T}
925 robbat2 1.204 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
926 johnm 1.25 echo "Attempting patch:" > ${STDERR_T}
927 robbat2 1.204 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
928 johnm 1.54 echo "=======================================================" >> ${STDERR_T}
929 robbat2 1.204 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
930 johnm 1.1 eend 0
931 johnm 1.25 rm ${STDERR_T}
932 johnm 1.1 break
933     else
934     eend 1
935     eerror "Failed to apply patch ${i/*\//}"
936 johnm 1.54 eerror "Please attach ${STDERR_T} to any bug you may post."
937 mpagano 1.238 eshopts_pop
938 johnm 1.1 die "Failed to apply ${i/*\//}"
939     fi
940     else
941     PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
942     fi
943     done
944 hollow 1.95 if [ ${PATCH_DEPTH} -eq 5 ]; then
945 johnm 1.1 eend 1
946 johnm 1.54 eerror "Please attach ${STDERR_T} to any bug you may post."
947 mpagano 1.238 eshopts_pop
948 johnm 1.1 die "Unable to dry-run patch."
949     fi
950     done
951     done
952 johnm 1.43
953 johnm 1.144 # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which
954     # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
955     # which is why I'm not taking too much time over this.
956     local tmp
957     for i in ${UNIPATCH_DOCS}; do
958     tmp="${tmp} ${i//*\/}"
959 mpagano 1.223 cp -f ${i} "${T}"/
960 johnm 1.144 done
961     UNIPATCH_DOCS="${tmp}"
962 swegener 1.146
963 johnm 1.43 # clean up KPATCH_DIR's - fixes bug #53610
964 hollow 1.95 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
965 swegener 1.135
966 johnm 1.78 LC_ALL="${myLC_ALL}"
967 johnm 1.122 LANG="${myLANG}"
968 mpagano 1.238 eshopts_pop
969 johnm 1.1 }
970    
971 johnm 1.74 # getfilevar accepts 2 vars as follows:
972     # getfilevar <VARIABLE> <CONFIGFILE>
973     # pulled from linux-info
974    
975     getfilevar() {
976 johnm 1.93 local workingdir basefname basedname xarch=$(tc-arch-kernel)
977 johnm 1.74
978 johnm 1.93 if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
979 johnm 1.74 echo -e "\n"
980     eerror "getfilevar requires 2 variables, with the second a valid file."
981     eerror " getfilevar <VARIABLE> <CONFIGFILE>"
982     else
983     workingdir=${PWD}
984     basefname=$(basename ${2})
985     basedname=$(dirname ${2})
986     unset ARCH
987 swegener 1.135
988 johnm 1.74 cd ${basedname}
989     echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
990 johnm 1.119 make ${BUILD_FIXES} -s -f - e 2>/dev/null
991 johnm 1.74 cd ${workingdir}
992 swegener 1.135
993 johnm 1.74 ARCH=${xarch}
994     fi
995     }
996    
997 johnm 1.28 detect_arch() {
998     # This function sets ARCH_URI and ARCH_PATCH
999     # with the neccessary info for the arch sepecific compatibility
1000     # patchsets.
1001 lu_zero 1.62
1002 johnm 1.93 local ALL_ARCH LOOP_ARCH COMPAT_URI i
1003 plasmaroo 1.33
1004     # COMPAT_URI is the contents of ${ARCH}_URI
1005     # ARCH_URI is the URI for all the ${ARCH}_URI patches
1006     # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
1007    
1008     ARCH_URI=""
1009     ARCH_PATCH=""
1010 vapier 1.145 ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
1011 johnm 1.31
1012 hollow 1.95 for LOOP_ARCH in ${ALL_ARCH}; do
1013 johnm 1.31 COMPAT_URI="${LOOP_ARCH}_URI"
1014     COMPAT_URI="${!COMPAT_URI}"
1015 lu_zero 1.62
1016 vapier 1.86 [[ -n ${COMPAT_URI} ]] && \
1017 johnm 1.55 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
1018 lu_zero 1.62
1019 johnm 1.93 if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
1020     for i in ${COMPAT_URI}; do
1021 plasmaroo 1.33 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
1022     done
1023     fi
1024 johnm 1.31 done
1025 johnm 1.28 }
1026    
1027 johnm 1.72 # sparc nastiness
1028     #==============================================================
1029     # This script generates the files in /usr/include/asm for sparc systems
1030     # during installation of sys-kernel/linux-headers.
1031     # Will no longer be needed when full 64 bit support is used on sparc64
1032     # systems.
1033     #
1034     # Shamefully ripped from Debian
1035     # ----------------------------------------------------------------------
1036    
1037     # Idea borrowed from RedHat's kernel package
1038    
1039 eradicator 1.76 # This is gonna get replaced by something in multilib.eclass soon...
1040     # --eradicator
1041 johnm 1.72 generate_sparc_asm() {
1042     local name
1043    
1044     cd $1 || die
1045     mkdir asm
1046    
1047     for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
1048     name="$(echo $h | tr a-z. A-Z_)"
1049     # common header
1050     echo "/* All asm/ files are generated and point to the corresponding
1051     * file in asm-sparc or asm-sparc64.
1052     */
1053    
1054     #ifndef __SPARCSTUB__${name}__
1055     #define __SPARCSTUB__${name}__
1056     " > asm/${h}
1057    
1058     # common for sparc and sparc64
1059     if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
1060     echo "#ifdef __arch64__
1061     #include <asm-sparc64/$h>
1062     #else
1063     #include <asm-sparc/$h>
1064     #endif
1065     " >> asm/${h}
1066    
1067     # sparc only
1068     elif [ -f asm-sparc/$h ]; then
1069     echo "#ifndef __arch64__
1070     #include <asm-sparc/$h>
1071     #endif
1072     " >> asm/${h}
1073    
1074     # sparc64 only
1075     else
1076     echo "#ifdef __arch64__
1077     #include <asm-sparc64/$h>
1078     #endif
1079     " >> asm/${h}
1080     fi
1081    
1082     # common footer
1083     echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
1084     done
1085     return 0
1086     }
1087    
1088 johnm 1.89 headers___fix() {
1089 plasmaroo 1.88 # Voodoo to partially fix broken upstream headers.
1090 vapier 1.205 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1091 johnm 1.72 sed -i \
1092 plasmaroo 1.186 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1093 plasmaroo 1.184 -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
1094 vapier 1.205 -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
1095     -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
1096     -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
1097 johnm 1.72 "$@"
1098     }
1099 johnm 1.28
1100 johnm 1.1 # common functions
1101     #==============================================================
1102 plasmaroo 1.33 kernel-2_src_unpack() {
1103 johnm 1.1 universal_unpack
1104 robbat2 1.163 debug-print "Doing unipatch"
1105 lu_zero 1.62
1106 dsd 1.126 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
1107     unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
1108 swegener 1.165
1109 robbat2 1.163 debug-print "Doing premake"
1110 lu_zero 1.62
1111 vapier 1.157 # allow ebuilds to massage the source tree after patching but before
1112     # we run misc `make` functions below
1113 vapier 1.158 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
1114 swegener 1.165
1115 mpagano 1.224 debug-print "Doing epatch_user"
1116     epatch_user
1117    
1118 robbat2 1.163 debug-print "Doing unpack_set_extraversion"
1119 vapier 1.157
1120 johnm 1.107 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
1121 dsd 1.104 unpack_fix_install_path
1122    
1123 johnm 1.172 # Setup xmakeopts and cd into sourcetree.
1124     env_setup_xmakeopts
1125     cd "${S}"
1126    
1127     # We dont need a version.h for anything other than headers
1128     # at least, I should hope we dont. If this causes problems
1129     # take out the if/fi block and inform me please.
1130     # unpack_2_6 should now be 2.6.17 safe anyways
1131     if [[ ${ETYPE} == headers ]]; then
1132     kernel_is 2 4 && unpack_2_4
1133     kernel_is 2 6 && unpack_2_6
1134     fi
1135 robbat2 1.229
1136 robbat2 1.230 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1137 robbat2 1.239 cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
1138     cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
1139     chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
1140 robbat2 1.229 fi
1141 johnm 1.1 }
1142    
1143 plasmaroo 1.33 kernel-2_src_compile() {
1144 vapier 1.136 cd "${S}"
1145 johnm 1.93 [[ ${ETYPE} == headers ]] && compile_headers
1146 robbat2 1.229
1147 robbat2 1.230 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1148 robbat2 1.229 echo ">>> Running deblob script ..."
1149     sh "${T}/${DEBLOB_A}" --force || \
1150     die "Deblob script failed to run!!!"
1151     fi
1152 johnm 1.1 }
1153    
1154 robbat2 1.240 # if you leave it to the default src_test, it will run make to
1155     # find whether test/check targets are present; since "make test"
1156     # actually produces a few support files, they are installed even
1157     # though the package is binchecks-restricted.
1158     #
1159     # Avoid this altogether by making the function moot.
1160     kernel-2_src_test() { :; }
1161    
1162 plasmaroo 1.33 kernel-2_pkg_preinst() {
1163 johnm 1.93 [[ ${ETYPE} == headers ]] && preinst_headers
1164 johnm 1.1 }
1165    
1166 plasmaroo 1.33 kernel-2_src_install() {
1167 johnm 1.1 install_universal
1168 johnm 1.93 [[ ${ETYPE} == headers ]] && install_headers
1169     [[ ${ETYPE} == sources ]] && install_sources
1170 johnm 1.1 }
1171    
1172 plasmaroo 1.33 kernel-2_pkg_postinst() {
1173 johnm 1.93 [[ ${ETYPE} == sources ]] && postinst_sources
1174 johnm 1.1 }
1175 johnm 1.12
1176 plasmaroo 1.33 kernel-2_pkg_setup() {
1177 phreak 1.192 if kernel_is 2 4; then
1178     if [ "$( gcc-major-version )" -eq "4" ] ; then
1179     echo
1180     ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1181     ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1182     ewarn "newer kernel that supports gcc-4."
1183     echo
1184     ewarn "Also be aware that bugreports about gcc-4 not working"
1185     ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
1186     echo
1187     epause 10
1188     fi
1189     fi
1190    
1191 blubb 1.167 ABI="${KERNEL_ABI}"
1192 johnm 1.93 [[ ${ETYPE} == headers ]] && setup_headers
1193     [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1194 johnm 1.12 }

  ViewVC Help
Powered by ViewVC 1.1.20