Update Debian packaging to 1.5.74.1-1
[openafs.git] / src / packaging / Debian / rules
1 #!/usr/bin/make -f
2 # Based on the sample debian/rules that uses debhelper. 
3 # GNU copyright 1997 by Joey Hess.
4
5 # Uncomment this to turn on verbose mode. 
6 #export DH_VERBOSE=1
7
8 # Tell Autoconf the correct system types.
9 DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
10 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
11 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
12     SYSTEM = --build $(DEB_HOST_GNU_TYPE)
13 else
14     SYSTEM = --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
15 endif
16
17 # Determine whether we're building with optimization.  This doesn't really
18 # work at the moment due to upstream problems.
19 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
20     DEBIAN_OPT_FLAGS = --disable-optimize --disable-optimize-lwp
21     DEBIAN_KERN_FLAGS = --disable-optimize-kernel
22 else
23     DEBIAN_OPT_FLAGS =
24     DEBIAN_KERN_FLAGS =
25 endif
26
27 SYS_NAME  := $(shell sh debian/sysname)
28
29 package    = openafs
30 srcpkg     = openafs-modules-source
31 dkmspkg    = openafs-modules-dkms
32 DOCS       = $(CURDIR)/debian/openafs-doc/usr/share/doc/openafs-doc
33
34 # The path to the XSLT used to generate HTML from the DocBook source files.
35 # This path is specific to different Linux distributions, so we have to pass
36 # it into configure.
37 HTML_XSL   = /usr/share/xml/docbook/stylesheet/nwalsh/html/chunk.xsl
38
39 # The /usr/share/doc directory for these packages should be a symlink to
40 # /usr/share/doc/openafs-client.  Any package on this list must depend on
41 # openafs-client.
42 DOC_PACKAGES = libpam-openafs-kaserver openafs-dbserver openafs-fuse \
43         openafs-kpasswd
44
45 # These are files that we know we don't want to install.  List them so that we
46 # can use dh_install --fail-missing and catch anything new that shows up.
47 IGNORE = -XAuthLog -Xcompile_et -Xcopyauth -Xdlog -Xdpass -Xfms.log         \
48         -Xfs_chgrp.1 -Xfs_chown.1 -Xfs_cscpolicy.1 -Xfs_flushall.1          \
49         -Xfs_memdump.1 -Xfs_minidump.1 -Xfs_trace.1 -Xkadb_check -Xkaserver \
50         -Xkdb -Xkdump -Xkpwvalid -Xlibafssetpag.so -Xlibafsrpc.so           \
51         -Xlibafsauthent.so -Xpackage -Xpagsh.krb -Xsymlink -Xtokens.krb     \
52         -Xuss -Xvldb_convert -Xvsys -Xxfs_size_check
53
54 # Installed via other means since we have to rename them.
55 IGNORE += -Xafsd.fuse.8 -Xpam_afs
56
57 # These variables are used by get-orig-source and to construct dkms.conf.
58 # You will need to change TAG to package stable releases instead of
59 # experimental releases.
60 DEBVERS := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 \
61                 | cut -d- -f1)
62 VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')
63 TAG     := $(shell echo 'openafs-devel-$(VERSION)' | sed 's/\./_/g')
64 REPO    := git://git.openafs.org/openafs.git
65
66 # Upstream does tarball releases for major releases, but not for point
67 # relesaes, and the tarball releases are split into src and doc and contain
68 # the WINNT directory.  Dropping WINNT, which is not used on Debian, saves a
69 # substantial amount of space in the source package, and there's no reason
70 # to include the files generated by regen.sh when we're going to run it
71 # again ourselves anyway.
72 #
73 # This rule therefore generates an upstream tarball from the upstream Git
74 # tag, rather than the tarball release, without the generated files that are
75 # not in Git and without the WINNT directory.  It assumes that git-core is
76 # installed and there's network connectivity to the upstream repository.
77 get-orig-source:
78         git archive --remote='$(REPO)' --prefix='openafs_$(DEBVERS).orig/' \
79             --format=tar '$(TAG)' | tar xf -
80         rm -r openafs_$(DEBVERS).orig/src/WINNT
81         tar cf openafs_$(DEBVERS).orig.tar openafs_$(DEBVERS).orig
82         rm -r openafs_$(DEBVERS).orig
83         gzip -9 openafs_$(DEBVERS).orig.tar
84
85 # Handle the renaming of the up man page to afs-up here since the man pages
86 # are generated from POD source by regen.sh.
87 build: build-arch build-indep
88 build-arch: build-stamp
89 build-indep:
90 build-stamp:
91         @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi
92         dh build --before configure
93         mv doc/man-pages/pod1/up.pod doc/man-pages/pod1/afs-up.pod
94         rm -f doc/man-pages/man1/up.1
95         sh regen.sh
96         afslogsdir=/var/log/openafs afslocaldir=/var/lib/openafs/local \
97             sh configure \
98             --with-afs-sysname=$(SYS_NAME) --disable-kernel-module \
99             --prefix=/usr --mandir=\$${prefix}/share/man \
100             --sysconfdir=/etc --libexecdir=/usr/lib \
101             --localstatedir=/var/lib --with-krb5-conf=/usr/bin/krb5-config \
102             --enable-supergroups --enable-demand-attach-fs \
103             --enable-disconnected --enable-fuse-client \
104             --with-xslt-processor=xsltproc --with-html-xsl=$(HTML_XSL) \
105             --enable-debug --enable-debug-lwp $(DEBIAN_OPT_FLAGS) $(SYSTEM)
106         chmod a+x config.sub src/libafs/make_kbuild_makefile.pl \
107             src/config/make_vnode.pl
108         dh build --after configure
109         $(MAKE) libafs_tree
110         set -e; for d in AdminGuide QuickStartUnix UserGuide ; do \
111             $(MAKE) -C doc/xml/$$d all ; \
112         done
113         touch $@
114
115 clean:
116         [ ! -f doc/man-pages/pod1/afs-up.pod ] \
117             || mv doc/man-pages/pod1/afs-up.pod doc/man-pages/pod1/up.pod
118         set -e; for d in AdminGuide QuickStartUnix UserGuide ; do \
119             [ ! -f doc/xml/$$d/Makefile ] || $(MAKE) -C doc/xml/$$d clean ; \
120         done
121         dh clean
122
123 install: install-stamp
124 install-stamp: build-stamp
125         dh install --until dh_prep
126         mkdir -p $(CURDIR)/debian/tmp
127         $(MAKE) install_nolibafs DESTDIR=$(CURDIR)/debian/tmp
128         rm -f debian/tmp/usr/bin/klog.krb
129         rm -f debian/tmp/usr/share/man/man1/klog.krb.1
130         chmod +x debian/afs-rootvol debian/afs-newcell
131         dh_installdirs
132         dh_install --fail-missing $(IGNORE)
133         dh_installinit -popenafs-client -r -- defaults 25 20
134         dh_installinit -popenafs-fileserver -r
135
136         mkdir -p $(DOCS)/html
137         cp doc/xml/*.gif doc/xml/*.html $(DOCS)/html/
138         set -e; for d in AdminGuide QuickStartUnix UserGuide ; do \
139             mkdir $(DOCS)/html/$$d ; \
140             cp doc/xml/$$d/*.html $(DOCS)/html/$$d/ ; \
141             cp doc/xml/$$d/*.pdf $(DOCS)/ ; \
142         done
143         cp doc/xml/AdminGuide/*.png $(DOCS)/html/AdminGuide/
144         mkdir $(DOCS)/html/arch-overview
145         cp doc/arch/arch-overview.h $(DOCS)/html/arch-overview
146         cd $(DOCS)/html/arch-overview && doxygen *.h && rm *.h && mv html/* . \
147             && rm -r latex html
148         set -e; for h in doc/protocol/*.h ; do \
149             mkdir $(DOCS)/html/`basename $$h .h` ; \
150             cp $$h $(DOCS)/html/`basename $$h .h` ; \
151             cd $(DOCS)/html/`basename $$h .h` && doxygen *.h && rm *.h \
152                 && mv html/* . && rm -r latex html && cd $(CURDIR) ; \
153         done
154
155         install -d debian/$(srcpkg)/usr/src/modules/$(package)
156         cd libafs_tree && find . -print | \
157             cpio -admp $(CURDIR)/debian/$(srcpkg)/usr/src/modules/$(package)
158         mkdir -p debian/$(srcpkg)/usr/src/modules/$(package)/debian
159         cp debian/copyright debian/module/* \
160             debian/$(srcpkg)/usr/src/modules/$(package)/debian/
161         sed 's/^openafs /openafs-modules /' debian/changelog \
162             > debian/$(srcpkg)/usr/src/modules/$(package)/debian/changelog
163         chmod 755 debian/$(srcpkg)/usr/src/modules/$(package)/debian/rules
164         chown -R root.src debian/$(srcpkg)
165         find debian/$(srcpkg) -type d | xargs chmod 755
166         find debian/$(srcpkg) -type f -perm -100 | xargs chmod 755
167         find debian/$(srcpkg) -type f -not -perm -100 | xargs chmod 644
168         chmod 775 debian/$(srcpkg)/usr/src/modules
169         cd debian/$(srcpkg)/usr/src && tar cf $(package).tar modules
170         bzip2 debian/$(srcpkg)/usr/src/$(package).tar
171         chmod 644 debian/$(srcpkg)/usr/src/$(package).tar.bz2
172         install -d debian/$(dkmspkg)/usr/src
173         mv debian/$(srcpkg)/usr/src/modules/$(package) \
174             debian/$(dkmspkg)/usr/src/openafs-$(VERSION)
175         rm -rf debian/$(dkmspkg)/usr/src/openafs-$(VERSION)/debian
176         rmdir debian/$(srcpkg)/usr/src/modules
177
178         set -e; for pkg in $(DOC_PACKAGES) ; do \
179             ln -s openafs-client debian/$$pkg/usr/share/doc/$$pkg; \
180         done
181
182         mv debian/openafs-client/usr/bin/pagsh \
183             debian/openafs-client/usr/bin/pagsh.openafs
184         mv debian/openafs-client/usr/share/man/man1/pagsh.1 \
185             debian/openafs-client/usr/share/man/man1/pagsh.openafs.1
186         mv debian/openafs-client/usr/bin/klog \
187             debian/openafs-client/usr/bin/klog.afs
188         mv debian/openafs-client/usr/share/man/man1/klog.1 \
189             debian/openafs-client/usr/share/man/man1/klog.afs.1
190         mv debian/openafs-client/usr/bin/up \
191             debian/openafs-client/usr/bin/afs-up
192
193         install -m 644 -c debian/tmp/usr/lib/pam_afs.so.1 \
194             debian/libpam-openafs-kaserver/lib/security/pam_afs.so
195         install -m 644 -c debian/tmp/usr/lib/pam_afs.krb.so.1 \
196             debian/libpam-openafs-kaserver/lib/security/pam_afs.krb.so
197
198         install -d debian/openafs-dbserver/usr/share/man/man8
199         ( cd debian && pod2man --section 8 --center "Debian GNU/Linux" \
200             afs-rootvol ) \
201             >debian/openafs-dbserver/usr/share/man/man8/afs-rootvol.8
202         ( cd debian && pod2man --section 8 --center "Debian GNU/Linux" \
203             afs-newcell ) \
204             >debian/openafs-dbserver/usr/share/man/man8/afs-newcell.8
205
206         install -d debian/$(srcpkg)/usr/share/doc/$(srcpkg)
207         install -m 644 debian/openafs-client.NEWS \
208             debian/$(srcpkg)/usr/share/doc/$(srcpkg)/NEWS.Debian
209
210         dh_dkms -V $(VERSION)
211         dh install --after dh_install
212         chmod 700 debian/openafs-client/var/cache/openafs
213         chmod 700 debian/openafs-dbserver/var/lib/openafs/db
214         chmod 700 debian/openafs-fileserver/var/lib/openafs/local
215         touch $@
216
217 binary-indep: install-stamp
218         dh binary-indep
219
220 # Only include debugging information for the servers installed into
221 # /usr/lib/openafs rather than for all binaries.  The servers are where
222 # debugging backtraces really matter, and a 10MB debugging package is
223 # overkill.
224 binary-arch: install-stamp
225         dh binary-arch --before dh_strip
226         dh_strip --dbg-package=openafs-dbg
227         rm -rf debian/openafs-dbg/usr/lib/debug/lib
228         rm -rf debian/openafs-dbg/usr/lib/debug/sbin
229         rm -rf debian/openafs-dbg/usr/lib/debug/usr/bin
230         rm -rf debian/openafs-dbg/usr/lib/debug/usr/sbin
231         dh binary-arch --remaining
232
233 binary: binary-indep binary-arch
234
235 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean
236 .PHONY: install