Explicity select what is copied inside the DKMS source tree

* We use the variable DKMSFILES to explicity select wich files
   or directories are copied inside the DKMS source tree.

 * Once copied. We rewrite configure.ac with awk to remove the
   userland/misc components and only keep the kernel stuff that
   is needed by DKMS.

   * The awk lines deletes from inside AC_CONFIG_FILES([]) of configure.ac
     everything except:
	(Makefile$|include/|module/|*.release$|dkms.conf$)

   * Then we run ./autogen.sh to generate the configure scripts
     inside the DKMS source tree

 * This allows us to ship a clean DKMS source tree with *only* the kernel
   components and free from the userland/misc ones (ex: splat)

    * Prevents manual build on the DKMS source tree.
This commit is contained in:
Carlos Alberto Lopez Perez 2013-02-20 23:06:48 +01:00
parent cc2a392625
commit 16b165ccad

29
debian/rules vendored
View File

@ -4,6 +4,9 @@ NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
VERSION := $(shell dpkg-parsechangelog \
| awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
DKMSFILES := module include config Makefile.in autogen.sh dkms.conf.in \
spl.release.in META spl_config.h AUTHORS DISCLAIMER
%:
dh $@ --with dkms
@ -34,18 +37,26 @@ override_dh_auto_install:
@# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
$(MAKE) distdir
@# Delete boilerplate to satisfy the lintian extra-license-file check.
rm '$(CURDIR)/$(NAME)-$(VERSION)/COPYING'
# Install the DKMS source.
@# We only want the files needed to build the modules
mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
$(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)';)
@# Hellish awk line:
@# * Deletes from configure.ac the parts not needed for building the kernel module
@# * It deletes from inside AC_CONFIG_FILES([]) everything except:
@# (Makefile$|include/|module/|*.release$|dkms.conf$)
@# * Takes care of spaces and tabs
awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$|dkms\.conf([ \t]+)?$$))/){next} } {print}' \
'$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
cp '$(CURDIR)/autogen.sh' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
@# This shunt allows DKMS to install the Module.symvers and spl_config.h
@# files to the ${dkms_tree} area through the POST_INSTALL directive.
echo '#!/bin/sh' >'$(CURDIR)/$(NAME)-$(VERSION)/cp'
echo 'cp "$$@"' >>'$(CURDIR)/$(NAME)-$(VERSION)/cp'
chmod 755 '$(CURDIR)/$(NAME)-$(VERSION)/cp'
# Install the DKMS source.
mkdir -p '$(CURDIR)/debian/tmp/usr/src/'
mv '$(CURDIR)/$(NAME)-$(VERSION)' '$(CURDIR)/debian/tmp/usr/src/'
echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
override_dh_dkms:
dh_dkms -V $(VERSION)