chiark / gitweb /
* summer has new -B option for suppressing times of unusual node types.
[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         strip --strip-unneeded --remove-section .note --remove-section .comment $t/chiark-really/usr/sbin/really
80         cd $t/chiark-utils-bin/usr/share/man/man8 && \
81                 mv really.8 $t/chiark-really/usr/share/man/man8/
82         rm      $t/chiark-utils-bin/usr/sbin/trivsoundd \
83                 $t/chiark-utils-bin/usr/share/man/man8/trivsoundd.8
84         rmdir   $t/chiark-utils-bin/usr/sbin \
85                 $t/chiark-utils-bin/usr/share/man/man8
86         #
87         gzip -9f $t/*/usr/share/man/man*/*
88
89 binary-hook-chiark-backup:
90 binary-hook-chiark-rwbuffer:
91 binary-hook-sync-accounts:
92 binary-hook-chiark-scripts:
93 binary-hook-chiark-really:
94 binary-hook-chiark-utils-bin:
95
96 binary-one:
97         set -e; for f in preinst postinst prerm postrm conffiles; do \
98                 test -f debian/$p/$$f || continue; \
99                 cp debian/$p/$$f $t/$p/DEBIAN/$$f; \
100                 chmod u=rwX,go=rX $t/$p/DEBIAN/$$f; \
101         done
102         dpkg-gencontrol -isp -p$p -P$t/$p -Tdebian/sv-$p
103         chown -R root.root debian/tmp
104         chmod -R g-ws debian/tmp
105         debian/rules binary-hook-$p
106         dpkg --build $t/$p ..
107
108 binary-indep:   checkroot build binary-prep
109         set -e; for p in $(packages_indep); do \
110                 debian/rules binary-one p=$$p; done
111
112 binary-arch:    checkroot build binary-prep
113         $(checkdir)
114         dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \
115                 $t/chiark-rwbuffer/usr/bin/*
116         dpkg-shlibdeps -Tdebian/sv-chiark-really \
117                 $t/chiark-really/usr/sbin/*
118         set -e; for f in $t/chiark-utils-bin/usr/bin/*; do \
119                 case "$$f" in \
120                 */xacpi-simple)         d=Suggests      ;; \
121                 */watershed|*/summer)   d=Recommends    ;; \
122                 *)                      d=Depends       ;; \
123                 esac; \
124                 a="$$a -d$$d $$f"; \
125             done; set -x; \
126             dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin $$a
127         perl -i~ -pe '                                          '\
128          -e'    next unless m/^shlibs:/;                        '\
129          -e'    s/$$/,/; s/=/=, /;                              '\
130          -e'    s/, libgmp3(?:c2)?,/, libgmp3 | libgmp3c2,/;    '\
131          -e'    s/=, /=/; s/,$$//;                              '\
132                         debian/sv-*[!~]
133         set -e; for p in $(packages_arch); \
134                 do debian/rules binary-one p=$$p; done
135
136 define checkdir
137         test -f cprogs/writebuffer.c
138 endef
139
140 # Below here is fairly generic really
141
142 binary:         binary-indep binary-arch
143
144 source diff:
145         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
146
147 checkroot:
148         $(checkdir)
149         test root = "`whoami`"
150
151 .PHONY: binary binary-arch binary-indep clean checkroot