3 # GNU copyright 1997 to 1999 by Joey Hess (sample file)
4 # Copyright 2000 to 2002 by Roland Mas and Christian Bayle for the Sourceforge package
5 # Copyright 2002 to 2008 by Roland Mas and Christian Bayle for the Gforge package
6 # Copyright 2008 to 2010 by Roland Mas and Christian Bayle for the FusionForge package
10 SRCPACKAGE=fusionforge
13 # Identify this FusionForge version
14 # keep type intact and change forge in derivates,
15 # unless there are deep changes (type is used for
16 # the Forge-Identification meta header)
17 WHICH_TYPE=FusionForge
18 WHICH_FORGE=FusionForge
19 WHICH_VERSION:=$(shell dpkg-parsechangelog | sed -n '/^Version: /s///p')
21 # Replace macros present in the files for forge's name
22 SED_REPLACE=sed -e 's/@PACKAGE@/$(PACKAGE)/g' -e 's/@SRCPACKAGE@/$(SRCPACKAGE)/g' -e 's/@OLDPACKAGE@/$(OLDPACKAGE)/g' -e 's/@FORGENAME@/$(FORGENAME)/g'
29 # The substitutions bellow can be quite tricky, so use 'debian/rules testpat' to check if it's OK
30 ENABLED_PLUGINS:=$(shell sh $(CURDIR)/utils/list-enabled-plugins.sh || echo error)
31 ifeq (${ENABLED_PLUGINS},error)
32 $(error list-enabled-plugins.sh failed)
35 PPOSTINST=$(foreach i,$(ENABLED_PLUGINS),debian/$(PACKAGE)-plugin-$i.postinst)
36 PPRERM=$(foreach i,$(ENABLED_PLUGINS),debian/$(PACKAGE)-plugin-$i.prerm)
38 CRONDFILES=$(patsubst packaging/cron.d/%,debian/$(OLDPACKAGE)-%.cron.d,$(wildcard packaging/cron.d/[a-z]*))
39 PCRONDFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/cron.d/[a-z]*),debian/$(PACKAGE)-plugin-$i.cron.d))
41 DIRSFILES=$(patsubst packaging/dirs/%,debian/$(OLDPACKAGE)-%.dirs,$(wildcard packaging/dirs/[a-z]*))
42 PDIRSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/dirs/[a-z]*),debian/$(PACKAGE)-plugin-$i.dirs))
44 LINKSFILES=$(patsubst packaging/links/%,debian/$(OLDPACKAGE)-%.links,$(wildcard packaging/links/[a-z]*))
45 PLINKSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/links/[a-z]*),debian/$(PACKAGE)-plugin-$i.links))
47 INSTALLFILES=$(patsubst packaging/install/%,debian/$(OLDPACKAGE)-%.install,$(wildcard packaging/install/[a-z]*))
48 PINSTALLFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/install/[a-z]*),debian/$(PACKAGE)-plugin-$i.install))
50 PTRIGGERSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/debian/[a-z]*.triggers),debian/$(PACKAGE)-plugin-$i.triggers))
52 DOCSFILES=$(patsubst packaging/docs/%,debian/$(OLDPACKAGE)-%.docs,$(wildcard packaging/docs/[a-z]*)) \
53 $(patsubst packaging/docs/%,debian/$(PACKAGE)-%.docs,$(wildcard packaging/docs/[a-z]*))
54 PDOCSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/docs/[a-z]*),debian/$(PACKAGE)-plugin-$i.docs))
56 PEXAMPLESSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/examples/[a-z]*),debian/$(PACKAGE)-plugin-$i.examples))
57 READMEFILES=$(patsubst packaging/readme/%,debian/$(OLDPACKAGE)-%.README.Debian,$(wildcard packaging/readme/[a-z]*)) \
58 $(patsubst packaging/readme/%,debian/$(PACKAGE)-%.README.Debian,$(wildcard packaging/readme/[a-z]*))
60 POFILES=$(patsubst debian/dsf-po/%,debian/po/%,$(wildcard debian/dsf-po/*) debian/po/POTFILES.in)
62 # Displays the variables to check if globbing and substitutions are correct
64 @echo "ENABLED_PLUGINS=$(ENABLED_PLUGINS)"
66 @echo "PPOSTINST=$(PPOSTINST)"
67 @echo "PPRERM=$(PPRERM)"
69 @echo "CRONDFILES=$(CRONDFILES)"
70 @echo "DIRSFILES=$(DIRSFILES)"
71 @echo "LINKSFILES=$(LINKSFILES)"
72 @echo "INSTALLFILES=$(INSTALLFILES)"
73 @echo "DOCSFILES=$(DOCSFILES)"
74 @echo "READMEFILES=$(READMEFILES)"
76 @echo "PCRONDFILES=$(PCRONDFILES)"
77 @echo "PDIRSFILES=$(PDIRSFILES)"
78 @echo "PLINKSFILES=$(PLINKSFILES)"
79 @echo "PINSTALLFILES=$(PINSTALLFILES)"
80 @echo "PDOCSFILES=$(PDOCSFILES)"
81 @echo "PEXAMPLESFILES=$(PEXAMPLESFILES)"
84 sh $(CURDIR)/deb-specific/manage-uufiles.sh clean
87 conffiles: $(PPOSTINST) $(PPRERM) $(CRONDFILES) $(DIRSFILES) $(LINKSFILES) $(INSTALLFILES) $(DOCSFILES) $(READMEFILES) $(PCRONDFILES) $(PDIRSFILES) $(PLINKSFILES) $(PINSTALLFILES) $(PDOCSFILES) $(PTRIGGERSFILES) $(PEXAMPLESFILES) debian/control
89 # Construct the plugin's 'postinst' script out of a template in debian/dsf-in/plugin.postinst
90 debian/$(PACKAGE)-plugin-%.postinst:
91 export PLUGLONGNAME="`cat $(CURDIR)/plugins/$*/NAME`"; \
92 [ -e $(CURDIR)/plugins/$*/debian/plugin-$*.postinst ] \
93 && $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/plugins/$*/debian/plugin-$*.postinst > $@ \
94 || $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/debian/dsf-in/plugin.postinst > $@
96 # Construct the plugin's 'prerm' script out of a template in debian/dsf-in/plugin.prerm
97 debian/$(PACKAGE)-plugin-%.prerm:
98 export PLUGLONGNAME="`cat $(CURDIR)/plugins/$*/NAME`"; \
99 [ -e $(CURDIR)/plugins/$*/debian/plugin-$*.prerm ] \
100 && $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/plugins/$*/debian/plugin-$*.prerm > $@ \
101 || $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/debian/dsf-in/plugin.prerm > $@
103 # Perform substitutions in plugin's cron.d file
104 debian/$(PACKAGE)-plugin-%.cron.d:
105 $(SED_REPLACE) -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/plugins/$*/packaging/cron.d/plugin-$* > $@
107 # Add a prefix and perform substitutions on the main cron.d files
108 debian/$(OLDPACKAGE)-%.cron.d:
109 (cat $(CURDIR)/packaging/cron.d/00phpcron ; $(SED_REPLACE) -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/packaging/cron.d/$*) | $(SED_REPLACE) > $@
111 # Perform subsitutions on 'dirs', 'links', 'install', 'docs', 'triggers' files
112 debian/$(PACKAGE)-plugin-%.dirs:
113 $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/dirs/plugin-$* > $@
115 debian/$(OLDPACKAGE)-%.dirs:
116 $(SED_REPLACE) $(CURDIR)/packaging/dirs/$* > $@
118 debian/$(PACKAGE)-plugin-%.links:
119 $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/links/plugin-$* > $@
121 debian/$(OLDPACKAGE)-%.links:
122 $(SED_REPLACE) $(CURDIR)/packaging/links/$* > $@
124 debian/$(PACKAGE)-plugin-%.install:
125 $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/install/plugin-$* > $@
127 debian/$(PACKAGE)-plugin-%.triggers:
128 $(SED_REPLACE) $(CURDIR)/plugins/$*/debian/plugin-$*.triggers > $@
130 debian/$(OLDPACKAGE)-%.install:
131 $(SED_REPLACE) $(CURDIR)/packaging/install/$* > $@
133 debian/$(PACKAGE)-plugin-%.docs:
134 $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/docs/plugin-$* > $@
135 debian/$(OLDPACKAGE)-%.docs:
136 $(SED_REPLACE) $(CURDIR)/packaging/docs/$* > $@
137 debian/$(PACKAGE)-%.docs:
138 $(SED_REPLACE) $(CURDIR)/packaging/docs/$* > $@
140 debian/$(PACKAGE)-plugin-%.examples:
141 $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/examples/plugin-$* > $@
143 debian/$(OLDPACKAGE)-%.README.Debian:
144 $(SED_REPLACE) $(CURDIR)/packaging/readme/$* > $@
145 debian/$(PACKAGE)-%.README.Debian:
146 $(SED_REPLACE) $(CURDIR)/packaging/readme/$* > $@
148 # Construct the control file
149 debian/control: $(wildcard packaging/control/*) $(wildcard plugins/*/packaging/control/[1-9][0-9][0-9]*) $(wildcard plugins/*/etc/*.ini)
150 ls $(CURDIR)/packaging/control/[0-9][0-9][0-9]* | grep -v shortdesc | \
151 while read file ; do \
153 if [ -f $${file}.shortdesc ] ; then \
154 cat $(CURDIR)/packaging/control/AAAdesc; \
156 cat $${file}.shortdesc; \
159 done | $(SED_REPLACE) > $@
160 @echo Enabled plugins: $(ENABLED_PLUGINS)
161 @echo Skipped plugins: $(shell sh $(CURDIR)/utils/list-enabled-plugins.sh --disabled)
162 for plugin in $(ENABLED_PLUGINS) ; do \
163 ls plugins/$$plugin/packaging/control/[1-9][0-9][0-9]plugin-$$plugin ; \
165 while read file ; do \
167 if [ -f $${file}.shortdesc ] ; then \
168 cat $(CURDIR)/packaging/control/AAAdesc; \
170 cat $${file}.shortdesc; \
173 done | $(SED_REPLACE) >> $@
175 # Update the translation of package descriptions fields
176 debian/po/templates.pot: $(wildcard debian/dsf-in/*.templates.dsfh-in) $(wildcard debian/dsf-helper/*.templates)
177 @debconf-updatepo --podir=debian/dsf-po
180 cat $(patsubst debian/po/%, debian/dsf-po/%, $@) | $(SED_REPLACE) > $@
182 override_dh_auto_build:
184 build: remove-binary-files debian/po/templates.pot conffiles
187 # Build man pages from Docbook sources
188 cat debian/dsf-in/config.sgml | $(SED_REPLACE) > debian/$(PACKAGE)-config.sgml
189 cat debian/dsf-in/common.manpages | $(SED_REPLACE) > debian/$(OLDPACKAGE)-common.manpages
190 /usr/bin/docbook-to-man debian/cvssh.sgml > cvssh.1
191 /usr/bin/docbook-to-man debian/$(PACKAGE)-config.sgml > $(PACKAGE)-config.1
193 # Build README.Debian from template
194 cat debian/README.Debian.tmpl | $(SED_REPLACE) > debian/README.Debian
196 # Uudecode binary files
197 sh $(CURDIR)/deb-specific/manage-uufiles.sh decode
199 # Build gettext *.mo files
200 utils/manage-translations.sh build
202 # Build FHS-compatible Apache config files (generates contents of etc/httpd.conf.d-fhs/ etc.)
203 utils/manage-apache-config.sh build
205 # Update SQL for list of country codes
206 utils/ffcountries.pl > 200403251.sql
208 # Preprocess files with DSF-Helper
209 perl $(CURDIR)/deb-specific/dsf-helper.pl
211 clean: remove-binary-files
214 rm -f $(CURDIR)/debian/*.cron.d
215 rm -f $(CURDIR)/debian/*.dirs
216 rm -f $(CURDIR)/debian/*.links
217 rm -f $(CURDIR)/debian/*.install
218 rm -f $(CURDIR)/debian/*.docs
219 rm -f $(CURDIR)/debian/*.examples
220 rm -f $(CURDIR)/debian/*.README.Debian
221 rm -f $(CURDIR)/debian/$(PACKAGE)-config.sgml
222 rm -f $(CURDIR)/debian/$(OLDPACKAGE)-common.manpages
223 rm -f cvssh.1 $(PACKAGE)-config.1 200403251.sql
224 rm -f $(CURDIR)/debian/README.Debian
227 rm -f $(POFILES) $(PPOSTINST) $(PPRERM)
229 perl $(CURDIR)/deb-specific/dsf-helper.pl --clean
233 rm -fr $(CURDIR)/etc/httpd.conf.d-fhs/ $(CURDIR)/etc/httpd.conf.d-opt/ $(CURDIR)/etc/httpd.conf.d-usrlocal/
239 -e 's!@PKGNAME@!${WHICH_FORGE}!g' \
240 -e 's!@PKGVERSION@!${WHICH_VERSION}!g' \
241 -e 's!@PLUCKERNAME@!${WHICH_TYPE}!g' \
242 <$(CURDIR)/deb-specific/pkginfo.inc.php \
243 >$(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/$(OLDPACKAGE)/common/pkginfo.inc.php
246 chmod 755 $(CURDIR)/debian/*/*/*/*/bin/* $(CURDIR)/debian/*/*/*/*/cronjobs/* \
247 $(CURDIR)/debian/*/bin/* $(CURDIR)/debian/*/usr/share/*/plugins/*/bin/* \
248 $(CURDIR)/debian/*/usr/share/*/plugins/*/cronjobs/*
249 chmod 644 $(CURDIR)/debian/$(OLDPACKAGE)-db-postgresql/usr/share/$(OLDPACKAGE)/cronjobs/*.inc
251 chmod 755 $(CURDIR)/debian/$(OLDPACKAGE)-db-postgresql/usr/share/*/db/*.php
253 rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/scm/viewvc/bin/cgi/viewvc-strace.sh
255 find $(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/*/common/docman/engine/ -type f -name \*.php -not -name \*.inc.php -exec chmod 0755 {} \;
256 find $(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/*/common/docman/engine/ -type f -name \*.sh -exec chmod 0755 {} \;
258 rm -f $(CURDIR)/debian/$(PACKAGE)-plugin-scm*/usr/share/*/plugins/scm*/*/README
259 chmod 755 $(CURDIR)/debian/$(PACKAGE)-plugin-scmcvs/usr/share/*/plugins/scmcvs/sbin/*
261 # Rename config files
262 mv $(CURDIR)/debian/$(OLDPACKAGE)-common/etc/$(PACKAGE)/config.ini-fhs $(CURDIR)/debian/$(OLDPACKAGE)-common/etc/$(PACKAGE)/config.ini
263 mkdir -p $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d
264 cp $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/$(OLDPACKAGE)/etc/httpd.conf.d-fhs/*.conf $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/
265 cp $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/$(OLDPACKAGE)/etc/httpd.conf.d-fhs/*.inc $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/
266 cp $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/$(OLDPACKAGE)/etc/httpd.conf-fhs $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf
268 # Remove those that need to be generated at install time
269 rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/secrets.inc
270 rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-list.inc
271 rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-main.inc
272 rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-projects.inc
274 # Remove Windows files
275 rm -rf $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/scm/viewvc/windows
277 # Remove extra copies of the GNU GPLv2
278 rm -f $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/themes/*/COPYING
280 # Remove Snoopy class from binary packages (provided by libphp-snoopy)
281 find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name Snoopy.class.php | xargs -r rm
283 # Remove NuSOAP class from binary packages (provided by libnusoap-php)
284 find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name nusoap.php | xargs -r rm
286 # Remove potential SCM artefacts from binary packages
287 find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name .svn -or -name {arch} -or -name .arch-ids -or -name .bzr -or -name .cvsignore | xargs -r rm -rf
289 # Also remove uuencoded files
290 find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name \*.uu | xargs -r rm