/[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.18
1# Copyright 1999-2004 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.18 2004/01/23 21:43:47 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
13# A Couple of env vars are available to effect usage of this eclass 17# A Couple of env vars are available to effect usage of this eclass
14# These are as follows: 18# These are as follows:
15# 19#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 20# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile
17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION 21# K_NOUSENAME - if this is set then EXTRAVERSION will not include the 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 22# 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
19# - and not use it as a true package revision 23# - and not use it as a true package revision
20# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages 24# 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 25# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
22 26
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild 27# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild
24 28
25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 29# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 30# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
31# UNIPATCH_STRICTORDER - if this is set places patches into directories of order, so they are applied in the order passed
27 32
28ECLASS="kernel-2" 33ECLASS="kernel-2"
29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 34EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
30 35
31HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 36HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
32LICENSE="GPL-2" 37LICENSE="GPL-2"
33IUSE="${IUSE} build" 38IUSE="${IUSE} build"
34SLOT="${KV}" 39SLOT="${KV}"
40
41# Grab kernel version from KV
42KV_MAJOR=$(echo ${KV} | cut -d. -f1)
43KV_MINOR=$(echo ${KV} | cut -d. -f2)
44KV_PATCH=$(echo ${KV} | cut -d. -f3)
45KV_PATCH=${KV_PATCH/[-_]*/}
46
47# set LINUX_HOSTCFLAGS if not already set
48[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
49
50
51#eclass functions only from here onwards.
52#==============================================================
53kernel_is_2_4() {
54 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
55}
56
57kernel_is_2_6() {
58 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
59}
35 60
36# capture the sources type and set depends 61# capture the sources type and set depends
37if [ "${ETYPE}" == "sources" ] 62if [ "${ETYPE}" == "sources" ]
38then 63then
39 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs. 64 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
43 RDEPEND="${DEPEND} 68 RDEPEND="${DEPEND}
44 !build? ( >=sys-libs/ncurses-5.2 69 !build? ( >=sys-libs/ncurses-5.2
45 dev-lang/perl 70 dev-lang/perl
46 sys-apps/module-init-tools 71 sys-apps/module-init-tools
47 sys-devel/make )" 72 sys-devel/make )"
48 73
49 PROVIDE="virtual/linux-sources virtual/alsa" 74 [ $(kernel_is_2_4) $? == 0 ] && PROVIDE="virtual/linux-sources" || PROVIDE="virtual/linux-sources virtual/alsa"
50 75
51elif [ "${ETYPE}" == "headers" ] 76elif [ "${ETYPE}" == "headers" ]
52then 77then
53 PROVIDE="virtual/kernel virtual/os-headers" 78 PROVIDE="virtual/kernel virtual/os-headers"
54else 79else
55 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\"" 80 eerror "Unknown ETYPE=\"${ETYPE}\", must be either \"sources\" or \"headers\""
56 die 81 die
57fi 82fi
58
59# Grab kernel version from KV
60KV_MAJOR=$(echo ${KV} | cut -d. -f1)
61KV_MINOR=$(echo ${KV} | cut -d. -f2)
62KV_PATCH=$(echo ${KV} | cut -d. -f3)
63KV_PATCH=${KV_PATCH/[-_]*/}
64
65# set LINUX_HOSTCFLAGS if not already set
66[ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
67
68
69#eclass functions only from here onwards.
70#==============================================================
71kernel_is_2_4() {
72 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 4 ] && return 0 || return 1
73}
74
75kernel_is_2_6() {
76 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && return 0 || return 1
77}
78
79 83
80# Unpack functions 84# Unpack functions
81#============================================================== 85#==============================================================
82unpack_2_4() { 86unpack_2_4() {
83 cd ${S} 87 cd ${S}
132 chmod -R a+r-w+X,u+w * 136 chmod -R a+r-w+X,u+w *
133} 137}
134 138
135install_headers() { 139install_headers() {
136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 140 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 141
138
139 cd ${S} 142 cd ${S}
140 dodir /usr/include/linux 143 dodir /usr/include/linux
144 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 145 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
142 rm -rf ${D}/usr/include/linux/modules 146 rm -rf ${D}/usr/include/linux/modules
147
143 dodir /usr/include/asm 148 dodir /usr/include/asm
144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 149 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145 150
146 if [ $(kernel_is_2_6) $? == 0 ] 151 if [ $(kernel_is_2_6) $? == 0 ]
147 then 152 then
279 local PIPE_CMD 284 local PIPE_CMD
280 local UNIPATCH_EXCLUDE 285 local UNIPATCH_EXCLUDE
281 local KPATCH_DIR 286 local KPATCH_DIR
282 local PATCH_DEPTH 287 local PATCH_DEPTH
283 local ELINE 288 local ELINE
289 local STRICT_COUNT
284 290
285 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/" 291 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
286 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR} 292 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
287 293
288 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers 294 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
302 gz) PIPE_CMD="tar -xvzf";; 308 gz) PIPE_CMD="tar -xvzf";;
303 *) eerror "Unrecognized tarball compression" 309 *) eerror "Unrecognized tarball compression"
304 die "Unrecognized tarball compression";; 310 die "Unrecognized tarball compression";;
305 esac 311 esac
306 312
313 if [ -n "${UNIPATCH_STRICTORDER}" ]
314 then
315 STRICT_COUNT=$((${STRICT_COUNT} + 1))
316 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
317 ${PIPE_CMD} ${i} -C ${KPATCH_DIR}/${STRICT_COUNT}/ 1>/dev/null
318 else
307 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null 319 ${PIPE_CMD} ${i} -C ${KPATCH_DIR} 1>/dev/null
320 fi
321
308 if [ $? == 0 ] 322 if [ $? == 0 ]
309 then 323 then
310 einfo "${i/*\//} unpacked" 324 einfo "${i/*\//} unpacked"
311 else 325 else
312 eerror "Failed to unpack ${i}" 326 eerror "Failed to unpack ${i}"
330 ZIP|zip) PIPE_CMD="unzip -p";; 344 ZIP|zip) PIPE_CMD="unzip -p";;
331 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";; 345 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";;
332 esac 346 esac
333 x=${i/*\//} 347 x=${i/*\//}
334 x=${x/\.${extention}/} 348 x=${x/\.${extention}/}
349
350 if [ -n "${UNIPATCH_STRICTORDER}" -a -n "${PIPE_CMD}" ]
351 then
352 STRICT_COUNT=$((${STRICT_COUNT} + 1))
353 mkdir -p ${KPATCH_DIR}/${STRICT_COUNT}/
354 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${STRICT_COUNT}/${x}.patch)
355 else
335 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch 356 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch)
357 fi
336 done 358 done
337 359
338 #populate KPATCH_DIRS so we know where to look to remove the excludes 360 #populate KPATCH_DIRS so we know where to look to remove the excludes
339 x=${KPATCH_DIR} 361 x=${KPATCH_DIR}
340 KPATCH_DIR="" 362 KPATCH_DIR=""
360 # and now, finally, we patch it :) 382 # and now, finally, we patch it :)
361 for x in ${KPATCH_DIR} 383 for x in ${KPATCH_DIR}
362 do 384 do
363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u) 385 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u)
364 do 386 do
365
366
367 PATCH_DEPTH=0 387 PATCH_DEPTH=0
368 ebegin "Applying ${i/*\//}" 388 ebegin "Applying ${i/*\//}"
369 while [ ${PATCH_DEPTH} -lt 5 ] 389 while [ ${PATCH_DEPTH} -lt 5 ]
370 do 390 do
371 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null) 391 if (patch -p${PATCH_DEPTH} --dry-run -f < ${i} >/dev/null)
509 [ "${ETYPE}" == "sources" ] && postinst_sources 529 [ "${ETYPE}" == "sources" ] && postinst_sources
510} 530}
511 531
512pkg_setup() { 532pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers 533 [ "${ETYPE}" == "headers" ] && setup_headers
534
535 # this is to fix some weird portage bug? in stable versions of portage.
536 [ "${ETYPE}" == "sources" ] && echo ">>> Preparing to unpack..."
514} 537}

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

  ViewVC Help
Powered by ViewVC 1.1.20