/[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.55
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.55 2004/11/26 15:06: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
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 50HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 51LICENSE="GPL-2"
33IUSE="${IUSE} build" 52IUSE="${IUSE} build doc"
34SLOT="${KV}" 53SLOT="${KV_FULL}"
35 54
55# Grab kernel version from KV_FULL
56KV_MAJOR=$(echo ${KV_FULL} | cut -d. -f1)
57KV_MINOR=$(echo ${KV_FULL} | cut -d. -f2)
58KV_PATCH=$(echo ${KV_FULL} | cut -d. -f3-)
59KV_PATCH=${KV_PATCH/[-_]*/}
60
61# set LINUX_HOSTCFLAGS if not already set
62[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
63
64#Eclass functions only from here onwards ...
65#==============================================================
66kernel_is() {
67 local RESULT
68 RESULT=1
69
70 if [ -n "${1}" ]
71 then
72 [ "${1}" = "${KV_MAJOR}" ] && RESULT=0
73 fi
74
75 if [ -n "${2}" ]
76 then
77 RESULT=1
78 [ "${2}" = "${KV_MINOR}" ] && RESULT=0
79 fi
80
81 if [ -n "${3}" ]
82 then
83 RESULT=1
84 [ "${3}" = "${KV_PATCH}" ] && RESULT=0
85 fi
86 return ${RESULT}
87}
88
89kernel_is_2_4() {
90 [ `kernel_is 2 4` ] && return 0 || return 1
91}
92
93kernel_is_2_6() {
94 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
95 return 0 || return 1
96}
97
36# capture the sources type and set depends 98# Capture the sources type and set DEPENDs
37if [ "${ETYPE}" == "sources" ] 99if [ "${ETYPE}" == "sources" ]
38then 100then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 101 # binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
40 DEPEND="!build? ( sys-apps/sed 102 DEPEND="!build? ( sys-apps/sed
41 >=sys-devel/binutils-2.11.90.0.31 )" 103 >=sys-devel/binutils-2.11.90.0.31 )
104 doc? ( !arm? ( !s390? ( app-text/docbook-sgml-utils ) ) )"
42 105
43 RDEPEND="${DEPEND} 106 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 107 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 108 dev-lang/perl
46 sys-apps/module-init-tools 109 sys-apps/module-init-tools
47 sys-devel/make )" 110 sys-devel/make )"
48 111
112 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" \
49 PROVIDE="virtual/linux-sources virtual/alsa" 113 || PROVIDE="virtual/linux-sources virtual/alsa"
50 114
51elif [ "${ETYPE}" == "headers" ] 115elif [ "${ETYPE}" == "headers" ]
52then 116then
53 PROVIDE="virtual/kernel virtual/os-headers" 117 PROVIDE="virtual/kernel virtual/os-headers"
54else 118else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 119 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
56 die 120 die
57fi 121fi
58
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 122
80# Unpack functions 123# Unpack functions
81#============================================================== 124#==============================================================
82unpack_2_4() { 125unpack_2_4() {
83 cd ${S} 126 cd ${S}
87 make include/linux/version.h || die "make include/linux/version.h failed" 130 make include/linux/version.h || die "make include/linux/version.h failed"
88 echo ">>> version.h compiled successfully." 131 echo ">>> version.h compiled successfully."
89} 132}
90 133
91universal_unpack() { 134universal_unpack() {
135 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
136
137 cd ${WORKDIR}
138 unpack linux-${OKV}.tar.bz2
139 if [ "${OKV}" != "${KV_FULL}" ]
140 then
141 mv linux-${OKV} linux-${KV_FULL} \
142 || die "Unable to move source tree to ${KV_FULL}."
143 fi
144 cd ${S}
145
146 # change incorrect install path
147 sed -ie 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
148
92 # remove all backup files 149 # remove all backup files
93 find . -iname "*~" -exec rm {} \; 2> /dev/null 150 find . -iname "*~" -exec rm {} \; 2> /dev/null
94 151
95 if [ -d "${S}/Documentation/DocBook" ] 152 if [ -d "${S}/Documentation/DocBook" ]
96 then 153 then
100 cd ${S} 157 cd ${S}
101 fi 158 fi
102} 159}
103 160
104unpack_set_extraversion() { 161unpack_set_extraversion() {
105 # Gentoo Linux uses /boot, so fix 'make install' to work properly and fix EXTRAVERSION
106 cd ${S} 162 cd ${S}
107 mv Makefile Makefile.orig
108 sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
109 -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \ 163 sed -ie "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
110 Makefile.orig > Makefile
111 rm Makefile.orig
112} 164}
113 165
114# Compile Functions 166# Compile Functions
115#============================================================== 167#==============================================================
116compile_headers() { 168compile_headers() {
121 yes "" | make oldconfig 173 yes "" | make oldconfig
122 echo ">>> make oldconfig complete" 174 echo ">>> make oldconfig complete"
123 ARCH=${MY_ARCH} 175 ARCH=${MY_ARCH}
124} 176}
125 177
178compile_manpages() {
179 local MY_ARCH
180
181 einfo "Making manpages ..."
182 MY_ARCH=${ARCH}
183 unset ARCH
184 make mandocs
185 ARCH=${MY_ARCH}
186}
187
126# install functions 188# install functions
127#============================================================== 189#==============================================================
128install_universal() { 190install_universal() {
129 #fix silly permissions in tarball 191 #fix silly permissions in tarball
130 cd ${WORKDIR} 192 cd ${WORKDIR}
132 chmod -R a+r-w+X,u+w * 194 chmod -R a+r-w+X,u+w *
133} 195}
134 196
135install_headers() { 197install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 198 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 199
138
139 cd ${S} 200 cd ${S}
140 dodir /usr/include/linux 201 dodir /usr/include/linux
202 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 203 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
142 rm -rf ${D}/usr/include/linux/modules 204 rm -rf ${D}/usr/include/linux/modules
205
143 dodir /usr/include/asm 206 dodir /usr/include/asm
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 207 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145 208
146 if [ $(kernel_is_2_6) $? == 0 ] 209 if [ $(kernel_is_2_6) $? == 0 ]
147 then 210 then
151} 214}
152 215
153install_sources() { 216install_sources() {
154 local doc 217 local doc
155 local docs 218 local docs
219 local file
156 220
157 cd ${S} 221 cd ${S}
158 dodir /usr/src 222 dodir /usr/src
159 echo ">>> Copying sources..." 223 echo ">>> Copying sources ..."
160 if [ -d "${WORKDIR}/${KV}/docs/" ] 224 file="$(find ${WORKDIR} -iname "docs" -type d)"
225 if [ -n "${file}" ]
161 then 226 then
162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 227 for file in $(find ${file} -type f)
163 do 228 do
164 echo "XX_${file}*" >> ${S}/patches.txt 229 echo "${file/*docs\//}" >> ${S}/patches.txt
230 echo "===================================================" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt 231 cat ${file} >> ${S}/patches.txt
232 echo "===================================================" >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt 233 echo "" >> ${S}/patches.txt
167 done 234 done
168 fi 235 fi
169 236
170 if [ ! -f ${S}/patches.txt ] 237 if [ ! -f ${S}/patches.txt ]
179 done 246 done
180 247
181 if [ -f ${S}/patches.txt ]; then 248 if [ -f ${S}/patches.txt ]; then
182 docs="${docs} ${S}/patches.txt" 249 docs="${docs} ${S}/patches.txt"
183 fi 250 fi
251
252 if use doc && ! use arm && ! use s390; then
253 install_manpages
254 fi
255
184 dodoc ${docs} 256 dodoc ${docs}
185 mv ${WORKDIR}/linux* ${D}/usr/src 257 mv ${WORKDIR}/linux* ${D}/usr/src
258}
259
260install_manpages() {
261 local MY_ARCH
262
263 ebegin "Installing manpages"
264 MY_ARCH=${ARCH}
265 unset ARCH
266 sed -ie "s#/usr/local/man#${D}/usr/man#g" scripts/makeman
267 make installmandocs
268 eend $?
269 sed -ie "s#${D}/usr/man#/usr/local/man#g" scripts/makeman
270 ARCH=${MY_ARCH}
186} 271}
187 272
188# pkg_preinst functions 273# pkg_preinst functions
189#============================================================== 274#==============================================================
190preinst_headers() { 275preinst_headers() {
195# pkg_postinst functions 280# pkg_postinst functions
196#============================================================== 281#==============================================================
197postinst_sources() { 282postinst_sources() {
198 if [ ! -h ${ROOT}usr/src/linux ] 283 if [ ! -h ${ROOT}usr/src/linux ]
199 then 284 then
200 ln -sf ${ROOT}usr/src/linux-${KV} ${ROOT}usr/src/linux 285 ln -sf ${ROOT}usr/src/linux-${KV_FULL} ${ROOT}usr/src/linux
201 fi 286 fi
202 287
203 # Don't forget to make directory for sysfs 288 # Don't forget to make directory for sysfs
204 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys 289 [ ! -d "${ROOT}/sys" -a $(kernel_is_2_6) $? == 0 ] && mkdir /sys
205 290
219 while read -s ELINE 304 while read -s ELINE
220 do 305 do
221 einfo "${ELINE}" 306 einfo "${ELINE}"
222 done 307 done
223 308
309 echo
310 fi
311
312 # Show policy version, if this kernel has SELinux ...
313 local secfile
314 secfile="${ROOT}usr/src/linux-${KV_FULL}/security/selinux/include/security.h"
315 if use selinux && [ -f "$secfile" ]
316 then
317 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
318 einfo "The SELinux policy version of this kernel is $polver."
224 echo 319 echo
225 fi 320 fi
226 321
227 # if K_EXTRAEWARN is set then lets display it now 322 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 323 if [ -n "${K_EXTRAEWARN}" ]
249} 344}
250 345
251# pkg_setup functions 346# pkg_setup functions
252#============================================================== 347#==============================================================
253setup_headers() { 348setup_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/) 349 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ \
350 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
255 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64" 351 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
256 352
257 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}" 353 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
258 for i in ${H_SUPPORTEDARCH} 354 for i in ${H_SUPPORTEDARCH}
259 do 355 do
275unipatch() { 371unipatch() {
276 local i 372 local i
277 local x 373 local x
278 local extention 374 local extention
279 local PIPE_CMD 375 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 376 local UNIPATCH_DROP
281 local KPATCH_DIR 377 local KPATCH_DIR
282 local PATCH_DEPTH 378 local PATCH_DEPTH
283 local ELINE 379 local ELINE
380 local STRICT_COUNT
381 local PATCH_LEVEL
284 382
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 383 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 384 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 385
386 # We're gonna need it when doing patches with a predefined patchlevel
387 shopt -s extglob
388
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 389 # 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 390 # usage can be either via an env var or by params
391 # although due to the nature we pass this within this eclass
392 # it shall be by param only.
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 393 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
394 UNIPATCH_LIST="${@}"
291 395
292 #unpack any passed tarballs 396 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 397 for i in ${UNIPATCH_LIST}
294 do 398 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 399 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
296 then 400 then
297 extention=${i/*./} 401 extention=${i/*./}
402 extention=${extention/:*/}
298 case ${extention} in 403 case ${extention} in
299 tbz2) PIPE_CMD="tar -xvjf";; 404 tbz2) PIPE_CMD="tar -xvjf";;
300 bz2) PIPE_CMD="tar -xvjf";; 405 bz2) PIPE_CMD="tar -xvjf";;
301 tgz) PIPE_CMD="tar -xvzf";; 406 tgz) PIPE_CMD="tar -xvzf";;
302 gz) PIPE_CMD="tar -xvzf";; 407 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 408 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 409 die "Unrecognized tarball compression";;
305 esac 410 esac
306 411
412 if [ -n "${UNIPATCH_STRICTORDER}" ]
413 then
414 STRICT_COUNT=$((${STRICT_COUNT} + 1))
415 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
416 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
417 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 418 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
419 fi
420
308 if [ $? == 0 ] 421 if [ $? == 0 ]
309 then 422 then
310 einfo "${i/*\//} unpacked" 423 einfo "${i/*\//} unpacked"
424 [ -n "$(echo ${i} | grep ':')" ] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
311 else 425 else
312 eerror "Failed to unpack ${i}" 426 eerror "Failed to unpack ${i/:*/}"
313 die "unable to unpack patch tarball" 427 die "unable to unpack patch tarball"
314 fi 428 fi
429 else
430 extention=${i/*./}
431 extention=${extention/:*/}
432 PIPE_CMD=""
433 case ${extention} in
434 bz2) PIPE_CMD="bzip2 -dc";;
435 patch) PIPE_CMD="cat";;
436 diff) PIPE_CMD="cat";;
437 gz|Z|z) PIPE_CMD="gzip -dc";;
438 ZIP|zip) PIPE_CMD="unzip -p";;
439 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
440 esac
315 441
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 442 PATCH_LEVEL=${i/*([^:])?(:)}
443 i=${i/:*/}
444 x=${i/*\//}
445 x=${x/\.${extention}/}
446
447 if [ -n "${PIPE_CMD}" ]
448 then
449 if [ ! -r "${i}" ]
450 then
451 echo
452 eerror "FATAL: unable to locate:"
453 eerror "${i}"
454 eerror "for read-only. The file either has incorrect permissions"
455 eerror "or does not exist."
456 die Unable to locate ${i}
457 fi
458
459 if [ -n "${UNIPATCH_STRICTORDER}" ]
460 then
461 STRICT_COUNT=$((${STRICT_COUNT} + 1))
462 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
463 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
464 else
465 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
466 fi
467 fi
317 fi 468 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 469 done
337 470
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 471 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 472 x=${KPATCH_DIR}
340 KPATCH_DIR="" 473 KPATCH_DIR=""
474 LC_ALL="C"
341 for i in $(find ${x} -type d) 475 for i in $(find ${x} -type d | sort -n)
342 do 476 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 477 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 478 done
345 479
346 #so now lets get rid of the patchno's we want to exclude 480 #so now lets get rid of the patchno's we want to exclude
481 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 482 for i in ${UNIPATCH_DROP}
348 do 483 do
484 ebegin "Excluding Patch #${i}"
349 for x in ${KPATCH_DIR} 485 for x in ${KPATCH_DIR}
350 do 486 do
351 rm ${x}/${i}_* 2>/dev/null 487 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 488 done
489 eend $?
358 done 490 done
359 491
360 # and now, finally, we patch it :) 492 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 493 for x in ${KPATCH_DIR}
362 do 494 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 495 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
364 do 496 do
497 STDERR_T="${T}/${i/*\//}"
498 STDERR_T="${STDERR_T/.patch*/.err}"
365 499
500 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
501 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
366 502
503 if [ -z "${PATCH_DEPTH}" ]; then
367 PATCH_DEPTH=0 504 PATCH_DEPTH=0
505 fi
506
368 ebegin "Applying ${i/*\//}" 507 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
369 while [ ${PATCH_DEPTH} -lt 5 ] 508 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 509 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 510 echo "Attempting Dry-run:" >> ${STDERR_T}
511 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
512 echo "=======================================================" >> ${STDERR_T}
513 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 514 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 515 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 516 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
517 echo "=======================================================" >> ${STDERR_T}
518 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 519 then
376 eend 0 520 eend 0
521 rm ${STDERR_T}
377 break 522 break
378 else 523 else
379 eend 1 524 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 525 eerror "Failed to apply patch ${i/*\//}"
526 eerror "Please attach ${STDERR_T} to any bug you may post."
381 die "Failed to apply ${i/*\//}" 527 die "Failed to apply ${i/*\//}"
382 fi 528 fi
383 else 529 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 530 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 531 fi
386 done 532 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 533 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 534 then
389 eend 1 535 eend 1
536 eerror "Please attach ${STDERR_T} to any bug you may post."
390 die "Unable to dry-run patch." 537 die "Unable to dry-run patch."
391 fi 538 fi
392
393
394 done 539 done
395 done 540 done
541
542 # clean up KPATCH_DIR's - fixes bug #53610
543 for x in ${KPATCH_DIR}
544 do
545 rm -Rf ${x}
546 done
547 unset LC_ALL
396} 548}
397 549
398# custom functions 550# custom functions
399#============================================================== 551#==============================================================
400detect_version() { 552detect_version() {
401 # this function will detect and set 553 # this function will detect and set
402 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 554 # - 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) 555 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
404 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 556 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
405 557
558 if [ -n "${KV_FULL}" ] ;
559 then
560 # we will set this for backwards compatibility.
561 KV=${KV_FULL}
562
563 # we know KV_FULL so lets stop here. but not without resetting S
564 S=${WORKDIR}/linux-${KV_FULL}
565 return
566 fi
567
406 OKV=${PV/_beta/-test} 568 OKV=${PV/_beta/-test}
407 OKV=${OKV/_rc/-rc} 569 OKV=${OKV/_rc/-rc}
408 OKV=${OKV/_pre*/} 570 OKV=${OKV/_pre*/}
409 OKV=${OKV/-r*/} 571 OKV=${OKV/-r*/}
410 572
411 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 573 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
412 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 574 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
413 KV_PATCH=$(echo ${OKV} | cut -d. -f3) 575 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
414 KV_PATCH=${KV_PATCH/[-_]*/} 576 KV_PATCH=${KV_PATCH/[-_]*/}
415 577
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 578 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 579
418 RELEASE=${PV/${OKV}/} 580 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 581 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 582 RELEASE=${RELEASE/_rc/-rc}
583 if [ $(kernel_is_2_4) $? == 0 ]
584 then
585 RELEASE=${RELEASE/_pre/-pre}
586 else
421 RELEASE=${RELEASE/_pre/-bk} 587 RELEASE=${RELEASE/_pre/-bk}
588 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 589 RELEASETYPE=${RELEASE//[0-9]/}
423
424 EXTRAVERSION="${RELEASE}" 590 EXTRAVERSION="${RELEASE}"
425 591
426 if [ -n "${K_PREPATCHED}" ] 592 if [ -n "${K_PREPATCHED}" ]
427 then 593 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 594 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 595 else
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 596 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 597 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432 598 fi
599
433 KV=${OKV}${EXTRAVERSION} 600 KV_FULL=${OKV}${EXTRAVERSION}
434 fi
435 601
436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 602 # -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 603 # these cannot be supported, but the code here can handle it up until this point
438 # and theoretically thereafter. 604 # and theoretically thereafter.
439 605
440 if [ "${RELEASETYPE}" == "-rc" ] 606 if [ "${RELEASETYPE}" == "-rc" -o "${RELEASETYPE}" == "-pre" ]
441 then 607 then
442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 608 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 609 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" 610 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 611 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${PV//_/-}.bz2"
446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION} 612 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
447 fi 613 fi
448 614
449 if [ "${RELEASETYPE}" == "-bk" ] 615 if [ "${RELEASETYPE}" == "-bk" ]
450 then 616 then
451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 617 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 618 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" 619 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}" 620 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} 621 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
456 fi 622 fi
457 623
458 if [ "${RELEASETYPE}" == "-rc-bk" ] 624 if [ "${RELEASETYPE}" == "-rc-bk" ]
459 then 625 then
460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 626 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})" 627 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
462 628
463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 629 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" 630 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}" 631 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} 632 KV_FULL=${PV/[-_]*/}${EXTRAVERSION}
467 fi 633 fi
468 634
469 S=${WORKDIR}/linux-${KV} 635 S=${WORKDIR}/linux-${KV_FULL}
636 # we will set this for backwards compatibility.
637 KV=${KV_FULL}
638}
639
640detect_arch() {
641 # This function sets ARCH_URI and ARCH_PATCH
642 # with the neccessary info for the arch sepecific compatibility
643 # patchsets.
644
645 local ALL_ARCH
646 local LOOP_ARCH
647 local COMPAT_URI
648 local i
649
650 # COMPAT_URI is the contents of ${ARCH}_URI
651 # ARCH_URI is the URI for all the ${ARCH}_URI patches
652 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
653
654 ARCH_URI=""
655 ARCH_PATCH=""
656 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
657
658 for LOOP_ARCH in ${ALL_ARCH}
659 do
660 COMPAT_URI="${LOOP_ARCH}_URI"
661 COMPAT_URI="${!COMPAT_URI}"
662
663 [ -n "${COMPAT_URI}" ] && \
664 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
665
666 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')" ]
667 then
668 for i in ${COMPAT_URI}
669 do
670 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
671 done
672 fi
673 done
470} 674}
471 675
472 676
473# common functions 677# common functions
474#============================================================== 678#==============================================================
475src_unpack() { 679kernel-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 680 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST} 681 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST}"
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 682 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 683 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491} 684}
492 685
493src_compile() { 686kernel-2_src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 687 [ "${ETYPE}" == "headers" ] && compile_headers
688 [ "${ETYPE}" == "sources" ] && \
689 use doc && ! use arm && ! use s390 && compile_manpages
495} 690}
496 691
497pkg_preinst() { 692kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 693 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 694}
500 695
501src_install() { 696kernel-2_src_install() {
502 install_universal 697 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 698 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 699 [ "${ETYPE}" == "sources" ] && install_sources
505} 700}
506 701
507pkg_postinst() { 702kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 703 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 704 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 705}
511 706
512pkg_setup() { 707kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 708 [ "${ETYPE}" == "headers" ] && setup_headers
709
710 # This is to fix some weird portage bug? in stable versions of portage.
711 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack ..."
514} 712}
713
714

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

  ViewVC Help
Powered by ViewVC 1.1.20