]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
Add LSB headers for iSCSI in /etc/init.d/zfs-share
[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 export SHLIB_MAJOR = 1
12
13 ifndef BUILD_UDEB
14 BUILD_UDEB=false
15 endif
16
17 ifndef DEB_HOST_ARCH
18 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
19 endif
20
21 ifndef KVERS
22 KVERS=$(shell uname -r)
23 endif
24
25 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
26 PACKAGE=zfs
27 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
28
29 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
30
31 %:
32 dh $@ --with dkms --parallel
33
34 override_dh_auto_configure:
35 @cp debian/control.in debian/control
36 ifeq ($(BUILD_UDEB), true)
37 cat debian/control.udeb.in >> debian/control
38 endif
39
40 @# Embed the downstream version in the module.
41 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
42
43 @# Create the makefiles and configure script.
44 ./autogen.sh
45
46 @# Build the userland, but don't build the kernel modules.
47 dh_auto_configure -- \
48 --bindir=/bin \
49 --sbindir=/sbin \
50 --libdir=/lib \
51 --with-udevdir=/lib/udev \
52 --with-config=user
53
54 override_dh_auto_test:
55 # The dh_auto_test rule is disabled because
56 # `make check` cannot run in an unprivileged build environment.
57
58 override_dh_auto_install:
59 @# Install the utilities.
60 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
61
62 @# Get a bare copy of the source code for DKMS.
63 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
64 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
65 $(MAKE) distdir
66
67 @# Install the DKMS source.
68 @# We only want the files needed to build the modules
69 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
70 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
71 @# Hellish awk line:
72 @# * Deletes from configure.ac the parts not needed for building the kernel module
73 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
74 @# (Makefile$|include/|module/|*.release$)
75 @# * Takes care of spaces and tabs
76 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
77 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
78 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
79 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
80 '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
81 @# Sanity test
82 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
83 @# Run autogen on the stripped source tree
84 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
85 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
86
87 @# This shunt allows DKMS to install the Module.symvers and zfs_config.h
88 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
89 echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
90 echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
91 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
92
93 mkdir -p $(CURDIR)/debian/tmp/usr/lib
94 for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \
95 ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \
96 rm $${i}; \
97 done
98
99 override_dh_installinit:
100 @# Install the /etc/default/zfs options file.
101 dh_installinit --name=zfs
102
103 @# Install the /etc/init.d/zfs-mount script.
104 ifeq ($(LSB_DISTRIBUTOR),Debian)
105 @# Debian runs local mounts at sysv sequences [10..12] [08..09].
106 dh_installinit --name=zfs-mount \
107 --no-restart-on-upgrade --no-start -- defaults 13 07
108 else
109 dh_installinit --name=zfs-mount \
110 --no-restart-on-upgrade --no-start
111 endif
112
113 @# Install the /etc/init.d/zfs-share script.
114 ifeq ($(LSB_DISTRIBUTOR),Debian)
115 @# Debian runs nfs-kernel-server at sysv sequence 17 01,
116 @# iscsitarget at 02 01, and samba at 01 02.
117 dh_installinit --name=zfs-share \
118 --no-restart-on-upgrade --no-start -- defaults 18 00
119 else ifeq ($(LSB_DISTRIBUTOR),Ubuntu)
120 @# Ubuntu runs nfs-kernel-server at sysv sequence 20 80,
121 @# iscsitarget at 20 20, and samba through upstart.
122 dh_installinit --name=zfs-share \
123 --no-restart-on-upgrade --no-start -- defaults 25 15
124 else
125 dh_installinit --name=zfs-share \
126 --no-restart-on-upgrade --no-start
127 endif
128
129 override_dh_dkms:
130 dh_dkms -V $(VERSION)
131
132 override_dh_makeshlibs:
133 dh_makeshlibs -a
134 ifeq ($(BUILD_UDEB), true)
135 dh_makeshlibs -plibnvpair$(SHLIB_MAJOR) --add-udeb=libnvpair$(SHLIB_MAJOR)-udeb
136 dh_makeshlibs -plibuutil$(SHLIB_MAJOR) --add-udeb=libuutil$(SHLIB_MAJOR)-udeb
137 dh_makeshlibs -plibzfs$(SHLIB_MAJOR) --add-udeb=libzfs$(SHLIB_MAJOR)-udeb
138 dh_makeshlibs -plibzpool$(SHLIB_MAJOR) --add-udeb=libzpool$(SHLIB_MAJOR)-udeb
139 dh_makeshlibs -pzfsutils --add-udeb=zfsutils-udeb
140 endif
141
142 override_dh_strip:
143 dh_strip --dbg-package=zfs-dbg
144 ifeq ($(BUILD_UDEB), true)
145 dh_strip -plibnvpair$(SHLIB_MAJOR)-udeb
146 dh_strip -plibuutil$(SHLIB_MAJOR)-udeb
147 dh_strip -plibzfs$(SHLIB_MAJOR)-udeb
148 dh_strip -plibzpool$(SHLIB_MAJOR)-udeb
149 dh_strip -pzfsutils-udeb
150 endif
151
152 override_dh_auto_clean:
153 dh_auto_clean
154 @if test -e META.orig; then mv META.orig META; fi
155 cp debian/control.in debian/control
156 ifeq ($(BUILD_UDEB), true)
157 cat debian/control.udeb.in >> debian/control
158 endif
159
160 override_dh_install:
161 find . -name lib*.la -delete
162 dh_install
163
164 # ------------
165
166 override_dh_prep-deb-files:
167 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
168 sed -e 's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/' \
169 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
170 done
171 sed -e 's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g' \
172 < debian/control.modules.in > debian/control
173
174 override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
175 override_dh_configure_modules_udeb_stamp:
176 ./configure \
177 --without-selinux \
178 --with-config=kernel \
179 --with-linux=$(KSRC) \
180 --with-linux-obj=$(KOBJ)
181 touch override_dh_configure_modules_udeb_stamp
182
183 override_dh_configure_modules: override_dh_configure_modules_stamp
184 override_dh_configure_modules_stamp:
185 ./configure \
186 --with-config=kernel \
187 --with-linux=$(KSRC) \
188 --with-linux-obj=$(KOBJ)
189 touch override_dh_configure_modules_stamp
190
191 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
192 dh_testdir
193 dh_testroot
194 dh_prep
195
196 $(MAKE) -C $(CURDIR)/module modules
197
198 dh_installdirs -p${pmodules}-di
199 dh_install -p${pmodules}-di
200 dh_gencontrol -p${pmodules}-di
201
202 dh_builddeb -p${pmodules}-di
203
204 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
205 dh_testdir
206 dh_testroot
207 dh_prep
208
209 $(MAKE) -C $(CURDIR)/module modules
210
211 dh_install -p${pmodules}
212 dh_installdocs -p${pmodules}
213 dh_installchangelogs -p${pmodules}
214 dh_compress -p${pmodules}
215 dh_strip -p${pmodules}
216 dh_fixperms -p${pmodules}
217 dh_installdeb -p${pmodules}
218 dh_gencontrol -p${pmodules}
219 dh_md5sums -p${pmodules}
220
221 dh_builddeb -p${pmodules}