pervio a la presentacion
[vsorcdistro/.git] / mininet / util / kbuild / kbuild
1 #!/bin/bash
2
3 # Script to build new Debian kernel packages for 2.6.33.1
4 #
5 # Caveats:
6 #
7 # Since kernel-package in debian-stable doesn't work with
8 # 2.6.33.1, we attempt to patch it in place. This may not be the
9 # right thing to do. A possibly better alternative is to install
10 # a later version of kernel-package, although that could potentially
11 # cause problems with upgrades, etc..
12 #
13 # The patch to tun.c is a workaround rather than a real fix.
14 #
15 # Building a full Debian kernel package with all drivers takes a long
16 # time, 60-80 minutes on my laptop.
17 #
18 # Re-running a make-kpkg may not work without running 'make-kpkg clean'
19
20 # Season to taste
21 # export PATH=/usr/lib/ccache:$PATH
22 export CONCURRENCY_LEVEL=3
23
24 debversion=2.6.26-2-686-bigmem
25
26 image=linux-image-$debversion
27
28 echo "*** Installing $image"
29 sudo aptitude install $image
30
31 newversion=2.6.33.1
32 archive=linux-$newversion.tar.bz2
33 location=http://www.kernel.org/pub/linux/kernel/v2.6
34
35 echo "*** Fetching $location/$archive"
36 wget -c $location/$archive
37
38 tree=linux-$newversion
39 if [ -e $tree ]; then 
40   echo "*** $tree already exists"
41 else
42   echo "*** Extracting $archive"
43   tar xjf $archive
44 fi
45
46 echo "*** Patching tun driver"
47 patch $tree/drivers/net/tun.c < tun.patch
48
49 echo "*** Patching debian build script"
50 sudo patch /usr/share/kernel-package/ruleset/misc/version_vars.mk < version_vars.patch
51
52 config=/boot/config-$debversion
53 echo "*** Copying $config to $tree/.config"
54 cp $config $tree/.config
55
56 echo "*** Updating config"
57 cd $tree
58 yes '' | make oldconfig 1> /dev/null
59 sed 's/# CONFIG_NET_NS is not set/CONFIG_NET_NS=y/' .config > .config-new
60 mv .config-new .config
61 echo "*** Result: " `grep CONFIG_NET_NS .config`
62
63 echo "*** Building kernel"
64 time fakeroot make-kpkg --initrd --append-to-version=-mininet kernel_image kernel_headers
65
66 cd ..
67 echo "*** Done - package should be in current directory"
68 ls *$newversion*.deb
69
70 echo "To install:"
71 echo "# dpkg -i "  *$newversion*.deb