summaryrefslogtreecommitdiff
path: root/extra/mailman/PKGBUILD
blob: 24a513b52851630bc6af3829f059a60817adacbc (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 102741 2010-12-10 21:29:32Z andyrtr $
# Maintainer: Paul Mattal <paul@archlinux.org>

pkgname=mailman
pkgver=2.1.14
pkgrel=1
pkgdesc="Mailing list manager with built in web access"
arch=('i686' 'x86_64' 'mips64el')
license=('GPL')
url="http://www.list.org/"
depends=('python2' 'smtp-server')
# 'Defaults.py' should not be changed by users; 'mm_cfg.py' should instead.
backup=('usr/lib/mailman/Mailman/mm_cfg.py')
install=$pkgname.install
source=(http://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tgz
	mailman-2.1-build.patch
	rc.mailman)
md5sums=('9ea163871ceccbd33fee4c9e335fcf7b'
         'ed04d062379eb21e39ce1e70e6b1ade2'
         '3d83d06d0ec3319bf3c7d9df5d18e89f')

# needs to be build as root for pam allowing to create new user/group
# LANG=C; time rm -rf src/ pkg/ && time makepkg -L --asroot

build() {
  cd $srcdir/$pkgname-$pkgver

  # fix calls to /usr/bin/python
  find . -name '*.py' | xargs sed -i 's@^#!.*python$@#!/usr/bin/python2@'

  # fix directory permissions to satisfy check_perms
  patch -Np1 -i ${srcdir}/mailman-2.1-build.patch
  
  # the mailman user and group are required to build (better to satisfy check_perms)
  if ! egrep '^mailman' /etc/passwd; then
    msg "Adding user/group mailman (temporarily)"
    groupadd -g 80 mailman
    useradd -s /sbin/nologin -c "GNU Mailing List Manager" -d /usr/lib/mailman -u 80 -g mailman -M -r mailman
    export cleanup=1
  else
    export cleanup=0
  fi

  ./configure --without-permcheck \
              --prefix=/usr/lib/mailman \
              --with-var-prefix=/var/lib/mailman \
              --with-mail-gid=mailman \
	      --with-username=mailman --with-groupname=mailman \
              --with-cgi-gid=http --with-python=/usr/bin/python2

  make
}

package() {
  cd $srcdir/$pkgname-$pkgver
  make DESTDIR=$pkgdir install

  # let's follow Fedora FHS way; Gentoo does it the other way round

  # Create a link so that the config file mm_cfg.py appears in config
  # directory /etc/mailman. We don't put mm_cfg.py in the config directory
  # because its executable code (python file) and the security policy wants
  # to keep executable code out of /etc and inside of a lib directory instead,
  # and because traditionally mm_cfg.py was in the Mailman subdirectory and
  # experienced mailman admins will expect to find it there. But having it
  # "appear" in the config directory is good practice and heading in the
  # right direction for FHS compliance.
  install -d -m755 ${pkgdir}/etc/${pkgname}
  ln -sv /usr/lib/mailman/Mailman/mm_cfg.py ${pkgdir}/etc/${pkgname}/mm_cfg.py

  # fix some permissions to satisfy check_perms
  chown -R mailman:mailman $pkgdir/{usr/lib/mailman,var/lib/mailman,etc/mailman/*}
  chown http:mailman ${pkgdir}/var/lib/mailman/archives/private
  chmod 2770 ${pkgdir}/var/lib/mailman/archives/private
  chmod 2755 ${pkgdir}/usr/lib/mailman/cgi-bin/* 
  chmod 2755 ${pkgdir}/usr/lib/mailman/mail/mailman
  
  # install the launch script
  install -D -m755 $srcdir/rc.mailman $pkgdir/etc/rc.d/mailman || return 1
  
  if [ $cleanup -eq 1 ]; then
    msg "Removing user/group mailman"
    userdel mailman
  fi
}