~ubuntu-branches/debian/sid/mailman/sid

2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
1
#! /bin/sh -e
2
#
3
# postinst script for Debian python packages
4
# Written 1998 by Gregor Hoffleit <flight@debian.org>.
5
# Updated 2001 by Tollef Fog Heen <tfheen@debian.org>
6
# mailman modifications 2004 by Bernd S. Brentrup <bsb@debian.org>
3 by Lionel Elie Mamane
Upgrade subject and author indexes of _all_ archiving volumes to
7
# Other modifications 2004-2007 by other maintainers of the Debian package:
8
#      Lionel Elie Mamane, Thijs Kinkhorst, Riccardo Setti, Matej Vela, Hector Garcia, László Böszörményi, Bernd S. Brentrup, ...
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
9
#
11 by Thijs Kinkhorst
* Remove potentially long running 'find' command in postinst, as
10
# $URL: svn+ssh://svn.debian.org/svn/svn/pkg-mailman/trunk/debian/postinst $
19 by Thijs Kinkhorst
* Make man page descruptions match more keywords (closes: #597112).
11
# $Id: postinst 693 2011-10-08 15:30:38Z thijs $
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
12
#
13
. /usr/share/debconf/confmodule
14
15
PACKAGE=mailman
16
DIRLIST="/usr/lib/mailman/Mailman /usr/lib/mailman/bin /usr/lib/mailman/cron /usr/lib/mailman/scripts"
17
PYLIBDIR="/usr/lib/python`python -c 'import sys; print sys.version[:3]'`"
18
19
if [ "$1" = "configure" ]; then
20
21
    mm_etc=/etc/mailman
22
    mm_dist=/usr/share/mailman
23
24
    # Install only languages selected by the administrator
25
    # forcing used languages to be always available.
26
    db_get mailman/site_languages
2.1.9 by Martin Pitt
* Synchronize to Debian; remaining Ubuntu change:
27
    site_languages="$(echo $RET | sed -e 's/, */ /g' | sed -r 's/ \([^\)]*\)//g')"
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
28
    need_languages="${site_languages}"
29
    db_get  mailman/used_languages
30
    db_fset mailman/used_languages seen true
31
    db_fset mailman/used_languages scanned false
32
    for lang in ${used_languages} ; do
33
      if echo " ${site_languages} " | grep -v -q " ${lang} " ; then
34
        need_languages="${need_languages:+${need_languages} }${lang}"
35
      fi
36
    done
37
    if [ "${need_languages}" != "${site_languages}" ]; then
38
      db_set mailman/site_languages "$(echo ${need_languages} | sed -e 's/  */, /g')"
39
    fi
40
41
    # At present ALL directories in /etc/mailman are language directories
42
    # but this may change in the future, better check.
3 by Lionel Elie Mamane
Upgrade subject and author indexes of _all_ archiving volumes to
43
    # Furthermore, the administrator may have have added other directories
2.1.9 by Martin Pitt
* Synchronize to Debian; remaining Ubuntu change:
44
    for dir in $(find ${mm_etc} -maxdepth 1 -mindepth 1 -type d -printf '%P\n'); do
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
45
      if [ -f ${mm_dist}/${dir}/options.html ]; then
46
        old_languages="${old_languages} ${dir}"
47
      fi
48
    done
49
50
    # Remove languages no longer used, but purging modified files
51
    # is a bad thing[TM].
52
    leftover=/etc/mailman/leftover
53
    : >${leftover}
54
    for lang in ${old_languages}; do
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
55
      if echo " ${site_languages} " | grep -v -q " ${lang} " ; then
56
        printf "Removing unmodified files from ${mm_etc}/${lang} " >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
57
        # UGLY HACK: Since ucf doesn't support conditional removal
58
        #            we access its hashfile directly
59
        md5sums=$(tempfile --prefix=mm_${lang})
2.1.6 by Martin Pitt
* Merge to Debian; remaining Ubuntu changes:
60
        grep "^[[:xdigit:]]{32}[[:space:]]\+${mm_etc}/$lang/" /var/lib/ucf/hashfile >${md5sums} || true
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
61
          # Language files are under ucf control, check md5sums
9 by Thijs Kinkhorst
* New upstream release.
62
          for file in $(md5sum -c ${md5sums} 2>&1 | sed -n 's/: *OK$//p'); do 
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
63
            ucf --debconf-ok --purge ${file}
64
            rm -f ${file} ${file}.dpkg-dist
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
65
            printf . >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
66
          done
67
          # For modified files remove corresponding .dpkg-dist
2.1.6 by Martin Pitt
* Merge to Debian; remaining Ubuntu changes:
68
          for file in $(grep "^[[:xdigit:]]{32}[[:space:]]\+${mm_etc}/$lang/" /var/lib/ucf/hashfile | awk '{ print $2 }'); do
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
69
            rm -f ${file}.dpkg-dist
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
70
            printf . >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
71
          done
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
72
        printf " done.\n" >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
73
        rmdir ${mm_etc}/${lang} 2>/dev/null \
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
74
          || printf "Directory ${mm_etc}/${lang} not empty, not removed.\n" >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
75
        rm -f ${md5sums}
76
      fi
77
    done
78
79
    for lang in ${site_languages}; do
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
80
      printf "Installing site language ${lang} " >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
81
      mkdir -p ${mm_etc}/${lang}
82
      for file in $(ls ${mm_dist}/${lang}); do
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
83
        printf . >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
84
        langfile=${lang}/${file}
85
        ucf --debconf-ok --three-way ${mm_dist}/${langfile} ${mm_etc}/${langfile} 2>/dev/null
86
      done
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
87
      printf " done.\n" >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
88
    done
89
    # Done with site language stuff
90
2.1.9 by Martin Pitt
* Synchronize to Debian; remaining Ubuntu change:
91
    # Don't forget the qmail specific stuff
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
92
    ucf --debconf-ok --three-way ${mm_dist}/qmail-to-mailman.py ${mm_etc}/qmail-to-mailman.py 2>/dev/null
93
    # Install postfix-to-mailman.py as well
94
    ucf --debconf-ok --three-way ${mm_dist}/postfix-to-mailman.py ${mm_etc}/postfix-to-mailman.py 2>/dev/null
95
96
    if [ -e /etc/mailman/mm_cfg.py ]; then
97
        db_get mailman/default_server_language || true
2.1.9 by Martin Pitt
* Synchronize to Debian; remaining Ubuntu change:
98
        if [ -n "$RET" ]; then
99
            default_server_language="$(echo $RET | sed -r 's/ \([^\)]*\)//g')"
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
100
            sed -e s/DEFAULT_SERVER_LANGUAGE.*=.*\'..\'/DEFAULT_SERVER_LANGUAGE\ =\ \'${default_server_language}\'/ ${mm_etc}/mm_cfg.py > ${mm_etc}/mm_cfg.py.$$
101
            mv -f ${mm_etc}/mm_cfg.py.$$ ${mm_etc}/mm_cfg.py
102
        fi
103
    fi
4 by Thijs Kinkhorst
* Updated Catalan debconf translation, thanks David Planella Molas
104
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
105
fi
106
107
db_stop || true
108
109
case "$1" in
110
    configure|abort-upgrade|abort-remove|abort-deconfigure)
111
        if [ -e /etc/mailname ]
112
	    then 
113
            DOMAIN=$(head -n 1 /etc/mailname)
114
            # fixme - should we look for a dot in the domainname?
115
        else
116
            DOMAIN=localhost.localdomain
117
        fi
118
	if [ ! -e /etc/$PACKAGE/mm_cfg.py ]; then
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
119
	    printf "Configuring $PACKAGE for domain $DOMAIN ...\n"
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
120
	    sed s/thunderchild.aszi.sztaki.hu/$DOMAIN/g /usr/lib/mailman/Mailman/mm_cfg.py.dist \
121
		> /etc/$PACKAGE/mm_cfg.py
122
	fi
123
124
	if grep -q mm_defaults /etc/mailman/mm_cfg.py; then
2.1.15 by Thijs Kinkhorst
Apply upstream patch to fix regression in cmd_subscribe
125
		printf "Changing mm_defaults to Defaults in /etc/mailman/mm_cfg.py\n"
126
		printf "Fixing host name in /etc/mailman/mm_cfg.py\n"
2.1.9 by Martin Pitt
* Synchronize to Debian; remaining Ubuntu change:
127
		sed s/mm_defaults/Defaults/ "s/'localhost'/$DOMAIN/g" "s#http://localhost#http://$DOMAIN#g" </etc/mailman/mm_cfg.py >/etc/mailman/mm_cfg.py.new
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
128
		mv /etc/mailman/mm_cfg.py /etc/mailman/mm_cfg.py.old
129
		mv /etc/mailman/mm_cfg.py.new /etc/mailman/mm_cfg.py
130
	fi
10 by Lionel Elie Mamane, Lionel Elie Mamane, Thijs Kinkhorst
[ Lionel Elie Mamane ]
131
	if ! [ -d /var/lock/mailman ]; then
132
	    install -d -o root -g list -m 2775 /var/lock/mailman
133
	fi
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
134
	sg list -c "umask 002; /usr/lib/mailman/bin/update;"
135
    ;;
136
137
    *)
2.1.13 by Thijs Kinkhorst
* Drop suggests for obsolete python-*-codecs and drop versioned
138
        printf "postinst called with unknown argument \`$1'\n" >&2
2 by Tollef Fog Heen
* Brown bag release -- use '/' instead of the undefined SLASH in
139
        exit 1
140
    ;;
141
esac
142
143
#DEBHELPER#