--- linux-kbuild-2.6-2.6.26.orig/debian/compat
+++ linux-kbuild-2.6-2.6.26/debian/compat
@@ -0,0 +1 @@
+4
--- linux-kbuild-2.6-2.6.26.orig/debian/changelog
+++ linux-kbuild-2.6-2.6.26/debian/changelog
@@ -0,0 +1,94 @@
+linux-kbuild-2.6 (2.6.26-3~bpo40+1) etch-backports; urgency=low
+
+  * Rebuild for etch.
+
+ -- Norbert Tretkowski <nobse@debian.org>  Tue, 26 Aug 2008 09:44:47 +0200
+
+linux-kbuild-2.6 (2.6.26-3) unstable; urgency=low
+
+  * Fix recursive installation. (closes: #494435)
+
+ -- Bastian Blank <waldi@debian.org>  Sun, 10 Aug 2008 13:01:41 +0200
+
+linux-kbuild-2.6 (2.6.26-2) unstable; urgency=low
+
+  * Include new scripts. (closes: #494435)
+
+ -- Bastian Blank <waldi@debian.org>  Sat, 09 Aug 2008 20:45:12 +0200
+
+linux-kbuild-2.6 (2.6.26-1) unstable; urgency=low
+
+  * New upstream version.
+  * modpost: Support new parameters.
+
+ -- Bastian Blank <waldi@debian.org>  Sat, 02 Aug 2008 13:09:54 +0200
+
+linux-kbuild-2.6 (2.6.25-2) unstable; urgency=low
+
+  * modpost: Support new parameters. (closes: #479271)
+
+ -- Bastian Blank <waldi@debian.org>  Mon, 05 May 2008 19:58:40 +0200
+
+linux-kbuild-2.6 (2.6.25-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Bastian Blank <waldi@debian.org>  Fri, 02 May 2008 10:32:13 +0200
+
+linux-kbuild-2.6 (2.6.24-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Bastian Blank <waldi@debian.org>  Tue, 29 Jan 2008 14:03:06 +0100
+
+linux-kbuild-2.6 (2.6.23-1) unstable; urgency=low
+
+  * New upstream version.
+  * modpost: Support -s.
+
+ -- Bastian Blank <waldi@debian.org>  Wed, 05 Dec 2007 08:23:28 +0100
+
+linux-kbuild-2.6 (2.6.22-1) unstable; urgency=low
+
+  * New upstream version.
+  * Don't fail if no module is specified.
+
+ -- Bastian Blank <waldi@debian.org>  Tue, 17 Jul 2007 23:14:23 +0200
+
+linux-kbuild-2.6 (2.6.21-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Bastian Blank <waldi@debian.org>  Fri, 18 May 2007 23:45:14 +0200
+
+linux-kbuild-2.6 (2.6.20-1) unstable; urgency=low
+
+  * New upstream version.
+  * modpost: Support -w.
+
+ -- Bastian Blank <waldi@debian.org>  Thu, 12 Apr 2007 06:53:00 +0200
+
+linux-kbuild-2.6 (2.6.18-1) unstable; urgency=low
+
+  * New upstream version.
+  * Use included headers. (closes: #382286, #384211)
+
+ -- Bastian Blank <waldi@debian.org>  Mon, 25 Sep 2006 21:45:50 +0200
+
+linux-kbuild-2.6 (2.6.17-3) unstable; urgency=low
+
+  * Replace own modpost with original one.
+
+ -- Bastian Blank <waldi@debian.org>  Tue,  1 Aug 2006 11:01:18 +0200
+
+linux-kbuild-2.6 (2.6.17-2) unstable; urgency=low
+
+  * Fix uninitialied variable. (closes: #377656)
+
+ -- Bastian Blank <waldi@debian.org>  Tue, 11 Jul 2006 10:10:24 +0200
+
+linux-kbuild-2.6 (2.6.17-1) unstable; urgency=low
+
+  * Initial release. (closes: #368544)
+
+ -- Bastian Blank <waldi@debian.org>  Sat,  1 Jul 2006 19:10:07 +0200
--- linux-kbuild-2.6-2.6.26.orig/debian/copyright
+++ linux-kbuild-2.6-2.6.26/debian/copyright
@@ -0,0 +1,45 @@
+This package was downloaded from http://kernel.org/pub/linux/kernel. 
+
+Linux was written by Linus Torvalds <Linus.Torvalds@cs.Helsinki.FI>
+and others.
+
+Copyright:
+1995-1997 H. Peter Anvin
+1996,1997 Linux International
+1997,1998 Andrew Tridgell
+1998 Michael Zucchi
+1999,2004 Matt Mackall
+2000 MontaVista Software, Inc.
+2000,2001 Tim Waugh
+2001 Simon Huggins
+2001-2003 Geert Uytterhoeven
+2002 David S. Miller
+2002 James Morris
+2002,2003 Randy Dunlap
+2002,2003 Kai Germaschewski
+2002-2003 Romain Lievin
+2002-2003 Rusty Russel
+2002-2005 Roman Zippel
+2002-2005 Sam Ravnborg
+2005 Arnaldo Carvalho de Melo
+2005,2006 Bastian Blank
+2006 Sam Ravnborg
+
+License:
+
+   This package is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This package is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this package; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
--- linux-kbuild-2.6-2.6.26.orig/debian/rules
+++ linux-kbuild-2.6-2.6.26/debian/rules
@@ -0,0 +1,77 @@
+#!/usr/bin/make -f
+
+SHELL    := sh -e
+DEB_HOST_ARCH  := $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+SOURCE   := $(shell dpkg-parsechangelog | sed -ne 's,^Source: *\(.*\)$$,\1,p')
+VERSION_DEBIAN := $(shell dpkg-parsechangelog | sed -ne 's,^Version: *\(.*\)$$,\1,p')
+VERSION  := $(shell echo "$(VERSION_DEBIAN)" | sed -e 's,-[^-]*$$,,')
+VERSION_DEBIAN_BINNMU := $(shell echo "$(VERSION_DEBIAN)" | sed -ne 's,.*\+b\(.*\)$$,\1,p')
+
+include debian/rules.defs
+
+build: debian/control $(STAMPS_DIR)/build-base
+$(STAMPS_DIR)/build-base: $(BUILD_DIR) $(STAMPS_DIR)
+	dh_testdir
+	$(MAKE) -f debian/rules.gen build
+	touch $@
+
+$(BUILD_DIR) $(STAMPS_DIR):
+	@[ -d $@ ] || mkdir $@
+
+DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
+TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz
+TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
+
+orig: $(DIR_ORIG)
+	rsync --delete --exclude debian --exclude src --exclude .svk --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .
+
+$(DIR_ORIG):
+ifeq ($(TAR_ORIG),)
+	$(error Cannot find orig tarball $(TAR_ORIG_NAME))
+else
+	mkdir -p ../orig
+	tar -C ../orig -xzf $(TAR_ORIG)
+endif
+
+maintainerclean:
+	-rm debian/control debian/control.md5sum debian/rules.gen
+	-rm -rf COPYING include scripts
+
+clean: debian/control
+	dh_testdir
+	rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc
+	dh_clean
+
+binary-indep:
+	dh_testdir
+
+binary-arch:
+	dh_testdir
+	$(MAKE) -f debian/rules.gen binary-arch
+
+binary:	binary-indep binary-arch
+
+CONTROL_FILES = debian/changelog $(wildcard debian/templates/control.*)
+debian/control debian/rules.gen: debian/bin/gencontrol.py $(CONTROL_FILES)
+	if [ -f debian/control.md5sum ]; then \
+		if md5sum $^ | diff - debian/control.md5sum > /dev/null; then true; else \
+			$(MAKE) -f debian/rules debian/control-real; \
+		fi \
+	else \
+		$(MAKE) -f debian/rules debian/control-real; \
+	fi
+
+debian/control-real: debian/bin/gencontrol.py $(CONTROL_FILES)
+	chmod +x $<
+	$<
+	md5sum $^ > debian/control.md5sum
+	@echo
+	@echo This target is made to fail intentionally, to make sure
+	@echo that it is NEVER run during the automated build. Please
+	@echo ignore the following error, the debian/control file has
+	@echo been generated SUCCESSFULLY.
+	@echo
+	exit 1
+
+.PHONY: clean build setup binary-indep binary-arch binary
--- linux-kbuild-2.6-2.6.26.orig/debian/rules.defs
+++ linux-kbuild-2.6-2.6.26/debian/rules.defs
@@ -0,0 +1,4 @@
+BUILD_DIR = debian/build
+STAMPS_DIR = debian/stamps
+TEMPLATES_DIR = debian/templates
+
--- linux-kbuild-2.6-2.6.26.orig/debian/rules.real
+++ linux-kbuild-2.6-2.6.26/debian/rules.real
@@ -0,0 +1,37 @@
+export DH_OPTIONS
+
+include debian/rules.defs
+
+binary-arch: install-kbuild
+
+build: $(STAMPS_DIR)/build
+
+$(STAMPS_DIR)/build: DIR=$(BUILD_DIR)/build
+$(STAMPS_DIR)/build:
+	rm -rf '$(DIR)'
+	mkdir -p '$(DIR)'
+	cp -al src/* '$(DIR)'
+	make -C $(DIR) top_srcdir=$(CURDIR)
+	touch '$@'
+
+install-kbuild: PACKAGE_NAME = linux-kbuild-$(VERSION)
+install-kbuild: DH_OPTIONS = -p$(PACKAGE_NAME)
+install-kbuild: BASE_DIR = /usr/src/$(PACKAGE_NAME)
+install-kbuild: SOURCE_DIR = $(BUILD_DIR)/build
+install-kbuild: DIR = $(CURDIR)/debian/$(PACKAGE_NAME)/$(BASE_DIR)
+install-kbuild: $(STAMPS_DIR)/build
+	dh_testdir
+	dh_testroot
+	dh_clean -k -d
+	make -C $(SOURCE_DIR) install prefix=$(DIR) top_srcdir=$(CURDIR)
+	dh_installchangelogs
+	dh_installdocs
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
--- linux-kbuild-2.6-2.6.26.orig/debian/control
+++ linux-kbuild-2.6-2.6.26/debian/control
@@ -0,0 +1,17 @@
+Source: linux-kbuild-2.6
+Section: devel
+Priority: optional
+Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
+Uploaders: Bastian Blank <waldi@debian.org>
+Standards-Version: 3.7.3
+Build-Depends: debhelper (>= 4.1.0)
+
+Package: linux-kbuild-2.6.26
+Architecture: any
+Section: devel
+Priority: optional
+Depends: ${shlibs:Depends}
+Description: Kbuild infrastructure for Linux 2.6.26
+ This package provides the kbuild infrastructure for the headers packages
+ for Linux kernel version 2.6.26.
+
--- linux-kbuild-2.6-2.6.26.orig/debian/rules.gen
+++ linux-kbuild-2.6-2.6.26/debian/rules.gen
@@ -0,0 +1,5 @@
+.NOTPARALLEL:
+binary-arch::
+	$(MAKE) -f debian/rules.real binary-arch MAJOR='2.6' VERSION='2.6.26' UPSTREAMVERSION='2.6.26'
+build::
+	$(MAKE) -f debian/rules.real build MAJOR='2.6' VERSION='2.6.26' UPSTREAMVERSION='2.6.26'
--- linux-kbuild-2.6-2.6.26.orig/debian/control.md5sum
+++ linux-kbuild-2.6-2.6.26/debian/control.md5sum
@@ -0,0 +1,4 @@
+0634cb921b2e1e6eef467f6ac30da086  debian/bin/gencontrol.py
+8c8efb63c8df9f252a40354d0134f61a  debian/changelog
+91291210f12b03b4f20a908bf5c2eebf  debian/templates/control.main.in
+0ad3e4d1e5166ece16fc4f2f130c3ddc  debian/templates/control.source.in
--- linux-kbuild-2.6-2.6.26.orig/debian/lib/python/debian_linux/gencontrol.py
+++ linux-kbuild-2.6-2.6.26/debian/lib/python/debian_linux/gencontrol.py
@@ -0,0 +1,312 @@
+from config import *
+from debian import *
+from utils import *
+
+class PackagesList(SortedDict):
+    def append(self, package):
+        self[package['Package']] = package
+
+    def extend(self, packages):
+        for package in packages:
+            self[package['Package']] = package
+
+class Makefile(object):
+    def __init__(self):
+        self.rules = {}
+        self.add('.NOTPARALLEL')
+
+    def add(self, name, deps = None, cmds = None):
+        if name in self.rules:
+            self.rules[name].add(deps, cmds)
+        else:
+            self.rules[name] = self.Rule(name, deps, cmds)
+
+    def write(self, out):
+        r = self.rules.keys()
+        r.sort()
+        for i in r:
+            self.rules[i].write(out)
+
+    class Rule(object):
+        def __init__(self, name, deps = None, cmds = None):
+            self.name = name
+            self.deps, self.cmds = set(), []
+            self.add(deps, cmds)
+
+        def add(self, deps = None, cmds = None):
+            if deps is not None:
+                self.deps.update(deps)
+            if cmds is not None:
+                self.cmds.append(cmds)
+
+        def write(self, out):
+            deps_string = ''
+            if self.deps:
+                deps = list(self.deps)
+                deps.sort()
+                deps_string = ' ' + ' '.join(deps)
+
+            if self.cmds:
+                if deps_string:
+                    out.write('%s::%s\n' % (self.name, deps_string))
+                for c in self.cmds:
+                    out.write('%s::\n' % self.name)
+                    for i in c:
+                        out.write('\t%s\n' % i)
+            else:
+                out.write('%s:%s\n' % (self.name, deps_string))
+
+class MakeFlags(dict):
+    def __repr__(self):
+        repr = super(flags, self).__repr__()
+        return "%s(%s)" % (self.__class__.__name__, repr)
+
+    def __str__(self):
+        return ' '.join(["%s='%s'" % i for i in self.iteritems()])
+
+    def copy(self):
+        return self.__class__(super(MakeFlags, self).copy())
+
+class Gencontrol(object):
+    makefile_targets = ('binary-arch', 'build', 'setup', 'source')
+
+    def __init__(self, config, templates):
+        self.config, self.templates = config, templates
+
+    def __call__(self):
+        packages = PackagesList()
+        makefile = Makefile()
+
+        self.do_source(packages)
+        self.do_main(packages, makefile)
+        self.do_extra(packages, makefile)
+
+        self.write_control(packages.itervalues())
+        self.write_makefile(makefile)
+
+    def do_source(self, packages):
+        source = self.templates["control.source"]
+        packages['source'] = self.process_package(source[0], self.vars)
+
+    def do_main(self, packages, makefile):
+        config_entry = self.config['base',]
+        vars = self.vars.copy()
+        vars.update(config_entry)
+
+        makeflags = MakeFlags()
+        extra = {}
+
+        self.do_main_setup(vars, makeflags, extra)
+        self.do_main_packages(packages, extra)
+        self.do_main_makefile(makefile, makeflags, extra)
+
+        for arch in iter(self.config['base',]['arches']):
+            self.do_arch(packages, makefile, arch, vars.copy(), makeflags.copy(), extra)
+
+    def do_main_setup(self, vars, makeflags, extra):
+        makeflags.update({
+            'MAJOR': self.version.linux_major,
+            'VERSION': self.version.linux_version,
+            'UPSTREAMVERSION': self.version.linux_upstream,
+            'ABINAME': self.abiname,
+        })
+
+    def do_main_makefile(self, makefile, makeflags, extra):
+        makefile.add('binary-indep', cmds = ["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags])
+
+    def do_main_packages(self, packages, extra):
+        pass
+
+    def do_extra(self, packages, makefile):
+        try:
+            templates_extra = self.templates["control.extra"]
+        except IOError:
+            return
+
+        packages.extend(self.process_packages(templates_extra, {}))
+        extra_arches = {}
+        for package in templates_extra:
+            arches = package['Architecture']
+            for arch in arches:
+                i = extra_arches.get(arch, [])
+                i.append(package)
+                extra_arches[arch] = i
+        archs = extra_arches.keys()
+        archs.sort()
+        for arch in archs:
+            cmds = []
+            for i in extra_arches[arch]:
+                tmp = []
+                if i.has_key('X-Version-Overwrite-Epoch'):
+                        tmp.append("-v1:%s" % self.version['source'])
+                cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
+            makefile.add('binary-arch_%s' % arch ['binary-arch_%s_extra' % arch])
+            makefile.add("binary-arch_%s_extra" % arch, cmds = cmds)
+
+    def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
+        config_base = self.config['base', arch]
+        vars.update(config_base)
+        vars['arch'] = arch
+
+        makeflags['ARCH'] = arch
+
+        self.do_arch_setup(vars, makeflags, arch, extra)
+        self.do_arch_makefile(makefile, arch, makeflags, extra)
+        self.do_arch_packages(packages, makefile, arch, vars, makeflags, extra)
+        self.do_arch_recurse(packages, makefile, arch, vars, makeflags, extra)
+
+    def do_arch_setup(self, vars, makeflags, arch, extra):
+        pass
+
+    def do_arch_makefile(self, makefile, arch, makeflags, extra):
+        for i in self.makefile_targets:
+            target1 = i
+            target2 = "%s_%s" % (i, arch)
+            makefile.add(target1, [target2])
+            makefile.add(target2, ['%s_real' % target2])
+            makefile.add('%s_real' % target2)
+
+    def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra):
+        pass
+
+    def do_arch_recurse(self, packages, makefile, arch, vars, makeflags, extra):
+        for featureset in self.config['base', arch]['featuresets']:
+            self.do_featureset(packages, makefile, arch, featureset, vars.copy(), makeflags.copy(), extra)
+
+    def do_featureset(self, packages, makefile, arch, featureset, vars, makeflags, extra):
+        config_base = self.config.merge('base', arch, featureset)
+        vars.update(config_base)
+
+        if not config_base.get('enabled', True):
+            return
+
+        makeflags['FEATURESET'] = featureset
+
+        vars['localversion'] = ''
+        if featureset != 'none':
+            vars['localversion'] = '-' + featureset
+
+        self.do_featureset_setup(vars, makeflags, arch, featureset, extra)
+        self.do_featureset_makefile(makefile, arch, featureset, makeflags, extra)
+        self.do_featureset_packages(packages, makefile, arch, featureset, vars, makeflags, extra)
+        self.do_featureset_recurse(packages, makefile, arch, featureset, vars, makeflags, extra)
+
+    def do_featureset_setup(self, vars, makeflags, arch, featureset, extra):
+        pass
+
+    def do_featureset_makefile(self, makefile, arch, featureset, makeflags, extra):
+        for i in self.makefile_targets:
+            target1 = "%s_%s" % (i, arch)
+            target2 = "%s_%s_%s" % (i, arch, featureset)
+            makefile.add(target1, [target2])
+            makefile.add(target2, ['%s_real' % target2])
+            makefile.add('%s_real' % target2)
+
+    def do_featureset_packages(self, packages, makefile, arch, featureset, vars, makeflags, extra):
+        pass
+
+    def do_featureset_recurse(self, packages, makefile, arch, featureset, vars, makeflags, extra):
+        for flavour in self.config['base', arch, featureset]['flavours']:
+            self.do_flavour(packages, makefile, arch, featureset, flavour, vars.copy(), makeflags.copy(), extra)
+
+    def do_flavour(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra):
+        config_base = self.config.merge('base', arch, featureset, flavour)
+        vars.update(config_base)
+
+        if not vars.has_key('longclass'):
+            vars['longclass'] = vars['class']
+
+        makeflags['FLAVOUR'] = flavour
+        vars['localversion'] += '-' + flavour
+
+        self.do_flavour_setup(vars, makeflags, arch, featureset, flavour, extra)
+        self.do_flavour_makefile(makefile, arch, featureset, flavour, makeflags, extra)
+        self.do_flavour_packages(packages, makefile, arch, featureset, flavour, vars, makeflags, extra)
+
+    def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour, extra):
+        for i in (
+            ('kernel-arch', 'KERNEL_ARCH'),
+            ('localversion', 'LOCALVERSION'),
+        ):  
+            if vars.has_key(i[0]):
+                makeflags[i[1]] = vars[i[0]]
+
+    def do_flavour_makefile(self, makefile, arch, featureset, flavour, makeflags, extra):
+        for i in self.makefile_targets:
+            target1 = "%s_%s_%s" % (i, arch, featureset)
+            target2 = "%s_%s_%s_%s" % (i, arch, featureset, flavour)
+            makefile.add(target1, [target2])
+            makefile.add(target2, ['%s_real' % target2])
+            makefile.add('%s_real' % target2)
+
+    def do_flavour_packages(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra):
+        pass
+
+    def process_relation(self, key, e, in_e, vars):
+        import copy
+        dep = copy.deepcopy(in_e[key])
+        for groups in dep:
+            for item in groups:
+                item.name = self.substitute(item.name, vars)
+        e[key] = dep
+
+    def process_description(self, e, in_e, vars):
+        in_desc = in_e['Description']
+        desc = in_desc.__class__()
+        desc.short = self.substitute(in_desc.short, vars)
+        for i in in_desc.long:
+            desc.append(self.substitute(i, vars))
+        e['Description'] = desc
+
+    def process_package(self, in_entry, vars):
+        e = Package()
+        for key, value in in_entry.iteritems():
+            if isinstance(value, PackageRelation):
+                self.process_relation(key, e, in_entry, vars)
+            elif key == 'Description':
+                self.process_description(e, in_entry, vars)
+            elif key[:2] == 'X-':
+                pass
+            else:
+                e[key] = self.substitute(value, vars)
+        return e
+
+    def process_packages(self, in_entries, vars):
+        entries = []
+        for i in in_entries:
+            entries.append(self.process_package(i, vars))
+        return entries
+
+    def process_version_linux(self, version, abiname):
+        return {
+            'upstreamversion': version.linux_upstream,
+            'version': version.linux_version,
+            'source_upstream': version.upstream,
+            'major': version.linux_major,
+            'abiname': abiname,
+        }
+
+    def substitute(self, s, vars):
+        if isinstance(s, (list, tuple)):
+            for i in xrange(len(s)):
+                s[i] = self.substitute(s[i], vars)
+            return s
+        def subst(match):
+            return vars[match.group(1)]
+        return re.sub(r'@([-_a-z]+)@', subst, s)
+
+    def write_control(self, list):
+        self.write_rfc822(file("debian/control", 'w'), list)
+
+    def write_makefile(self, makefile):
+        f = file("debian/rules.gen", 'w')
+        makefile.write(f)
+        f.close()
+
+    def write_rfc822(self, f, list):
+        for entry in list:
+            for key, value in entry.iteritems():
+                f.write("%s: %s\n" % (key, value))
+            f.write('\n')
+
+
--- linux-kbuild-2.6-2.6.26.orig/debian/lib/python/debian_linux/utils.py
+++ linux-kbuild-2.6-2.6.26/debian/lib/python/debian_linux/utils.py
@@ -0,0 +1,100 @@
+import debian, re, os, textwrap
+
+class SortedDict(dict):
+    __slots__ = '_list',
+
+    def __init__(self, entries = None):
+        super(SortedDict, self).__init__()
+        self._list = []
+        if entries is not None:
+            for key, value in entries:
+                self[key] = value
+
+    def __delitem__(self, key):
+        super(SortedDict, self).__delitem__(key)
+        self._list.remove(key)
+
+    def __setitem__(self, key, value):
+        super(SortedDict, self).__setitem__(key, value)
+        if key not in self._list:
+            self._list.append(key)
+
+    def iterkeys(self):
+        for i in iter(self._list):
+            yield i
+
+    def iteritems(self):
+        for i in iter(self._list):
+            yield (i, self[i])
+
+    def itervalues(self):
+        for i in iter(self._list):
+            yield self[i]
+
+class Templates(dict):
+    def __init__(self, dirs = ["debian/templates"]):
+        self.dirs = dirs
+
+    def __getitem__(self, key):
+        try:
+            return super(Templates, self).__getitem__(key)
+        except KeyError: pass
+        value = self._read(key)
+        super(Templates, self).__setitem__(key, value)
+        return value
+
+    def __setitem__(self, key, value):
+        raise NotImplemented()
+
+    def _read(self, name):
+        prefix, id = name.split('.', 1)
+
+        for dir in self.dirs:
+            filename = "%s/%s.in" % (dir, name)
+            if os.path.exists(filename):
+                f = file(filename)
+                if prefix == 'control':
+                    return self._read_control(f)
+                return f.read()
+        raise KeyError(name)
+
+    def _read_control(self, f):
+        entries = []
+
+        while True:
+            e = debian.Package()
+            last = None
+            lines = []
+            while True:
+                line = f.readline()
+                if not line:
+                    break
+                line = line.strip('\n')
+                if not line:
+                    break
+                if line[0] in ' \t':
+                    if not last:
+                        raise ValueError('Continuation line seen before first header')
+                    lines.append(line.lstrip())
+                    continue
+                if last:
+                    e[last] = '\n'.join(lines)
+                i = line.find(':')
+                if i < 0:
+                    raise ValueError("Not a header, not a continuation: ``%s''" % line)
+                last = line[:i]
+                lines = [line[i+1:].lstrip()]
+            if last:
+                e[last] = '\n'.join(lines)
+            if not e:
+                break
+
+            entries.append(e)
+
+        return entries
+
+class TextWrapper(textwrap.TextWrapper):
+    wordsep_re = re.compile(
+        r'(\s+|'                                  # any whitespace
+        r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')   # em-dash
+
--- linux-kbuild-2.6-2.6.26.orig/debian/lib/python/debian_linux/debian.py
+++ linux-kbuild-2.6-2.6.26/debian/lib/python/debian_linux/debian.py
@@ -0,0 +1,344 @@
+import itertools, os.path, re, utils
+
+class Changelog(list):
+    _rules = r"""
+^
+(?P<source>
+    \w[-+0-9a-z.]+
+)
+\ 
+\(
+(?P<version>
+    [^\(\)\ \t]+
+)
+\)
+\s+
+(?P<distribution>
+    [-+0-9a-zA-Z.]+
+)
+\;
+"""
+    _re = re.compile(_rules, re.X)
+
+    class Entry(object):
+        __slot__ = 'distribution', 'source', 'version'
+
+        def __init__(self, distribution, source, version):
+            self.distribution, self.source, self.version = distribution, source, version
+
+    def __init__(self, dir = '', version = None):
+        if version is None:
+            version = Version
+        f = file(os.path.join(dir, "debian/changelog"))
+        while True:
+            line = f.readline()
+            if not line:
+                break
+            match = self._re.match(line)
+            if not match:
+                continue
+            try:
+                v = version(match.group('version'))
+            except Exception:
+                if not len(self):
+                    raise
+                v = Version(match.group('version'))
+            self.append(self.Entry(match.group('distribution'), match.group('source'), v))
+
+class Version(object):
+    _version_rules = ur"""
+^
+(?:
+    (?P<epoch>
+        \d+
+    )
+    :
+)?
+(?P<upstream>
+    .+?
+)   
+(?:
+    -
+    (?P<debian>[^-]+)
+)?
+$
+"""
+    _version_re = re.compile(_version_rules, re.X)
+
+    def __init__(self, version):
+        match = self._version_re.match(version)
+        if match is None:
+            raise RuntimeError, "Invalid debian version"
+        self.epoch = None
+        if match.group("epoch") is not None:
+            self.epoch = int(match.group("epoch"))
+        self.upstream = match.group("upstream")
+        self.debian = match.group("debian")
+
+    def __str__(self):
+        return self.complete
+
+    @property
+    def complete(self):
+        if self.epoch is not None:
+            return "%d:%s" % (self.epoch, self.complete_noepoch)
+        return self.complete_noepoch
+
+    @property
+    def complete_noepoch(self):
+        if self.debian is not None:
+            return "%s-%s" % (self.upstream, self.debian)
+        return self.upstream
+
+class VersionLinux(Version):
+    _version_linux_rules = ur"""
+^
+(?P<version>
+    (?P<major>\d+\.\d+)
+    \.
+    \d+
+)
+(?:
+    (\.\d+)
+    |
+    ~
+    (?P<modifier>
+        .+?
+    )
+)?
+(?:
+    \.dfsg\.
+    (?P<dfsg>
+        \d+
+    )
+)?
+-
+(?:[^-]+)
+$
+"""
+    _version_linux_re = re.compile(_version_linux_rules, re.X)
+
+    def __init__(self, version):
+        super(VersionLinux, self).__init__(version)
+        match = self._version_linux_re.match(version)
+        if match is None:
+            raise RuntimeError, "Invalid debian linux version"
+        d = match.groupdict()
+        self.linux_major = d['major']
+        self.linux_modifier = d['modifier']
+        self.linux_version = d['version']
+        if d['modifier'] is not None:
+            self.linux_upstream = '-'.join((d['version'], d['modifier']))
+        else:
+            self.linux_upstream = d['version']
+        self.linux_dfsg = d['dfsg']
+ 
+class PackageFieldList(list):
+    def __init__(self, value = None):
+        self.extend(value)
+
+    def __str__(self):
+        return ' '.join(self)
+
+    def _extend(self, value):
+        if value is not None:
+            self.extend([j.strip() for j in re.split('\s', value.strip())])
+
+    def extend(self, value):
+        if isinstance(value, str):
+            self._extend(value)
+        else:
+            super(PackageFieldList, self).extend(value)
+
+class PackageDescription(object):
+    __slots__ = "short", "long"
+
+    def __init__(self, value = None):
+        self.long = []
+        if value is not None:
+            self.short, long = value.split("\n", 1)
+            self.append(long)
+        else:
+            self.short = None
+
+    def __str__(self):
+        ret = self.short + '\n'
+        w = utils.TextWrapper(width = 74, fix_sentence_endings = True)
+        pars = []
+        for i in self.long:
+            pars.append('\n '.join(w.wrap(i)))
+        return self.short + '\n ' + '\n .\n '.join(pars)
+
+    def append(self, str):
+        str = str.strip()
+        if str:
+            self.long.extend(str.split("\n.\n"))
+
+class PackageRelation(list):
+    def __init__(self, value = None):
+        if value is not None:
+            self.extend(value)
+
+    def __str__(self):
+        return ', '.join([str(i) for i in self])
+
+    def _match(self, value):
+        for i in self:
+            if i._match(value):
+                return i
+        return None
+
+    def append(self, value):
+        if isinstance(value, basestring):
+            value = PackageRelationGroup(value)
+        elif not isinstance(value, PackageRelationGroup):
+            raise ValueError, "got %s" % type(value)
+        j = self._match(value)
+        if j:
+            j._updateArches(value)
+        else:
+            super(PackageRelation, self).append(value)
+
+    def extend(self, value):
+        if isinstance(value, basestring):
+            value = [j.strip() for j in re.split(',', value.strip())]
+        elif not isinstance(value, (list, tuple)):
+            raise ValueError, "got %s" % type(value)
+        for i in value:
+            self.append(i)
+
+class PackageRelationGroup(list):
+    def __init__(self, value = None):
+        if value is not None:
+            self.extend(value)
+
+    def __str__(self):
+        return ' | '.join([str(i) for i in self])
+
+    def _match(self, value):
+        for i, j in itertools.izip(self, value):
+            if i.name != j.name or i.version != j.version:
+                return None
+        return self
+
+    def _updateArches(self, value):
+        for i, j in itertools.izip(self, value):
+            if i.arches:
+                for arch in j.arches:
+                    if arch not in i.arches:
+                        i.arches.append(arch)
+
+    def append(self, value):
+        if isinstance(value, basestring):
+            value = PackageRelationEntry(value)
+        elif not isinstance(value, PackageRelationEntry):
+            raise ValueError
+        super(PackageRelationGroup, self).append(value)
+
+    def extend(self, value):
+        if isinstance(value, basestring):
+            value = [j.strip() for j in re.split('\|', value.strip())]
+        elif not isinstance(value, (list, tuple)):
+            raise ValueError
+        for i in value:
+            self.append(i)
+
+class PackageRelationEntry(object):
+    __slots__ = "name", "operator", "version", "arches"
+
+    _re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
+
+    class _operator(object):
+        OP_LT = 1; OP_LE = 2; OP_EQ = 3; OP_NE = 4; OP_GE = 5; OP_GT = 6
+        operators = { '<<': OP_LT, '<=': OP_LE, '=':  OP_EQ, '!=': OP_NE, '>=': OP_GE, '>>': OP_GT }
+        operators_neg = { OP_LT: OP_GE, OP_LE: OP_GT, OP_EQ: OP_NE, OP_NE: OP_EQ, OP_GE: OP_LT, OP_GT: OP_LE }
+        operators_text = dict([(b, a) for a, b in operators.iteritems()])
+
+        __slots__ = '_op',
+
+        def __init__(self, value):
+            self._op = self.operators[value]
+
+        def __neg__(self):
+            return self.__class__(self.operators_text[self.operators_neg[self._op]])
+
+        def __str__(self):
+            return self.operators_text[self._op]
+
+    def __init__(self, value = None):
+        if isinstance(value, basestring):
+            self.parse(value)
+        else:
+            raise ValueError
+
+    def __str__(self):
+        ret = [self.name]
+        if self.operator is not None and self.version is not None:
+            ret.extend([' (', str(self.operator), ' ', self.version, ')'])
+        if self.arches:
+            ret.extend([' [', ' '.join(self.arches), ']'])
+        return ''.join(ret)
+
+    def parse(self, value):
+        match = self._re.match(value)
+        if match is None:
+            raise RuntimeError, "Can't parse dependency %s" % value
+        match = match.groups()
+        self.name = match[0]
+        if match[1] is not None:
+            self.operator = self._operator(match[1])
+        else:
+            self.operator = None
+        self.version = match[2]
+        if match[3] is not None:
+            self.arches = re.split('\s+', match[3])
+        else:
+            self.arches = []
+
+class Package(dict):
+    _fields = utils.SortedDict((
+        ('Package', str),
+        ('Source', str),
+        ('Architecture', PackageFieldList),
+        ('Section', str),
+        ('Priority', str),
+        ('Maintainer', str),
+        ('Uploaders', str),
+        ('Standards-Version', str),
+        ('Build-Depends', PackageRelation),
+        ('Build-Depends-Indep', PackageRelation),
+        ('Provides', PackageRelation),
+        ('Pre-Depends', PackageRelation),
+        ('Depends', PackageRelation),
+        ('Recommends', PackageRelation),
+        ('Suggests', PackageRelation),
+        ('Replaces', PackageRelation),
+        ('Conflicts', PackageRelation),
+        ('Description', PackageDescription),
+    ))
+
+    def __setitem__(self, key, value):
+        try:
+            cls = self._fields[key]
+            if not isinstance(value, cls):
+                value = cls(value)
+        except KeyError: pass
+        super(Package, self).__setitem__(key, value)
+
+    def iterkeys(self):
+        keys = set(self.keys())
+        for i in self._fields.iterkeys():
+            if self.has_key(i):
+                keys.remove(i)
+                yield i
+        for i in keys:
+            yield i
+
+    def iteritems(self):
+        for i in self.iterkeys():
+            yield (i, self[i])
+
+    def itervalues(self):
+        for i in self.iterkeys():
+            yield self[i]
+
--- linux-kbuild-2.6-2.6.26.orig/debian/lib/python/debian_linux/config.py
+++ linux-kbuild-2.6-2.6.26/debian/lib/python/debian_linux/config.py
@@ -0,0 +1,209 @@
+import os, os.path, re, sys, textwrap
+
+__all__ = [
+    'ConfigParser',
+    'ConfigReaderCore',
+]
+
+class SchemaItemBoolean(object):
+    def __call__(self, i):
+        i = i.strip().lower()
+        if i in ("true", "1"):
+            return True
+        if i in ("false", "0"):
+            return False
+        raise Error
+
+class SchemaItemList(object):
+    def __init__(self, type = "\s+"):
+        self.type = type
+
+    def __call__(self, i):
+        i = i.strip()
+        if not i:
+            return []
+        return [j.strip() for j in re.split(self.type, i)]
+
+class ConfigReaderCore(dict):
+    config_name = "defines"
+
+    schemas = {
+        'base': {
+            'arches': SchemaItemList(),
+            'enabled': SchemaItemBoolean(),
+            'featuresets': SchemaItemList(),
+            'flavours': SchemaItemList(),
+            'modules': SchemaItemBoolean(),
+        },
+        'image': {
+            'configs': SchemaItemList(),
+            'initramfs': SchemaItemBoolean(),
+            'initramfs-generators': SchemaItemList(),
+        },
+        'relations': {
+        },
+        'xen': {
+            'dom0-support': SchemaItemBoolean(),
+            'versions': SchemaItemList(),
+        }
+    }
+
+    def __init__(self, dirs = []):
+        self._dirs = dirs
+        self._read_base()
+
+    def _read_arch(self, arch):
+        config = ConfigParser(self.schemas)
+        config.read(self.get_files("%s/%s" % (arch, self.config_name)))
+
+        featuresets = config['base',].get('featuresets', [])
+        flavours = config['base',].get('flavours', [])
+
+        for section in iter(config):
+            if section[0] in featuresets:
+                real = (section[-1], arch, section[0])
+            elif len(section) > 1:
+                real = (section[-1], arch, None) + section[:-1]
+            else:
+                real = (section[-1], arch) + section[:-1]
+            s = self.get(real, {})
+            s.update(config[section])
+            self[tuple(real)] = s
+
+        for featureset in featuresets:
+            self._read_arch_featureset(arch, featureset)
+
+        if flavours:
+            base = self['base', arch]
+            featuresets.insert(0, 'none')
+            base['featuresets'] = featuresets
+            del base['flavours']
+            self['base', arch] = base
+            self['base', arch, 'none'] = {'flavours': flavours, 'implicit-flavour': True}
+
+    def _read_arch_featureset(self, arch, featureset):
+        config = ConfigParser(self.schemas)
+        config.read(self.get_files("%s/%s/%s" % (arch, featureset, self.config_name)))
+
+        flavours = config['base',].get('flavours', [])
+
+        for section in iter(config):
+            real = (section[-1], arch, featureset) + section[:-1]
+            s = self.get(real, {})
+            s.update(config[section])
+            self[tuple(real)] = s
+
+    def _read_base(self):
+        config = ConfigParser(self.schemas)
+        config.read(self.get_files(self.config_name))
+
+        arches = config['base',]['arches']
+        featuresets = config['base',]['featuresets']
+
+        for section in iter(config):
+            if section[0].startswith('featureset-'):
+                real = (section[-1], None, section[0].lstrip('featureset-'))
+            else:
+                real = (section[-1],) + section[1:]
+            self[real] = config[section]
+
+        for arch in arches:
+            self._read_arch(arch)
+        for featureset in featuresets:
+            self._read_featureset(featureset)
+
+    def _read_featureset(self, featureset):
+        config = ConfigParser(self.schemas)
+        config.read(self.get_files("featureset-%s/%s" % (featureset, self.config_name)))
+
+        for section in iter(config):
+            real = (section[-1], None, featureset)
+            s = self.get(real, {})
+            s.update(config[section])
+            self[real] = s
+
+    def get_files(self, name):
+        return [os.path.join(i, name) for i in self._dirs if i]
+
+    def merge(self, section, arch = None, featureset = None, flavour = None):
+        ret = {}
+        ret.update(self.get((section,), {}))
+        if featureset:
+            ret.update(self.get((section, None, featureset), {}))
+        if arch:
+            ret.update(self.get((section, arch), {}))
+        if arch and featureset:
+            ret.update(self.get((section, arch, featureset), {}))
+        if arch and featureset and flavour:
+            ret.update(self.get((section, arch, None, flavour), {}))
+            ret.update(self.get((section, arch, featureset, flavour), {}))
+        return ret
+
+class ConfigParser(object):
+    __slots__ = '_config', 'schemas'
+
+    def __init__(self, schemas):
+        self.schemas = schemas
+
+        from ConfigParser import RawConfigParser
+        self._config = config = RawConfigParser()
+
+    def __getitem__(self, key):
+        return self._convert()[key]
+
+    def __iter__(self):
+        return iter(self._convert())
+
+    def __str__(self):
+        return '<%s(%s)>' % (self.__class__.__name__, self._convert())
+
+    def _convert(self):
+        ret = {}
+        for section in self._config.sections():
+            data = {}
+            for key, value in self._config.items(section):
+                data[key] = value
+            s1 = section.split('_')
+            if s1[-1] in self.schemas:
+                ret[tuple(s1)] = self.SectionSchema(data, self.schemas[s1[-1]])
+            else:
+                ret[(section,)] = self.Section(data)
+        return ret
+
+    def keys(self):
+        return self._convert().keys()
+
+    def read(self, data):
+        return self._config.read(data)
+
+    class Section(dict):
+        def __init__(self, data):
+            super(ConfigParser.Section, self).__init__(data)
+
+        def __str__(self):
+            return '<%s(%s)>' % (self.__class__.__name__, self._data)
+
+    class SectionSchema(Section):
+        __slots__ = ()
+
+        def __init__(self, data, schema):
+            for key in data.keys():
+                try:
+                    data[key] = schema[key](data[key])
+                except KeyError: pass
+            super(ConfigParser.SectionSchema, self).__init__(data)
+
+if __name__ == '__main__':
+    import sys
+    config = ConfigReaderCore(['debian/config'])
+    sections = config.keys()
+    sections.sort()
+    for section in sections:
+        print "[%s]" % (section,)
+        items = config[section]
+        items_keys = items.keys()
+        items_keys.sort()
+        for item in items:
+            print "%s: %s" % (item, items[item])
+        print
+
--- linux-kbuild-2.6-2.6.26.orig/debian/bin/gencontrol.py
+++ linux-kbuild-2.6-2.6.26/debian/bin/gencontrol.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python2.4
+
+import sys
+sys.path.append("debian/lib/python")
+
+from debian_linux.debian import *
+from debian_linux.gencontrol import PackagesList, Makefile, MakeFlags
+from debian_linux.utils import *
+
+class gencontrol(object):
+    makefile_targets = ('binary-arch', 'build')
+
+    def __init__(self, underlay = None):
+        self.templates = Templates(['debian/templates'])
+        self.process_changelog()
+
+    def __call__(self):
+        packages = PackagesList()
+        makefile = Makefile()
+
+        self.do_source(packages)
+        self.do_main(packages, makefile)
+
+        self.write_control(packages.itervalues())
+        self.write_makefile(makefile)
+
+    def do_source(self, packages):
+        source = self.templates["control.source"]
+        packages['source'] = self.process_package(source[0], self.vars)
+
+    def do_main(self, packages, makefile):
+        vars = self.vars.copy()
+        makeflags = MakeFlags()
+
+        self.do_main_setup(vars, makeflags)
+        self.do_main_packages(packages)
+        self.do_main_makefile(makefile, makeflags)
+
+    def do_main_setup(self, vars, makeflags):
+        makeflags.update({
+            'MAJOR': self.version.linux_major,
+            'VERSION': self.version.linux_version,
+            'UPSTREAMVERSION': self.version.linux_upstream,
+        })
+
+    def do_main_makefile(self, makefile, makeflags):
+        for i in self.makefile_targets:
+            makefile.add(i, cmds = ["$(MAKE) -f debian/rules.real %s %s" % (i, makeflags)])
+
+    def do_main_packages(self, packages):
+        main = self.templates["control.main"]
+        packages.extend(self.process_packages(main, self.vars))
+
+    def process_changelog(self):
+        changelog = Changelog(version = VersionLinux)
+        self.version = version = changelog[0].version
+        self.vars = {
+            'upstreamversion': version.linux_upstream,
+            'version': version.linux_version,
+            'source_upstream': version.upstream,
+            'major': version.linux_major,
+        }
+
+    def process_relation(self, key, e, in_e, vars):
+        import copy
+        dep = copy.deepcopy(in_e[key])
+        for groups in dep:
+            for item in groups:
+                item.name = self.substitute(item.name, vars)
+        e[key] = dep
+
+    def process_description(self, e, in_e, vars):
+        in_desc = in_e['Description']
+        desc = in_desc.__class__()
+        desc.short = self.substitute(in_desc.short, vars)
+        for i in in_desc.long:
+            desc.append(self.substitute(i, vars))
+        e['Description'] = desc
+
+    def process_package(self, in_entry, vars):
+        e = Package()
+        for key, value in in_entry.iteritems():
+            if isinstance(value, PackageRelation):
+                self.process_relation(key, e, in_entry, vars)
+            elif key == 'Description':
+                self.process_description(e, in_entry, vars)
+            elif key[:2] == 'X-':
+                pass
+            else:
+                e[key] = self.substitute(value, vars)
+        return e
+
+    def process_packages(self, in_entries, vars):
+        entries = []
+        for i in in_entries:
+            entries.append(self.process_package(i, vars))
+        return entries
+
+    def substitute(self, s, vars):
+        if isinstance(s, (list, tuple)):
+            for i in xrange(len(s)):
+                s[i] = self.substitute(s[i], vars)
+            return s
+        def subst(match):
+            return vars[match.group(1)]
+        return re.sub(r'@([a-z_]+)@', subst, s)
+
+    def write_control(self, list):
+        self.write_rfc822(file("debian/control", 'w'), list)
+
+    def write_makefile(self, makefile):
+        f = file("debian/rules.gen", 'w')
+        makefile.write(f)
+        f.close()
+
+    def write_rfc822(self, f, list):
+        for entry in list:
+            for key, value in entry.iteritems():
+                f.write("%s: %s\n" % (key, value))
+            f.write('\n')
+
+if __name__ == '__main__':
+    gencontrol()()
--- linux-kbuild-2.6-2.6.26.orig/debian/bin/genorig.py
+++ linux-kbuild-2.6-2.6.26/debian/bin/genorig.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append("debian/lib/python")
+
+import os, os.path, re, shutil
+from debian_linux.debian import Changelog, VersionLinux
+
+class Main(object):
+    def __init__(self, input_tar, input_patch, override_version):
+        self.log = sys.stdout.write
+
+        self.input_tar = input_tar
+        self.input_patch = input_patch
+
+        changelog = Changelog(version = VersionLinux)[0]
+        source = changelog.source
+        version = changelog.version
+
+        if override_version:
+            version = VersionLinux('%s-undef' % override_version)
+
+        self.log('Using source name %s, version %s\n' % (source, version.upstream))
+
+        self.orig = '%s-%s' % (source, version.upstream)
+        self.orig_tar = '%s_%s.orig.tar.gz' % (source, version.upstream)
+
+    def __call__(self):
+        import tempfile
+        self.dir = tempfile.mkdtemp(prefix = 'genorig', dir = 'debian')
+        try:
+            self.upstream_extract()
+            self.upstream_patch()
+            self.generate()
+            self.tar()
+        finally:
+            shutil.rmtree(self.dir)
+
+    def upstream_extract(self):
+        self.log("Extracting tarball %s\n" % self.input_tar)
+        match = re.match(r'(^|.*/)(?P<dir>linux-[\d.]+(-\S+)?)\.tar(\.(?P<extension>(bz2|gz)))?$', self.input_tar)
+        if not match:
+            raise RuntimeError("Can't identify name of tarball")
+        cmdline = ['tar -xf', self.input_tar, '-C', self.dir]
+        if match.group('extension') == 'bz2':
+            cmdline.append('-j')
+        elif match.group('extension') == 'gz':
+            cmdline.append('-z')
+        if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
+            raise RuntimeError("Can't extract tarball")
+        os.rename(os.path.join(self.dir, match.group('dir')), os.path.join(self.dir, 'temp'))
+
+    def upstream_patch(self):
+        if self.input_patch is None:
+            return
+        self.log("Patching source with %s\n" % self.input_patch)
+        match = re.match(r'(^|.*/)patch-\d+\.\d+\.\d+(-\S+?)?(\.(?P<extension>(bz2|gz)))?$', self.input_patch)
+        if not match:
+            raise RuntimeError("Can't identify name of patch")
+        cmdline = []
+        if match.group('extension') == 'bz2':
+            cmdline.append('bzcat')
+        elif match.group('extension') == 'gz':
+            cmdline.append('zcat')
+        else:
+            cmdline.append('cat')
+        cmdline.append(self.input_patch)
+        cmdline.append('| (cd %s; patch -p1 -f -s -t --no-backup-if-mismatch)' % os.path.join(self.dir, 'temp'))
+        if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
+            raise RuntimeError("Can't patch source")
+
+    def generate(self):
+        self.log("Generate orig\n")
+        orig = os.path.join(self.dir, self.orig)
+        temp = os.path.join(self.dir, 'temp')
+        os.makedirs(os.path.join(orig, 'include', 'linux'))
+        shutil.copyfile(os.path.join(temp, 'COPYING'), os.path.join(orig, 'COPYING'))
+        for i in ('input.h', 'license.h', 'mod_devicetable.h'):
+            shutil.copyfile(os.path.join(temp, 'include', 'linux', i), os.path.join(orig, 'include', 'linux', i))
+        shutil.copytree(os.path.join(temp, 'scripts'), os.path.join(orig, 'scripts'))
+
+    def tar(self):
+        out = os.path.join("../orig", self.orig_tar)
+        try:
+            os.mkdir("../orig")
+        except OSError: pass
+        try:
+            os.stat(out)
+            raise RuntimeError("Destination already exists")
+        except OSError: pass
+        self.log("Generate tarball %s\n" % out)
+        cmdline = ['tar -czf', out, '-C', self.dir, self.orig]
+        try:
+            if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
+                raise RuntimeError("Can't patch source")
+            os.chmod(out, 0644)
+        except:
+            try:
+                os.unlink(out)
+            except OSError:
+                pass
+            raise
+
+if __name__ == '__main__':
+    from optparse import OptionParser
+    parser = OptionParser(usage = "%prog [OPTION]... TAR [PATCH]")
+    parser.add_option("-V", "--override-version", dest = "override_version", help = "Override version", metavar = "VERSION")
+    options, args = parser.parse_args()
+
+    input_tar = args[0]
+    input_patch = None
+    if len(args) > 1:
+        input_patch = args[1]
+
+    Main(input_tar, input_patch, options.override_version)()
--- linux-kbuild-2.6-2.6.26.orig/debian/templates/control.source.in
+++ linux-kbuild-2.6-2.6.26/debian/templates/control.source.in
@@ -0,0 +1,7 @@
+Source: linux-kbuild-@major@
+Section: devel
+Priority: optional
+Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
+Uploaders: Bastian Blank <waldi@debian.org>
+Standards-Version: 3.7.3
+Build-Depends: debhelper (>= 4.1.0)
--- linux-kbuild-2.6-2.6.26.orig/debian/templates/control.main.in
+++ linux-kbuild-2.6-2.6.26/debian/templates/control.main.in
@@ -0,0 +1,7 @@
+Package: linux-kbuild-@version@
+Architecture: any
+Section: devel
+Priority: optional
+Depends: ${shlibs:Depends}
+Description: Kbuild infrastructure for Linux @version@
+ This package provides the kbuild infrastructure for the headers packages for Linux kernel version @version@.
--- linux-kbuild-2.6-2.6.26.orig/src/Makefile.inc
+++ linux-kbuild-2.6-2.6.26/src/Makefile.inc
@@ -0,0 +1,44 @@
+SHELL = /bin/sh -e
+
+CC = gcc
+CXX = g++
+CFLAGS += -Wall -O2
+CXXFLAGS = $(CFLAGS)
+
+all: all-local all-recursive
+install: install-local install-recursive
+
+all-recursive install-recursive:
+	@target=$(shell echo $@ | sed s/-recursive//); \
+	list='$(SUBDIRS)'; \
+	for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  $(MAKE) -C $$subdir $$target \
+	  || exit 1; \
+	done
+
+all-local: $(PROGS)
+
+install-local: install-local-dir install-local-progs install-local-scripts install-local-data
+
+install-local-dir:
+	install -d "$(prefix)/scripts/$(OUTDIR)"
+
+install-local-progs: $(PROGS)
+	@for p in $^; do \
+	  echo " install -m755 '$$p' '$(prefix)/scripts/$(OUTDIR)'"; \
+	  install -m755 "$$p" "$(prefix)/scripts/$(OUTDIR)"; \
+	done
+
+install-local-scripts: $(SCRIPTS)
+	@for p in $^; do \
+	  echo " install -m755 '$$p' '$(prefix)/scripts/$(OUTDIR)'"; \
+	  install -m755 "$$p" "$(prefix)/scripts/$(OUTDIR)"; \
+	done
+
+install-local-data: $(DATA)
+	@for p in $^; do \
+	  echo " install -m644 '$$p' '$(prefix)/scripts/$(OUTDIR)'"; \
+	  install -m644 "$$p" "$(prefix)/scripts/$(OUTDIR)"; \
+	done
+
--- linux-kbuild-2.6-2.6.26.orig/src/Makefile
+++ linux-kbuild-2.6-2.6.26/src/Makefile
@@ -0,0 +1,42 @@
+PROGS = \
+	bin2c \
+	conmakehash \
+	kallsyms \
+	pnmtologo
+
+DATA = \
+	Kbuild.include \
+	Makefile.build \
+	Makefile.clean \
+	Makefile.host \
+	Makefile.lib \
+	Makefile.modinst \
+	Makefile.modpost \
+	mkversion
+
+SCRIPTS =  \
+	checkincludes.pl \
+	checkstack.pl \
+	checkversion.pl \
+	gcc-version.sh \
+	gcc-x86_64-has-stack-protector.sh \
+	gen_initramfs_list.sh \
+	kernel-doc \
+	Lindent \
+	makelst \
+	mksysmap \
+	mkuboot.sh \
+	namespace.pl \
+	patch-kernel \
+	setlocalversion \
+	ver_linux
+
+SUBDIRS = \
+	basic \
+	genksyms \
+	kconfig \
+	mod
+
+VPATH = $(top_srcdir)/scripts
+
+include Makefile.inc
--- linux-kbuild-2.6-2.6.26.orig/src/mod/Makefile.real
+++ linux-kbuild-2.6-2.6.26/src/mod/Makefile.real
@@ -0,0 +1,12 @@
+PROGS = modpost.real-$(TYPE)
+
+CFLAGS += -I$(top_srcdir)/include
+
+include ../Makefile.inc
+
+modpost.real-$(TYPE): file2alias.real-$(TYPE).o modpost.real-$(TYPE).o sumversion.real-$(TYPE).o
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+%.real-$(TYPE).o: $(SOURCEDIR)/%.c
+	$(CC) -I real-$(TYPE) $(CFLAGS) -c -o $@ $^
+
--- linux-kbuild-2.6-2.6.26.orig/src/mod/elfconfig.h
+++ linux-kbuild-2.6-2.6.26/src/mod/elfconfig.h
@@ -0,0 +1,7 @@
+#include <endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define HOST_ELFDATA ELFDATA2LSB
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define HOST_ELFDATA ELFDATA2MSB
+#endif
--- linux-kbuild-2.6-2.6.26.orig/src/mod/modpost.c
+++ linux-kbuild-2.6-2.6.26/src/mod/modpost.c
@@ -0,0 +1,81 @@
+#include <elf.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main (int argc, char *argv[])
+{
+  char const *data, *class;
+  char prog[1024];
+  unsigned char ei[EI_NIDENT];
+  int opt;
+  FILE *file;
+
+  while ((opt = getopt (argc, argv, "acei:I:K:mM:o:sSw")) != -1)
+  { 
+    switch(opt)
+    {
+      case 'a':
+      case 'e':
+      case 'i':
+      case 'c':
+      case 'I':
+      case 'K':
+      case 'm':
+      case 'M':
+      case 'o':
+      case 's':
+      case 'S':
+      case 'w':
+        break;
+      default:
+        return EXIT_FAILURE;
+    }
+  }
+
+  if (optind == argc)
+    return EXIT_SUCCESS;
+
+  if (!(file = fopen (argv[optind], "r")))
+  {
+    fprintf (stderr, "Can't open file\n");
+    return EXIT_FAILURE;
+  }
+
+  if (fread (ei, 1, EI_NIDENT, file) != EI_NIDENT)
+  {
+    fprintf (stderr, "Error: input truncated\n");
+    return EXIT_FAILURE;
+  }
+
+  if (memcmp (ei, ELFMAG, SELFMAG) != 0)
+  {
+    fprintf (stderr, "Error: not ELF\n");
+    return EXIT_FAILURE;
+  }
+  switch (ei[EI_DATA]) {
+    case ELFDATA2LSB:
+      data = "lsb";
+      break;
+    case ELFDATA2MSB:
+      data = "msb";
+      break;
+    default:
+      return EXIT_FAILURE;
+  }
+  switch (ei[EI_CLASS]) {
+    case ELFCLASS32:
+      class = "32";
+      break;
+    case ELFCLASS64:
+      class = "64";
+      break;
+    default:
+      return EXIT_FAILURE;
+  }
+  snprintf (prog, sizeof prog, "%s.real-%s-%s", argv[0], data, class);
+
+  return execv (prog, argv);
+}
--- linux-kbuild-2.6-2.6.26.orig/src/mod/Makefile
+++ linux-kbuild-2.6-2.6.26/src/mod/Makefile
@@ -0,0 +1,20 @@
+PROGS = \
+	modpost \
+	modpost.real-lsb-32 \
+	modpost.real-lsb-64 \
+	modpost.real-msb-32 \
+	modpost.real-msb-64
+
+OUTDIR = mod
+
+modpost.real-%:
+	$(MAKE) -f Makefile.real TYPE=$* SOURCEDIR=$(top_srcdir)/scripts/mod
+
+%: %.o
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+include ../Makefile.inc
+
+clean:
+	rm $(PROGS) *.o
+
--- linux-kbuild-2.6-2.6.26.orig/src/mod/real-lsb-32/elfconfig.h
+++ linux-kbuild-2.6-2.6.26/src/mod/real-lsb-32/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS32
+#define KERNEL_ELFDATA ELFDATA2LSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
--- linux-kbuild-2.6-2.6.26.orig/src/mod/real-msb-32/elfconfig.h
+++ linux-kbuild-2.6-2.6.26/src/mod/real-msb-32/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS32
+#define KERNEL_ELFDATA ELFDATA2MSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
--- linux-kbuild-2.6-2.6.26.orig/src/mod/real-lsb-64/elfconfig.h
+++ linux-kbuild-2.6-2.6.26/src/mod/real-lsb-64/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS64
+#define KERNEL_ELFDATA ELFDATA2LSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
--- linux-kbuild-2.6-2.6.26.orig/src/mod/real-msb-64/elfconfig.h
+++ linux-kbuild-2.6-2.6.26/src/mod/real-msb-64/elfconfig.h
@@ -0,0 +1,4 @@
+#define KERNEL_ELFCLASS ELFCLASS64
+#define KERNEL_ELFDATA ELFDATA2MSB
+#define MODULE_SYMBOL_PREFIX ""
+#include "../elfconfig.h"
--- linux-kbuild-2.6-2.6.26.orig/src/genksyms/Makefile
+++ linux-kbuild-2.6-2.6.26/src/genksyms/Makefile
@@ -0,0 +1,18 @@
+PROGS = genksyms
+
+OUTDIR = genksyms
+VPATH = $(top_srcdir)/scripts/genksyms
+
+CFLAGS += -I$(top_srcdir)/scripts/genksyms
+
+genksyms: genksyms.o parse.o lex.o
+
+lex.o: keywords.c parse.h
+
+%.c: %.c_shipped
+	ln -s $< $@
+
+%.h: %.h_shipped
+	ln -s $< $@
+
+include ../Makefile.inc
--- linux-kbuild-2.6-2.6.26.orig/src/kconfig/Makefile
+++ linux-kbuild-2.6-2.6.26/src/kconfig/Makefile
@@ -0,0 +1,18 @@
+PROGS = conf
+
+OUTDIR = kconfig
+VPATH = $(top_srcdir)/scripts/kconfig
+
+CFLAGS += -I$(top_srcdir)/scripts/kconfig
+
+conf: conf.o zconf.tab.o
+
+zconf.tab.c: zconf.hash.c lex.zconf.c
+
+%.c: %.c_shipped
+	ln -s $< $@
+
+%.h: %.h_shipped
+	ln -s $< $@
+
+include ../Makefile.inc
--- linux-kbuild-2.6-2.6.26.orig/src/basic/Makefile
+++ linux-kbuild-2.6-2.6.26/src/basic/Makefile
@@ -0,0 +1,8 @@
+PROGS = \
+	docproc \
+	fixdep
+
+OUTDIR = basic
+VPATH = $(top_srcdir)/scripts/basic
+
+include ../Makefile.inc
