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

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

  ViewVC Help
Powered by ViewVC 1.1.20