debian-packagings-20020826
[openafs.git] / src / packaging / Debian / rules
1 #!/usr/bin/make -f
2 # Sample debian/rules that uses debhelper. 
3 # GNU copyright 1997 by Joey Hess.
4 #
5 # This version is for a hypothetical package that builds an
6 # architecture-dependant package, as well as an architecture-independent
7 # package.
8
9 # Uncomment this to turn on verbose mode. 
10 #export DH_VERBOSE=1
11
12 # This is the debhelper compatability version to use.
13 export DH_COMPAT=2
14
15 # This has to be exported to make some magic below work.
16 export DH_OPTIONS
17
18 # The AFS sysname is determined by a script
19 KVERS=`awk '{ if (NR==1) v=$$3; else if (NR==2) p=$$3; else if (NR==3) s=$$3; \
20        else if (NR==4) { e=$$3; exit; } } \
21        END { printf("%s.%s.%s%s\n",v,p,s,e); }' $(KSRC)/Makefile`
22 SYS_NAME=$(shell KVERS=$(KVERS) sh debian/sysname)
23 package=openafs
24 srcpkg = openafs-modules-source
25 modulepkg=$(shell echo openafs-modules-$(KVERS)${INT_SUBARCH})
26 ifndef KSRC
27 KSRC=/usr/src/linux
28 endif
29 MODDIR=..
30 LINTIAN_PACKAGES= openafs-client openafs-fileserver
31 export KSRC 
32 export KVERS
33
34
35 configure: configure-stamp
36 configure-stamp:
37         dh_testdir
38         -ln -s @sys/dest dest
39         -ln -s $(SYS_NAME) @sys
40 #       sh regen.sh
41          afslogsdir=/var/log/openafs sh configure --with-afs-sysname=$(SYS_NAME) --disable-kernel-module \
42         --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib \
43         --localstatedir=/var/lib 
44         install -d $(SYS_NAME)/dest/root.client/usr/vice/etc
45         install -d dest/root.server/usr/afs/bin
46
47         touch configure-stamp
48
49 build: configure-stamp build-stamp
50 build-stamp:
51         dh_testdir
52
53         $(MAKE) dest 
54         -rm $(SYS_NAME)/dest/include/crypt.h
55         touch build-stamp
56
57 clean:
58         dh_testdir
59         dh_testroot
60         rm -f build-stamp configure-stamp build-modules-stamp
61         # Add here commands to clean up after the build process.
62         -$(MAKE) -ki distclean
63         -rm -rf obj dest $(SYS_NAME) @sys Makefile debian/openafs-client.init
64         -rm -rf config.status config.cache lib include
65         dh_clean
66
67 install: DH_OPTIONS=
68 install: build
69         dh_testdir
70         dh_testroot
71         dh_clean -k
72         dh_installdirs
73         mkdir -p debian/openafs-dbserver/usr/share/man/man8
74                 /usr/bin/docbook-to-man debian/pt_util.sgml >debian/openafs-dbserver/usr/share/man/man8/pt_util.8
75         for foo in $(LINTIAN_PACKAGES) ; do \
76                 install -d debian/$$foo/usr/share/lintian/overrides; \
77                 cp debian/$$foo.lintian debian/$$foo/usr/share/lintian/overrides/$$foo; \
78                 done
79         for pkg in openafs-dbserver openafs-fileserver openafs-kpasswd; do \
80                 ln -s openafs-client debian/$$pkg/usr/share/doc/$$pkg; \
81                 done
82         # Add here commands to install the package into debian/tmp.
83         cat debian/filelist |sh debian/movefiles
84         mv debian/openafs-client/usr/bin/pagsh  \
85         debian/openafs-client/usr/bin/pagsh.openafs
86
87         cp debian/CellServDB debian/openafs-client/usr/share/openafs
88         cp dest/root.client/usr/vice/etc/afs.rc debian/openafs-client.init
89         cp dest/root.client/usr/vice/etc/afs.conf debian/openafs-client/etc/openafs/afs.conf
90         install -m 755 -o root -g root debian/afs-rootvol debian/openafs-dbserver/usr/sbin
91         install -g root -o root -m 755 debian/afs-newcell \
92                 debian/openafs-dbserver/usr/sbin
93         install -D -m 644 debian/ConfigUtils.pm \
94                 debian/openafs-dbserver/usr/lib/perl5/Debian/OpenAFS/ConfigUtils.pm
95         (cd debian&&pod2man --section 8 --center "Debian GNU/Linux"  \
96                 afs-rootvol ) >debian/openafs-dbserver/usr/share/man/man8/afs-rootvol.8
97         (cd debian&&pod2man --section 8 --center "Debian GNU/Linux"  \
98                 afs-newcell ) >debian/openafs-dbserver/usr/share/man/man8/afs-newcell.8
99         # No, includes should not have the x bit set
100         find debian/libopenafs-dev/usr/include -type f -print | \
101                 xargs chmod a-x
102         # And drop the pam modules
103         rm debian/libopenafs-dev/usr/lib/*pam*
104
105 # Build architecture-independent files here.
106 # Pass -i to all debhelper commands in this target to reduce clutter.
107 binary-indep: DH_OPTIONS=-i
108 binary-indep: build install binary-source
109         # Need this version of debhelper for DH_OPTIONS to work.
110         dh_testversion 1.1.17
111         dh_testdir
112         dh_testroot
113 #       dh_installdebconf
114         dh_installdocs
115         dh_installexamples
116         dh_installmenu
117 #       dh_installemacsen
118 #       dh_installpam
119 #       dh_installinit
120         dh_installcron
121 #       dh_installmanpages
122         dh_installinfo
123         dh_undocumented
124         dh_installchangelogs   ChangeLog
125         dh_link
126         dh_compress
127         dh_fixperms
128         # You may want to make some executables suid here.
129         dh_suidregister
130         dh_installdeb
131 #       dh_perl
132         dh_gencontrol
133         dh_md5sums
134         dh_builddeb
135
136 # Build architecture-dependent files here.
137 # Pass -a to all debhelper commands in this target to reduce clutter.
138 binary-arch: DH_OPTIONS=-a
139 binary-arch: build install
140         # Need this version of debhelper for DH_OPTIONS to work.
141         dh_testversion 1.1.17
142         dh_testdir
143         dh_testroot
144         dh_installdebconf
145         dh_installdocs
146         dh_installexamples
147         dh_installmenu
148 #       dh_installemacsen
149 #       dh_installpam
150         DH_OPTIONS= dh_installinit -popenafs-client -r -- defaults 25 18
151         DH_OPTIONS= dh_installinit -popenafs-fileserver -r
152         dh_installcron
153 #       dh_installmanpages
154         dh_installinfo
155         dh_undocumented
156         dh_installchangelogs   ChangeLog
157         dh_strip
158         dh_link
159         dh_compress
160         dh_fixperms
161         # You may want to make some executables suid here.
162         chmod 700 debian/openafs-client/var/cache/openafs
163         chmod 700 debian/openafs-fileserver/etc/openafs/server
164         chmod 700 debian/openafs-dbserver/var/lib/openafs/db
165         chmod 700 debian/openafs-fileserver/var/lib/openafs/cores
166         dh_suidregister
167         dh_installdeb
168 #       dh_makeshlibs
169 #       dh_perl
170         dh_shlibdeps
171         dh_gencontrol
172         dh_md5sums
173         dh_builddeb
174
175 binary:   binary-indep binary-arch
176 .PHONY: build clean binary-indep binary-arch binary install configure
177
178 ############################Module package support
179 kdist_image:  build-modules
180         $(MAKE) $(MFLAGS) -f debian/rules MODDIR=$(KSRC)/.. binary-modules
181         $(MAKE) $(MFLAGS) -f debian/rules MODDIR=$(KSRC)/.. clean
182
183 kdist:  build-modules
184         $(MAKE) $(MFLAGS) -f debian/rules MODDIR=$(KSRC)/.. KERNEL_DEPENDS=y binary-modules
185         KSRC="$(KSRC)" KMAINT="$(KMAINT)" KEMAIL="$(KEMAIL)" \
186                 sh -v debian/genchanges.sh
187         $(MAKE) $(MFLAGS) -f debian/rules MODDIR=$(KSRC)/.. clean
188
189
190
191 kdist_config: configure
192
193 kdist_clean: clean
194
195 ############################ source stuff #################################
196 binary-source:
197 # Perform some tests
198         test -f debian/rules
199         test `id -u` = "0"
200
201
202 # Setup everything first
203         -rm -rf debian/$(srcpkg) debian/substvars
204         install -d debian/$(srcpkg)
205 # Clean up the sources  
206         install -d debian/$(srcpkg)/usr/src/modules/$(package)
207         find . \( -name \*.o -o -path ./debian/$(srcpkg) -o -path \*/CVS -o -path ./src/WINNT  \
208                 -o -path ./obj -o -path ./$(SYS_NAME)  \
209         -o \( -path ./debian/\* -type d \) \
210         -o -path ./debian/\*debhelper \) -prune -o -print | \
211                 cpio -admp debian/$(srcpkg)/usr/src/modules/$(package)
212         ( cd debian/$(srcpkg)/usr/src/modules/$(package)&& \
213                 $(MAKE) -f debian/rules clean && \
214         rm -rf src/libafs/rx src/libafs/afs src/libafs/afsint; \
215                 mv debian/kern-sysname debian/sysname)
216         chown -R root.root debian/$(srcpkg)
217         find debian/$(srcpkg) -type d | xargs chmod 755
218         find debian/$(srcpkg) -type f -perm -100 | xargs chmod 755
219         find debian/$(srcpkg) -type f -not -perm -100 | xargs chmod 644
220         cd debian/$(srcpkg)/usr/src && \
221           tar cf $(package).tar modules && \
222           $(RM) -r modules/$(package)
223         gzip -9 debian/$(srcpkg)/usr/src/$(package).tar
224         chmod 644 debian/$(srcpkg)/usr/src/$(package).tar.gz
225 ############################ modules stuff #################################
226
227 build-modules: build-modules-stamp
228
229 build-modules-stamp: 
230         -ln -s @sys/dest dest
231         -ln -s $(SYS_NAME) @sys
232         sh configure --with-afs-sysname=$(SYS_NAME) --with-linux-kernel-headers=$(KSRC)
233         make dest_only_libafs
234         touch build-modules-stamp
235
236 binary-modules: build-modules
237 # Perform some tests
238         test -f debian/rules
239         test `id -u` = "0"
240
241 # Setup everything first
242         -rm -rf debian/$(modulepkg) debian/substvars
243         install -d debian/$(modulepkg)
244
245 # Install the software
246         install -d -g root -o root -m 755 debian/$(modulepkg)/lib/modules/$(KVERS)/fs
247         install -g root -o root -m 755  dest/root.client/usr/vice/etc/modload/*.o \
248                 debian/$(modulepkg)/lib/modules/$(KVERS)/fs
249 # Fix some stuff up
250         install -d -o root -g root -m 755 debian/$(modulepkg)/usr/share/doc
251         ln -s openafs-client debian/$(modulepkg)/usr/share/doc/$(modulepkg)
252         rm -rf debian/$(modulepkg)/usr/include
253 ifeq ($(KERNEL_DEPENDS),y)
254         sh debian/prep-modules $(KSRC) debian/control.module > debian/control
255 else
256         sh debian/prep-modules $(KSRC) debian/control.module-image > debian/control
257 endif
258
259 # Install control files
260         install -d -o root -g root -m 755 debian/$(modulepkg)/DEBIAN
261         install -p -o root -g root -m 755 debian/prerm.mod \
262                 debian/$(modulepkg)/DEBIAN/prerm
263         install -p -o root -g root -m 755 debian/postinst.mod \
264                 debian/$(modulepkg)/DEBIAN/postinst
265
266 # And now.. for the final packaging!
267         find debian/$(modulepkg) -type f | grep -v "./DEBIAN" | xargs md5sum | \
268                 sed -e 's#debian/$(modulepkg)/##' > debian/$(modulepkg)/DEBIAN/md5sums
269
270         dpkg-gencontrol -isp \
271                 -p$(modulepkg) \
272                 -v`cat debian/VERSION` \
273                 -Pdebian/$(modulepkg)
274         chown -R root.root debian/$(modulepkg)
275         chmod -R go=rX debian/$(modulepkg)
276         dpkg --build debian/$(modulepkg) $(MODDIR)