Whamcloud - gitweb
LU-9087 build: add support for DKMS debs
[fs/lustre-release.git] / debian / rules
index a872fb1..902d4ab 100755 (executable)
@@ -17,6 +17,15 @@ DEB_BUILD_GNU_CPU = $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
 # whether to use module-assistant to build the kernel modules or not
 USE_MA = true
 
+# Whether to build the DKMS packages
+BUILD_DKMS ?= false
+
+ifeq ($(BUILD_DKMS),true)
+       DKMS_TARGET = binary-$(DKMS_PKG)
+else
+       DKMS_TARGET =
+endif
+
 CFLAGS = -Wall -g
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
         CFLAGS += -O0
@@ -30,7 +39,7 @@ endif
 #export CC
 
 # This is the debhelper compatibility version to use.
-export DH_COMPAT=7
+export DH_COMPAT=9
 
 # Module-assistant stuff
 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
@@ -47,7 +56,7 @@ TOP_DIR:=$(shell pwd)
 
 # This is the Lustre version
 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
-UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
+UPVERSION=$(shell echo $(VERSION) | sed -e 's/-[^-]*$$//')
 
 # KVER is set to LINUXRELEASE being by autoconf which is either
 # $(uname -r) or the version of the source specified by the user
@@ -62,20 +71,21 @@ KSRC_TREE?=$(LINUX)
 IB_OPTIONS?=""
 
 # Packages provided for both client and server builds
-PATCH_PKG=linux-patch-lustre
+IOKIT_PKG=lustre-iokit
 TESTS_PKG=lustre-tests
 DEV_PKG=lustre-dev
 SOURCE_PKG=lustre-source
-SOURCE_PKG=lustre-source
 
 # Packages that are only built for server OR client builds
 # The difference is that server build contain more modules & utils
 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
        UTILS_PKG=lustre-server-utils
        MODS_PKG=lustre-server-modules
+       DKMS_PKG=
 else
        UTILS_PKG=lustre-client-utils
        MODS_PKG=lustre-client-modules
+       DKMS_PKG=lustre-client-modules-dkms
 endif
 
 #Build dir
@@ -145,7 +155,7 @@ configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
        if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
                export EXTRAFLAGS="--enable-server"; \
        else \
-               export EXTRAFLAGS="--disable-server"; \
+               export EXTRAFLAGS="--disable-server --disable-modules"; \
        fi; \
        if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
                export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
@@ -191,50 +201,13 @@ build-stamp: patch-stamp configure-stamp
 # instead we will build the modules with m-a in the "make debs" target
 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
 # binary-$(MODS_PKG) binary-kern-mods
-binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG)
+binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
+            binary-$(IOKIT_PKG) binary-$(TESTS_PKG)
 
-binary-indep: binary-$(PATCH_PKG) binary-$(SOURCE_PKG)
+binary-indep: binary-$(SOURCE_PKG) $(DKMS_TARGET)
 
 binary: binary-indep binary-arch
 
-binary-$(PATCH_PKG): patch-stamp
-       dh_testdir
-       dh_testroot
-       dh_installdirs -p $(PATCH_PKG)
-       dh_installdocs -p $(PATCH_PKG)
-#      dh_installkpatches -p $(PATCH_PKG)
-       dh_install -p $(PATCH_PKG)
-
-       # Install apply script
-       cp $(TOP_DIR)/debian/linux-patch-lustre.apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
-       chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
-       set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
-         mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/; \
-         ln -s ../../../lustre/scripts/apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/lustre; \
-       done
-
-       # Install unpatch script
-       cp $(TOP_DIR)/debian/linux-patch-lustre.unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
-       chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
-       set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
-         mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/; \
-         ln -s ../../../lustre/scripts/unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/lustre; \
-       done
-
-       # Install series
-       cp lustre/kernel_patches/series/*.series $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/series/
-
-       # Install patches
-       cp lustre/kernel_patches/patches/*.patch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/patches/
-
-       dh_installchangelogs -p $(PATCH_PKG) lustre/ChangeLog
-       dh_compress -p $(PATCH_PKG)
-       dh_installdeb -p $(PATCH_PKG)
-       dh_fixperms -p $(PATCH_PKG)
-       dh_gencontrol -p $(PATCH_PKG)
-       dh_md5sums -p $(PATCH_PKG)
-       dh_builddeb -p $(PATCH_PKG)
-
 binary-$(UTILS_PKG): build-stamp
        dh_testdir
        dh_testroot
@@ -242,6 +215,12 @@ binary-$(UTILS_PKG): build-stamp
        dh_installdocs -p  $(UTILS_PKG)
        dh_installman -p $(UTILS_PKG)
        dh_install -p $(UTILS_PKG)
+       rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
+              debian/$(UTILS_PKG)/usr/bin/*-survey \
+              debian/$(UTILS_PKG)/usr/bin/mcreate \
+              debian/$(UTILS_PKG)/usr/bin/munlink \
+              debian/$(UTILS_PKG)/usr/sbin/wirecheck \
+              debian/$(UTILS_PKG)/usr/sbin/wiretest
        dh_makeshlibs -p $(UTILS_PKG)
        dh_installexamples -p $(UTILS_PKG)
        dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
@@ -253,6 +232,27 @@ binary-$(UTILS_PKG): build-stamp
        dh_md5sums -p $(UTILS_PKG)
        dh_builddeb -p $(UTILS_PKG)
 
+binary-$(IOKIT_PKG): build-stamp
+       dh_testdir
+       dh_testroot
+       dh_installdirs -p $(IOKIT_PKG)
+       dh_installdocs -p  $(IOKIT_PKG)
+       dh_installman -p $(IOKIT_PKG)
+       dh_install -p $(IOKIT_PKG)
+       rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
+              debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
+              debian/$(IOKIT_PKG)/usr/bin/lfs-*
+       dh_makeshlibs -p $(IOKIT_PKG)
+       dh_installexamples -p $(IOKIT_PKG)
+       dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
+       dh_compress -p $(IOKIT_PKG)
+       dh_strip -p $(IOKIT_PKG)
+       dh_installdeb -p $(IOKIT_PKG)
+       dh_fixperms -p $(IOKIT_PKG)
+       dh_gencontrol -p $(IOKIT_PKG)
+       dh_md5sums -p $(IOKIT_PKG)
+       dh_builddeb -p $(IOKIT_PKG)
+
 binary-$(TESTS_PKG): build-stamp
        dh_testdir
        dh_testroot
@@ -314,6 +314,31 @@ binary-$(SOURCE_PKG): build-stamp
        dh_md5sums -p $(SOURCE_PKG)
        dh_builddeb -p $(SOURCE_PKG)
 
+binary-$(DKMS_PKG): build-stamp
+       dh_testdir
+       dh_testroot
+       # Create /usr/src/lustre-client-modules-<version>
+       dh_installdirs -p $(DKMS_PKG) usr/src/lustre-client-modules-$(UPVERSION)
+       # Copy the source
+       rsync -av --exclude='debian/$(DKMS_PKG)/*' --exclude='.git/' \
+               --link-dest=$(PWD) \
+               . debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)
+       # Clean it up
+       $(MAKE) -C debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION) -f debian/rules clean
+
+       # Put the DKMS configuration file in place
+       sed -e 's/[@]UPVERSION[@]/$(UPVERSION)/' debian/dkms.conf.in > debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)/dkms.conf
+       dh_install -p $(DKMS_PKG)
+       dh_installchangelogs -p $(DKMS_PKG) lustre/ChangeLog
+       dh_installdocs -p $(DKMS_PKG)
+       dh_compress -p $(DKMS_PKG)
+       dh_installdeb -p $(DKMS_PKG)
+       dh_strip -p $(DKMS_PKG)
+       dh_fixperms -p $(DKMS_PKG)
+       dh_gencontrol -p $(DKMS_PKG)
+       dh_md5sums -p $(DKMS_PKG)
+       dh_builddeb -p $(DKMS_PKG)
+
 # if only we could use m-a for this, but this stupid "compliant.list"
 # thing fouls that up
 binary-kern-mods:
@@ -398,7 +423,8 @@ kdist_config: prep-deb-files patch-stamp
                export EXTRAFLAGS="$${EXTRAFLAGS} \
                        --enable-ldiskfs --enable-quilt"; \
        else \
-               export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
+               export EXTRAFLAGS="$${EXTRAFLAGS} \
+                       --disable-ldiskfs --disable-quilt"; \
        fi; \
        echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
        ./configure --with-linux=$(KSRC_TREE) \
@@ -408,7 +434,6 @@ kdist_config: prep-deb-files patch-stamp
                --disable-iokit \
                --disable-snmp \
                --disable-tests \
-               --disable-utils \
                --enable-quota \
                --with-kmp-moddir=updates \
                $${EXTRAFLAGS} \
@@ -426,7 +451,7 @@ binary-modules: prep-deb-files
        $(MAKE) $(PMAKEARGS)
        $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
        # Remove stuff that doesn't belong (no module-only target)
-       cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr sbin etc
+       cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre lib/systemd sbin etc
        dh_installdocs -p$(PKGNAME)
        dh_installchangelogs -p$(PKGNAME)
        dh_installmodules -p $(PKGNAME)
@@ -443,8 +468,8 @@ clean:
        dh_testroot
        dpatch deapply-all -v
        -$(MAKE) distclean
-       rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp debian/$(PATCH_PKG)
-       ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | xargs rm -f || true
+       rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp
+       ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | grep -v dkms | xargs rm -f || true
        # only remove this if the clean was not called from kdist_clean
        if [ "$$MA_SOURCE_PKG" = "" ]; then \
                rm -rf  debian/m-a_root; \