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