chiark / gitweb /
@@ -1,3 +1,11 @@
[chiark-utils.git] / debian / rules
1 #!/usr/bin/make -f
2
3 subdirs_build=  cprogs
4 subdirs_nobuild=backup sync-accounts scripts
5 package=        chiark-utils
6 packages_indep= chiark-backup chiark-scripts
7 packages_arch=  chiark-rwbuffer chiark-really chiark-utils-bin
8 packages=       $(packages_indep) $(packages_arch)
9
10 cwd=    $(shell pwd)
11 d=      $(cwd)/debian
12 t=      $d/tmp
13
14 build:
15         $(checkdir)
16         set -e; for s in $(subdirs_build); do $(MAKE) -C $$s all; done
17         touch build
18
19 clean:
20         $(checkdir)
21         rm -f build
22         set -e; for s in $(subdirs_build); do \
23                 $(MAKE) -C $$s -i distclean || \
24                 $(MAKE) -C $$s -f Makefile.in distclean; \
25         done
26         rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*
27
28 binary-prep:
29         $(checkdir)
30         rm -rf debian/tmp*
31         #
32         set -e; for s in $(subdirs_build) $(subdirs_nobuild); do \
33                 $(MAKE) -C $$s install install-docs install-examples \
34                         prefix=$t/$$s/usr \
35                         etcdir=$t/$$s/etc \
36                         varlib=$t/$$s/var/lib \
37                         mandir=$t/$$s/usr/share/man; \
38         done
39         #
40         mv $t/cprogs $t/chiark-utils-bin
41         #
42         cp -a debian/tmp/sync-accounts/* debian/tmp/scripts/.
43         rm -r debian/tmp/sync-accounts
44         mv debian/tmp/scripts debian/tmp/chiark-scripts
45         mv debian/tmp/backup debian/tmp/chiark-backup
46         #
47         set -e; for p in $(packages); do \
48                 install -d $t/$$p/DEBIAN $t/$$p/usr/share/doc/$$p; \
49                 cp debian/copyright debian/changelog \
50                         $t/$$p/usr/share/doc/$$p/; \
51                 ln -s changelog.gz \
52                         $t/$$p/usr/share/doc/$$p/changelog.Debian.gz; \
53                 gzip -9v $t/$$p/usr/share/doc/$$p/changelog; \
54                 done
55         #
56         install -d $t/chiark-rwbuffer/usr/bin
57         install -d $t/chiark-rwbuffer/usr/share/man/man1
58         cd $t/chiark-utils-bin/usr/bin && \
59                 mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin/
60         cd $t/chiark-utils-bin/usr/share/man/man1 && \
61                 mv readbuffer.1 writebuffer.1 $t/chiark-rwbuffer/usr/share/man/man1/
62         #
63         install -d $t/chiark-backup/usr/share/man/man1
64         cp backup/man/*.1 $t/chiark-backup/usr/share/man/man1/
65         cd $t/chiark-backup/usr/share/man/man1 && \
66                 for m in *.1; do \
67                         mv "$$m" backup-"$$m"; \
68                 done
69         cp \
70  $t/chiark-backup/usr/share/doc/chiark-backup/examples/chiark/settings.sh \
71  $t/chiark-backup/etc/chiark-backup/settings.sh
72         #
73         install -d $t/chiark-really/usr/sbin
74         install -d $t/chiark-really/usr/share/man/man8
75         cd $t/chiark-utils-bin/usr/sbin && \
76                 mv really $t/chiark-really/usr/sbin/
77         strip --strip-unneeded --remove-section .note --remove-section .comment $t/chiark-really/usr/sbin/really
78         cd $t/chiark-utils-bin/usr/share/man/man8 && \
79                 mv really.8 $t/chiark-really/usr/share/man/man8/
80         rm      $t/chiark-utils-bin/usr/sbin/trivsoundd \
81                 $t/chiark-utils-bin/usr/share/man/man8/trivsoundd.8
82         rmdir   $t/chiark-utils-bin/usr/sbin \
83                 $t/chiark-utils-bin/usr/share/man/man8
84         #
85         gzip -9f $t/*/usr/share/man/man*/*
86
87 binary-hook-chiark-backup:
88 binary-hook-chiark-rwbuffer:
89 binary-hook-sync-accounts:
90 binary-hook-chiark-scripts:
91 binary-hook-chiark-really:
92 binary-hook-chiark-utils-bin:
93
94 binary-one:
95         set -e; for f in preinst postinst prerm postrm conffiles; do \
96                 test -f debian/$p/$$f || continue; \
97                 cp debian/$p/$$f $t/$p/DEBIAN/$$f; \
98                 chmod u=rwX,go=rX $t/$p/DEBIAN/$$f; \
99         done
100         dpkg-gencontrol -isp -p$p -P$t/$p -Tdebian/sv-$p
101         chown -R root.root debian/tmp
102         chmod -R g-ws debian/tmp
103         debian/rules binary-hook-$p
104         dpkg --build $t/$p ..
105
106 binary-indep:   checkroot build binary-prep
107         set -e; for p in $(packages_indep); do \
108                 debian/rules binary-one p=$$p; done
109
110 binary-arch:    checkroot build binary-prep
111         $(checkdir)
112         dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \
113                 $t/chiark-rwbuffer/usr/bin/*
114         dpkg-shlibdeps -Tdebian/sv-chiark-really \
115                 $t/chiark-really/usr/sbin/*
116         dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin \
117                 $t/chiark-utils-bin/usr/bin/[^x]* \
118                 -dSuggests $t/chiark-utils-bin/usr/bin/x*
119         set -e; for p in $(packages_arch); \
120                 do debian/rules binary-one p=$$p; done
121
122 define checkdir
123         test -f cprogs/writebuffer.c
124 endef
125
126 # Below here is fairly generic really
127
128 binary:         binary-indep binary-arch
129
130 source diff:
131         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
132
133 checkroot:
134         $(checkdir)
135         test root = "`whoami`"
136
137 .PHONY: binary binary-arch binary-indep clean checkroot