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

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

  ViewVC Help
Powered by ViewVC 1.1.20