#!/usr/bin/make -f # # Copyright 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 by Stefan Hornburg (Racke) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA. BUILD=$(shell pwd)/debian/tmp RELUP=$(shell dpkg-parsechangelog | perl -ne 'print $$1 if /^Version: (.*?)-(.*)$$/') # Uncomment this to turn on verbose mode. # export DH_VERBOSE=1 # This has to be exported to make some magic below work. export DH_OPTIONS # Common configuration options COMMON_CONFOPTS=--prefix=/usr --mandir=\$${prefix}/share/man \ --with-piddir=/var/run/courier \ --sysconfdir=/etc/courier \ --libexecdir=\$${prefix}/lib/courier \ --datadir=\$${prefix}/lib/courier \ --localstatedir=/var/lib/courier \ --sbindir=\$${exec_prefix}/sbin \ --with-mailuser=daemon \ --with-mailgroup=daemon \ --without-socks \ --enable-workarounds-for-imap-client-bugs \ --with-authdaemonvar=/var/run/courier/authdaemon \ --with-db=gdbm \ --without-fcgi \ --with-htmllibdir=/usr/share/sqwebmail \ --with-ispell=/usr/bin/ispell \ --enable-imageurl=/sqwebmail \ --with-mailer="/usr/sbin/sendmail" \ --enable-sendmail="/usr/sbin/sendmail" \ --with-cachedir=/var/cache/sqwebmail \ --with-calendardir=/var/run/courier/calendar \ --with-webadmindir=/usr/share/courier/webadmin \ --enable-userdb \ --enable-syslog=1 \ --enable-unicode \ --disable-root-check check: dh_testdir # check for openssl if [ ! -x /usr/bin/openssl ]; then \ echo "You need to install openssl first"; \ exit 1; \ fi # fix permissions chmod +x debian/fixlinks chmod +x debian/courier_perms chmod +x debian/correctpermissions.pl build: check # create a list of files that currently exists chmod +x debian/srcmgr if [ ! -f srcmgr.list ]; then debian/srcmgr > srcmgr.list; fi if [ ! -f stamp-build ]; then \ LINGUAS="de sv" ./configure $(COMMON_CONFOPTS) \ --with-postgresql-includes=/usr/include/postgresql \ && $(MAKE) LIBTOOL=/usr/bin/libtool && touch stamp-build; \ fi stamp-build: build clean: check dh_testroot debconf-updatepo rm -f stamp-build stamp-install # Add here commands to clean up after the build process. [ ! -f Makefile ] || $(MAKE) LIBTOOL=/usr/bin/libtool clean dh_clean if [ -f srcmgr.list ]; then debian/srcmgr cleanse < srcmgr.list; rm srcmgr.list; fi #can be removed later rm -f debian/permissions install: check stamp-build dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tmp. umask 0022 && $(MAKE) LIBTOOL=/usr/bin/libtool DESTDIR=$(BUILD) install umask 0022 && $(MAKE) LIBTOOL=/usr/bin/libtool DESTDIR=$(BUILD) install-perms perl -i -pe 's%/usr/bin/sendmail%/usr/sbin/sendmail%; s%^/%$(BUILD)/% unless m%/debian/tmp/%' permissions.dat /usr/bin/perl sysconftool `awk ' $$5 == "config" && $$1 ~ /\.dist$$/ { print $$1 }' debian/permissions # Change absolute link made by make install to a relative one debian/fixlinks $(BUILD)/usr/sbin (cd $(BUILD)/usr/bin && ln -fs ../lib/courier/courier/modules/esmtp/addcr ./addcr) (cd $(BUILD)/usr/bin && ln -fs ../lib/courier/makedat ./makedat) # We use update-alternatives to manage these, because they're shared # by other packages, notably qmail, maildrop, mutt, mush for i in maildirmake deliverquota lockmail preline makedat; do \ (cd $(BUILD)/usr/bin && mv $$i $$i.courier); done cd $(BUILD)/usr/share/man/man5 && mv maildir.5 maildir.courier.5 cd $(BUILD)/usr/share/man/man1 && mv maildirmake.1 maildirmake.courier.1 cd $(BUILD)/usr/share/man/man7 && mv maildirquota.7 maildirquota.courier.7 cd $(BUILD)/usr/share/man/man8 && mv deliverquota.8 deliverquota.courier.8 cd $(BUILD)/usr/share/man/man1 && mv lockmail.1 lockmail.courier.1 cd $(BUILD)/usr/share/man/man1 && mv preline.1 preline.courier.1 cd $(BUILD)/usr/share/man/man1 && mv makedat.1 makedat.courier.1 # Move programs with too generic names cd $(BUILD)/usr/sbin && mv showconfig courier-mtaconfig # Install "sendmail" into the right places mv $(BUILD)/usr/bin/sendmail $(BUILD)/usr/sbin (cd $(BUILD)/usr/lib && ln -fs ../sbin/sendmail .) # Install "newaliases" stuff cp -p debian/newaliases $(BUILD)/usr/sbin chmod +x $(BUILD)/usr/sbin/newaliases # Install "logcheck" stuff install -d $(BUILD)/etc/logcheck/ignore.d.server install -m 0644 debian/logcheck/courier-* $(BUILD)/etc/logcheck/ignore.d.server install -d $(BUILD)/etc/logcheck/violations.ignore.d install -m 0644 debian/logcheck/violations/courier-* $(BUILD)/etc/logcheck/violations.ignore.d # Empty file to avoid warnings mkdir -p $(BUILD)/etc/courier/shared touch $(BUILD)/etc/courier/shared/index # Additional manpages pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=1 debian/addcr.pod > $(BUILD)/usr/share/man/man1/addcr.1 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=1 debian/courier-config.pod > $(BUILD)/usr/share/man/man1/courier-config.1 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=8 debian/newaliases.pod > $(BUILD)/usr/share/man/man8/newaliases.8 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=8 debian/sharedindexinstall.pod > $(BUILD)/usr/share/man/man8/sharedindexinstall.8 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=8 debian/sharedindexsplit.pod > $(BUILD)/usr/share/man/man8/sharedindexsplit.8 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=8 debian/webgpg.pod > $(BUILD)/usr/share/man/man8/webgpg.8 pod2man --center='Debian GNU/Linux Documentation' --release='Debian GNU/Linux '`cat /etc/debian_version` --section=8 debian/webmaild.pod > $(BUILD)/usr/share/man/man8/webmaild.8 # Move sqwebmail images mv $(BUILD)/usr/lib/courier/sqwebmail/images $(BUILD)/usr/share/sqwebmail # Ispell dictionary configuration will be produced by postinst rm $(BUILD)/usr/lib/courier/sqwebmail/html/en-us/ISPELLDICT (cd $(BUILD)/usr/lib/courier/sqwebmail/html/en-us && ln -s /etc/courier/ispelldict ISPELLDICT) # Remove examples rm $(BUILD)/usr/lib/courier/perlfilter-example.pl rm $(BUILD)/etc/courier/quotawarnmsg.example # Fix Perl paths in webadmin stuff perl -i -pe 's%^#!\s?perl%#!/usr/bin/perl%' $(BUILD)/usr/share/courier/webadmin/*.pl # Fix ldapsearch path perl -i -pe 's%/usr/local/%/usr/%' $(BUILD)/usr/lib/courier/sqwebmail/ldapsearch # Fix sendit.sh perl -i -pe 's%sendmail%sendmail -oi -t%' $(BUILD)/usr/lib/courier/sqwebmail/sendit.sh # Remove showmodules so we get rid of the libmysqlclient dependency rm $(BUILD)/usr/sbin/showmodules # Ensure that a valid symlink is used for some manpages (cd $(BUILD)/usr/share/man/man8 && rm makeuucpneighbors.8 && ln -sf courieruucp.8.gz makeuucpneighbors.8.gz) (cd $(BUILD)/usr/share/man/man8 && rm -f esmtpd-ssl.8 && ln -sf esmtpd.8.gz esmtpd-ssl.8.gz) (cd $(BUILD)/usr/share/man/man8 && ln -sf imapd.8.gz imapd-ssl.8.gz) dh_installdocs # Install documentation where dh_installdocs doesn't fit our needs mkdir -p $(BUILD)/usr/share/doc/sqwebmail cp -p debian/sqwebmail.html $(BUILD)/usr/share/doc/sqwebmail cp -p gpglib/README.html $(BUILD)/usr/share/doc/sqwebmail/GPG.html cp -p pcp/README.html $(BUILD)/usr/share/doc/sqwebmail/PCP.html # Delete docs so that they don't end in courier-base rm -rf debian/tmp/usr/lib/courier/htmldoc # Adapt configuration files to our needs # - security: disable EXPN and VRFY perl -i -pe 's/^BOFHNO(EXPN|VRFY)=0/BOFHNO$$1=1/' $(BUILD)/etc/courier/esmtpd # - start daemon by default perl -i -pe 's/^ESMTPDSTART=NO/ESMTPDSTART=YES/;' $(BUILD)/etc/courier/esmtpd # - fix PID location perl -i -pe 's%^PIDFILE=.*%PIDFILE=/var/run/courier/esmtpd.pid%' $(BUILD)/etc/courier/esmtpd perl -i -pe 's%^PIDFILE=.*%PIDFILE=/var/run/courier/esmtpd-msa.pid%' $(BUILD)/etc/courier/esmtpd-msa perl -i -pe 's%^PORT=.*%PORT=/var/run/courier/webmlmd%' $(BUILD)/etc/courier/webmlmrc # - fix location for certificate perl -i -pe 's%^TLS_CERTFILE=.*%TLS_CERTFILE=/etc/courier/esmtpd.pem%' $(BUILD)/etc/courier/esmtpd # - start daemons by default perl -i -pe 's/^POP3DSTART=NO/POP3DSTART=YES/' $(BUILD)/etc/courier/pop3d perl -i -pe 's/^MAXPERIP=\d+/MAXPERIP=20/; s/^IMAPDSTART=NO/IMAPDSTART=YES/' $(BUILD)/etc/courier/imapd # - change default LDAP server perl -i -pe 's/^(LDAP_SERVER\s+)ldap.example.com/$$1localhost/' $(BUILD)/etc/courier/ldapaliasrc perl -i -pe 's/^POP3DSSLSTART=NO/POP3DSSLSTART=YES/' $(BUILD)/etc/courier/pop3d-ssl perl -i -pe 's%^TLS_CERTFILE=.*%TLS_CERTFILE=/etc/courier/pop3d.pem%' $(BUILD)/etc/courier/pop3d-ssl perl -i -pe 's/^IMAPDSSLSTART=NO/IMAPDSSLSTART=YES/' $(BUILD)/etc/courier/imapd-ssl perl -i -pe 's%^TLS_CERTFILE=.*%TLS_CERTFILE=/etc/courier/imapd.pem%' $(BUILD)/etc/courier/imapd-ssl perl -i -pe 's%^SSLPIDFILE=.*%SSLPIDFILE=/var/run/courier/esmtpd-ssl.pid%' $(BUILD)/etc/courier/esmtpd-ssl perl -i -pe 's/^ESMTPDSSLSTART=NO/ESMTPDSSLSTART=YES/' $(BUILD)/etc/courier/esmtpd-ssl perl -i -pe 's%^TLS_CERTFILE=.*%TLS_CERTFILE=/etc/courier/esmtpd.pem%' $(BUILD)/etc/courier/esmtpd-ssl # - ensure compatibility which common MUA's perl -i -pe 's%^TLS_PROTOCOL=SSL3%TLS_PROTOCOL=SSL23%' $(BUILD)/etc/courier/*-ssl # - adjust IMAP ulimit for 64bit systems perl -i -pe 's%^IMAP_ULIMITD=65536%IMAP_ULIMITD=131072%' $(BUILD)/etc/courier/imapd perl -i -pe 's%^ULIMIT=16384%ULIMIT=32768%' $(BUILD)/etc/courier/esmtpd rm $(BUILD)/etc/courier/*.dist # Links for the certificates cd $(BUILD)/usr/lib/courier && ln -s /etc/courier/pop3d.pem . cd $(BUILD)/usr/lib/courier && ln -s /etc/courier/imapd.pem . cd $(BUILD)/usr/lib/courier && ln -s /etc/courier/esmtpd.pem . # Replace scripts with symlinks to startup scripts rm $(BUILD)/usr/sbin/imapd cd $(BUILD)/usr/sbin && ln -s /etc/init.d/courier-imap imapd rm $(BUILD)/usr/lib/courier/pop3d-ssl rm $(BUILD)/usr/sbin/pop3d-ssl cd $(BUILD)/usr/sbin && ln -s /etc/init.d/courier-pop-ssl pop3d-ssl rm $(BUILD)/usr/lib/courier/imapd-ssl rm $(BUILD)/usr/sbin/imapd-ssl cd $(BUILD)/usr/sbin && ln -s /etc/init.d/courier-imap-ssl imapd-ssl # Replace PAM files with our versions rm $(BUILD)/etc/courier/*.authpam mkdir $(BUILD)/etc/pam.d cp debian/courier-mta.pam $(BUILD)/etc/pam.d/esmtp cp debian/courier-imap.pam $(BUILD)/etc/pam.d/imap cp debian/courier-pop.pam $(BUILD)/etc/pam.d/pop3 cp debian/sqwebmail.pam $(BUILD)/etc/pam.d/webmail cp debian/sqwebmail.pam $(BUILD)/etc/pam.d/calendar # Lintian overrides mkdir -p $(BUILD)/usr/share/lintian/overrides cp debian/courier-faxmail.lintian $(BUILD)/usr/share/lintian/overrides/courier-faxmail cp debian/courier-imap.lintian $(BUILD)/usr/share/lintian/overrides/courier-imap cp debian/courier-imap-ssl.lintian $(BUILD)/usr/share/lintian/overrides/courier-imap-ssl cp debian/courier-ldap.lintian $(BUILD)/usr/share/lintian/overrides/courier-ldap cp debian/courier-maildrop.lintian $(BUILD)/usr/share/lintian/overrides/courier-maildrop cp debian/courier-mta.lintian $(BUILD)/usr/share/lintian/overrides/courier-mta cp debian/courier-pcp.lintian $(BUILD)/usr/share/lintian/overrides/courier-pcp cp debian/courier-pop.lintian $(BUILD)/usr/share/lintian/overrides/courier-pop cp debian/courier-pop-ssl.lintian $(BUILD)/usr/share/lintian/overrides/courier-pop-ssl cp debian/courier-ssl.lintian $(BUILD)/usr/share/lintian/overrides/courier-ssl cp debian/courier-webadmin.lintian $(BUILD)/usr/share/lintian/overrides/courier-webadmin cp debian/sqwebmail.lintian $(BUILD)/usr/share/lintian/overrides/sqwebmail # Webmlm stuff mkdir -p $(BUILD)/usr/lib/cgi-bin cp $(BUILD)/usr/lib/courier/courier/webmail/webmlm $(BUILD)/usr/lib/cgi-bin # This seems to be necessary for building in fakeroot # environment (otherwise dh_strip fails) # set all binaries to 755, by checking if user has x-bit # debian/courier_perms will set the right permissions find $(BUILD) -perm -u+x -type f | xargs chmod u+rwx,go+rx dh_movefiles # Check if all files have moved out if [ `find $(BUILD) -not -type d | wc -l` -ne 0 ]; then find $(BUILD) -not -type d; echo "File(s) found not belonging to any package, please contact maintainer"; exit 1; fi touch stamp-install stamp-install: install # Build architecture-independent files here. binary-indep: stamp-build stamp-install dh_testdir dh_testroot dh_installdebconf -i dh_installexamples -i dh_installmenu -i dh_installinit -i dh_installinfo -i dh_installchangelogs -p courier-doc dh_strip -i dh_link -i dh_compress -i dh_fixperms -i debian/courier_perms -i dh_installdeb -i dh_perl -i dh_shlibdeps -i dh_gencontrol -i dh_md5sums -i dh_builddeb -i # Build architecture-dependent files here. binary-arch: stamp-build stamp-install dh_testdir dh_testroot dh_installdebconf -a dh_installexamples -a dh_installmenu -a dh_installinit -a dh_installcron -a dh_installinfo -a dh_installchangelogs -p courier-authmysql dh_installchangelogs -p courier-authpostgresql dh_installchangelogs -p courier-base ChangeLog dh_installchangelogs -p courier-faxmail dh_installchangelogs -p courier-imap imap/ChangeLog dh_installchangelogs -p courier-imap-ssl dh_installchangelogs -p courier-ldap dh_installchangelogs -p courier-maildrop dh_installchangelogs -p courier-mlm dh_installchangelogs -p courier-mta dh_installchangelogs -p courier-mta-ssl dh_installchangelogs -p courier-pcp dh_installchangelogs -p courier-pop dh_installchangelogs -p courier-pop-ssl dh_installchangelogs -p courier-ssl dh_installchangelogs -p courier-webadmin dh_installchangelogs -p sqwebmail webmail/ChangeLog dh_strip -a dh_link -a dh_compress -a dh_fixperms -a debian/courier_perms -a dh_installdeb -a dh_perl -a dh_shlibdeps -a dh_gencontrol -a -Ncourier-imap -Ncourier-imap-ssl -- -VRELUP="$(RELUP)" dh_gencontrol -pcourier-imap -- -VRELUP="$(RELUP)" -v4.9.1-$(shell dpkg-parsechangelog | perl -ne 'print $$2 if /^Version: (.*?)-(.*)$$/') dh_gencontrol -pcourier-imap-ssl -- -VRELUP="$(RELUP)" -v4.9.1-$(shell dpkg-parsechangelog | perl -ne 'print $$2 if /^Version: (.*?)-(.*)$$/') dh_md5sums -a dh_builddeb -a binary: binary-indep binary-arch .PHONY: check build clean binary-indep binary-arch binary install