summaryrefslogtreecommitdiff
path: root/extra/imap/PKGBUILD
blob: c53316299362f97adfb91ca3b5d8e94fef2c3aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# $Id: PKGBUILD 75284 2010-04-01 07:07:12Z pierre $
# Maintainer: judd <jvinet@zeroflux.org>
pkgname=imap
pkgver=2007e
pkgrel=2
pkgdesc="An IMAP/POP server"
arch=('i686' 'x86_64' 'mips64el')
license=('APACHE')
url="http://www.washington.edu/imap"
depends=('openssl' 'pam')
provides=('imap-server' 'pop3-server')
conflicts=('courier-mta' 'courier-imap')
source=("ftp://ftp.cac.washington.edu/imap/${pkgname}-${pkgver}.tar.gz"
        'imap' 'ipop2' 'ipop3')
backup=(etc/xinetd.d/{imap,ipop2,ipop3} etc/ssl/certs/{imapd,ipop3d}.pem)
md5sums=('7903800dc2604000016de070e0c55840'
         'e77dedb80c2fec9bf2ef784ed5f976fb'
	 'cc3eba6453242aa0b1bc8881160b2136'
	 '0a5e27183a9b7e8ec5f6703125371e0a')


build() {
  # fix Makefile
  cd $srcdir/$pkgname-$pkgver/src/osdep/unix
  cp Makefile Makefile.orig
  sed \
    -e "s:-g -fno-omit-frame-pointer -O6:\${CFLAGS}:" \
    -e "s:SSLDIR=/usr/local/ssl:SSLDIR=/usr:" \
    -e "s:SSLCERTS=\$(SSLDIR)/certs:SSLCERTS=/etc/ssl/certs:" \
    < Makefile.orig > Makefile

  cd $srcdir/$pkgname-$pkgver
  # NOTE: if you wish to enforce SSL, use SSLTYPE=unix.nopwd

  if [ "$CARCH" == "x86_64" ]; then
         yes "y" | make lnp SPECIALAUTHENTICATORS=ssl SSLTYPE=unix EXTRACFLAGS="${CFLAGS} -fPIC" || return 1
    else yes "y" | make lnp SPECIALAUTHENTICATORS=ssl SSLTYPE=unix || return 1
  fi
}

package() {
  cd $srcdir/$pkgname-$pkgver
  mkdir -p $pkgdir/usr/sbin
  install -D -m755 imapd/imapd $pkgdir/usr/sbin/imapd
  install -D -m755 ipopd/ipop2d $pkgdir/usr/sbin/ipop2d
  install -D -m755 ipopd/ipop3d $pkgdir/usr/sbin/ipop3d
  for i in c-client mail imap4r1 rfc822 linkage misc smtp nntp \
    osdep env_unix env fs ftl nl tcp sslio utf8 utf8aux; do
    install -D -m644 c-client/${i}.h $pkgdir/usr/include/imap/${i}.h
  done
  install -D -m644 c-client/c-client.a $pkgdir/usr/lib/c-client.a
  ln -sf c-client.a $pkgdir/usr/lib/libc-client.a

  # create ssl certs for secure imap
  for i in imapd ipop3d; do
    umask 077
    PEM1=`/usr/bin/mktemp /tmp/openssl.XXXXXX`
    PEM2=`/usr/bin/mktemp /tmp/openssl.XXXXXX`
    /usr/bin/openssl req -newkey rsa:1024 -keyout $$PEM1 \
      -nodes -x509 -days 365 -out  $$PEM2 << EOF
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
localhost.localdomain
root@localhost.localdomain
EOF

    cat $$PEM1 >  ${i}.pem
    echo ""    >> ${i}.pem
    cat $$PEM2 >> ${i}.pem
    rm $$PEM1 $$PEM2
    umask 022
  done

  # install 'em
  install -D -m600 imapd.pem $pkgdir/etc/ssl/certs/imapd.pem
  install -D -m600 ipop3d.pem $pkgdir/etc/ssl/certs/ipop3d.pem

  # install xinetd.d configs
  install -D -m644 ../imap $pkgdir/etc/xinetd.d/imap
  install -D -m644 ../ipop2 $pkgdir/etc/xinetd.d/ipop2
  install -D -m644 ../ipop3 $pkgdir/etc/xinetd.d/ipop3
}