Skip to content

Instantly share code, notes, and snippets.

@mss
Last active June 19, 2022 13:41
Show Gist options
  • Save mss/3d26769f9d3bf6bd58f3fb228e81630a to your computer and use it in GitHub Desktop.
Save mss/3d26769f9d3bf6bd58f3fb228e81630a to your computer and use it in GitHub Desktop.
How to build the last available Dovecot 1.x version on a recent Linux (for migration purposes)
#!/bin/bash
set -o errexit
set -o pipefail
# Dovecot 1.x is not compatible to OpenSSL 1.1 and later but LibreSSL mostly kept that API
curl -JLO \
https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.3.tar.gz
tar xfa libressl-3.4.3.tar.gz
cd libressl-3.4.3
./configure --prefix=/opt/$(basename $PWD)
make
make install
ln -sf $(basename $PWD) /opt/libressl
rmdir /opt/libressl/etc/ssl/certs
ln -sf /etc/ssl/{openssl.cnf,certs,private} /opt/libressl/etc/ssl/
cd ..
# Download, build, and install Dovecot 1.2.17 including the latest Sieve patches available
curl -JLO \
https://dovecot.org/releases/1.2/dovecot-1.2.17.tar.gz \
https://pigeonhole.dovecot.org/releases/1.2/dovecot-1.2-sieve-0.1.19.tar.gz \
https://pigeonhole.dovecot.org/releases/1.2/dovecot-1.2-managesieve-0.11.13.tar.gz \
https://pigeonhole.dovecot.org/releases/1.2/dovecot-1.2.17-managesieve-0.11.13.diff.gz
ls -1 dovecot-1.2.17.tar.gz dovecot-1.2-sieve-0.1.19.tar.gz dovecot-1.2-managesieve-0.11.13.tar.gz | xargs -n 1 tar xfa
cd dovecot-1.2.17
zcat ../dovecot-1.2.17-managesieve-0.11.13.diff.gz | patch -p1
sed -i -e 's/1024/2048/g' src/master/ssl-init-openssl.c src/login-common/ssl-proxy-openssl.c
CPPFLAGS="-I/opt/libressl/include -I/usr/include/tirpc" LDFLAGS="-L/opt/libressl/lib" ./configure \
--prefix=/opt/dovecot-1.2.17 \
--with-ssl=openssl \
--without-gssapi \
--with-pam \
--without-ldap \
--without-nss \
--without-vpopmail \
--without-db \
--with-sqlite \
--without-pgsql \
--without-mysql \
--without-solr \
--with-storages=maildir
sed -i -e '/^#define HAVE_SSL_COMPRESSION/d' config.h
make
make install
ln -sf dovecot-1.2.17 /opt/dovecot
ln -sf /etc/dovecot/dovecot.conf /opt/dovecot/etc/
ln -sf /var /opt/dovecot/var
cd ..
cd dovecot-1.2-sieve-0.1.19/
CPPFLAGS="-I/opt/libressl/include" LDFLAGS="-L/opt/libressl/lib" ./configure \
--prefix=/opt/dovecot-1.2.17 \
--with-dovecot=../dovecot-1.2.17
make
make install
cd ..
cd dovecot-1.2-managesieve-0.11.13
CPPFLAGS="-I/opt/libressl/include" LDFLAGS="-L/opt/libressl/lib" ./configure \
--prefix=/opt/dovecot-1.2.17 \
--with-dovecot=../dovecot-1.2.17 \
--with-dovecot-sieve=../dovecot-1.2-sieve-0.1.19
make
make install
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment