/[gentoo-x86]/eclass/kernel.eclass
Gentoo

Contents of /eclass/kernel.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (show annotations) (download)
Wed Jul 16 17:40:05 2003 UTC (16 years, 11 months ago) by lostlogic
Branch: MAIN
Branch point for: RELEASE-1_4
Changes since 1.28: +21 -7 lines
Few changes to vars and stuff for 2.6 and forward support

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/kernel.eclass,v 1.28 2003/06/26 22:07:43 vapier Exp $
4 #
5 # This eclass contains the common functions to be used by all lostlogic
6 # based kernel ebuilds
7 # with error handling contributions by gerk, and small fixes by zwelch
8 # small naming fix by kain
9
10 ECLASS=kernel
11 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
12
13 # OKV=original kernel version, KV=patched kernel version. They can be the same.
14 [ -z "${OKV}" ] && \
15 OKV="`echo ${PV}|sed -e 's:^\([0-9]\+\.[0-9]\+\.[0-9]\+\).*:\1:'`"
16 if [ -z "${EXTRAVERSION}" ]; then
17 EXTRAVERSION="`echo ${PN}-${PV}-${PR} | \
18 sed -e 's:^\(.*\)-\(.*\)-[0-9]\+\.[0-9]\+\.[0-9]\+.r*\([0-9]\+\)\(_[^-_]\+\)\?\(-r[0-9]\+\)\?$:-\1-r\3\4:'`"
19 KV=${OKV}${EXTRAVERSION}
20 fi
21 S=${WORKDIR}/linux-${KV}
22 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
23 LICENSE="GPL-2"
24 IUSE="${IUSE} doc tcltk"
25 if [ "${ETYPE}" = "sources" ]
26 then
27 #console-tools is needed to solve the loadkeys fiasco; binutils version needed to avoid Athlon/PIII/SSE assembler bugs.
28 DEPEND="!build? ( sys-apps/sed
29 >=sys-devel/binutils-2.11.90.0.31 )
30 doc? ( app-text/docbook-sgml-utils
31 media-gfx/transfig )
32 app-admin/addpatches"
33 RDEPEND="${DEPEND}
34 !build? ( >=sys-libs/ncurses-5.2
35 tcltk? dev-lang/tk
36 dev-lang/perl
37 virtual/modutils
38 sys-devel/make )"
39 PROVIDE="virtual/linux-sources"
40
41 elif [ "${ETYPE}" = "headers" ]
42 then
43 PROVIDE="virtual/kernel virtual/os-headers"
44 else
45 eerror "Unknown ETYPE=\"${ETYPE}\"!"
46 die
47 fi
48
49 [ -z "$LINUX_HOSTCFLAGS" ] && LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
50
51 kernel_exclude() {
52 for mask in ${KERNEL_EXCLUDE}; do
53 for patch in *${mask}*; do
54 einfo "Excluding: ${patch}"
55 rm ${patch}
56 done
57 done
58 }
59
60 kernel_universal_unpack() {
61
62 echo "KV=${KV}" > /tmp/KV
63 find . -iname "*~" | xargs rm 2> /dev/null
64
65 # Gentoo Linux uses /boot, so fix 'make install' to work properly
66 # also fix the EXTRAVERSION
67 cd ${S}
68 mv Makefile Makefile.orig
69 sed -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
70 -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" \
71 Makefile.orig >Makefile || die # test, remove me if Makefile ok
72 rm Makefile.orig
73
74 cd ${S}/Documentation/DocBook
75 sed -e "s:db2:docbook2:g" Makefile > Makefile.new \
76 && mv Makefile.new Makefile
77 cd ${S}
78
79 #This is needed on > 2.5
80 MY_ARCH=${ARCH}
81 unset ${ARCH}
82 #sometimes we have icky kernel symbols; this seems to get rid of them
83 make mrproper || die "make mrproper died"
84 ARCH=${MY_ARCH}
85
86 # this file is required for other things to build properly,
87 # so we autogenerate it
88 make include/linux/version.h || die "make include/linux/version.h failed"
89
90 }
91
92 kernel_src_unpack() {
93
94 kernel_exclude
95
96 /usr/bin/addpatches . ${WORKDIR}/linux-${KV} || \
97 die "Addpatches failed, bad KERNEL_EXCLUDE?"
98
99 kernel_universal_unpack
100
101 }
102
103 kernel_src_compile() {
104 if [ "$ETYPE" = "headers" ]
105 then
106 #This is needed on > 2.5
107 MY_ARCH=${ARCH}
108 unset ${ARCH}
109 yes "" | make oldconfig
110 ARCH=${MY_ARCH}
111 echo "Ignore any errors from the yes command above."
112 fi
113 }
114
115 kernel_src_install() {
116 #fix silly permissions in tarball
117 cd ${WORKDIR}
118 chown -R root:root *
119 chmod -R a+r-w+X,u+w *
120
121 cd ${S}
122 if [ "$ETYPE" = "sources" ]
123 then
124 dodir /usr/src
125 echo ">>> Copying sources..."
126 for file in `ls -1 ${WORKDIR}/${KV}/docs/`; do
127 echo "XX_${file}*" >> patches.txt
128 cat ${WORKDIR}/${KV}/docs/${file} >> patches.txt
129 done
130 dodoc patches.txt
131 mv ${WORKDIR}/linux* ${D}/usr/src
132 else
133 #linux-headers
134 dodir /usr/include/linux
135 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
136 rm -rf ${D}/usr/include/linux/modules
137 dodir /usr/include/asm
138 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
139 fi
140 }
141
142 kernel_pkg_preinst() {
143 if [ "$ETYPE" = "headers" ]
144 then
145 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux
146 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm
147 true
148 fi
149 }
150
151 kernel_pkg_postinst() {
152 [ "$ETYPE" = "headers" ] && return
153 if [ ! -e ${ROOT}usr/src/linux ]
154 then
155 rm -f ${ROOT}usr/src/linux
156 ln -sf linux-${KV} ${ROOT}/usr/src/linux
157 fi
158 einfo "After installing a new kernel of any version, it is important"
159 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
160 einfo "created (X.Y is the first 2 parts of your new kernel version)"
161 }
162

  ViewVC Help
Powered by ViewVC 1.1.20