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