-include /usr/share/dpkg/pkg-info.mk
+include /usr/share/dpkg/default.mk
# howto add rule updates:
-# edit paths ($srcdir) in changes.pl
-# update changes.diff - verify changes!
-
-# dig -t any 3.4.3.updates.spamassassin.org
-# wget http://spamassassin.kluge.net/updates/501214.tar.gz
-# wget http://spamassassin.kluge.net/updates/501214.tar.gz.asc
-# gpg --verify 501214.tar.gz.asc 501214.tar.gz
-#
-# or just use: make sa-updates.tgz (from the last stable version)
-# warning: start with an empty sa-updates.tgz, install the package,
-# the run sa-update to generate the updates
-#
-# Note: we also add KAM.cf from
-# http://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf
-#
-# edit debin/rules to apply updates
-
-OPKGNAME = Mail-SpamAssassin-${DEB_VERSION_UPSTREAM}
-NPKGNAME = proxmox-spamassassin_${DEB_VERSION_UPSTREAM}
-DEB = proxmox-spamassassin_${DEB_VERSION_UPSTREAM_REVISION}_amd64.deb
-DSC = proxmox-spamassassin_${DEB_VERSION_UPSTREAM_REVISION}.dsc
-
-EXTRA_RULES = KAM.cf
+# running `make update-sa` updates the core SA rules (in the sa-updates directory)
+# running `make update-kam` updates the KAM ruleset (in the kam-updates directory)
+
+PACKAGE = proxmox-spamassassin
+
+OPKGNAME = Mail-SpamAssassin-$(DEB_VERSION_UPSTREAM)
+
+BUILDDIR = $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
+ORIG_SRC_TAR=$(PACKAGE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
+DSC = $(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
+
+DEB = $(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_amd64.deb
+DBG_DEB = $(PACKAGE)-dbgsym_$(DEB_VERSION_UPSTREAM_REVISION)_amd64.deb
+DEBS = $(DEB) $(DBG_DEB)
+
+KAM_CHANNEL_FILE = debian/tree/etc/mail/spamassassin/channel.d/KAM_channel.conf
+KAM_KEYID = $(shell awk -F '=' '/^KEYID/ { print $$2 }' $(KAM_CHANNEL_FILE))
+
SA_UPDATE_GPG_DIR = .sa-update-gpghome
-deb: ${DEB}
+deb: $(DEB)
-${DEB}: ${NPKGNAME}
- cd ${NPKGNAME}; dpkg-buildpackage -b -us -uc -rfakeroot
- lintian ${DEB}
+$(DEB) $(DBG_DEB): $(BUILDDIR)
+ cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
+ lintian $(DEB)
-dsc: ${DSC}
+dsc:
+ $(MAKE) $(DSC)
+ lintian $(DSC)
-${DSC}: ${NPKGNAME}
- cd ${NPKGNAME}; dpkg-buildpackage -S -us -uc -rfakeroot -d
- lintian ${DSC}
+$(DSC): $(ORIG_SRC_TAR) $(BUILDDIR)
+ cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
-${NPKGNAME}.orig.tar.gz: ${OPKGNAME}.tar.gz
- rm -rf ${NPKGNAME}
- tar -xzf $<
- mv ${OPKGNAME} ${NPKGNAME}
- tar -czf ${NPKGNAME}.orig.tar.gz ${NPKGNAME}
+.PHONY: sbuild
+sbuild: $(DSC)
+ sbuild $(DSC)
-${NPKGNAME}: sa-updates.tgz ${EXTRA_RULES} ${NPKGNAME}.orig.tar.gz
- cp -a debian $@
- mkdir -p $@/debian/tree/usr/share/spamassassin
- tar -C $@/debian/tree/usr/share/spamassassin -xzf sa-updates.tgz
- mkdir -p $@/debian/tree/usr/share/spamassassin-extra
- cp -a ${EXTRA_RULES} $@/debian/tree/usr/share/spamassassin-extra
+.PHONY: update-upstream
+update-upstream: $(OPKGNAME).tar.gz
+ rm -rf upstream
+ tar -xzf $<
+ mv $(OPKGNAME) upstream
+
+$(ORIG_SRC_TAR): $(BUILDDIR)
+ tar czf $(ORIG_SRC_TAR) --exclude="$(BUILDDIR)/debian" $(BUILDDIR)
+
+$(BUILDDIR): sa-updates kam-updates
+ rm -rf $@ $@.tmp
+ cp -a upstream $@.tmp
+ cp -a debian $@.tmp
+ mkdir -p $@.tmp/rule-updates/spamassassin
+ rsync -av sa-updates/ $@.tmp/rule-updates/spamassassin
+ mkdir -p $@.tmp/debian/rule-updates/spamassassin-extra
+ rsync -av kam-updates/ $@.tmp/rule-updates/spamassassin-extra
+ mv $@.tmp $@
-${OPKGNAME}.tar.gz:
+$(OPKGNAME).tar.gz:
rm -f $@*
curl -L -o '$@#1.tmp' 'https://www-eu.apache.org/dist/spamassassin/source/$@{,.asc}'
mv $@.tmp $@
mv $@.asc.tmp $@.asc
gpgv --keyring ./sa-releasekey.gpg $@.asc $@
-KAM.cf:
- wget https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf -O $@.tmp
- mv KAM.cf.tmp $@
-
-${SA_UPDATE_GPG_DIR}/.prepared: ${OPKGNAME}.tar.gz
- rm -rf ${SA_UPDATE_GPG_DIR}
- mkdir --mode=0700 -p ${SA_UPDATE_GPG_DIR}
- tar --strip-components 2 -xzf ${OPKGNAME}.tar.gz ${OPKGNAME}/rules/sa-update-pubkey.txt
- sa-update --gpghomedir ${SA_UPDATE_GPG_DIR} --import sa-update-pubkey.txt
+$(SA_UPDATE_GPG_DIR)/.prepared: $(OPKGNAME).tar.gz
+ rm -rf $(SA_UPDATE_GPG_DIR)
+ mkdir --mode=0700 -p $(SA_UPDATE_GPG_DIR)
+ tar --strip-components 2 -xzf $(OPKGNAME).tar.gz $(OPKGNAME)/rules/sa-update-pubkey.txt
+ sa-update --gpghomedir $(SA_UPDATE_GPG_DIR) --import sa-update-pubkey.txt
+ sa-update --gpghomedir $(SA_UPDATE_GPG_DIR) --import $(KAM_CHANNEL_FILE)
rm sa-update-pubkey.txt
touch $@
.PHONY: update-sa
-update-sa: ${SA_UPDATE_GPG_DIR}/.prepared
+update-sa: $(SA_UPDATE_GPG_DIR)/.prepared
rm -rf updates.tmp
- sa-update --gpghomedir ${SA_UPDATE_GPG_DIR} --updatedir updates.tmp --channel updates.spamassassin.org
- tar cvzf sa-updates.tgz --exclude=local.cf --exclude=regression_tests.cf --exclude=*.txt --exclude=MIRRORED.BY -C updates.tmp/updates_spamassassin_org/ .
+ sa-update --gpghomedir $(SA_UPDATE_GPG_DIR) --updatedir updates.tmp --channel updates.spamassassin.org
+ rsync -av --delete --exclude=local.cf --exclude=regression_tests.cf --exclude=*.txt --exclude=MIRRORED.BY updates.tmp/updates_spamassassin_org/ sa-updates
+
+.PHONY: update-kam
+update-kam: $(SA_UPDATE_GPG_DIR)/.prepared
+ rm -rf kam-updates.tmp kam-updates
+ sa-update --gpghomedir $(SA_UPDATE_GPG_DIR) --gpgkey $(KAM_KEYID) --updatedir kam-updates.tmp --channel kam.sa-channels.mcgrail.com
+ rm -rf kam-updates.tmp/kam_sa-channels_mcgrail_com/MIRRORED.BY
+ mv kam-updates.tmp kam-updates
.PHONY: upload
-upload: ${DEB}
- tar cf - ${DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pmg --dist stretch
+upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
+upload: $(DEBS)
+ tar cf - $(DEBS) | ssh -X repoman@repo.proxmox.com -- upload --product pmg --dist $(UPLOAD_DIST)
+
+.PHONY: clean distclean
+clean:
+ rm -rf *.deb $(PACKAGE)-[0-9]*/ *.tmp $(SA_UPDATE_GPG_DIR)
+ rm -f *.deb *.dsc *.changes *.build *.buildinfo $(OPKGNAME).tar.gz.* $(PACKAGE)*.tar*
-CLEANFILES = *~ debian/*~ *.deb proxmox-spamassassin_* updates.tmp ${SA_UPDATE_GPG_DIR} ${OPKGNAME}.tar.gz.*
-.PHONY: clean
-clean:
- rm -rf ${CLEANFILES}
+distclean: clean
+ rm -rf $(OPKGNAME).*
.PHONY: dinstall
-dinstall: ${DEB}
- dpkg -i ${DEB}
+dinstall: $(DEB)
+ dpkg -i $(DEB)