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