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

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.249 - (hide annotations) (download)
Thu Apr 14 06:10:32 2011 UTC (8 years, 2 months ago) by ulm
Branch: MAIN
Changes since 1.248: +14 -16 lines
Don't PROVIDE virtual/os-headers, it is a new-style virtual now, bug 358999.
Fix whitespace.

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

  ViewVC Help
Powered by ViewVC 1.1.20