/[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.2 Revision 1.12
1# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel 1# kernel.eclass rewrite for a clean base regarding the 2.6 series of kernel
2# with back-compatibility for 2.4 2# with back-compatibility for 2.4
3#
4# Author: John Mylchreest <johnm@gentoo.org>
5# Copyright 2004 Gentoo Linux
6#
7# Please direct your bugs to the current eclass maintainer :)
8# thatll be: johnm
3 9
4# added functionality: 10# added functionality:
5# unipatch - a flexible, singular method to extract, add and remove patches. 11# unipatch - a flexible, singular method to extract, add and remove patches.
6 12
7# A Couple of env vars are available to effect usage of this eclass 13# A Couple of env vars are available to effect usage of this eclass
8# These are as follows: 14# These are as follows:
9# 15#
10# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile
11# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION 17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION
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
19# - and not use it as a true package revision
12# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages 20# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages
21# 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
24
13# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
14# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
15 27
16ECLASS="kernel-2" 28ECLASS="kernel-2"
17EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
29 >=sys-devel/binutils-2.11.90.0.31 )" 41 >=sys-devel/binutils-2.11.90.0.31 )"
30 42
31 RDEPEND="${DEPEND} 43 RDEPEND="${DEPEND}
32 !build? ( >=sys-libs/ncurses-5.2 44 !build? ( >=sys-libs/ncurses-5.2
33 dev-lang/perl 45 dev-lang/perl
34 virtual/modutils 46 sys-apps/module-init-tools
35 sys-devel/make )" 47 sys-devel/make )"
36 48
37 PROVIDE="virtual/linux-sources virtual/alsa" 49 PROVIDE="virtual/linux-sources virtual/alsa"
38 50
39elif [ "${ETYPE}" == "headers" ] 51elif [ "${ETYPE}" == "headers" ]
40then 52then
41 PROVIDE="virtual/kernel virtual/os-headers" 53 PROVIDE="virtual/kernel virtual/os-headers"
120 chmod -R a+r-w+X,u+w * 132 chmod -R a+r-w+X,u+w *
121} 133}
122 134
123install_headers() { 135install_headers() {
124 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
125 138
126 cd ${S} 139 cd ${S}
127 dodir /usr/include/linux 140 dodir /usr/include/linux
128 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
129 rm -rf ${D}/usr/include/linux/modules 142 rm -rf ${D}/usr/include/linux/modules
130 dodir /usr/include/asm 143 dodir /usr/include/asm
131 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145
146 if [ $(kernel_is_2_6) $? == 0 ]
147 then
148 dodir /usr/include/asm-generic
149 cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic
150 fi
132} 151}
133 152
134install_sources() { 153install_sources() {
135 local doc 154 local doc
136 local docs 155 local docs
137 156
138 cd ${S} 157 cd ${S}
139 dodir /usr/src 158 dodir /usr/src
140 echo ">>> Copying sources..." 159 echo ">>> Copying sources..."
141 if [ -d "${WORKDIR}/${KV}/docs/" ] 160 if [ -d "${WORKDIR}/${KV}/docs/" ]
142 then 161 then
143 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/)
144 do
145 echo "XX_${file}*" >> ${S}/patches.txt
146 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt
147 echo "" >> ${S}/patches.txt
148 done
149 fi
150
151 if [ ! -f ${S}/patches.txt ]
152 then
153 # patches.txt is empty so lets use our ChangeLog
154 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
155 fi
156
157 for doc in ${UNIPATCH_DOCS}
158 do 163 do
159 [ -f ${doc} ] && docs="${docs} ${doc}" 164 echo "XX_${file}*" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt
160 done 167 done
168 fi
161 169
170 if [ ! -f ${S}/patches.txt ]
171 then
172 # 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
174 fi
175
176 for doc in ${UNIPATCH_DOCS}
177 do
178 [ -f ${doc} ] && docs="${docs} ${doc}"
179 done
180
162 if [ -f ${S}/patches.txt ]; then 181 if [ -f ${S}/patches.txt ]; then
163 docs="${docs} ${S}/patches.txt" 182 docs="${docs} ${S}/patches.txt"
164 fi 183 fi
165 dodoc ${docs} 184 dodoc ${docs}
166 mv ${WORKDIR}/linux* ${D}/usr/src 185 mv ${WORKDIR}/linux* ${D}/usr/src
167} 186}
168 187
169# pkg_preinst functions 188# pkg_preinst functions
170#============================================================== 189#==============================================================
171preinst_headers() { 190preinst_headers() {
172 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux 191 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux
173 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm 192 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm
174} 193}
175 194
176# pkg_postinst functions 195# pkg_postinst functions
177#============================================================== 196#==============================================================
178postinst_sources() { 197postinst_sources() {
199 echo ${K_EXTRAEINFO} | fmt | 218 echo ${K_EXTRAEINFO} | fmt |
200 while read -s ELINE 219 while read -s ELINE
201 do 220 do
202 einfo "${ELINE}" 221 einfo "${ELINE}"
203 done 222 done
223
224 echo
225 fi
226
227 # if K_EXTRAEWARN is set then lets display it now
228 if [ -n "${K_EXTRAEWARN}" ]
229 then
230 echo ${K_EXTRAEWARN} | fmt |
231 while read -s ELINE
232 do
233 ewarn "${ELINE}"
234 done
235
236 echo
237 fi
238}
239
240postinst_headers() {
241 echo
242 einfo "Kernel headers are usually only used when recompiling glibc."
243 einfo "Following the installation of newer headers it is advised that"
244 einfo "you re-merge glibc as follows:"
245 einfo "# emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer"
247 einfo "features present in the updated kernelheaders."
248 echo
249}
250
251# pkg_setup functions
252#==============================================================
253setup_headers() {
254 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
255 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
256
257 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
258 for i in ${H_SUPPORTEDARCH}
259 do
260 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
261 done
262
263 if [ "${H_ACCEPT_ARCH}" != "yes" ]
264 then
265 echo
266 eerror "This version of ${PN} does not support ${ARCH}."
267 eerror "Please merge the appropriate sources, in most cases"
268 eerror "this will be ${ARCH}-headers."
269 die "incorrect headers"
204 fi 270 fi
205} 271}
206 272
207# unipatch 273# unipatch
208#============================================================== 274#==============================================================
224 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
225 291
226 #unpack any passed tarballs 292 #unpack any passed tarballs
227 for i in ${UNIPATCH_LIST} 293 for i in ${UNIPATCH_LIST}
228 do 294 do
229 if [ -n "$(echo ${i} | grep -e ".tar" -e ".tbz" -e ".tgz")" ] 295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
230 then 296 then
231 extention=${i/*./} 297 extention=${i/*./}
232 case ${extention} in 298 case ${extention} in
233 tbz2) PIPE_CMD="tar -xvjf";; 299 tbz2) PIPE_CMD="tar -xvjf";;
234 bz2) PIPE_CMD="tar -xvjf";; 300 bz2) PIPE_CMD="tar -xvjf";;
257 extention=${i/*./} 323 extention=${i/*./}
258 PIPE_CMD="" 324 PIPE_CMD=""
259 case ${extention} in 325 case ${extention} in
260 bz2) PIPE_CMD="bzip2 -dc";; 326 bz2) PIPE_CMD="bzip2 -dc";;
261 patch) PIPE_CMD="cat";; 327 patch) PIPE_CMD="cat";;
328 diff) PIPE_CMD="cat";;
262 gz|Z|z) PIPE_CMD="gzip -dc";; 329 gz|Z|z) PIPE_CMD="gzip -dc";;
263 ZIP|zip) PIPE_CMD="unzip -p";; 330 ZIP|zip) PIPE_CMD="unzip -p";;
264 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";; 331 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";;
265 esac 332 esac
333 x=${i/*\//}
334 x=${x/\.${extention}/}
266 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${i/*\//}.patch 335 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch
267 done 336 done
268 337
269 #populate KPATCH_DIRS so we know where to look to remove the excludes 338 #populate KPATCH_DIRS so we know where to look to remove the excludes
270 x=${KPATCH_DIR} 339 x=${KPATCH_DIR}
271 KPATCH_DIR="" 340 KPATCH_DIR=""
289 done 358 done
290 359
291 # and now, finally, we patch it :) 360 # and now, finally, we patch it :)
292 for x in ${KPATCH_DIR} 361 for x in ${KPATCH_DIR}
293 do 362 do
294 for i in $(find ${x} -maxdepth 1 -iname "*.patch" | sort -u) 363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u)
295 do 364 do
296 365
297 366
298 PATCH_DEPTH=0 367 PATCH_DEPTH=0
299 ebegin "Applying ${i/*\//}" 368 ebegin "Applying ${i/*\//}"
351 RELEASE=${RELEASE/_rc/-rc} 420 RELEASE=${RELEASE/_rc/-rc}
352 RELEASE=${RELEASE/_pre/-bk} 421 RELEASE=${RELEASE/_pre/-bk}
353 RELEASETYPE=${RELEASE//[0-9]/} 422 RELEASETYPE=${RELEASE//[0-9]/}
354 423
355 EXTRAVERSION="${RELEASE}" 424 EXTRAVERSION="${RELEASE}"
425
426 if [ -n "${K_PREPATCHED}" ]
427 then
428 KV="${OKV}-${PN/-*/}${PR/r/}"
429 else
356 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
357 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
358 432
359 KV=${OKV}${EXTRAVERSION} 433 KV=${OKV}${EXTRAVERSION}
434 fi
360 435
361 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
362 # these cannot be supported, but the code here can handle it up until this point 437 # these cannot be supported, but the code here can handle it up until this point
363 # and theoretically thereafter. 438 # and theoretically thereafter.
364 439
366 then 441 then
367 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
368 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 443 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
369 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 444 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
370 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}"
371 KV=${PV/[-_]*/}${EXTRAVERSION} 446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
372 fi 447 fi
373 448
374 if [ "${RELEASETYPE}" == "-bk" ] 449 if [ "${RELEASETYPE}" == "-bk" ]
375 then 450 then
376 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
377 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 452 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
378 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 453 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
379 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 454 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
380 KV=${PV/[-_]*/}${EXTRAVERSION} 455 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
381 fi 456 fi
382 457
383 if [ "${RELEASETYPE}" == "-rc-bk" ] 458 if [ "${RELEASETYPE}" == "-rc-bk" ]
384 then 459 then
385 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
386 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})" 461 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
387 462
388 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
389 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 464 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
390 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 465 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
391 KV=${PV/[-_]*/}${EXTRAVERSION} 466 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
392 fi 467 fi
393 468
394 S=${WORKDIR}/linux-${KV} 469 S=${WORKDIR}/linux-${KV}
395} 470}
396 471
400src_unpack() { 475src_unpack() {
401 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 476 [ -z "${OKV}" ] && OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
402 477
403 cd ${WORKDIR} 478 cd ${WORKDIR}
404 unpack linux-${OKV}.tar.bz2 479 unpack linux-${OKV}.tar.bz2
480 if [ "${OKV}" != "${KV}" ]
481 then
405 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}." 482 mv linux-${OKV} linux-${KV} || die "Unable to move source tree to ${KV}."
483 fi
406 cd ${S} 484 cd ${S}
407 485
408 universal_unpack 486 universal_unpack
409 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST} 487 [ -n "${UNIPATCH_LIST}" ] && unipatch ${UNIPATCH_LIST}
410 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion 488 [ -z "${K_NOSETEXTRAVERSION}" ] && unpack_set_extraversion
425 [ "${ETYPE}" == "headers" ] && install_headers 503 [ "${ETYPE}" == "headers" ] && install_headers
426 [ "${ETYPE}" == "sources" ] && install_sources 504 [ "${ETYPE}" == "sources" ] && install_sources
427} 505}
428 506
429pkg_postinst() { 507pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers
430 [ "${ETYPE}" == "sources" ] && postinst_sources 509 [ "${ETYPE}" == "sources" ] && postinst_sources
431} 510}
511
512pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers
514}

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

  ViewVC Help
Powered by ViewVC 1.1.20