Whamcloud - gitweb
LU-11086 test: reset quota setting properly
[fs/lustre-release.git] / debian / rules
1 #!/usr/bin/make -f
2 #
3 # Created 2009 by Brian J. Murrell based on work by
4 # Alastair McKinstry, <alastair.mckinstry@ichec.ie>, <mckinstry@debian.org>
5 # Patrick Winnertz, and the pkg-lustre Debian maintainers
6 #
7 # Copying and modification is unlimited, provided that the modified
8 # version is marked as being modified.
9
10 # Uncomment this to turn on verbose mode.
11 # export DH_VERBOSE=1
12
13 DEB_BUILD_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
14 DEB_BUILD_GNU_CPU = $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
15
16
17 # whether to use module-assistant to build the kernel modules or not
18 USE_MA = true
19
20 CFLAGS = -Wall -g
21 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
22         CFLAGS += -O0
23 else
24         CFLAGS += -O2
25 endif
26
27 # We need the kernels to be built with gcc-3.3; suspect that gcc-4.1 uses too
28 # much stack and crashes because of it.
29 #CC?=gcc-3.3
30 #export CC
31
32 # This is the debhelper compatibility version to use.
33 export DH_COMPAT=9
34
35 # Module-assistant stuff
36 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
37         PACKAGE=lustre-server-modules
38 else
39         PACKAGE=lustre-client-modules
40 endif
41 MA_DIR ?= /usr/share/modass
42 -include $(MA_DIR)/include/generic.make
43 -include $(MA_DIR)/include/common-rules.make
44
45 ARCH=$(shell dpkg --print-architecture)
46 TOP_DIR:=$(shell pwd)
47
48 # This is the Lustre version
49 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
50 UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
51
52 # KVER is set to LINUXRELEASE being by autoconf which is either
53 # $(uname -r) or the version of the source specified by the user
54 KVER?=$(LINUXRELEASE)
55
56 # KVERS, KSRC are the kernel version and source to use when building lustre
57 # Will be the default when building lustre-utils, etc but whatever module-assistant
58 # supplied when building modules
59 KVERS?=$(KVER)
60 KSRC?=$(LINUX_OBJ)
61 KSRC_TREE?=$(LINUX)
62 IB_OPTIONS?=""
63
64 # Packages provided for both client and server builds
65 IOKIT_PKG=lustre-iokit
66 TESTS_PKG=lustre-tests
67 DEV_PKG=lustre-dev
68 SOURCE_PKG=lustre-source
69
70 # Packages that are only built for server OR client builds
71 # The difference is that server build contain more modules & utils
72 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
73         UTILS_PKG=lustre-server-utils
74         MODS_PKG=lustre-server-modules
75 else
76         UTILS_PKG=lustre-client-utils
77         MODS_PKG=lustre-client-modules
78 endif
79
80 #Build dir
81 #BUILDDIR=debian/build
82 #SRCDIR=../..
83 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
84 # autoconf macros
85 BUILDDIR=.
86 SRCDIR=.
87
88 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
89 ifneq ($(AVAIL_CPUS),1)
90       PMAKEARGS := -j $(AVAIL_CPUS)
91 endif
92
93 autogen: autogen-stamp
94 autogen-stamp: patch-stamp
95         # see if any patches requires us to run autogen
96         # (for a distribution release tarball, it is expected that if
97         #  downstream adds any patches that requires autogen.sh to be
98         #  run, a patch will be added by downstream to install the
99         #  needed autogen.sh scripts
100         #  see https://bugzilla.lustre.org/attachment.cgi?id=27156
101         #  for an example)
102         if grep -e "^--- .*\/autoconf\/" \
103                 -e "^--- .*\/autoMakefile\.am" \
104                 -e "^--- .*\/Makefile\.am" \
105                 -e "^--- .*\/configure\.ac" \
106                 -e "^--- .*\/configure\.in" \
107             debian/patches/*; then \
108                 if [ ! -f build/autogen.sh ]; then \
109                         echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
110                         echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
111                         exit 1; \
112                 fi; \
113                 cp /usr/share/misc/config.sub config.sub; \
114                 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
115                 cp /usr/share/misc/config.guess config.guess; \
116                 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
117                 sh build/autogen.sh; \
118         fi; \
119         touch $@
120
121 # This section configures the lustre-utilities packages.
122 #
123 # Both client and server builds are quite similar, as the utilities build
124 # must create the modules too, to produce the "osd_<fstype>.so" libraries.
125 #
126 # The main difference is that the utilities build does not archive the
127 # modules, whereas the modules build omits the utilities, to create two
128 # neatly separated debian files.
129 #
130 # Note: KERNEL_SRC, KERNEL_CFG, ZFS_SRC and SPL_SRC need to be set from the
131 # outside. This is done by "make debs". As such, invoking "debuild" or such
132 # direct debian build tools will lead to a client-only build.
133 configure: configure-stamp
134 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
135         dh_testdir
136         # touch files to same date, to avoid auto*
137         find . -type f -print0 | xargs -0 touch -r COPYING; \
138         if [ "$(BUILDDIR)" != "." ]; then \
139                 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
140                 cp build/Makefile $(BUILDDIR)/build/; \
141         fi
142         # Determine flags that are different between server/client module builds
143         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
144         if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
145                 export EXTRAFLAGS="--enable-server"; \
146         else \
147                 export EXTRAFLAGS="--disable-server --disable-modules"; \
148         fi; \
149         if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
150                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
151         else \
152                 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
153         fi; \
154         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
155                 export EXTRAFLAGS="$${EXTRAFLAGS} \
156                         --enable-ldiskfs --enable-quilt"; \
157         else \
158                 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
159         fi; \
160         echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
161         ( cd $(BUILDDIR) && \
162                 $(SRCDIR)/configure --disable-dependency-tracking \
163                         --with-linux=$${KERNEL_SRC} \
164                         --with-linux-config=$${KERNEL_CFG} \
165                         --disable-snmp \
166                         --enable-quota \
167                         $${EXTRAFLAGS} \
168         ); \
169         touch $@
170
171 build-arch build-indep: build
172
173 build: build-stamp
174 build-stamp: patch-stamp configure-stamp
175         dh_testdir
176         $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
177         $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
178         # jump our lustre-[client|server]-modules into the control file if not using m-a
179         if ! $(USE_MA); then \
180                 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
181                 for file in debian/*_KVERS_*; do \
182                         newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
183                         cp $$file $$newfile; \
184                 done; \
185         fi
186         touch $@
187
188 # let's try and operate as close as the user would and not build modules
189 # here (for now)
190 # instead we will build the modules with m-a in the "make debs" target
191 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
192 # binary-$(MODS_PKG) binary-kern-mods
193 binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
194              binary-$(IOKIT_PKG) binary-$(TESTS_PKG)
195
196 binary-indep: binary-$(SOURCE_PKG)
197
198 binary: binary-indep binary-arch
199
200 binary-$(UTILS_PKG): build-stamp
201         dh_testdir
202         dh_testroot
203         dh_installdirs -p $(UTILS_PKG)
204         dh_installdocs -p  $(UTILS_PKG)
205         dh_installman -p $(UTILS_PKG)
206         dh_install -p $(UTILS_PKG)
207         rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
208                debian/$(UTILS_PKG)/usr/bin/*-survey \
209                debian/$(UTILS_PKG)/usr/bin/mcreate \
210                debian/$(UTILS_PKG)/usr/bin/munlink \
211                debian/$(UTILS_PKG)/usr/sbin/wirecheck \
212                debian/$(UTILS_PKG)/usr/sbin/wiretest
213         dh_makeshlibs -p $(UTILS_PKG)
214         dh_installexamples -p $(UTILS_PKG)
215         dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
216         dh_compress -p $(UTILS_PKG)
217         dh_strip -p $(UTILS_PKG)
218         dh_installdeb -p $(UTILS_PKG)
219         dh_fixperms -p $(UTILS_PKG)
220         dh_gencontrol -p $(UTILS_PKG)
221         dh_md5sums -p $(UTILS_PKG)
222         dh_builddeb -p $(UTILS_PKG)
223
224 binary-$(IOKIT_PKG): build-stamp
225         dh_testdir
226         dh_testroot
227         dh_installdirs -p $(IOKIT_PKG)
228         dh_installdocs -p  $(IOKIT_PKG)
229         dh_installman -p $(IOKIT_PKG)
230         dh_install -p $(IOKIT_PKG)
231         rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
232                debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
233                debian/$(IOKIT_PKG)/usr/bin/lfs-*
234         dh_makeshlibs -p $(IOKIT_PKG)
235         dh_installexamples -p $(IOKIT_PKG)
236         dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
237         dh_compress -p $(IOKIT_PKG)
238         dh_strip -p $(IOKIT_PKG)
239         dh_installdeb -p $(IOKIT_PKG)
240         dh_fixperms -p $(IOKIT_PKG)
241         dh_gencontrol -p $(IOKIT_PKG)
242         dh_md5sums -p $(IOKIT_PKG)
243         dh_builddeb -p $(IOKIT_PKG)
244
245 binary-$(TESTS_PKG): build-stamp
246         dh_testdir
247         dh_testroot
248         dh_installdirs -p $(TESTS_PKG)
249         dh_installdocs -p  $(TESTS_PKG)
250         dh_installman -p $(TESTS_PKG)
251         dh_install -p $(TESTS_PKG)
252         dh_makeshlibs -p $(TESTS_PKG)
253         dh_installexamples -p $(TESTS_PKG)
254         dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
255         dh_compress -p $(TESTS_PKG)
256         dh_strip -p $(TESTS_PKG)
257         dh_installdeb -p $(TESTS_PKG)
258         dh_fixperms -p $(TESTS_PKG)
259         dh_gencontrol -p $(TESTS_PKG)
260         dh_md5sums -p $(TESTS_PKG)
261         dh_builddeb -p $(TESTS_PKG)
262
263 binary-$(DEV_PKG): build-stamp
264         dh_testdir
265         dh_testroot
266         dh_installdirs -p $(DEV_PKG)
267         dh_install -p $(DEV_PKG)
268         dh_installdocs -p $(DEV_PKG)
269         dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
270         dh_compress -p $(DEV_PKG)
271         dh_installdeb -p $(DEV_PKG)
272         dh_fixperms -p $(DEV_PKG)
273         dh_gencontrol -p $(DEV_PKG)
274         dh_md5sums -p $(DEV_PKG)
275         dh_builddeb -p $(DEV_PKG)
276
277 binary-$(SOURCE_PKG): build-stamp
278         dh_testdir 
279         dh_testroot
280         # Copy everything 
281         dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
282         rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
283               --link-dest=$(PWD) \
284               . debian/$(SOURCE_PKG)/usr/src/modules/lustre
285         # Remove FULLCLEAN setting
286         rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
287         sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
288         # clean up dest
289         rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
290                debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/* 
291         $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
292         # Create the module-source tarball.
293         cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules 
294         rm -rf debian/$(SOURCE_PKG)/usr/src/modules
295         dh_install -p$(SOURCE_PKG)
296         dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
297         dh_installdocs -p $(SOURCE_PKG) 
298         dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
299         dh_compress -p $(SOURCE_PKG)
300         dh_installdeb -p $(SOURCE_PKG)
301         dh_fixperms -p $(SOURCE_PKG)
302         dh_gencontrol -p $(SOURCE_PKG)
303         dh_md5sums -p $(SOURCE_PKG)
304         dh_builddeb -p $(SOURCE_PKG)
305
306 # if only we could use m-a for this, but this stupid "compliant.list"
307 # thing fouls that up
308 binary-kern-mods:
309         # Build client or server modules
310         mkdir -p debian/m-a_root/usr_src/modules
311         ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
312         m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
313         mv -f debian/m-a_root/*.deb ..
314
315 # an alternative (to module-assistant) method of building the kernel modules
316 binary-$(MODS_PKG): build-stamp
317         if ! $(USE_MA); then \
318                 cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
319                 dh_testdir; \
320                 dh_testroot; \
321                 dh_installdirs -p $(MODS_PKG)-$(KVER); \
322                 dh_installdocs -p $(MODS_PKG)-$(KVER); \
323                 dh_install -p $(MODS_PKG)-$(KVER); \
324                 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
325                 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
326                 dh_compress -p $(MODS_PKG)-$(KVER); \
327                 dh_installdeb -p $(MODS_PKG)-$(KVER); \
328                 dh_strip -p $(MODS_PKG)-$(KVER); \
329                 dh_fixperms -p $(MODS_PKG)-$(KVER); \
330                 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
331                 dh_md5sums -p $(MODS_PKG)-$(KVER); \
332                 dh_builddeb -p $(MODS_PKG)-$(KVER); \
333         fi
334
335
336 ###
337 ### For module-assistant
338 ###
339
340 # the kdist_clean target is called by make-kpkg modules_clean and from
341 # kdist* rules. It is responsible for cleaning up any changes that have
342 # been made by the other kdist_commands (except for the .deb files created)
343
344 kdist_clean: 
345         # can't dh_clean here or we remove the build artifacts for the other packages
346         # still in progress
347         #dh_clean
348         #-$(MAKE) $(MFLAGS) -f debian/rules clean
349         # put the userspace tools' control file back
350         cp debian/control.main debian/control
351
352
353 # module assistant calculates all needed things for us and sets
354 # # following variables:
355 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
356 # # (revision of the Debian kernel-image package), CC (the correct
357 # # compiler), VERSION (the final package version string), PKGNAME (full
358 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
359 #
360 # # The kdist_configure target is called by make-kpkg modules_config and
361 # # by kdist* rules by dependency. It should configure the module so it is
362 # # ready for compilation (mostly useful for calling configure).
363 # # prep-deb-files from module-assistant creates the neccessary debian/ 
364 kdist_config: prep-deb-files patch-stamp
365         #  Check build dependencies again, needs to be done since we just
366         # replaced the control file.
367         dpkg-checkbuilddeps
368         # Prepare the kernel to lustres' liking
369         # as non-root, we won't have permission for this
370         #-$(MAKE) -C $(KSRC) prepare scripts
371         # touch files to same date, to avoid auto*
372         find . -type f -print0 | xargs -0 touch -r COPYING \;
373         # Determine flags that are different between server/client module builds
374         # Note: It doesn't seem possible to *only* build modules.
375         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
376         if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
377                 export EXTRAFLAGS="--enable-server"; \
378         else \
379                 export EXTRAFLAGS="--disable-server"; \
380         fi; \
381         if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
382                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
383         else \
384                 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
385         fi; \
386         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
387                 export EXTRAFLAGS="$${EXTRAFLAGS} \
388                         --enable-ldiskfs --enable-quilt"; \
389         else \
390                 export EXTRAFLAGS="$${EXTRAFLAGS} \
391                         --disable-ldiskfs --disable-quilt"; \
392         fi; \
393         echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
394         ./configure --with-linux=$(KSRC_TREE) \
395                 --with-linux-obj=$(KSRC) \
396                 --disable-dependency-tracking \
397                 --disable-doc  \
398                 --disable-iokit \
399                 --disable-snmp \
400                 --disable-tests \
401                 --enable-quota \
402                 --with-kmp-moddir=updates \
403                 $${EXTRAFLAGS} \
404                 $(IB_OPTIONS)
405
406
407 kdist_configure: kdist_config
408
409 # the binary-modules rule is invoked by module-assistant while processing the
410 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
411 # during a normal build
412 binary-modules: prep-deb-files
413         dh_testroot
414         dh_prep
415         $(MAKE) $(PMAKEARGS)
416         $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
417         # Remove stuff that doesn't belong (no module-only target)
418         cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre lib/systemd sbin etc
419         dh_installdocs -p$(PKGNAME)
420         dh_installchangelogs -p$(PKGNAME)
421         dh_installmodules -p $(PKGNAME)
422         dh_compress -p $(PKGNAME)
423         dh_fixperms -p $(PKGNAME)
424         dh_installdeb -p $(PKGNAME)
425         dh_gencontrol -- -v$(VERSION)
426         dh_md5sums -p $(PKGNAME)
427         dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
428         dh_prep -p $(PKGNAME)
429
430 clean:
431         dh_testdir
432         dh_testroot
433         dpatch deapply-all -v
434         -$(MAKE) distclean
435         rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp
436         ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | xargs rm -f || true
437         # only remove this if the clean was not called from kdist_clean
438         if [ "$$MA_SOURCE_PKG" = "" ]; then \
439                 rm -rf  debian/m-a_root; \
440         fi
441         dh_clean
442         # make sure we have at least a basic control in place (see build-stamp)
443         rm -f debian/control
444         cp debian/control.main debian/control
445
446 patch: patch-stamp
447 patch-stamp:
448         dpatch apply-all -v
449         touch $@
450
451 unpatch:
452         dpatch deapply-all -v
453         rm -rf debian/patched patch-stamp
454
455 .PHONY: binary-arch clean source diff  binary binary-indep binary-arch install configure