/[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.72
1# Copyright 1999-2004 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.72 2005/01/11 15:12:17 johnm 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# Maintainer: John Mylchreest <johnm@gentoo.org>
5# Copyright 2004 Gentoo Linux 9# Copyright 2004 Gentoo Linux
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#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 19# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
20# 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 21# 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 22# first part of ${PN} in EXTRAVERSION
23# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
24# ck-sources, ac-sources) it will use PR (ie: -r5) as
25# the patchset version for
19# - and not use it as a true package revision 26# - 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 27# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
28# postinst and can be used to carry additional postinst
29# messages
21# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's 30# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
22 31
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild 32# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
33# can be supported by the headers ebuild
24 34
25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 35# UNIPATCH_LIST - space delimetered list of patches to be applied to the
36# kernel
37# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
38# on "<passedstring>*" and not "<passedno#>_*"
39# - this should _NOT_ be used from the ebuild as this is
40# reserved for end users passing excludes from the cli
26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 41# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
42# the doc dir
43# UNIPATCH_STRICTORDER - if this is set places patches into directories of
44# order, so they are applied in the order passed
27 45
28ECLASS="kernel-2" 46ECLASS="kernel-2"
47INHERITED="$INHERITED $ECLASS"
29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 48EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
30 49
50export CTARGET="${CTARGET:-${CHOST}}"
51
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 52HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 53LICENSE="GPL-2"
33IUSE="${IUSE} build"
34SLOT="${KV}"
35 54
55# set LINUX_HOSTCFLAGS if not already set
56[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
57
58#Eclass functions only from here onwards ...
59#==============================================================
60kernel_is() {
61 # And lets add a sanity check
62 [ -z "${KV_FULL}" ] && return 1
63
64 local RESULT operator test value i len
65 RESULT=0
66
67 operator="="
68 if [ "${1}" == "lt" ]
69 then
70 operator="-lt"
71 shift
72 elif [ "${1}" == "gt" ]
73 then
74 operator="-gt"
75 shift
76 elif [ "${1}" == "le" ]
77 then
78 operator="-le"
79 shift
80 elif [ "${1}" == "ge" ]
81 then
82 operator="-ge"
83 shift
84 fi
85
86 if [ -n "${1}" ]
87 then
88 value="${value}${1}"
89 test="${test}${KV_MAJOR}"
90 fi
91 if [ -n "${2}" ]
92 then
93 len=$[ 3 - ${#2} ]
94 for((i=0; i<$len; i++)); do
95 value="${value}0"
96 done
97 value="${value}${2}"
98
99 len=$[ 3 - ${#KV_MINOR} ]
100 for((i=0; i<$len; i++)); do
101 test="${test}0"
102 done
103 test="${test}${KV_MINOR}"
104 fi
105 if [ -n "${3}" ]
106 then
107 len=$[ 3 - ${#3} ]
108 for((i=0; i<$len; i++)); do
109 value="${value}0"
110 done
111 value="${value}${3}"
112
113 len=$[ 3 - ${#KV_PATCH} ]
114 for((i=0; i<$len; i++)); do
115 test="${test}0"
116 done
117 test="${test}${KV_PATCH}"
118 fi
119
120 [ ${test} ${operator} ${value} ] && return 0 || return 1
121}
122
123
124kernel_is_2_4() {
125 kernel_is 2 4
126 return $?
127}
128
129kernel_is_2_6() {
130 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
131 return 0 || return 1
132}
133
134kernel_header_destdir() {
135 [ "${CTARGET}" = "${CHOST}" ] \
136 && echo /usr/include \
137 || echo /usr/${CTARGET}/include
138}
139
36# capture the sources type and set depends 140# Capture the sources type and set DEPENDs
37if [ "${ETYPE}" == "sources" ] 141if [ "${ETYPE}" == "sources" ]
38then 142then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 143 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
40 DEPEND="!build? ( sys-apps/sed 144 DEPEND="!build? ( sys-apps/sed
41 >=sys-devel/binutils-2.11.90.0.31 )" 145 >=sys-devel/binutils-2.11.90.0.31 )
146 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
42 147
43 RDEPEND="${DEPEND} 148 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 149 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 150 dev-lang/perl
46 sys-apps/module-init-tools 151 virtual/modutils
47 sys-devel/make )" 152 sys-devel/make )"
48 153
154 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" \
49 PROVIDE="virtual/linux-sources virtual/alsa" 155 || PROVIDE="virtual/linux-sources virtual/alsa"
50 156
157 SLOT="${PVR}"
158 DESCRIPTION="Sources for the Linux kernel"
159 IUSE="${IUSE} build doc"
51elif [ "${ETYPE}" == "headers" ] 160elif [ "${ETYPE}" == "headers" ]
52then 161then
162 DESCRIPTION="Linux system headers"
163 IUSE="${IUSE}"
164
165 if [[ ${CTARGET} = ${CHOST} ]]
166 then
167 DEPEND="!virtual/os-headers"
53 PROVIDE="virtual/kernel virtual/os-headers" 168 PROVIDE="virtual/kernel virtual/os-headers"
169 SLOT="0"
170 else
171 SLOT="${CTARGET}"
172 fi
54else 173else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 174 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
56 die 175 die
57fi 176fi
58 177
59# Grab kernel version from KV
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#==============================================================
71kernel_is_2_4() {
72 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
73}
74
75kernel_is_2_6() {
76 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
77}
78
79
80# Unpack functions 178# Unpack functions
81#============================================================== 179#==============================================================
82unpack_2_4() { 180unpack_2_4() {
83 cd ${S} 181 cd ${S}
84 # this file is required for other things to build properly, 182 # this file is required for other things to build properly,
85 # so we autogenerate it 183 # so we autogenerate it
86 make mrproper || die "make mrproper died" 184 make mrproper || die "make mrproper died"
87 make include/linux/version.h || die "make include/linux/version.h failed" 185 make include/linux/version.h || die "make include/linux/version.h failed"
88 echo ">>> version.h compiled successfully." 186 echo ">>> version.h compiled successfully."
89} 187}
90 188
91universal_unpack() { 189universal_unpack() {
190 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
191
192 cd ${WORKDIR}
193 unpack linux-${OKV}.tar.bz2
194 if [ "${OKV}" != "${KV_FULL}" ]
195 then
196 mv linux-${OKV} linux-${KV_FULL} \
197 || die "Unable to move source tree to ${KV_FULL}."
198 fi
199 cd ${S}
200
201 # change incorrect install path
202 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
203
92 # remove all backup files 204 # remove all backup files
93 find . -iname "*~" -exec rm {} \; 2> /dev/null 205 find . -iname "*~" -exec rm {} \; 2> /dev/null
94 206
95 if [ -d "${S}/Documentation/DocBook" ] 207 if [ -d "${S}/Documentation/DocBook" ]
96 then 208 then
97 cd ${S}/Documentation/DocBook 209 cd ${S}/Documentation/DocBook
98 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \ 210 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
99 && mv Makefile.new Makefile 211 && mv Makefile.new Makefile
100 cd ${S} 212 cd ${S}
101 fi 213 fi
214 # fix a problem on ppc
215 use ppc && \
216 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
217 ${S}/arch/ppc/Makefile
102} 218}
103 219
104unpack_set_extraversion() { 220unpack_set_extraversion() {
105 # Gentoo Linux uses /boot, so fix 'make install' to work properly and fix EXTRAVERSION
106 cd ${S} 221 cd ${S}
107 mv Makefile Makefile.orig
108 sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
109 -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \ 222 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
110 Makefile.orig > Makefile
111 rm Makefile.orig
112} 223}
113 224
114# Compile Functions 225# Compile Functions
115#============================================================== 226#==============================================================
116compile_headers() { 227compile_headers() {
228 local extra_makeopts=
229 local HOSTCFLAGS=
230 unset ARCH
231
232 if kernel_is 2 4
233 then
234 yes "" | make oldconfig
235 echo ">>> make oldconfig complete"
236 use sparc && make dep
237 elif kernel_is 2 6
238 then
239 # autoconf.h isnt generated unless it already exists. plus, we have
240 # no guarantee that any headers are installed on the system...
241 [ -f "${ROOT}"/usr/include/linux/autoconf.h ] \
242 || touch include/linux/autoconf.h
243
244 # When cross-compiling, we need to set the CROSS_COMPILE var properly
245 if [[ ${CTARGET} != ${CHOST} ]] ; then
246 extra_makeopts="CROSS_COMPILE=${CTARGET}-"
247 elif type -p ${CHOST}-ar ; then
248 extra_makeopts="CROSS_COMPILE=${CHOST}-"
249 fi
250
251 # if there arent any installed headers, then there also isnt an asm
252 # symlink in /usr/include/, and make defconfig will fail, so we have
253 # to force an include path with $S.
254 local HOSTCFLAGS="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I${S}/include/"
255 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
256 make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "defconfig failed"
257 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "prepare failed"
258 fi
259}
260
261compile_manpages() {
117 local MY_ARCH 262 local MY_ARCH
118 263
264 einfo "Making manpages ..."
119 MY_ARCH=${ARCH} 265 MY_ARCH=${ARCH}
120 unset ${ARCH} 266 unset ARCH
121 yes "" | make oldconfig 267 make mandocs
122 echo ">>> make oldconfig complete"
123 ARCH=${MY_ARCH} 268 ARCH=${MY_ARCH}
124} 269}
125 270
126# install functions 271# install functions
127#============================================================== 272#==============================================================
128install_universal() { 273install_universal() {
131 chown -R root:root * 276 chown -R root:root *
132 chmod -R a+r-w+X,u+w * 277 chmod -R a+r-w+X,u+w *
133} 278}
134 279
135install_headers() { 280install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 281 local ddir=$(kernel_header_destdir)
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
138 282
139 cd ${S} 283 cd ${S}
140 dodir /usr/include/linux 284 dodir ${ddir}/linux
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 285 cp -ax ${S}/include/linux/* ${D}/${ddir}/linux
142 rm -rf ${D}/usr/include/linux/modules 286 rm -rf ${D}/${ddir}/linux/modules
143 dodir /usr/include/asm 287 dodir ${ddir}/asm
288
289 if [ "${PROFILE_ARCH}" = "sparc64" -o "${PROFILE_ARCH}" = "sparc64-multilib" ] ; then
290 rm -Rf ${ddir}/asm
291 dodir ${ddir}/asm-sparc
292 dodir ${ddir}/asm-sparc64
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 293 cp -ax ${S}/include/asm-sparc/* ${D}/usr/include/asm-sparc
145 294 cp -ax ${S}/include/asm-sparc64/* ${D}/usr/include/asm-sparc64
146 if [ $(kernel_is_2_6) $? == 0 ] 295 generate_sparc_asm ${D}/usr/include
296 else
297 cp -ax ${S}/include/asm/* ${D}/${ddir}/asm
298 fi
299
300 if kernel_is 2 6
147 then 301 then
148 dodir /usr/include/asm-generic 302 dodir ${ddir}/asm-generic
149 cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic 303 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic
304
305
150 fi 306 fi
151} 307}
152 308
153install_sources() { 309install_sources() {
154 local doc 310 local doc
155 local docs 311 local docs
312 local file
156 313
157 cd ${S} 314 cd ${S}
158 dodir /usr/src 315 dodir /usr/src
159 echo ">>> Copying sources..." 316 echo ">>> Copying sources ..."
160 if [ -d "${WORKDIR}/${KV}/docs/" ] 317 file="$(find ${WORKDIR} -iname "docs" -type d)"
318 if [ -n "${file}" ]
161 then 319 then
162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 320 for file in $(find ${file} -type f)
163 do 321 do
164 echo "XX_${file}*" >> ${S}/patches.txt 322 echo "${file/*docs\//}" >> ${S}/patches.txt
323 echo "===================================================" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt 324 cat ${file} >> ${S}/patches.txt
325 echo "===================================================" >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt 326 echo "" >> ${S}/patches.txt
167 done 327 done
168 fi 328 fi
169 329
170 if [ ! -f ${S}/patches.txt ] 330 if [ ! -f ${S}/patches.txt ]
179 done 339 done
180 340
181 if [ -f ${S}/patches.txt ]; then 341 if [ -f ${S}/patches.txt ]; then
182 docs="${docs} ${S}/patches.txt" 342 docs="${docs} ${S}/patches.txt"
183 fi 343 fi
344
345 if use doc && ! use arm && ! use s390; then
346 install_manpages
347 fi
348
184 dodoc ${docs} 349 dodoc ${docs}
185 mv ${WORKDIR}/linux* ${D}/usr/src 350 mv ${WORKDIR}/linux* ${D}/usr/src
186} 351}
187 352
353install_manpages() {
354 local MY_ARCH
355
356 ebegin "Installing manpages"
357 MY_ARCH=${ARCH}
358 unset ARCH
359 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
360 make installmandocs
361 eend $?
362 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
363 ARCH=${MY_ARCH}
364}
365
188# pkg_preinst functions 366# pkg_preinst functions
189#============================================================== 367#==============================================================
190preinst_headers() { 368preinst_headers() {
191 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux 369 local ddir=$(kernel_header_destdir)
192 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm 370 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
371 [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
193} 372}
194 373
195# pkg_postinst functions 374# pkg_postinst functions
196#============================================================== 375#==============================================================
197postinst_sources() { 376postinst_sources() {
198 if [ ! -h ${ROOT}usr/src/linux ] 377 if [ ! -h ${ROOT}usr/src/linux ]
199 then 378 then
200 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux 379 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
201 fi 380 fi
202 381
203 # Don't forget to make directory for sysfs 382 # Don't forget to make directory for sysfs
204 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys 383 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
205 384
209 einfo "created (X.Y is the first 2 parts of your new kernel version)" 388 einfo "created (X.Y is the first 2 parts of your new kernel version)"
210 echo 389 echo
211 einfo "For example, this kernel will require:" 390 einfo "For example, this kernel will require:"
212 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" 391 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
213 echo 392 echo
214 393
215 # if K_EXTRAEINFO is set then lets display it now 394 # if K_EXTRAEINFO is set then lets display it now
216 if [ -n "${K_EXTRAEINFO}" ] 395 if [ -n "${K_EXTRAEINFO}" ]
217 then 396 then
218 echo ${K_EXTRAEINFO} | fmt | 397 echo ${K_EXTRAEINFO} | fmt |
219 while read -s ELINE 398 while read -s ELINE
222 done 401 done
223 402
224 echo 403 echo
225 fi 404 fi
226 405
406 # Show policy version, if this kernel has SELinux ...
407 local secfile
408 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
409 if use selinux && [ -f "$secfile" ]
410 then
411 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
412 einfo "The SELinux policy version of this kernel is $polver."
413 echo
414 fi
415
227 # if K_EXTRAEWARN is set then lets display it now 416 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 417 if [ -n "${K_EXTRAEWARN}" ]
229 then 418 then
230 echo ${K_EXTRAEWARN} | fmt | 419 echo ${K_EXTRAEWARN} | fmt |
231 while read -s ELINE 420 while read -s ELINE
236 echo 425 echo
237 fi 426 fi
238} 427}
239 428
240postinst_headers() { 429postinst_headers() {
241 echo
242 einfo "Kernel headers are usually only used when recompiling glibc." 430 einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation"
243 einfo "Following the installation of newer headers it is advised that" 431 einfo "of newer headers, it is advised that you re-merge glibc as follows:"
244 einfo "you re-merge glibc as follows:"
245 einfo "# emerge glibc" 432 einfo "emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer" 433 einfo "Failure to do so will cause glibc to not make use of newer features present in the updated kernel"
247 einfo "features present in the updated kernelheaders." 434 einfo "headers."
248 echo
249} 435}
250 436
251# pkg_setup functions 437# pkg_setup functions
252#============================================================== 438#==============================================================
253setup_headers() { 439setup_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/-*/}" 440 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
258 for i in ${H_SUPPORTEDARCH} 441 for i in ${H_SUPPORTEDARCH}
259 do 442 do
260 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes" 443 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
261 done 444 done
262 445
263 if [ "${H_ACCEPT_ARCH}" != "yes" ] 446 if [ "${H_ACCEPT_ARCH}" != "yes" ]
264 then 447 then
265 echo 448 echo
266 eerror "This version of ${PN} does not support ${ARCH}." 449 eerror "This version of ${PN} does not support ${ARCH}."
267 eerror "Please merge the appropriate sources, in most cases" 450 eerror "Please merge the appropriate sources, in most cases"
268 eerror "this will be ${ARCH}-headers." 451 eerror "(but not all) this will be called ${ARCH}-headers."
269 die "incorrect headers" 452 die "Package unsupported for ${ARCH}"
270 fi 453 fi
271} 454}
272 455
273# unipatch 456# unipatch
274#============================================================== 457#==============================================================
275unipatch() { 458unipatch() {
276 local i 459 local i
277 local x 460 local x
278 local extention 461 local extention
279 local PIPE_CMD 462 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 463 local UNIPATCH_DROP
281 local KPATCH_DIR 464 local KPATCH_DIR
282 local PATCH_DEPTH 465 local PATCH_DEPTH
283 local ELINE 466 local ELINE
467 local STRICT_COUNT
468 local PATCH_LEVEL
284 469
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 470 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 471 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 472
473 # We're gonna need it when doing patches with a predefined patchlevel
474 shopt -s extglob
475
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 476 # 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 477 # usage can be either via an env var or by params
478 # although due to the nature we pass this within this eclass
479 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 480 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
481 UNIPATCH_LIST="${@}"
291 482
292 #unpack any passed tarballs 483 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 484 for i in ${UNIPATCH_LIST}
294 do 485 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 486 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
296 then 487 then
297 extention=${i/*./} 488 extention=${i/*./}
489 extention=${extention/:*/}
298 case ${extention} in 490 case ${extention} in
299 tbz2) PIPE_CMD="tar -xvjf";; 491 tbz2) PIPE_CMD="tar -xvjf";;
300 bz2) PIPE_CMD="tar -xvjf";; 492 bz2) PIPE_CMD="tar -xvjf";;
301 tgz) PIPE_CMD="tar -xvzf";; 493 tgz) PIPE_CMD="tar -xvzf";;
302 gz) PIPE_CMD="tar -xvzf";; 494 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 495 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 496 die "Unrecognized tarball compression";;
305 esac 497 esac
306 498
499 if [ -n "${UNIPATCH_STRICTORDER}" ]
500 then
501 STRICT_COUNT=$((${STRICT_COUNT} + 1))
502 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
503 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
504 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 505 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
506 fi
507
308 if [ $? == 0 ] 508 if [ $? == 0 ]
309 then 509 then
310 einfo "${i/*\//} unpacked" 510 einfo "${i/*\//} unpacked"
511 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
311 else 512 else
312 eerror "Failed to unpack ${i}" 513 eerror "Failed to unpack ${i/:*/}"
313 die "unable to unpack patch tarball" 514 die "unable to unpack patch tarball"
314 fi 515 fi
516 else
517 extention=${i/*./}
518 extention=${extention/:*/}
519 PIPE_CMD=""
520 case ${extention} in
521 bz2) PIPE_CMD="bzip2 -dc";;
522 patch) PIPE_CMD="cat";;
523 diff) PIPE_CMD="cat";;
524 gz|Z|z) PIPE_CMD="gzip -dc";;
525 ZIP|zip) PIPE_CMD="unzip -p";;
526 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
527 esac
315 528
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 529 PATCH_LEVEL=${i/*([^:])?(:)}
530 i=${i/:*/}
531 x=${i/*\//}
532 x=${x/\.${extention}/}
533
534 if [ -n "${PIPE_CMD}" ]
535 then
536 if [ ! -r "${i}" ]
537 then
538 echo
539 eerror "FATAL: unable to locate:"
540 eerror "${i}"
541 eerror "for read-only. The file either has incorrect permissions"
542 eerror "or does not exist."
543 die Unable to locate ${i}
544 fi
545
546 if [ -n "${UNIPATCH_STRICTORDER}" ]
547 then
548 STRICT_COUNT=$((${STRICT_COUNT} + 1))
549 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
550 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
551 else
552 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
553 fi
554 fi
317 fi 555 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 556 done
337 557
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 558 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 559 x=${KPATCH_DIR}
340 KPATCH_DIR="" 560 KPATCH_DIR=""
561 LC_ALL="C"
341 for i in $(find ${x} -type d) 562 for i in $(find ${x} -type d | sort -n)
342 do 563 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 564 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 565 done
345 566
346 #so now lets get rid of the patchno's we want to exclude 567 #so now lets get rid of the patchno's we want to exclude
568 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 569 for i in ${UNIPATCH_DROP}
348 do 570 do
571 ebegin "Excluding Patch #${i}"
349 for x in ${KPATCH_DIR} 572 for x in ${KPATCH_DIR}
350 do 573 do
351 rm ${x}/${i}_* 2>/dev/null 574 rm -f ${x}/${i}* 2>/dev/null
352 if [ $? == 0 ]
353 then
354 einfo "Excluding Patch #${i}"
355 einfo "From: ${x/${WORKDIR}/}"
356 fi
357 done 575 done
576 eend $?
358 done 577 done
359 578
360 # and now, finally, we patch it :) 579 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 580 for x in ${KPATCH_DIR}
362 do 581 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 582 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
364 do 583 do
584 STDERR_T="${T}/${i/*\//}"
585 STDERR_T="${STDERR_T/.patch*/.err}"
365 586
587 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
588 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
366 589
590 if [ -z "${PATCH_DEPTH}" ]; then
367 PATCH_DEPTH=0 591 PATCH_DEPTH=0
592 fi
593
368 ebegin "Applying ${i/*\//}" 594 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
369 while [ ${PATCH_DEPTH} -lt 5 ] 595 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 596 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 597 echo "Attempting Dry-run:" >> ${STDERR_T}
598 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
599 echo "=======================================================" >> ${STDERR_T}
600 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 601 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 602 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 603 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
604 echo "=======================================================" >> ${STDERR_T}
605 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 606 then
376 eend 0 607 eend 0
608 rm ${STDERR_T}
377 break 609 break
378 else 610 else
379 eend 1 611 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 612 eerror "Failed to apply patch ${i/*\//}"
613 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 614 die "Failed to apply ${i/*\//}"
382 fi 615 fi
383 else 616 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 617 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 618 fi
386 done 619 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 620 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 621 then
389 eend 1 622 eend 1
623 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 624 die "Unable to dry-run patch."
391 fi 625 fi
392
393
394 done 626 done
395 done 627 done
628
629 # clean up KPATCH_DIR's - fixes bug #53610
630 for x in ${KPATCH_DIR}
631 do
632 rm -Rf ${x}
633 done
634 unset LC_ALL
396} 635}
397 636
398# custom functions 637# custom functions
399#============================================================== 638#==============================================================
400detect_version() { 639detect_version() {
401 # this function will detect and set 640 # this function will detect and set
402 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 641 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
403 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1) 642 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
404 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 643 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
405 644
645 if [ -n "${KV_FULL}" ] ;
646 then
647 # we will set this for backwards compatibility.
648 KV=${KV_FULL}
649
650 # we know KV_FULL so lets stop here. but not without resetting S
651 S=${WORKDIR}/linux-${KV_FULL}
652 return
653 fi
654
406 OKV=${PV/_beta/-test} 655 OKV=${PV/_beta/-test}
407 OKV=${OKV/_rc/-rc} 656 OKV=${OKV/_rc/-rc}
408 OKV=${OKV/_pre*/} 657 OKV=${OKV/_p*/}
409 OKV=${OKV/-r*/} 658 OKV=${OKV/-r*/}
410 659
411 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 660 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
412 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 661 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
413 KV_PATCH=$(echo ${OKV} | cut -d. -f3) 662 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
414 KV_PATCH=${KV_PATCH/[-_]*/} 663 KV_PATCH=${KV_PATCH/[-_]*/}
415 664
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 665 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 666
418 RELEASE=${PV/${OKV}/} 667 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 668 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 669 RELEASE=${RELEASE/_rc/-rc}
670 if [ $(kernel_is_2_4) $? == 0 ]
671 then
672 RELEASE=${RELEASE/_pre/-pre}
673 else
421 RELEASE=${RELEASE/_pre/-bk} 674 RELEASE=${RELEASE/_pre/-bk}
675 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 676 RELEASETYPE=${RELEASE//[0-9]/}
423
424 EXTRAVERSION="${RELEASE}" 677 EXTRAVERSION="${RELEASE}"
425 678
426 if [ -n "${K_PREPATCHED}" ] 679 if [ -n "${K_PREPATCHED}" ]
427 then 680 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 681 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 682 elif [ ${ETYPE} != "headers" ]
683 then
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 684 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 685 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 686 fi
687
433 KV=${OKV}${EXTRAVERSION} 688 KV_FULL=${OKV}${EXTRAVERSION}
434 fi 689
435
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 690 # -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 691 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 692 # and theoretically thereafter.
439 693
440 if [ "${RELEASETYPE}" == "-rc" ] 694 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 695 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 696 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 697 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" 698 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 699 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 700 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
447 fi 701 fi
448 702
449 if [ "${RELEASETYPE}" == "-bk" ] 703 if [ "${RELEASETYPE}" == "-bk" ]
450 then 704 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 705 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 706 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" 707 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}" 708 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
455 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 709 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
456 fi 710 fi
457 711
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 712 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 713 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 714 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})" 715 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 716
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 717 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" 718 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}" 719 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
466 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 720 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
467 fi 721 fi
468 722
469 S=${WORKDIR}/linux-${KV} 723 S=${WORKDIR}/linux-${KV_FULL}
724 # we will set this for backwards compatibility.
725 KV=${KV_FULL}
470} 726}
471 727
728detect_arch() {
729 # This function sets ARCH_URI and ARCH_PATCH
730 # with the neccessary info for the arch sepecific compatibility
731 # patchsets.
732
733 local ALL_ARCH
734 local LOOP_ARCH
735 local COMPAT_URI
736 local i
737
738 # COMPAT_URI is the contents of ${ARCH}_URI
739 # ARCH_URI is the URI for all the ${ARCH}_URI patches
740 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
741
742 ARCH_URI=""
743 ARCH_PATCH=""
744 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
745
746 for LOOP_ARCH in ${ALL_ARCH}
747 do
748 COMPAT_URI="${LOOP_ARCH}_URI"
749 COMPAT_URI="${!COMPAT_URI}"
750
751 [ -n "${COMPAT_URI}" ] && \
752 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
753
754 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
755 then
756 for i in ${COMPAT_URI}
757 do
758 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
759 done
760 fi
761 done
762}
763
764# sparc nastiness
765#==============================================================
766# This script generates the files in /usr/include/asm for sparc systems
767# during installation of sys-kernel/linux-headers.
768# Will no longer be needed when full 64 bit support is used on sparc64
769# systems.
770#
771# Shamefully ripped from Debian
772# ----------------------------------------------------------------------
773
774# Idea borrowed from RedHat's kernel package
775
776generate_sparc_asm() {
777 local name
778
779 cd $1 || die
780 mkdir asm
781
782 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
783 name="$(echo $h | tr a-z. A-Z_)"
784 # common header
785 echo "/* All asm/ files are generated and point to the corresponding
786 * file in asm-sparc or asm-sparc64.
787 */
788
789#ifndef __SPARCSTUB__${name}__
790#define __SPARCSTUB__${name}__
791" > asm/${h}
792
793 # common for sparc and sparc64
794 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
795 echo "#ifdef __arch64__
796#include <asm-sparc64/$h>
797#else
798#include <asm-sparc/$h>
799#endif
800" >> asm/${h}
801
802 # sparc only
803 elif [ -f asm-sparc/$h ]; then
804echo "#ifndef __arch64__
805#include <asm-sparc/$h>
806#endif
807" >> asm/${h}
808
809 # sparc64 only
810 else
811echo "#ifdef __arch64__
812#include <asm-sparc64/$h>
813#endif
814" >> asm/${h}
815 fi
816
817 # common footer
818 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
819 done
820 return 0
821}
822
823headers___fix() {
824 sed -i \
825 -e "s/\([ "$'\t'"]\)u8\([ "$'\t'"]\)/\1__u8\2/g;" \
826 -e "s/\([ "$'\t'"]\)u16\([ "$'\t'"]\)/\1__u16\2/g;" \
827 -e "s/\([ "$'\t'"]\)u32\([ "$'\t'"]\)/\1__u32\2/g;" \
828 -e "s/\([ "$'\t'"]\)u64\([ "$'\t'"]\)/\1__u64\2/g;" \
829 "$@"
830}
472 831
473# common functions 832# common functions
474#============================================================== 833#==============================================================
475src_unpack() { 834kernel-2_src_unpack() {
476 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 835 detect_version
836 universal_unpack
477 837
478 cd ${WORKDIR} 838 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
479 unpack linux-${OKV}.tar.bz2 839 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
480 if [ "${OKV}" != "${KV}" ] 840
481 then 841 [ -z "${K_NOSETEXTRAVERSION}" ] && \
482 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}." 842 unpack_set_extraversion
483 fi 843
844 kernel_is 2 4 && unpack_2_4
845}
846
847kernel-2_src_compile() {
848 detect_version
484 cd ${S} 849 cd ${S}
485
486 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST}
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491}
492
493src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 850 [ "${ETYPE}" == "headers" ] && compile_headers
851 [ "${ETYPE}" == "sources" ] && \
852 use doc && ! use arm && ! use s390 && compile_manpages
495} 853}
496 854
497pkg_preinst() { 855kernel-2_pkg_preinst() {
856 detect_version
498 [ "${ETYPE}" == "headers" ] && preinst_headers 857 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 858}
500 859
501src_install() { 860kernel-2_src_install() {
861 detect_version
502 install_universal 862 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 863 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 864 [ "${ETYPE}" == "sources" ] && install_sources
505} 865}
506 866
507pkg_postinst() { 867kernel-2_pkg_postinst() {
868 detect_version
508 [ "${ETYPE}" == "headers" ] && postinst_headers 869 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 870 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 871}
511 872
512pkg_setup() { 873kernel-2_pkg_setup() {
874 detect_version
513 [ "${ETYPE}" == "headers" ] && setup_headers 875 [ "${ETYPE}" == "headers" ] && setup_headers
876
877 # This is to fix some weird portage bug? in stable versions of portage.
878 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
514} 879}
880
881

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

  ViewVC Help
Powered by ViewVC 1.1.20