summaryrefslogtreecommitdiff
path: root/debian/modules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/modules')
-rw-r--r--debian/modules/gencontrol.py62
-rw-r--r--debian/modules/rules.defs3
-rw-r--r--debian/modules/rules.include61
-rw-r--r--debian/modules/rules.real.include16
4 files changed, 142 insertions, 0 deletions
diff --git a/debian/modules/gencontrol.py b/debian/modules/gencontrol.py
new file mode 100644
index 00000000..9dce85e0
--- /dev/null
+++ b/debian/modules/gencontrol.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append(sys.path[0] + "/../lib/python")
+import debian_linux.gencontrol
+from debian_linux.config import *
+from debian_linux.debian import *
+
+class gencontrol(debian_linux.gencontrol.gencontrol):
+ def __init__(self, config):
+ super(gencontrol, self).__init__(config)
+ self.process_config_version(config_parser({}, [sys.path[0] + "/../version"]))
+
+ def do_main_packages(self, packages, extra):
+ vars = self.vars
+
+ main = self.templates["control.main"]
+ packages.extend(self.process_packages(main, vars))
+
+ packages['source']['Build-Depends'].extend(
+ ['linux-support-%s%s' % (self.version['upstream'], self.abiname)]
+ )
+ packages['source']['Build-Depends'].extend(
+ ['linux-headers-%s%s-all-%s [%s]' % (self.version['upstream'], self.abiname, arch, arch)
+ for arch in self.config['base',]['arches']],
+ )
+
+ def do_flavour(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
+ config_entry = self.config.merge('base', arch, subarch, flavour)
+ if config_entry.get('modules', True) is False:
+ return
+
+ super(gencontrol, self).do_flavour(packages, makefile, arch, subarch, flavour, vars, makeflags, extra)
+
+ def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
+ modules = self.templates["control.modules"]
+ modules = self.process_packages(modules, vars)
+
+ for package in modules:
+ name = package['Package']
+ if packages.has_key(name):
+ package = packages.get(name)
+ package['Architecture'].append(arch)
+ else:
+ package['Architecture'] = [arch]
+ packages.append(package)
+
+ cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-flavour %s" % makeflags]
+ cmds_build = ["$(MAKE) -f debian/rules.real build %s" % makeflags]
+ cmds_setup = ["$(MAKE) -f debian/rules.real setup-flavour %s" % makeflags]
+ makefile.add('binary-arch_%s_%s_%s_real' % (arch, subarch, flavour), cmds = cmds_binary_arch)
+ makefile.add('build_%s_%s_%s_real' % (arch, subarch, flavour), cmds = cmds_build)
+ makefile.add('setup_%s_%s_%s_real' % (arch, subarch, flavour), cmds = cmds_setup)
+
+ def process_config_version(self, config):
+ entry = config['version',]
+ self.version = parse_version(entry['source'])
+ self.abiname = entry['abiname']
+ self.vars = self.process_version_linux(self.version, self.abiname)
+
+if __name__ == '__main__':
+ gencontrol(sys.path[0] + "/../arch")()
diff --git a/debian/modules/rules.defs b/debian/modules/rules.defs
new file mode 100644
index 00000000..f070af0b
--- /dev/null
+++ b/debian/modules/rules.defs
@@ -0,0 +1,3 @@
+BUILD_DIR = debian/build
+STAMPS_DIR = debian/stamps
+TEMPLATES_DIR = debian/templates
diff --git a/debian/modules/rules.include b/debian/modules/rules.include
new file mode 100644
index 00000000..38c9748c
--- /dev/null
+++ b/debian/modules/rules.include
@@ -0,0 +1,61 @@
+__MODULES_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+
+include $(__MODULES_DIR)rules.defs
+
+__BINNMU := $(shell dpkg-parsechangelog | sed -rne 's,^Version: .*\+b([0-9]+)$$,\1,p')
+
+BUILD_STAMP = $(STAMPS_DIR)/build-base
+
+build: debian/control $(BUILD_STAMP)
+$(BUILD_STAMP): $(BUILD_DIR) $(STAMPS_DIR)
+ dh_testdir
+ $(MAKE) -f debian/rules.gen build_$(DEB_HOST_ARCH)
+ touch $@
+
+$(BUILD_DIR) $(STAMPS_DIR):
+ @[ -d $@ ] || mkdir $@
+
+clean: debian/control
+ dh_testdir
+ rm -rf $(BUILD_DIR) $(STAMPS_DIR)
+ dh_clean
+
+binary-indep:
+ dh_testdir
+ $(MAKE) -f debian/rules.gen binary-indep
+
+binary-arch:
+ dh_testdir
+ $(MAKE) -f debian/rules.gen binary-arch_$(DEB_HOST_ARCH)
+
+binary: binary-indep binary-arch
+
+CONTROL_FILES += debian/changelog $(wildcard debian/templates/control.*)
+CONTROL_FILES += $(wildcard debian/arch/defines) $(wildcard debian/arch/*/defines) $(wildcard debian/arch/*/*/defines)
+GENCONTROL = $(__MODULES_DIR)gencontrol.py
+debian/control debian/rules.gen: $(CONTROL_FILES)
+ifeq ($(wildcard debian/control.md5sum),)
+ $(MAKE) -f debian/rules debian/control-real
+else ifeq ($(__BINNMU),)
+ md5sum --check debian/control.md5sum --status || \
+ $(MAKE) -f debian/rules debian/control-real
+else
+ grep -v debian/changelog debian/control.md5sum | md5sum --check - --status || \
+ $(MAKE) -f debian/rules debian/control-real
+endif
+
+debian/control-real: $(CONTROL_FILES)
+ $(GENCONTROL) $(__MODULES_DIR)..
+ 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 binary-indep binary-arch binary
diff --git a/debian/modules/rules.real.include b/debian/modules/rules.real.include
new file mode 100644
index 00000000..04a44592
--- /dev/null
+++ b/debian/modules/rules.real.include
@@ -0,0 +1,16 @@
+__MODULES_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+DEB_HOST_ARCH := $(shell dpkg-architecture -a$(ARCH) -qDEB_HOST_ARCH)
+DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -a$(ARCH) -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_ARCH := $(shell dpkg-architecture -a$(ARCH) -qDEB_BUILD_ARCH)
+
+export DH_OPTIONS
+
+HEADERS_DIR = /usr/src/linux-headers-$(UPSTREAMVERSION)$(ABINAME)$(LOCALVERSION)
+
+include $(__MODULES_DIR)rules.defs
+
+ifdef DEBIAN_KERNEL_JOBS
+ JOBS_ARG = -j$(DEBIAN_KERNEL_JOBS)
+endif
+