Whamcloud - gitweb
LU-11086 test: reset quota setting properly
[fs/lustre-release.git] / debian / rules
index 9c257f3..237904a 100755 (executable)
@@ -13,6 +13,7 @@
 DEB_BUILD_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
 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
 
@@ -28,11 +29,15 @@ endif
 #CC?=gcc-3.3
 #export CC
 
-# This is the debhelper compatability version to use.
-export DH_COMPAT=5
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=9
 
 # Module-assistant stuff
-PACKAGE=lustre-client-modules
+ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
+       PACKAGE=lustre-server-modules
+else
+       PACKAGE=lustre-client-modules
+endif
 MA_DIR ?= /usr/share/modass
 -include $(MA_DIR)/include/generic.make
 -include $(MA_DIR)/include/common-rules.make
@@ -40,31 +45,37 @@ MA_DIR ?= /usr/share/modass
 ARCH=$(shell dpkg --print-architecture)
 TOP_DIR:=$(shell pwd)
 
-#  the lustre build process. This is $(KERNEL_VERSION)
+# This is the Lustre version
 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
-#SUPPORTED_KERNELS=2.6.27
-SUPPORTED_KERNELS=2.6.18 2.6.20 2.6.22
 UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
-#KERNEL_VERSION=2.6.27
-# the kernel version to build all of this with
-#KVER=2.6.27-11-generic
-# if the above is not set, default to whatever kernel is booted
-KVER?=$$(uname -r)
-KERNEL_TREE=/lib/modules/$(KVER)/build
+
+# KVER is set to LINUXRELEASE being by autoconf which is either
+# $(uname -r) or the version of the source specified by the user
+KVER?=$(LINUXRELEASE)
+
 # KVERS, KSRC are the kernel version and source to use when building lustre
 # Will be the default when building lustre-utils, etc but whatever module-assistant
 # supplied when building modules
-KVERS?=$(KERNEL_VERSION)
-#KSRC?=$(KERNEL_TREE)
-KSRC=$(KERNEL_TREE)
+KVERS?=$(KVER)
+KSRC?=$(LINUX_OBJ)
+KSRC_TREE?=$(LINUX)
+IB_OPTIONS?=""
 
-# Packages
-PATCH_PKG=linux-patch-lustre
-UTILS_PKG=lustre-utils
+# Packages provided for both client and server builds
+IOKIT_PKG=lustre-iokit
 TESTS_PKG=lustre-tests
 DEV_PKG=lustre-dev
 SOURCE_PKG=lustre-source
-MODS_PKG=lustre-client-modules
+
+# 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
+else
+       UTILS_PKG=lustre-client-utils
+       MODS_PKG=lustre-client-modules
+endif
 
 #Build dir
 #BUILDDIR=debian/build
@@ -100,33 +111,61 @@ autogen-stamp: patch-stamp
                        exit 1; \
                fi; \
                cp /usr/share/misc/config.sub config.sub; \
-               cp /usr/share/misc/config.sub libsysio/config.sub; \
                cp /usr/share/misc/config.sub ldiskfs/config.sub; \
                cp /usr/share/misc/config.guess config.guess; \
-               cp /usr/share/misc/config.guess libsysio/config.guess; \
                cp /usr/share/misc/config.guess ldiskfs/config.guess; \
                sh build/autogen.sh; \
        fi; \
        touch $@
 
+# This section configures the lustre-utilities packages.
+#
+# Both client and server builds are quite similar, as the utilities build
+# must create the modules too, to produce the "osd_<fstype>.so" libraries.
+#
+# The main difference is that the utilities build does not archive the
+# modules, whereas the modules build omits the utilities, to create two
+# neatly separated debian files.
+#
+# Note: KERNEL_SRC, KERNEL_CFG, ZFS_SRC and SPL_SRC need to be set from the
+# outside. This is done by "make debs". As such, invoking "debuild" or such
+# direct debian build tools will lead to a client-only build.
 configure: configure-stamp
 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
        dh_testdir
        # touch files to same date, to avoid auto*
        find . -type f -print0 | xargs -0 touch -r COPYING; \
        if [ "$(BUILDDIR)" != "." ]; then \
-               mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib $(BUILDDIR)/libsysio; \
+               mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
                cp build/Makefile $(BUILDDIR)/build/; \
-               cp lustre/contrib/mpich-*.patch $(BUILDDIR)/lustre/contrib/; \
-               ln -s ../../../libsysio/include $(BUILDDIR)/libsysio/; \
        fi
+       # Determine flags that are different between server/client module builds
+       echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
+       if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
+               export EXTRAFLAGS="--enable-server"; \
+       else \
+               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}"; \
+       else \
+               export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
+       fi; \
+       if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
+               export EXTRAFLAGS="$${EXTRAFLAGS} \
+                       --enable-ldiskfs --enable-quilt"; \
+       else \
+               export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
+       fi; \
+       echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
        ( cd $(BUILDDIR) && \
-        $(SRCDIR)/configure --disable-dependency-tracking \
-                  --disable-modules \
-                  --disable-snmp \
-                  --disable-client \
-                  --enable-quota \
-                  --disable-server )
+               $(SRCDIR)/configure --disable-dependency-tracking \
+                       --with-linux=$${KERNEL_SRC} \
+                       --with-linux-config=$${KERNEL_CFG} \
+                       --disable-snmp \
+                       --enable-quota \
+                       $${EXTRAFLAGS} \
+       ); \
        touch $@
 
 build-arch build-indep: build
@@ -136,7 +175,7 @@ build-stamp: patch-stamp configure-stamp
        dh_testdir
        $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
        $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
-       # jump our lustre-client-modules into the control file if not using m-a
+       # jump our lustre-[client|server]-modules into the control file if not using m-a
        if ! $(USE_MA); then \
                (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
                for file in debian/*_KVERS_*; do \
@@ -151,50 +190,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)
 
 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
@@ -202,6 +204,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
@@ -213,6 +221,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
@@ -277,6 +306,7 @@ binary-$(SOURCE_PKG): build-stamp
 # if only we could use m-a for this, but this stupid "compliant.list"
 # thing fouls that up
 binary-kern-mods:
+       # Build client or server modules
        mkdir -p debian/m-a_root/usr_src/modules
        ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
        m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
@@ -285,7 +315,7 @@ binary-kern-mods:
 # an alternative (to module-assistant) method of building the kernel modules
 binary-$(MODS_PKG): build-stamp
        if ! $(USE_MA); then \
-               cp debian/lustre-client-modules.install debian/lustre-client-modules-$(KVER).install ; \
+               cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
                dh_testdir; \
                dh_testroot; \
                dh_installdirs -p $(MODS_PKG)-$(KVER); \
@@ -302,6 +332,7 @@ binary-$(MODS_PKG): build-stamp
                dh_builddeb -p $(MODS_PKG)-$(KVER); \
        fi
 
+
 ###
 ### For module-assistant
 ###
@@ -339,18 +370,39 @@ kdist_config: prep-deb-files patch-stamp
        #-$(MAKE) -C $(KSRC) prepare scripts
        # touch files to same date, to avoid auto*
        find . -type f -print0 | xargs -0 touch -r COPYING \;
-       # Doesn't seem possible to only build modules...
-       ./configure --with-linux=$(KSRC) \
-                   --disable-server \
-                   --disable-quilt  \
-                   --disable-dependency-tracking \
-                   --disable-doc  \
-                   --disable-utils \
-                   --disable-liblustre \
-                   --disable-snmp \
-                   --disable-zerocopy \
-                   --disable-tests \
-                   --enable-quota
+       # Determine flags that are different between server/client module builds
+       # Note: It doesn't seem possible to *only* build modules.
+       echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
+       if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
+               export EXTRAFLAGS="--enable-server"; \
+       else \
+               export EXTRAFLAGS="--disable-server"; \
+       fi; \
+       if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
+               export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
+       else \
+               export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
+       fi; \
+       if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
+               export EXTRAFLAGS="$${EXTRAFLAGS} \
+                       --enable-ldiskfs --enable-quilt"; \
+       else \
+               export EXTRAFLAGS="$${EXTRAFLAGS} \
+                       --disable-ldiskfs --disable-quilt"; \
+       fi; \
+       echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
+       ./configure --with-linux=$(KSRC_TREE) \
+               --with-linux-obj=$(KSRC) \
+               --disable-dependency-tracking \
+               --disable-doc  \
+               --disable-iokit \
+               --disable-snmp \
+               --disable-tests \
+               --enable-quota \
+               --with-kmp-moddir=updates \
+               $${EXTRAFLAGS} \
+               $(IB_OPTIONS)
+
 
 kdist_configure: kdist_config
 
@@ -359,11 +411,11 @@ kdist_configure: kdist_config
 # during a normal build
 binary-modules: prep-deb-files
        dh_testroot
-       dh_clean -k
+       dh_prep
        $(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)
@@ -373,15 +425,15 @@ binary-modules: prep-deb-files
        dh_gencontrol -- -v$(VERSION)
        dh_md5sums -p $(PKGNAME)
        dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
-       dh_clean -k -p $(PKGNAME)
+       dh_prep -p $(PKGNAME)
 
 clean:
        dh_testdir
        dh_testroot
        dpatch deapply-all -v
        -$(MAKE) distclean
-       rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp debian/$(PATCH_PKG)
-       ls -d debian/lustre-client-modules-* | grep -v _KVERS_ | xargs rm -f || true
+       rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp
+       ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | 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; \