/[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.51
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.51 2004/11/26 01:47:42 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() {
222 done 323 done
223 324
224 echo 325 echo
225 fi 326 fi
226 327
328 # Show policy version, if this kernel has SELinux...
329 local secfile
330 secfile="${ROOT}usr/src/linux-${KV}/security/selinux/include/security.h"
331 if use selinux && [ -f "$secfile" ]
332 then
333 local polver=$(awk '/POLICYDB_VERSION /{print $3}' $secfile)
334 einfo "The SELinux policy version of this kernel is $polver."
335 echo
336 fi
337
227 # if K_EXTRAEWARN is set then lets display it now 338 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ] 339 if [ -n "${K_EXTRAEWARN}" ]
229 then 340 then
230 echo ${K_EXTRAEWARN} | fmt | 341 echo ${K_EXTRAEWARN} | fmt |
231 while read -s ELINE 342 while read -s ELINE
242 einfo "Kernel headers are usually only used when recompiling glibc." 353 einfo "Kernel headers are usually only used when recompiling glibc."
243 einfo "Following the installation of newer headers it is advised that" 354 einfo "Following the installation of newer headers it is advised that"
244 einfo "you re-merge glibc as follows:" 355 einfo "you re-merge glibc as follows:"
245 einfo "# emerge glibc" 356 einfo "# emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer" 357 einfo "Failure to do so will cause glibc to not make use of newer"
247 einfo "features present in the updated kernelheaders." 358 einfo "features present in the updated kernel headers."
248 echo 359 echo
249} 360}
250 361
251# pkg_setup functions 362# pkg_setup functions
252#============================================================== 363#==============================================================
253setup_headers() { 364setup_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/) 365 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ \
366 -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ \
367 -e s/amd64/x86_64/)
255 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64" 368 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
256 369
257 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}" 370 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
258 for i in ${H_SUPPORTEDARCH} 371 for i in ${H_SUPPORTEDARCH}
259 do 372 do
275unipatch() { 388unipatch() {
276 local i 389 local i
277 local x 390 local x
278 local extention 391 local extention
279 local PIPE_CMD 392 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 393 local UNIPATCH_DROP
281 local KPATCH_DIR 394 local KPATCH_DIR
282 local PATCH_DEPTH 395 local PATCH_DEPTH
283 local ELINE 396 local ELINE
397 local STRICT_COUNT
398 local PATCH_LEVEL
284 399
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 400 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 401 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 402
403 # We're gonna need it when doing patches with a predefined patchlevel
404 shopt -s extglob
405
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 406 # This function will unpack all passed tarballs, add any passed patches,
407 # and remove any passed patchnumbers
289 # usage can be either via an env var or by params 408 # usage can be either via an env var or by params
290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 409 [ -n "${@}" ] && UNIPATCH_LIST="${@} ${UNIPATCH_LIST}"
291 410
292 #unpack any passed tarballs 411 #unpack any passed tarballs
293 for i in ${UNIPATCH_LIST} 412 for i in ${UNIPATCH_LIST}
294 do 413 do
295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ] 414 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
296 then 415 then
297 extention=${i/*./} 416 extention=${i/*./}
417 extention=${extention/:*/}
298 case ${extention} in 418 case ${extention} in
299 tbz2) PIPE_CMD="tar -xvjf";; 419 tbz2) PIPE_CMD="tar -xvjf";;
300 bz2) PIPE_CMD="tar -xvjf";; 420 bz2) PIPE_CMD="tar -xvjf";;
301 tgz) PIPE_CMD="tar -xvzf";; 421 tgz) PIPE_CMD="tar -xvzf";;
302 gz) PIPE_CMD="tar -xvzf";; 422 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 423 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 424 die "Unrecognized tarball compression";;
305 esac 425 esac
306 426
427 if [ -n "${UNIPATCH_STRICTORDER}" ]
428 then
429 STRICT_COUNT=$((${STRICT_COUNT} + 1))
430 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
431 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR}/${STRICT_COUNT}/ \
432 1>/dev/null
433 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 434 ${PIPE_CMD} ${i/:*/} -C ${KPATCH_DIR} 1>/dev/null
435 fi
436
308 if [ $? == 0 ] 437 if [ $? == 0 ]
309 then 438 then
310 einfo "${i/*\//} unpacked" 439 einfo "${i/*\//} unpacked"
440 [ -n "$(echo ${i} | grep ':')" ] && \
441 echo ">>> Strict patch levels not currently supported for tarballed patchsets"
311 else 442 else
312 eerror "Failed to unpack ${i}" 443 eerror "Failed to unpack ${i/:*/}"
313 die "unable to unpack patch tarball" 444 die "unable to unpack patch tarball"
314 fi 445 fi
446 else
447 extention=${i/*./}
448 extention=${extention/:*/}
449 PIPE_CMD=""
450 case ${extention} in
451 bz2) PIPE_CMD="bzip2 -dc";;
452 patch) PIPE_CMD="cat";;
453 diff) PIPE_CMD="cat";;
454 gz|Z|z) PIPE_CMD="gzip -dc";;
455 ZIP|zip) PIPE_CMD="unzip -p";;
456 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
457 esac
315 458
316 UNIPATCH_LIST="${UNIPATCH_LIST/${i}/}" 459 PATCH_LEVEL=${i/*([^:])?(:)}
460 i=${i/:*/}
461 x=${i/*\//}
462 x=${x/\.${extention}/}
463
464 if [ -n "${PIPE_CMD}" ]
465 then
466 if [ ! -r "${i}" ]
467 then
468 echo
469 eerror "FATAL: unable to locate:"
470 eerror "${i}"
471 eerror "for read-only. The file either has incorrect"
472 eerror "permissions or does not exist."
473 die Unable to locate ${i}
474 fi
475
476 if [ -n "${UNIPATCH_STRICTORDER}" ]
477 then
478 STRICT_COUNT=$((${STRICT_COUNT} + 1))
479 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
480 $(${PIPE_CMD} ${i} > \
481 ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch${PATCH_LEVEL})
482 else
483 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
484 fi
485 fi
317 fi 486 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 487 done
337 488
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 489 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 490 x=${KPATCH_DIR}
340 KPATCH_DIR="" 491 KPATCH_DIR=""
492 LC_ALL="C"
341 for i in $(find ${x} -type d) 493 for i in $(find ${x} -type d | sort -n)
342 do 494 do
343 KPATCH_DIR="${KPATCH_DIR} ${i}" 495 KPATCH_DIR="${KPATCH_DIR} ${i}"
344 done 496 done
345 497
346 #so now lets get rid of the patchno's we want to exclude 498 #so now lets get rid of the patchno's we want to exclude
499 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
347 for i in ${UNIPATCH_EXCLUDE} 500 for i in ${UNIPATCH_DROP}
348 do 501 do
502 einfo "Excluding Patch #${i}"
349 for x in ${KPATCH_DIR} 503 for x in ${KPATCH_DIR}
350 do 504 do
351 rm ${x}/${i}_* 2>/dev/null 505 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 506 done
358 done 507 done
359 508
360 # and now, finally, we patch it :) 509 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 510 for x in ${KPATCH_DIR}
362 do 511 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 512 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n)
364 do 513 do
514 unset PATCH_DEPTH
515
516 STDERR_T="${T}/${i/*\//}"
517 STDERR_T="${STDERR_T/.patch*/.err}"
518 STDERR_T="${STDERR_T/.diff*/.err}"
365 519
520 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
521 [ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
366 522
523 if [ -z "${PATCH_DEPTH}" ]; then
367 PATCH_DEPTH=0 524 PATCH_DEPTH=0
525 fi
526
368 ebegin "Applying ${i/*\//}" 527 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
369 while [ ${PATCH_DEPTH} -lt 5 ] 528 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 529 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 530 echo "Attempting Dry-run:" >> ${STDERR_T}
531 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T}
532 echo "==========================================" >> ${STDERR_T}
533 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]
372 then 534 then
373 $(patch -p${PATCH_DEPTH} -f < ${i} >/dev/null) 535 echo "Attempting patch:" > ${STDERR_T}
374 if [ "$?" -eq 0 ] 536 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T}
537 echo "======================================" >> ${STDERR_T}
538 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]
375 then 539 then
376 eend 0 540 eend 0
541 rm ${STDERR_T}
377 break 542 break
378 else 543 else
379 eend 1 544 eend 1
380 eerror "Failed to apply patch ${i/*\//}" 545 eerror "Failed to apply patch ${i/*\//}"
546 eerror "Please attach ${STDERR_T} to any bug you post."
381 die "Failed to apply ${i/*\//}" 547 die "Failed to apply ${i/*\//}"
382 fi 548 fi
383 else 549 else
384 PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) 550 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
385 fi 551 fi
386 done 552 done
387 if [ ${PATCH_DEPTH} -eq 5 ] 553 if [ ${PATCH_DEPTH} -eq 5 ]
388 then 554 then
389 eend 1 555 eend 1
556 eerror "Please attach ${STDERR_T} to any bug you post."
390 die "Unable to dry-run patch." 557 die "Unable to dry-run patch."
391 fi 558 fi
392
393
394 done 559 done
395 done 560 done
561
562 # clean up KPATCH_DIR's - fixes bug #53610
563 for x in ${KPATCH_DIR}
564 do
565 rm -Rf ${x}
566 done
567 unset LC_ALL
396} 568}
397 569
398# custom functions 570# custom functions
399#============================================================== 571#==============================================================
400detect_version() { 572detect_version() {
401 # this function will detect and set 573 # this function will detect and set
402 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11) 574 # 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) 575 # KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
404 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1) 576 # EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
405 577
578 [ -n "${DETECTED}" ] && return
579
580 if [ -z "${OKV}" ];
581 then
406 OKV=${PV/_beta/-test} 582 OKV=${PV/_beta/-test}
407 OKV=${OKV/_rc/-rc} 583 OKV=${OKV/_rc/-rc}
408 OKV=${OKV/_pre*/} 584 OKV=${OKV/_pre*/}
409 OKV=${OKV/-r*/} 585 OKV=${OKV/-r*/}
586 fi
410 587
411 KV_MAJOR=$(echo ${OKV} | cut -d. -f1) 588 KV_MAJOR=$(echo ${OKV} | cut -d. -f1)
412 KV_MINOR=$(echo ${OKV} | cut -d. -f2) 589 KV_MINOR=$(echo ${OKV} | cut -d. -f2)
413 KV_PATCH=$(echo ${OKV} | cut -d. -f3) 590 KV_PATCH=$(echo ${OKV} | cut -d. -f3-)
414 KV_PATCH=${KV_PATCH/[-_]*/} 591 KV_PATCH=${KV_PATCH/[-_]*/}
415 592
416 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 593 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
417 594
418 RELEASE=${PV/${OKV}/} 595 RELEASE=${PV/${OKV}/}
419 RELEASE=${RELEASE/_beta/} 596 RELEASE=${RELEASE/_beta/}
420 RELEASE=${RELEASE/_rc/-rc} 597 RELEASE=${RELEASE/_rc/-rc}
598 if [ $(kernel_is_2_4) $? == 0 ]
599 then
600 RELEASE=${RELEASE/_pre/-pre}
601 else
421 RELEASE=${RELEASE/_pre/-bk} 602 RELEASE=${RELEASE/_pre/-bk}
603 fi
422 RELEASETYPE=${RELEASE//[0-9]/} 604 RELEASETYPE=${RELEASE//[0-9]/}
423
424 EXTRAVERSION="${RELEASE}" 605 EXTRAVERSION="${RELEASE}"
425 606
426 if [ -n "${K_PREPATCHED}" ] 607 if [ -n "${K_PREPATCHED}" ]
427 then 608 then
428 KV="${OKV}-${PN/-*/}${PR/r/}" 609 EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}${PR/r/}"
429 else 610 else
430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 611 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
612 [ "${PN/-*/}" == "wolk" ] && EXTRAVERSION="-${PN/-*/}-${PV}"
431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 613 [ "${PR}" != "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
432
433 KV=${OKV}${EXTRAVERSION}
434 fi 614 fi
435 615
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}
651 DETECTED="yes"
652}
653
654detect_arch() {
655 # This function sets ARCH_URI and ARCH_PATCH
656 # with the neccessary info for the arch sepecific compatibility
657 # patchsets.
658
659 local ALL_ARCH
660 local LOOP_ARCH
661 local COMPAT_URI
662 local i
663
664 # COMPAT_URI is the contents of ${ARCH}_URI
665 # ARCH_URI is the URI for all the ${ARCH}_URI patches
666 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
667
668 ARCH_URI=""
669 ARCH_PATCH=""
670 ALL_ARCH="X86 PPC PPC64 SPARC MIPS ALPHA ARM HPPA AMD64 IA64 X86OBSD S390"
671
672 for LOOP_ARCH in ${ALL_ARCH}
673 do
674 COMPAT_URI="${LOOP_ARCH}_URI"
675 COMPAT_URI="${!COMPAT_URI}"
676
677 [ -n "${COMPAT_URI}" ] && \
678 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr [A-Z] [a-z])? ( ${COMPAT_URI} )"
679
680 if [ "${LOOP_ARCH}" == "$(echo ${ARCH} | tr [a-z] [A-Z])" ]
681 then
682 for i in ${COMPAT_URI}
683 do
684 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
685 done
686 fi
687 done
470} 688}
471 689
472 690
473# common functions 691# common functions
474#============================================================== 692#==============================================================
475src_unpack() { 693kernel-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 694 universal_unpack
487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST} 695 [ -n "${UNIPATCH_LIST}" -o -n "${UNIPATCH_LIST_DEFAULT}" ] && \
696 unipatch "${UNIPATCH_LIST_DEFAULT}"
488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 697 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
489
490 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 698 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
491} 699}
492 700
493src_compile() { 701kernel-2_src_compile() {
494 [ "${ETYPE}" == "headers" ] && compile_headers 702 [ "${ETYPE}" == "headers" ] && compile_headers
703 [ "${ETYPE}" == "sources" ] && \
704 use doc && ! use arm && ! use s390 && compile_manpages
495} 705}
496 706
497pkg_preinst() { 707kernel-2_pkg_preinst() {
498 [ "${ETYPE}" == "headers" ] && preinst_headers 708 [ "${ETYPE}" == "headers" ] && preinst_headers
499} 709}
500 710
501src_install() { 711kernel-2_src_install() {
502 install_universal 712 install_universal
503 [ "${ETYPE}" == "headers" ] && install_headers 713 [ "${ETYPE}" == "headers" ] && install_headers
504 [ "${ETYPE}" == "sources" ] && install_sources 714 [ "${ETYPE}" == "sources" ] && install_sources
505} 715}
506 716
507pkg_postinst() { 717kernel-2_pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers 718 [ "${ETYPE}" == "headers" ] && postinst_headers
509 [ "${ETYPE}" == "sources" ] && postinst_sources 719 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 720}
511 721
512pkg_setup() { 722kernel-2_pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 723 [ "${ETYPE}" == "headers" ] && setup_headers
724
725 # This is to fix some weird portage bug? in stable versions of portage.
726 if [ "${ETYPE}" == "sources" ] ;
727 then
728 [ -z "${K_NODETECTVER}" ] && detect_version
729 detect_arch
730 fi
514} 731}

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

  ViewVC Help
Powered by ViewVC 1.1.20