]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
Merge tag 'upstream/0.6.1'
[mirror_zfs-debian.git] / debian / rules
1 #!/usr/bin/make -f
2
3 LSB_DISTRIBUTOR := $(shell lsb_release -is)
4 NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
5 VERSION := $(shell dpkg-parsechangelog \
6 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
7
8 DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \
9 DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown
10
11 %:
12 dh $@ --with dkms
13
14 override_dh_auto_configure:
15 @# Embed the downstream version in the module.
16 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
17
18 @# Create the makefiles and configure script.
19 ./autogen.sh
20
21 @# Build the userland, but don't build the kernel modules.
22 ./configure \
23 --prefix='' \
24 --libexecdir=/usr/libexec \
25 --libdir=/lib \
26 --includedir=/usr/include \
27 --datarootdir=/usr/share \
28 --with-config=user
29
30 override_dh_auto_test:
31 # The dh_auto_test rule is disabled because
32 # `make check` cannot run in an unprivileged build environment.
33
34 override_dh_auto_install:
35 @# Install the utilities.
36 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
37
38 @# Get a bare copy of the source code for DKMS.
39 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
40 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
41 $(MAKE) distdir
42
43 @# Install the DKMS source.
44 @# We only want the files needed to build the modules
45 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
46 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
47 @# Hellish awk line:
48 @# * Deletes from configure.ac the parts not needed for building the kernel module
49 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
50 @# (Makefile$|include/|module/|*.release$)
51 @# * Takes care of spaces and tabs
52 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
53 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
54 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
55 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
56 '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
57 @# Sanity test
58 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
59 @# Run autogen on the stripped source tree
60 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
61 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
62
63 @# This shunt allows DKMS to install the Module.symvers and zfs_config.h
64 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
65 echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
66 echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
67 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
68
69 override_dh_installinit:
70 @# Install the /etc/default/zfs options file.
71 dh_installinit --name=zfs
72
73 @# Install the /etc/init.d/zfs-mount script.
74 ifeq ($(LSB_DISTRIBUTOR),Debian)
75 @# Debian runs local mounts at sysv sequences [10..12] [08..09].
76 dh_installinit --name=zfs-mount \
77 --no-restart-on-upgrade --no-start -- defaults 13 07
78 else
79 dh_installinit --name=zfs-mount \
80 --no-restart-on-upgrade --no-start
81 endif
82
83 @# Install the /etc/init.d/zfs-share script.
84 ifeq ($(LSB_DISTRIBUTOR),Debian)
85 @# Debian runs nfs-kernel-server at sysv sequence 17 01.
86 dh_installinit --name=zfs-share \
87 --no-restart-on-upgrade --no-start -- defaults 18 00
88 else ifeq ($(LSB_DISTRIBUTOR),Ubuntu)
89 @# Ubuntu runs nfs-kernel-server at sysv sequence 20 80.
90 dh_installinit --name=zfs-share \
91 --no-restart-on-upgrade --no-start -- defaults 21 79
92 else
93 dh_installinit --name=zfs-share \
94 --no-restart-on-upgrade --no-start
95 endif
96
97 override_dh_dkms:
98 dh_dkms -V $(VERSION)
99
100 override_dh_shlibdeps:
101 @# Suppress libtool dependency_libs warnings that are caused by
102 @# inter-library dependencies. (eg: zfs -> libzfs -> libuuid)
103 @# @TODO: Add pkgconfig support instead.
104 dh_shlibdeps -- --warnings=0
105
106 override_dh_strip:
107 dh_strip -plibnvpair1 --dbg-package=libnvpair1-dbg
108 dh_strip -plibuutil1 --dbg-package=libuutil1-dbg
109 dh_strip -plibzfs1 --dbg-package=libzfs1-dbg
110 dh_strip -plibzpool1 --dbg-package=libzpool1-dbg
111 dh_strip -pzfsutils --dbg-package=zfsutils-dbg
112
113 override_dh_auto_clean:
114 dh_auto_clean
115 @if test -e META.orig; then mv META.orig META; fi
116