Add Debian directory
[mspang/vmailman.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*- made with the aid of debmake, by Christoph Lameter,
3 # based on the sample debian/rules file for GNU hello by Ian Jackson.
4
5 package=mailman
6 PACKAGE=$(package)
7
8 include /usr/share/quilt/quilt.make
9
10 binaries=list_lists find_member config_list mmsitepass newlist rmlist   \
11         add_members list_members remove_members arch clone_member       \
12         sync_members check_db check_perms list_admins withlist
13
14 #export DH_VERBOSE=1
15
16 SHELL=/bin/bash
17
18 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
19 CFLAGS += -g
20 endif
21 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
22 INSTALL_PROGRAM += -s
23 endif
24
25 build: patch build-stamp
26 build-stamp: Makefile debian/po/templates.pot
27         $(MAKE) 
28         touch build-stamp
29
30 debian/po/templates.pot: debian/templates
31         @debconf-updatepo
32
33 Makefile:
34         if [ -x /usr/bin/autoconf2.50 ]; then \
35           autoconf2.50; \
36         else \
37           autoconf; \
38         fi
39         ./configure --prefix=/var/lib/$(package) --with-username=list \
40                 --with-groupname=list \
41                 --with-mail-gid=daemon --with-cgi-gid=www-data \
42                 --without-permcheck --with-mailhost=localhost \
43                 --with-urlhost=localhost
44
45 clean: unpatch
46         dh_testdir
47         -$(MAKE) distclean
48         rm -rf build-stamp Makefile debian/ucffiles debian/mailman.postinst.ucf
49         rm -f debian/mailman.postrm.ucf
50         dh_clean
51         chmod +x debian/{prerm,postinst}
52
53 binary-indep:   checkroot build
54         dh_testdir
55 # There are no architecture-independent files to be uploaded
56 # generated by this package.  If there were any they would be
57 # made here.
58
59
60 binary-arch:    checkroot build
61         dh_testdir
62         chmod +x debian/unicodify_archives.py
63         dh_install
64         dh_installdirs
65         dh_installdocs ACKNOWLEDGMENTS README* TODO FAQ
66         dh_installchangelogs NEWS
67         $(MAKE) doinstall prefix=$$(pwd)/debian/mailman/var/lib/$(package) \
68                 var_prefix=$$(pwd)/debian/mailman/var/lib/$(package) \
69                 icondir=$$(pwd)/debian/mailman/usr/share/images/mailman \
70                 ICONDIR=$$(pwd)/debian/mailman/usr/share/images/mailman
71
72         #rmdir debian/$(package)/var/lib/mailman/pythonlib
73
74 # move the nonchanging directories to /usr/lib/mailman, except for
75 # cgi-bin, which goes to /usr/lib/cgi-bin/mailman
76
77         cd debian/mailman/var/lib/$(package) ; \
78            mv cgi-bin ../../../usr/lib/cgi-bin/mailman ; \
79            for i in Mailman bin cron mail scripts pythonlib; do \
80                 mv $$i ../../../usr/lib/$(package); \
81            done
82
83
84         # link them back to /var/lib/mailman
85         for i in debian/mailman/usr/lib/$(package)/*; do \
86            dh_link usr/lib/$(package)/`basename $$i` var/lib/$(package)/`basename $$i`; \
87         done
88
89         # Link cgi-bin as well
90         dh_link usr/lib/cgi-bin/$(package) var/lib/$(package)/cgi-bin
91
92         # Backwards compatibility link
93         dh_link usr/lib/mailman/mail/mailman usr/lib/mailman/mail/wrapper
94         dh_link usr/share/images/mailman usr/share/doc/mailman/images
95         rmdir debian/$(package)/var/lib/mailman/icons
96         dh_link usr/share/images/mailman var/lib/mailman/icons
97
98         # move the templates to /etc/mailman
99         mv debian/mailman/var/lib/$(package)/templates debian/mailman/etc/mailman
100
101         # link it back to /var/lib/mailman/templates
102         dh_link etc/mailman var/lib/$(package)/templates
103
104         # remove the log directory and link it to /var/log/mailman
105         rmdir debian/mailman/var/lib/$(package)/logs 
106         dh_link var/log/mailman var/lib/$(package)/logs
107
108         # move the pending subscriptions database so it doesnt overwrite the
109         # old one when installing
110
111         # move the locks to /var/lock
112         mv debian/mailman/var/lib/$(package)/locks debian/mailman/var/lock/mailman
113
114         # link it back to /var/lib/mailman/locks
115         dh_link var/lock/mailman var/lib/$(package)/locks
116
117         dh_installlogrotate
118
119         install -m 0644 debian/mm_cfg.py debian/mailman/usr/lib/mailman/Mailman/mm_cfg.py.dist
120
121         rm debian/$(package)/usr/lib/$(package)/Mailman/mm_cfg.py
122         dh_link etc/$(package)/mm_cfg.py \
123                 usr/lib/$(package)/Mailman/mm_cfg.py
124         cp -a admin/www debian/mailman/usr/share/doc/$(package)/html
125         for bin in $(binaries); \
126                 do dh_link usr/lib/$(package)/bin/$$bin usr/sbin/$$bin; done
127         mv debian/mailman/usr/sbin/arch debian/mailman/usr/sbin/mmarch
128         dh_installman
129         dh_installinit
130         dh_installdebconf
131         dh_installexamples templates/* debian/mm_cfg.py \
132                 debian/mailman/usr/lib/$(package)/Mailman/Defaults.py
133         dh_strip
134         dh_compress
135         dh_fixperms
136         chown -R root:root debian/mailman
137         chown -R root:list \
138                 debian/mailman/{etc/$(package),var/lib/$(package),usr/lib/{$(package),cgi-bin/$(package)}}
139         chown list:list debian/mailman/var/{lock/mailman,lib/mailman/qfiles,run/mailman}
140         chown root:list debian/mailman/var/log/mailman
141         find debian/mailman/var/lib/$(package) -type d -exec chmod 2775 {} \;
142         find debian/mailman/var/lib/$(package)/messages -type d -exec chmod 755 {} \;
143
144         # make lintian happy
145         install -m 0644 debian/lintian-overrides debian/mailman/usr/share/lintian/overrides/mailman
146
147 # Spamassassin plugin
148         install -m 0644 debian/contrib/SpamAssassin.py debian/mailman/usr/lib/$(package)/Mailman/Handlers
149         install -m 0644 debian/contrib/spamd.py debian/mailman/usr/lib/$(package)/Mailman/Handlers
150
151 # postfix-to-mailman.py
152         install -m 0755 debian/contrib/postfix-to-mailman.py debian/mailman/usr/share/mailman
153         dh_link etc/mailman/postfix-to-mailman.py usr/lib/mailman/bin/postfix-to-mailman.py
154
155 # apache default config
156         install -m 0644 debian/contrib/apache.conf debian/mailman/etc/mailman
157
158 # Move templates
159         mv `find debian/mailman/etc/mailman -mindepth 1 -maxdepth 1 -type d` debian/mailman/usr/share/mailman
160         cp build/contrib/qmail-to-mailman.py debian/mailman/usr/share/mailman
161
162         find debian/mailman/usr/share/mailman -type f -printf '/etc/mailman/%P\n' > debian/ucffiles
163
164         dh_link etc/mailman/qmail-to-mailman.py usr/lib/mailman/bin/qmail-to-mailman.py
165
166
167 # Fix permissions
168         chmod +x debian/mailman/usr/lib/$(package)/Mailman/Cgi/*
169 #       chmod +x debian/mailman/usr/lib/$(package)/scripts/*
170         chmod +x debian/mailman/usr/lib/$(package)/Mailman/Archiver/pipermail.py
171
172         chmod g+s debian/mailman/usr/lib/cgi-bin/mailman/* \
173                 debian/mailman/usr/lib/mailman/mail/mailman
174
175         chmod -x debian/mailman/usr/lib/$(package)/scripts/paths.py \
176                 debian/mailman/usr/lib/$(package)/Mailman/Cgi/*
177
178         chmod o-x debian/mailman/var/lib/$(package)/archives/private
179         chmod 0755 debian/mailman/usr/lib/$(package)/cron/*
180         chmod 0644 debian/mailman/usr/lib/$(package)/cron/{crontab.in,paths.py}
181         chmod 2775 debian/mailman/var/log/mailman
182         chmod g+w debian/mailman/var/lock/mailman
183
184 #       Python Policy
185         dh_pysupport -a `find debian/mailman/usr/lib/mailman/Mailman/ debian/mailman/usr/lib/mailman/pythonlib/ -type d`
186
187         install -d debian/mailman/usr/share/python/runtime.d
188         install debian/mailman.rtupdate debian/mailman/usr/share/python/runtime.d
189
190
191         egrep -rlZ '^#!(.*)python' debian/mailman/usr/lib/mailman | xargs -0 chmod a+x --
192         find debian/mailman/usr/share/doc/mailman -name "*.html" -exec chmod -x {} \;
193         find debian/mailman/usr/share/doc/mailman -name "*.txt" -exec chmod -x {} \;
194
195         dh_installdeb
196
197 #       echo 'if [ "$$1" = purge ]; then' >> debian/mailman.postrm.ucf
198 #       for f in `cat debian/ucffiles`; do \
199 #               echo -e "\techo Removing $$f" >> debian/mailman.postrm.ucf; \
200 #               echo -e "\tucf --debconf-ok --purge $$f" >> debian/mailman.postrm.ucf ; \
201 #       done
202 #       echo 'fi' >> debian/mailman.postrm.ucf
203
204 #       echo 'if [ "$$1" = "configure" ]; then'>> debian/mailman.postinst.ucf
205 #       for dir in $$(for f in $$(cat debian/ucffiles); do dirname "$$f" ; done | sort | uniq); do echo -e "\tmkdir -p $$dir" >> debian/mailman.postinst.ucf ; done
206
207 #       echo -e "\techo -n 'Checking/installing config files (this takes time)': " >> debian/mailman.postinst.ucf
208 #       for f in `cat debian/ucffiles`; do \
209 #               echo -e "\techo -n ." >> debian/mailman.postinst.ucf ; \
210 #               echo -e "\tucf `echo $$f | sed s,/etc/mailman,/usr/share/mailman,` $$f < /dev/tty > /dev/tty" >> debian/mailman.postinst.ucf ; \
211 #       done
212 #       echo 'fi' >> debian/mailman.postinst.ucf
213 #       echo -e "\techo \" done!\"" >> debian/mailman.postinst.ucf
214
215 #       perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postinst.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postinst
216 #       perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postrm.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postrm
217
218         dh_shlibdeps
219         dh_gencontrol
220         dh_md5sums
221         dh_builddeb
222
223
224 # Below here is fairly generic really
225
226 binary:         binary-indep binary-arch
227
228 checkroot:
229         dh_testdir
230         dh_testroot
231
232 .PHONY: binary binary-arch binary-indep clean checkroot