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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.252 - (hide annotations) (download)
Fri Jun 3 13:07:33 2011 UTC (8 years ago) by mpagano
Branch: MAIN
Changes since 1.251: +119 -48 lines
Add support for 2 part versioning. bug #369533

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

  ViewVC Help
Powered by ViewVC 1.1.20