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