summaryrefslogtreecommitdiff
blob: f69c80b059730316737517cb1cd5a0c66253429b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# Copyright 1999-2000 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Author Daniel Robbins <drobbins@gentoo.org>
# /home/cvsroot/gentoo-x86/sys-kernel/linux/linux-2.4.4.3.ebuild,v 1.1 2001/05/02 14:31:06 achim Exp

#OKV=original kernel version, KV=patched kernel version
OKV=2.4.4
KV=2.4.4-ac9
S=${WORKDIR}/linux-${KV}

# Versions of LVM
LVMV=0.9.1_beta7

LVMVARC=0.9.1_beta7
# Versions of alsa
AV=0.5.11

# Versionos of jfs
JFSV=0.2.1

# Versions of lm_sensors
SENV=2.5.5

# Versions of reiserfs
RV=20010327
KNV="6.g"
PIV="1.d"

# Versions of xmlprocfs
XMLV=0.3

# Versions of pcmcia-cs
PCV="3.1.26"

[ "${PN}" = "linux" ] && DESCRIPTION="Linux kernel version ${KV}, including modules, binary tools, libraries and includes"
[ "${PN}" = "linux-sources" ] && DESCRIPTION="Linux kernel version ${KV} - full sources"
[ "${PN}" = "linux-extras" ] && DESCRIPTION="Linux kernel support tools and libraries"

# We use build in /usr/src/linux in case of linux-extras
# so we need no sources
if [ ! "${PN}" = "linux-extras" ] ; then
SRC_URI="http://www.kernel.org/pub/linux/kernel/v2.4/linux-${OKV}.tar.bz2
	http://www.kernel.org/pub/linux/kernel/people/alan/linux-2.4/${OKV}/patch-${KV}.bz2
	http://dice.mfa.kfki.hu/download/reiserfs-3.6.25-2.4.4/linux-2.4.4-knfsd-6.g.patch.gz
	http://dice.mfa.kfki.hu/download/reiserfs-3.6.25-2.4.4/linux-2.4.4-procinfo-1.d.patch.gz
	http://dice.mfa.kfki.hu/download/reiserfs-3.6.25-2.4.4/reiserfs-quota-2.4.4.dif.bz2
	http://www.netroedge.com/~lm78/archive/lm_sensors-${SENV}.tar.gz
	ftp://ftp.sistina.com/pub/LVM/0.9.1_beta/lvm_${LVMVARC}.tar.gz
	ftp://ftp.alsa-project.org/pub/driver/alsa-driver-${AV}.tar.bz2
	http://prdownloads.sourceforge.net/pcmcia-cs/pcmcia-cs-${PCV}.tar.gz"
fi

if [ "$PN" != "linux-extras" ]
then
	PROVIDE="virtual/kernel"
fi
if [ "$PN" != "linux-sources" ]
then
	if [ "`use alsa`" ]
	then
		PROVIDE="$PROVIDE virtual/alsa"
	fi
fi

HOMEPAGE="http://www.kernel.org/
	  http://www.netroedge.com/~lm78/
	  http://www.namesys.com
	  http://www.sistina.com/lvm/
	  http://www.alsa-project.org
	  http://pcmcia-cs.sourceforge.net"



if [ ! $PN = "linux-extras" ] ; then
    RDEPEND=">=sys-apps/reiserfs-utils-3.6.25-r1"
    DEPEND=">=sys-apps/modutils-2.4.2 sys-devel/perl"
else
    DEPEND=">=sys-kernel/${PF/extras/sources}"
fi
if [ "`use build`" ] && [ $PN = "linux-sources" ] ; then
    DEPEND=""
    RDEPEND=""
fi

# this is not pretty...
LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I${S}/include"

src_unpack() {

    # We only need to unpack for linux and linux-sources

    if [ ! "$PN" = "linux-extras" ]
	then

		#unpack kernel and apply reiserfs-related patches
		cd ${WORKDIR}
		unpack linux-${OKV}.tar.bz2
		try mv linux linux-${KV}
		cd ${S}
		echo "Applying ${KV} patch..."
		bzip2 -dc ${DISTDIR}/patch-${KV}.bz2 | patch -p1 || die
		#    echo "Applying reiserfs-update patch..."
		#    try gzip -dc ${DISTDIR}/linux-2.4.2-reiserfs-${RV}.patch.gz | patch -N -p1
		#    echo "You can ignore the rejects the changes already are in rc11"
		
		#    echo
		#    echo "Applying xmlprocfs patch..."
		#    try gzip -dc ${DISTDIR}/linux-2.4-xmlprocfs-${XMLV}.patch.gz | patch -p1   
		echo "Applying ac-nfsfh patch..."
		patch -p0 < ${FILESDIR}/${KV}/nfsfh-ac-fix.diff || die
		echo "Applying reiserfs-knfsd patch..."
		gzip -dc ${DISTDIR}/linux-${OKV}-knfsd-${KNV}.patch.gz | patch -p1 || die
		echo "Applying ac-nfsfh-knfsd patch..."
		patch -p0 < ${FILESDIR}/${KV}/nfsfh-ac-knfsd.diff || die
		echo "Applying reiserfs-procinfo patch..."
		gzip -dc ${DISTDIR}/linux-${OKV}-procinfo-${PIV}.patch.gz | patch -p1 || die
		#    echo "Applying reiserfs-quota patch..."
		#    try bzip2 -dc ${DISTDIR}/reiserfs-quota-${OKV}.dif.bz2 | patch -p1
    
		if [ "`use lvm`" ] || [ "`use alsa`" ] || [ "`use lm_sensors`" ] || [ "`use pcmcia-cs`" ]
		then
			mkdir ${S}/extras
		fi
    
		if [ "`use lvm`" ]
		then
			#create and apply LVM patch.  The tools get built later.
			cd ${S}/extras
			echo "Unpacking and applying LVM patch..."
			unpack lvm_${LVMVARC}.tar.gz
			try cd LVM/${LVMV}
	
			# I had to hack this in so that LVM will look in the current linux
			# source directory instead of /usr/src/linux for stuff - pete
			try CFLAGS="${CFLAGS} -I${S}/include" ./configure --prefix=/ --mandir=/usr/share/man --with-kernel_dir="${S}"
			cd PATCHES
			try make KERNEL_VERSION=${KV} KERNEL_DIR=${S}
			cd ${S}
			# the -l option allows this patch to apply cleanly (ignore whitespace changes)
			try patch -l -p1 < ${S}/extras/LVM/${LVMV}/PATCHES/lvm-${LVMV}-${KV}.patch
			cd ${S}/drivers/md
			try patch -p0 < ${FILESDIR}/${KV}/lvm.c.diff
		fi
    
		if [ "`use alsa`" ]
		then  
			#unpack alsa drivers
			echo "Unpacking ALSA drivers..."
			cd ${S}/extras
			unpack alsa-driver-${AV}.tar.bz2
		fi
    
		if [ "`use lm_sensors`" ]
		then
			#unpack and apply the lm_sensors patch
			echo "Unpacking and applying lm_sensors patch..."
			cd ${S}/extras
			unpack lm_sensors-${SENV}.tar.gz
			try cd lm_sensors-${SENV}
			try mkpatch/mkpatch.pl . ${S} > ${S}/lm_sensors-patch
			try rmdir src
			try ln -s ../.. src
			try cp -a Makefile Makefile.orig

			cd ${S}
			try patch -p1 < lm_sensors-patch
		fi
		if [ "`use pcmcia-cs`" ]
		then
			echo "Unpacking pcmcia-cs tools..."
			cd ${S}/extras
			unpack pcmcia-cs-${PCV}.tar.gz
			patch -p0 < ${FILESDIR}/${KV}/pcmcia-cs-${PCV}-gentoo.diff
		fi
		#get sources ready for compilation or for sitting at /usr/src/linux
		echo "Preparing for compilation..."
		cd ${S}
		#sometimes we have icky kernel symbols; this seems to get rid of them
		try make mrproper

		#linux-sources needs to be fully configured, too.  Not just linux
		if [ "${PN}" != "linux-extras" ]
		then
			#this is the configuration for the default kernel
			try cp ${FILESDIR}/${KV}/config.bootcomp .config
			try yes "" | make oldconfig
			echo "Ignore any errors from the yes command above."
		fi
    
		#fix silly permissions in tarball
		cd ${WORKDIR}
		chown -R 0.0 ${S}
		chmod -R a+r-w+X,u+w ${S}
	
	fi
}

src_compile() {

    if [ "${PN}" != "linux-sources" ]
	then
    	if [ $PN = "linux-extras" ]
		then
        	KS=/usr/src/linux
    	else
        	KS=${S}
    	fi
		if [ $PN = "linux" ]
		then
			try make symlinks
		fi
		if [ "`use lvm`" ]
		then
			#LVM tools are included in the linux and linux-extras pakcages
			cd ${KS}/extras/LVM/${LVMV}

			# This is needed for linux-extras
			if [ -f "Makefile" ]
			then
				try make clean
			fi
			# I had to hack this in so that LVM will look in the current linux
			# source directory instead of /usr/src/linux for stuff - pete
			try CFLAGS="${CFLAGS} -I${KS}/include" ./configure --prefix=/ --mandir=/usr/share/man --with-kernel_dir="${KS}"
			try make 
		fi
	
		if [ "`use lm_sensors`" ]
		then
			cd ${KS}/extras/lm_sensors-${SENV}
			try sed -e "s:^LINUX=.*:LINUX=src:" \
			-e "s/^COMPILE_KERNEL.*/COMPILE_KERNEL := 0/" \
			-e "s:^I2C_HEADERS.*:I2C_HEADERS=src/include:" \
			-e "s#^DESTDIR.*#DESTDIR := ${D}#" \
			-e "s#^PREFIX.*#PREFIX := /usr#" \
			-e "s#^MANDIR.*#MANDIR := /usr/share/man#" \
			Makefile.orig > Makefile

			try make
		fi
	
		cd ${S}
	
		if [ "$PN" == "linux" ]
		then
			try make HOSTCFLAGS="${LINUX_HOSTCFLAGS}" dep
			try make HOSTCFLAGS="${LINUX_HOSTCFLAGS}" bzImage
			#LEX=\""flex -l"\" bzImage
			try make HOSTCFLAGS="${LINUX_HOSTCFLAGS}" modules
			#LEX=\""flex -l"\" modules
		fi
	    
		# This must come after the kernel compilation in linux
        if [ "`use alsa`" ]
        then
			cd ${KS}/extras/alsa-driver-${AV}
			# This is needed for linux-extras
			if [ -f "Makefile.conf" ] 
			then
				try make clean
			fi
			try ./configure --with-kernel="${KS}" --with-isapnp=yes --with-sequencer=yes --with-oss=yes --with-cards=all
			try make
		fi
		if [ "`use pcmcia-cs`" ]
		then
			cd ${KS}/extras/pcmcia-cs-${PCV}
			# This is needed for linux-extras
			if [ -f "Makefile" ] 
			then
				try make clean
			fi
			try ./Configure -n --kernel=${KS} --moddir=/lib/modules/${KV} \
			--notrust --cardbus --nopnp --noapm --srctree --sysv --rcdir=/etc/rc.d/
			try make all
		fi
    else
		#linux-sources
		try make HOSTCFLAGS="${LINUX_HOSTCFLAGS}" dep
	fi
}

src_install() {

    if [ $PN = "linux-extras" ] ; then
        KS=/usr/src/linux
    else
        KS=${S}
    fi
    # We install the alsa headers in all three packages
    if [ "`use alsa`" ]
	then
		#i get alsa includes
		cd ${KS}/extras/alsa-driver-${AV}
		insinto /usr/src/linux-${KV}/include/linux
		cd include
		doins asound.h asoundid.h asequencer.h ainstr_*.h
    fi

    if [ ! "${PN}" = "linux-sources" ]
    then
		if [ $PN = "linux" ]
		then
			KS=${S}
		else
			KS=/usr/src/linux
		fi
		dodir /usr/lib
	
		if [ "`use lvm`" ]
		then
			cd ${KS}/extras/LVM/${LVMV}/tools
	    
			try CFLAGS="${CFLAGS} -I${KS}/include" make install -e prefix=${D} mandir=${D}/usr/share/man \
			sbindir=${D}/sbin libdir=${D}/lib
			#no need for a static library in /lib
			mv ${D}/lib/*.a ${D}/usr/lib
		fi
	
		if [ "`use lm_sensors`" ]
		then
			echo "Install sensor tools..."
			#install sensors tools
			cd ${KS}/extras/lm_sensors-${SENV}
			make install
		fi
		if [ "${PN}" = "linux" ] 
		then
			dodir /usr/src
			dodir /usr/src/linux-${KV}
			cd ${D}/usr/src
			#grab includes and documentation only
			echo ">>> Copying includes and documentation..."
			cp -ax ${S}/include ${D}/usr/src/linux-${KV}
			cp -ax ${S}/Documentation ${D}/usr/src/linux-${KV}
	       
			#grab compiled kernel
			dodir /boot/boot
			insinto /boot/boot
			cd ${S}
			doins arch/i386/boot/bzImage
	    
			#grab modules
			# Do we have a bug in modutils ?
			# Meanwhile we use this quick fix (achim)
	    
			install -d ${D}/lib/modules/`uname -r`
			try make INSTALL_MOD_PATH=${D} modules_install
	    
			depmod -b ${D} -F ${S}/System.map ${KV}	
			#rm -rf ${D}/lib/modules/`uname -r`
			#fix symlink
			cd ${D}/lib/modules/${KV}
			rm build
			ln -sf /usr/src/linux-${KV} build
		fi

        if [ "`use alsa`" ]
        then
		  	#install ALSA modules
            cd ${KS}/extras/alsa-driver-${AV}
			dodoc INSTALL FAQ
			dodir /lib/modules/${KV}/misc
			cp modules/*.o ${D}/lib/modules/${KV}/misc
        fi
		if [ "`use pcmcia-cs`" ]
		then
			#install PCMCIA modules and utilities
			cd ${KS}/extras/pcmcia-cs-${PCV}
			try make PREFIX=${D} MANDIR=${D}/usr/share/man install  
			rm -rf ${D}/etc/rc.d
			exeinto /etc/rc.d/init.d
			doexe ${FILESDIR}/${KV}/pcmcia
		fi	    
	else
		dodir /usr/src
		cd ${S}
		#make mrproper

		if [ "`use build`" ] ; then
			dodir /usr/src/linux-${KV}
			#grab includes and documentation only
			echo ">>> Copying includes..."
			cp -ax ${S}/include ${D}/usr/src/linux-${KV}
		else
			echo ">>> Copying sources..."
			cp -ax ${S} ${D}/usr/src
		fi
	fi	
    if [ "$PN" != "linux-extras" ]
    then
		#don't overwrite existing .config if present
		cd ${D}/usr/src/linux-${KV}
		if [ -e .config ]
		then
			cp -a .config .config.eg
		fi
	fi
}

pkg_postinst() {
    rm -f ${ROOT}/usr/src/linux
    ln -sf linux-${KV} ${ROOT}/usr/src/linux
    
    #copy over our .config if one isn't already present
    cd ${ROOT}/usr/src/linux-${KV}
    if [ "${PN}" = "linux-sources" ] && [ -e .config.eg ] && [ ! -e .config ]
    then
		cp -a .config.eg .config
    fi
}