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