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

Diff of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.228

  ViewVC Help
Powered by ViewVC 1.1.20