SRCPACKAGE=fusionforge
FORGENAME=FusionForge
+# Identify this FusionForge version
+# keep type intact and change forge in derivates,
+# unless there are deep changes (type is used for
+# the Forge-Identification meta header)
+WHICH_TYPE=FusionForge
+WHICH_FORGE=FusionForge
+WHICH_VERSION:=$(shell dpkg-parsechangelog | sed -n '/^Version: /s///p')
+
+# Replace macros present in the files for forge's name
SED_REPLACE=sed -e 's/@PACKAGE@/$(PACKAGE)/g' -e 's/@SRCPACKAGE@/$(SRCPACKAGE)/g' -e 's/@OLDPACKAGE@/$(OLDPACKAGE)/g' -e 's/@FORGENAME@/$(FORGENAME)/g'
default:
@echo $(PACKAGE)
-include /usr/share/dpatch/dpatch.make
+# The substitutions bellow can be quite tricky, so use 'debian/rules testpat' to check if it's OK
+ENABLED_PLUGINS=$(shell sh $(CURDIR)/utils/list-enabled-plugins.sh)
+
+PPOSTINST=$(foreach i,$(ENABLED_PLUGINS),debian/$(PACKAGE)-plugin-$i.postinst)
+PPRERM=$(foreach i,$(ENABLED_PLUGINS),debian/$(PACKAGE)-plugin-$i.prerm)
CRONDFILES=$(patsubst packaging/cron.d/%,debian/$(OLDPACKAGE)-%.cron.d,$(wildcard packaging/cron.d/[a-z]*))
-PCRONDFILES=$(patsubst %,debian/$(PACKAGE)-%.cron.d,$(shell ls plugins/*/packaging/cron.d/[a-z]* | sed 's:.*/\(.[^/]*\):\1:'))
+PCRONDFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/cron.d/[a-z]*),debian/$(PACKAGE)-plugin-$i.cron.d))
DIRSFILES=$(patsubst packaging/dirs/%,debian/$(OLDPACKAGE)-%.dirs,$(wildcard packaging/dirs/[a-z]*))
-PDIRSFILES=$(patsubst %,debian/$(PACKAGE)-%.dirs,$(shell ls plugins/*/packaging/dirs/[a-z]* | sed 's:.*/\(.[^/]*\):\1:'))
+PDIRSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/dirs/[a-z]*),debian/$(PACKAGE)-plugin-$i.dirs))
LINKSFILES=$(patsubst packaging/links/%,debian/$(OLDPACKAGE)-%.links,$(wildcard packaging/links/[a-z]*))
-PLINKSFILES=$(patsubst %,debian/$(PACKAGE)-%.links,$(shell ls plugins/*/packaging/links/[a-z]* | sed 's:.*/\(.[^/]*\):\1:'))
+PLINKSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/links/[a-z]*),debian/$(PACKAGE)-plugin-$i.links))
INSTALLFILES=$(patsubst packaging/install/%,debian/$(OLDPACKAGE)-%.install,$(wildcard packaging/install/[a-z]*))
-PINSTALLFILES=$(patsubst %,debian/$(PACKAGE)-%.install,$(shell ls plugins/*/packaging/install/[a-z]* | sed 's:.*/\(.[^/]*\):\1:'))
+PINSTALLFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/install/[a-z]*),debian/$(PACKAGE)-plugin-$i.install))
DOCSFILES=$(patsubst packaging/docs/%,debian/$(OLDPACKAGE)-%.docs,$(wildcard packaging/docs/[a-z]*)) \
$(patsubst packaging/docs/%,debian/$(PACKAGE)-%.docs,$(wildcard packaging/docs/[a-z]*))
-PDOCSFILES=$(patsubst %,debian/$(PACKAGE)-%.docs,$(shell ls plugins/*/packaging/docs/[a-z]* | sed 's:.*/\(.[^/]*\):\1:'))
+PDOCSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/docs/[a-z]*),debian/$(PACKAGE)-plugin-$i.docs))
+
+PEXAMPLESSFILES=$(foreach i,$(ENABLED_PLUGINS),$(if $(wildcard plugins/$i/packaging/examples/[a-z]*),debian/$(PACKAGE)-plugin-$i.examples))
POFILES=$(patsubst debian/dsf-po/%,debian/po/%,$(wildcard debian/dsf-po/*) debian/po/POTFILES.in)
+# Displays the variables to check if globbing and substitutions are correct
testpat:
+ @echo "ENABLED_PLUGINS=$(ENABLED_PLUGINS)"
+ @echo ""
+ @echo "PPOSTINST=$(PPOSTINST)"
+ @echo "PPRERM=$(PPRERM)"
+ @echo ""
@echo "CRONDFILES=$(CRONDFILES)"
@echo "DIRSFILES=$(DIRSFILES)"
@echo "LINKSFILES=$(LINKSFILES)"
@echo "PLINKSFILES=$(PLINKSFILES)"
@echo "PINSTALLFILES=$(PINSTALLFILES)"
@echo "PDOCSFILES=$(PDOCSFILES)"
+ @echo "PEXAMPLESFILES=$(PEXAMPLESFILES)"
remove-binary-files:
sh $(CURDIR)/deb-specific/manage-uufiles.sh clean
.PHONY: conffiles
-conffiles: $(CRONDFILES) $(DIRSFILES) $(LINKSFILES) $(INSTALLFILES) $(DOCSFILES) $(PCRONDFILES) $(PDIRSFILES) $(PLINKSFILES) $(PINSTALLFILES) $(PDOCSFILES) debian/control
+conffiles: $(PPOSTINST) $(PPRERM) $(CRONDFILES) $(DIRSFILES) $(LINKSFILES) $(INSTALLFILES) $(DOCSFILES) $(PCRONDFILES) $(PDIRSFILES) $(PLINKSFILES) $(PINSTALLFILES) $(PDOCSFILES) $(PEXAMPLESFILES) debian/control
+
+# Construct the plugin's 'postinst' script out of a template in debian/dsf-in/plugin.postinst
+debian/$(PACKAGE)-plugin-%.postinst:
+ export PLUGLONGNAME="`cat $(CURDIR)/plugins/$*/NAME`"; \
+ $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/debian/dsf-in/plugin.postinst > $@
+
+# Construct the plugin's 'prerm' script out of a template in debian/dsf-in/plugin.prerm
+debian/$(PACKAGE)-plugin-%.prerm:
+ export PLUGLONGNAME="`cat $(CURDIR)/plugins/$*/NAME`"; \
+ $(SED_REPLACE) -e 's/@PLUGSHORTNAME@/$*/g' -e "s/@PLUGLONGNAME@/$$PLUGLONGNAME/g" $(CURDIR)/debian/dsf-in/plugin.prerm > $@
-debian/$(OLDPACKAGE)-plugin-%.cron.d:
- sed -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/plugins/$*/packaging/cron.d/plugin-$* > $@
+# Perform substitutions in plugin's cron.d file
+debian/$(PACKAGE)-plugin-%.cron.d:
+ $(SED_REPLACE) -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/plugins/$*/packaging/cron.d/plugin-$* > $@
+# Add a prefix and perform substitutions on the main cron.d files
debian/$(OLDPACKAGE)-%.cron.d:
- (cat $(CURDIR)/packaging/cron.d/00phpcron ; sed -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/packaging/cron.d/$*) | $(SED_REPLACE) > $@
+ (cat $(CURDIR)/packaging/cron.d/00phpcron ; $(SED_REPLACE) -e 's/\$$FFUSER/$(OLDPACKAGE)/g' $(CURDIR)/packaging/cron.d/$*) | $(SED_REPLACE) > $@
+# Perform subsitutions on 'dirs', 'links', 'install', 'docs' files
debian/$(PACKAGE)-plugin-%.dirs:
$(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/dirs/plugin-$* > $@
debian/$(PACKAGE)-plugin-%.docs:
$(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/docs/plugin-$* > $@
-
debian/$(OLDPACKAGE)-%.docs:
$(SED_REPLACE) $(CURDIR)/packaging/docs/$* > $@
debian/$(PACKAGE)-%.docs:
$(SED_REPLACE) $(CURDIR)/packaging/docs/$* > $@
-debian/control: $(wildcard packaging/control/*) $(wildcard plugins/*/packaging/control/[0-9][0-9][0-9]*)
- ls $(CURDIR)/packaging/control/[0-9][0-9][0-9]* $(CURDIR)/plugins/*/packaging/control/[0-9][0-9][0-9]* | grep -v shortdesc | grep -v scmcpold | while read file ; do cat $${file}; if [ -f $${file}.shortdesc ] ; then cat $(CURDIR)/packaging/control/AAAdesc; echo ' .'; cat $${file}.shortdesc; fi; echo ''; done | $(SED_REPLACE) > $@
+debian/$(PACKAGE)-plugin-%.examples:
+ $(SED_REPLACE) $(CURDIR)/plugins/$*/packaging/examples/plugin-$* > $@
+
+# Construct the control file
+debian/control: $(wildcard packaging/control/*) $(wildcard plugins/*/packaging/control/[1-9][0-9][0-9]*) $(wildcard plugins/*/etc/*.ini)
+ ls $(CURDIR)/packaging/control/[0-9][0-9][0-9]* | grep -v shortdesc | while read file ; do cat $${file}; if [ -f $${file}.shortdesc ] ; then cat $(CURDIR)/packaging/control/AAAdesc; echo ' .'; cat $${file}.shortdesc; fi; echo ''; done | $(SED_REPLACE) > $@
+ @echo Enabled plugins: $(ENABLED_PLUGINS)
+ @echo Skipped plugins: $(shell $(CURDIR)/utils/list-enabled-plugins.sh --disabled)
+ for plugin in $(ENABLED_PLUGINS) ; do ls plugins/$$plugin/packaging/control/[1-9][0-9][0-9]plugin-$$plugin ; done | while read file ; do cat $${file}; if [ -f $${file}.shortdesc ] ; then cat $(CURDIR)/packaging/control/AAAdesc; echo ' .'; cat $${file}.shortdesc; fi; echo ''; done | $(SED_REPLACE) >> $@
+# Update the translation of package descriptions fields
debian/po/templates.pot: $(wildcard debian/dsf-in/*.templates.dsfh-in) $(wildcard debian/dsf-helper/*.templates)
@debconf-updatepo --podir=debian/dsf-po
debian/po/%:
- cat $(patsubst debian/po/%,debian/dsf-po/%,$@) | $(SED_REPLACE) > $@
-
-.PHONY: patch
+ cat $(patsubst debian/po/%, debian/dsf-po/%, $@) | $(SED_REPLACE) > $@
-build: patch remove-binary-files debian/po/templates.pot conffiles
- dh $@
+build: remove-binary-files debian/po/templates.pot conffiles
+ dh --with quilt $@
-# Build man pages from Docbook sources
+# Build man pages from Docbook sources
cat debian/dsf-in/config.sgml | $(SED_REPLACE) > debian/$(PACKAGE)-config.sgml
cat debian/dsf-in/common.manpages | $(SED_REPLACE) > debian/$(OLDPACKAGE)-common.manpages
/usr/bin/docbook-to-man debian/cvssh.sgml > cvssh.1
/usr/bin/docbook-to-man debian/$(PACKAGE)-config.sgml > $(PACKAGE)-config.1
-# Build README.Debian from template
+# Build README.Debian from template
cat debian/README.Debian.tmpl | $(SED_REPLACE) > debian/README.Debian
-# Uudecode binary files
+# Uudecode binary files
sh $(CURDIR)/deb-specific/manage-uufiles.sh decode
-# Build gettext *.mo files
+# Build gettext *.mo files
utils/manage-translations.sh build
-# Build FHS-compatible Apache config files
+# Build FHS-compatible Apache config files (generates contents of etc/httpd.conf.d-fhs/ etc.)
utils/manage-apache-config.sh build
-# Preprocess files with DSF-Helper
+# Preprocess files with DSF-Helper
perl $(CURDIR)/deb-specific/dsf-helper.pl
-clean: remove-binary-files unpatch
- dh $@
+clean: remove-binary-files
+ dh --with quilt $@
rm -f $(CURDIR)/debian/*.cron.d
rm -f $(CURDIR)/debian/*.dirs
rm -f $(CURDIR)/debian/*.links
rm -f $(CURDIR)/debian/*.install
rm -f $(CURDIR)/debian/*.docs
+ rm -f $(CURDIR)/debian/*.examples
rm -f $(CURDIR)/debian/$(PACKAGE)-config.sgml
rm -f $(CURDIR)/debian/$(OLDPACKAGE)-common.manpages
rm -f cvssh.1 $(PACKAGE)-config.1
perl $(CURDIR)/deb-specific/dsf-helper.pl --clean
+
install: build
- dh $@
+ dh --with quilt $@
+
+ sed \
+ -e 's!@PKGNAME@!${WHICH_FORGE}!g' \
+ -e 's!@PKGVERSION@!${WHICH_VERSION}!g' \
+ -e 's!@PLUCKERNAME@!${WHICH_TYPE}!g' \
+ <$(CURDIR)/deb-specific/pkginfo.inc.php \
+ >$(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/$(OLDPACKAGE)/common/pkginfo.inc.php
-# Fix permissions
+# Fix permissions
chmod 755 $(CURDIR)/debian/*/*/*/*/bin/* $(CURDIR)/debian/*/*/*/*/cronjobs/* \
$(CURDIR)/debian/*/bin/* $(CURDIR)/debian/*/usr/share/*/plugins/*/bin/* \
$(CURDIR)/debian/*/usr/share/*/plugins/*/cronjobs/*
find $(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/*/common/docman/engine/ -type f -name \*.php -not -name \*.inc.php -exec chmod 0755 {} \;
find $(CURDIR)/debian/$(OLDPACKAGE)-common/usr/share/*/common/docman/engine/ -type f -name \*.sh -exec chmod 0755 {} \;
- rm -f $(CURDIR)/debian/$(OLDPACKAGE)-plugin-scm*/usr/share/*/plugins/scm*/*/README
- chmod 755 $(CURDIR)/debian/$(OLDPACKAGE)-plugin-scmcvs/usr/share/*/plugins/scmcvs/sbin/*
+ rm -f $(CURDIR)/debian/$(PACKAGE)-plugin-scm*/usr/share/*/plugins/scm*/*/README
+ chmod 755 $(CURDIR)/debian/$(PACKAGE)-plugin-scmcvs/usr/share/*/plugins/scmcvs/sbin/*
-# Rename config files
+# Rename config files
mv $(CURDIR)/debian/$(OLDPACKAGE)-common/etc/$(PACKAGE)/config.ini-fhs $(CURDIR)/debian/$(OLDPACKAGE)-common/etc/$(PACKAGE)/config.ini
cp -r $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/$(OLDPACKAGE)/etc/httpd.conf.d-fhs $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d
cp $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/$(OLDPACKAGE)/etc/httpd.conf-fhs $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf
-# Remove those that need to be generated at install time
+# Remove those that need to be generated at install time
rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/secrets.inc
rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-list.inc
rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-main.inc
rm $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/etc/$(OLDPACKAGE)/httpd.conf.d/vhost-projects.inc
-# Remove Windows files
+# Remove Windows files
rm -rf $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/scm/viewvc/windows
rm -f $(CURDIR)/debian/$(OLDPACKAGE)-web-apache2/usr/share/*/www/themes/$(OLDPACKAGE)/COPYING
-# Remove Snoopy class from binary packages (provided by libphp-snoopy)
- find $(addprefix $(CURDIR)/debian/,$(shell dh_listpackages)) -name Snoopy.class.php | xargs -r rm
+# Remove Snoopy class from binary packages (provided by libphp-snoopy)
+ find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name Snoopy.class.php | xargs -r rm
+
+# Remove NuSOAP class from binary packages (provided by libnusoap-php)
+ find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name nusoap.php | xargs -r rm
-# Remove NuSOAP class from binary packages (provided by libnusoap-php)
- find $(addprefix $(CURDIR)/debian/,$(shell dh_listpackages)) -name nusoap.php | xargs -r rm
+# Remove potential SCM artefacts from binary packages
+ 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
-# Remove potential SCM artefacts from binary packages
- 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
+# Also remove uuencoded files
+ find $(addprefix $(CURDIR)/debian/, $(shell dh_listpackages)) -name \*.uu | xargs -r rm
-# Also remove uuencoded files
- find $(addprefix $(CURDIR)/debian/,$(shell dh_listpackages)) -name \*.uu | xargs -r rm
binary: install
%:
- dh $@
+ dh --with quilt $@