First commit
diff --git a/util/kbuild/kbuild b/util/kbuild/kbuild
new file mode 100644
index 0000000..c8d2f96
--- /dev/null
+++ b/util/kbuild/kbuild
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+# Script to build new Debian kernel packages for 2.6.33.1
+#
+# Caveats:
+#
+# Since kernel-package in debian-stable doesn't work with
+# 2.6.33.1, we attempt to patch it in place. This may not be the
+# right thing to do. A possibly better alternative is to install
+# a later version of kernel-package, although that could potentially
+# cause problems with upgrades, etc..
+#
+# The patch to tun.c is a workaround rather than a real fix.
+#
+# Building a full Debian kernel package with all drivers takes a long
+# time, 60-80 minutes on my laptop.
+#
+# Re-running a make-kpkg may not work without running 'make-kpkg clean'
+
+# Season to taste
+# export PATH=/usr/lib/ccache:$PATH
+export CONCURRENCY_LEVEL=3
+
+debversion=2.6.26-2-686-bigmem
+
+image=linux-image-$debversion
+
+echo "*** Installing $image"
+sudo aptitude install $image
+
+newversion=2.6.33.1
+archive=linux-$newversion.tar.bz2
+location=http://www.kernel.org/pub/linux/kernel/v2.6
+
+echo "*** Fetching $location/$archive"
+wget -c $location/$archive
+
+tree=linux-$newversion
+if [ -e $tree ]; then 
+  echo "*** $tree already exists"
+else
+  echo "*** Extracting $archive"
+  tar xjf $archive
+fi
+
+echo "*** Patching tun driver"
+patch $tree/drivers/net/tun.c < tun.patch
+
+echo "*** Patching debian build script"
+sudo patch /usr/share/kernel-package/ruleset/misc/version_vars.mk < version_vars.patch
+
+config=/boot/config-$debversion
+echo "*** Copying $config to $tree/.config"
+cp $config $tree/.config
+
+echo "*** Updating config"
+cd $tree
+yes '' | make oldconfig 1> /dev/null
+sed 's/# CONFIG_NET_NS is not set/CONFIG_NET_NS=y/' .config > .config-new
+mv .config-new .config
+echo "*** Result: " `grep CONFIG_NET_NS .config`
+
+echo "*** Building kernel"
+time fakeroot make-kpkg --initrd --append-to-version=-mininet kernel_image kernel_headers
+
+cd ..
+echo "*** Done - package should be in current directory"
+ls *$newversion*.deb
+
+echo "To install:"
+echo "# dpkg -i "  *$newversion*.deb
diff --git a/util/kbuild/tun.patch b/util/kbuild/tun.patch
new file mode 100644
index 0000000..3c4cc69
--- /dev/null
+++ b/util/kbuild/tun.patch
@@ -0,0 +1,13 @@
+--- linux-2.6.33.1/drivers/net/tun.c	2010-03-24 22:47:32.000000000 -0700
++++ tun-new.c	2010-03-24 22:45:00.000000000 -0700
+@@ -1006,7 +1006,9 @@
+ 		if (err < 0)
+ 			goto err_free_sk;
+ 
+-		if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
++		/* BL hack: check for null parent kobj */
++		if (!tun->dev->dev.kobj.sd ||
++		    device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
+ 		    device_create_file(&tun->dev->dev, &dev_attr_owner) ||
+ 		    device_create_file(&tun->dev->dev, &dev_attr_group))
+ 			printk(KERN_ERR "Failed to create tun sysfs files\n");
diff --git a/util/kbuild/version_vars.patch b/util/kbuild/version_vars.patch
new file mode 100644
index 0000000..6f55901
--- /dev/null
+++ b/util/kbuild/version_vars.patch
@@ -0,0 +1,18 @@
+--- /usr/share/kernel-package/ruleset/misc/version_vars.mk	2010-03-25 18:14:41.000000000 -0700
++++ version_vars.mk	2010-03-03 06:46:59.000000000 -0800
+@@ -138,11 +138,13 @@
+ EXTRAV_ARG :=
+ endif
+ 
+-UTS_RELEASE_HEADER=$(call doit,if [ -f include/linux/utsrelease.h ]; then  \
++UTS_RELEASE_HEADER=$(call doit, if [ -f include/generated/utsrelease.h ]; then \
++	                       echo include/generated/utsrelease.h;            \
++			   else if [ -f include/linux/utsrelease.h ]; then  \
+ 	                       echo include/linux/utsrelease.h;            \
+ 	                   else                                            \
+                                echo include/linux/version.h ;              \
+-	                   fi)
++	                   fi fi)
+ UTS_RELEASE_VERSION=$(call doit,if [ -f $(UTS_RELEASE_HEADER) ]; then                    \
+                  grep 'define UTS_RELEASE' $(UTS_RELEASE_HEADER) |                       \
+                  perl -nle  'm/^\s*\#define\s+UTS_RELEASE\s+("?)(\S+)\1/g && print $$2;';\