[Pkg-mailman-hackers] Pkg-mailman commit - rev 164 - branches/pkg-split/core/debian

Bernd S. Brentrup bsb@haydn.debian.org
Sun, 30 May 2004 10:57:14 -0600


Author: bsb
Date: 2004-05-30 10:57:12 -0600 (Sun, 30 May 2004)
New Revision: 164

Added:
   branches/pkg-split/core/debian/mailman.NEWS
Removed:
   branches/pkg-split/core/debian/mailman-i18n.preinst
Modified:
   branches/pkg-split/core/debian/changelog
   branches/pkg-split/core/debian/mailman-i18n.postinst
   branches/pkg-split/core/debian/mailman-i18n.postrm
   branches/pkg-split/core/debian/mailman-i18n.prerm
   branches/pkg-split/core/debian/mailman.config
   branches/pkg-split/core/debian/mailman.links
   branches/pkg-split/core/debian/mailman.postinst
   branches/pkg-split/core/debian/mailman.preinst
   branches/pkg-split/core/debian/mailman.prerm
Log:
Adapt maintainer scripts to template override mechanism.
Add mailman/NEWS.Debian.

Modified: branches/pkg-split/core/debian/changelog
===================================================================
--- branches/pkg-split/core/debian/changelog	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/changelog	2004-05-30 16:57:12 UTC (rev 164)
@@ -11,8 +11,18 @@
   * Move user modified templates to /var/lib/mailman/templates/site
     (closes: #199039).
 
- -- Siggy Brentrup <bsb@debian.org>  Mon, 24 May 2004 11:21:12 +0200
+ -- Siggy Brentrup <bsb@debian.org>  Sun, 30 May 2004 18:35:58 +0200
 
+mailman (2.1.4-5) unstable; urgency=high
+
+  * This is an intermediate release to fix a security issue, 2.1.5 will be
+    released as split binary packages.
+  * Applied Mandrake security patch for CAN-2004-0412, thanks to Florian
+    Weimer (closes: #251176).
+  * Fixed spanish translation (closes: #248083).
+
+ -- Siggy Brentrup <bsb@debian.org>  Sat, 29 May 2004 14:53:41 +0200
+
 mailman (2.1.4-4) unstable; urgency=medium
 
   * Urgency medium because RC bugs are fixed.

Modified: branches/pkg-split/core/debian/mailman-i18n.postinst
===================================================================
--- branches/pkg-split/core/debian/mailman-i18n.postinst	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman-i18n.postinst	2004-05-30 16:57:12 UTC (rev 164)
@@ -5,7 +5,6 @@
 #
 
 """
-
 Fooling lintian that complains about not sourcing confmodule:
 . /usr/share/debconf/confmodule
 """#
@@ -29,8 +28,6 @@
 #  Exception class and convenience constants
 from debconf import DebconfError, LOW, MEDIUM, HIGH, CRITICAL
 
-print >>sys.stderr, '>>>', sys.argv
-
 PACKAGE='mailman-i18n'
 MM_INST = '/usr/lib/mailman'
 
@@ -38,103 +35,16 @@
 sys.path.insert(0, os.path.join(MM_INST, 'Mailman'))
 from Debian import DebuggingLogger, cfdb, mm_languages
 
-from errno import EEXIST, ENOTEMPTY
-#from errno import *
 
-mm_etc='/etc/mailman'
-mm_tmpl=os.path.join(mm_etc, 'templates')
-mm_dist='/usr/share/mailman/templates'
-
-
-def setup():
-    """
-    """#
-
-    # Install only languages selected by the administrator
-    # forcing used languages to be always available.
-    site_languages = db.get('mailman/site_languages').split(', ')
-    site_languages = [ s.strip() for s in site_languages if s.strip() ]
-    need_languages = site_languages[:]
-    used_languages = db.get('mailman/used_languages').split()
-    db.fset('mailman/used_languages', 'seen', 'true')
-    db.fset('mailman/used_languages', 'scanned', 'false')
-
-    log('DEBCONF: used_languages=%(used_languages)r' % locals(), lvl=2)
-    log('DEBCONF: site_languages=%(site_languages)r' % locals(), lvl=2)
-
-    for lang in used_languages:
-        if lang not in site_languages:
-            need_languages.append(lang)
-
-    log('SETUP: need_languages=%(need_languages)r' % locals(), lvl=2)
-
-    site_languages.sort()
-    need_languages.sort()
-    if need_languages != site_languages:
-        db.set('mailman/site_languages', ', '.join(need_languages))
-        site_languages = need_languages
-        log('SETUP: site_languages=%(site_languages)r' % locals(), lvl=2)
-
-    remove_templates(need_languages)
-    install_templates(need_languages)
-
-
-def remove_templates(languages):
-    """
-    """#
-    old_languages = os.listdir(mm_tmpl)
-
-    for lang in old_languages:
-        if lang not in languages:
-            langdir = os.path.join(mm_tmpl, lang)
-            log('Removing unmodified files from %(langdir)s ' % locals(),
-                nl='')
-            def cb(*args):
-                log('.', nl='')
-            cfdb.remove_unmod(lang+'/', dst=mm_tmpl, callback=cb)
-            cfdb.sync()
-            log(' done.')
-            try:
-                os.rmdir(langdir)
-            except OSError,err:
-                if err.errno == ENOTEMPTY:
-                    log('Directory %(langdir)s not empty so not removed.' % locals())
-                else: raise
-
-
-def install_templates(languages):
-    """
-    """#
-    for lang in languages:
-        log('Installing site language %(lang)s ' % locals(), nl='')
-        try:
-            os.mkdir(os.path.join(mm_tmpl, lang))
-        except OSError, err:
-            if err.errno != EEXIST: raise
-
-        for fn in os.listdir(os.path.join(mm_dist, lang)):
-            log('.', nl='')
-            langfile='%(lang)s/%(fn)s' % locals()
-            msg = cfdb.update(langfile, src=mm_dist, dst=mm_tmpl)
-            log(msg, lvl=9, nl='\n ')
-            # TBD: remove templates no longer distributed
-        cfdb.sync()
-        log(' done.')
-
-
 def start_mm_qrunner():
-    log('>> entering start_mm_qrunner', lvl=3)
-    if not cfdb.has_key('mailman/setup'):
-        log('Must reconfigure mailman to restart daemons.')
-        return
     from popen2 import Popen4
     runner = Popen4('/bin/sh -e')
     runner.tochild.write("""\
 if [ -x "/etc/init.d/mailman" ]; then
   if [ -x /usr/sbin/invoke-rc.d ] ; then
-    invoke-rc.d mailman start || true
+    invoke-rc.d mailman reload || true
   else
-    /etc/init.d/mailman start || true
+    /etc/init.d/mailman reload || true
   fi
 fi
 """)
@@ -152,10 +62,7 @@
     log = DebuggingLogger('MM_MAINT')
     try:
         op = sys.argv[1]
-        if op == 'configure':
-            setup()
         if op in ('configure','abort-upgrade','abort-remove','abort-deconfigure'):
-            cfdb['mailman/templates'] = PACKAGE
             start_mm_qrunner()
         else:
             log("postinst called with unknown argument %r." % op)

Modified: branches/pkg-split/core/debian/mailman-i18n.postrm
===================================================================
--- branches/pkg-split/core/debian/mailman-i18n.postrm	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman-i18n.postrm	2004-05-30 16:57:12 UTC (rev 164)
@@ -2,8 +2,15 @@
 # $URL$
 # $Id$
 
-echo ">>> $0 $*" >&2
-
-#DEBHELPER#
-
+# After removing templates restart the mailman to make sure
+# its mm_cfg.LC_DESCRIPTIONS are up to date.
+if [ "$1" = "remove" ]; then
+  if [ -x "/etc/init.d/mailman" ]; then
+    if [ -x /usr/sbin/invoke-rc.d ] ; then
+      invoke-rc.d mailman reload || true
+    else
+      /etc/init.d/mailman reload || true
+    fi
+  fi
+fi
 exit 0

Deleted: branches/pkg-split/core/debian/mailman-i18n.preinst
===================================================================
--- branches/pkg-split/core/debian/mailman-i18n.preinst	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman-i18n.preinst	2004-05-30 16:57:12 UTC (rev 164)
@@ -1,21 +0,0 @@
-#!/bin/sh -e
-# $URL$
-# $Id$
-
-mm_etc=/etc/mailman
-mm_tmpl=${mm_etc}/templates
-
-mm_languages="big5 ca cs da de en es et eu fi fr gb hr hu it ja ko lt nl no pl pt pt_BR ro ru sl sr sv uk"
-
-if [ "$1" = "install" ] ; then
-  for lang in $(cd ${mm_etc} ; find * -maxdepth 0 -type d); do
-    if echo " ${mm_languages} " | grep -q " ${lang} " ; then
-      [ -d ${mm_tmpl} ] || mkdir -p ${mm_tmpl}
-      mv -f ${mm_etc}/${lang} ${mm_tmpl}
-    fi
-  done
-fi
-
-#DEBHELPER#
-
-exit 0

Modified: branches/pkg-split/core/debian/mailman-i18n.prerm
===================================================================
--- branches/pkg-split/core/debian/mailman-i18n.prerm	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman-i18n.prerm	2004-05-30 16:57:12 UTC (rev 164)
@@ -4,38 +4,22 @@
 
 . /usr/share/debconf/confmodule
 
-echo ">>>" $0 $* >&2
-
 package=mailman-i18n
 
-mm_shutdown () {
-    if [ -x "/etc/init.d/mailman" ]; then
-        if [ -x /usr/sbin/invoke-rc.d ] ; then
-            invoke-rc.d mailman stop || true
-        else
-            /etc/init.d/mailman stop || true
-        fi
-    fi
-}
+db_fset mailman/other_languages seen false || true
 
-
 case $1 in
     remove)
-        mm_shutdown
         used_languages=$(withlist -q -a -r used_languages)
         db_set mailman/used_languages "${used_languages}" || true
         if [ "${used_languages}" != "en" ] ; then
-            db_fset mailman/other_languages seen false || true
             db_input critical mailman/other_languages || true
             db_go || true
             exit 1
         fi
         ;;
-    upgrade)
-        mm_shutdown
+    upgrade|failed-upgrade|deconfigure)
         ;;
-    failed-upgrade|deconfigure)
-        ;;
     *)
         echo "${package}.prerm called with unknown arguments $*" >&2
         exit 1

Added: branches/pkg-split/core/debian/mailman.NEWS
===================================================================
--- branches/pkg-split/core/debian/mailman.NEWS	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.NEWS	2004-05-30 16:57:12 UTC (rev 164)
@@ -0,0 +1,16 @@
+mailman (2.1.5-0split1) UNRELEASED; urgency=low
+
+  * Mailman now comes in separate binary packages mailman, mailman-bin,
+    mailman-doc and mailman-i18n with the latter being needed only if you
+    plan to support languages other than english in Mailman's web
+    interface or for automatically generated messages.
+
+  * Debian mailman packages no longer store HTML and text templates in
+    /etc/mailman but use Mailman's own override mechanism, see
+    README.Debian for a more detailed discussion.  If you have changed any
+    templates under /etc/mailman/<lang>, these are assumed to be site-wide
+    changes moving them to /var/lib/mailman/templates/site/<lang>.
+
+ -- Siggy Brentrup <bsb@debian.org>  Tue, 25 May 2004 08:28:38 +0200
+
+ $Id$


Property changes on: branches/pkg-split/core/debian/mailman.NEWS
___________________________________________________________________
Name: svn:keywords
   + Id URL

Modified: branches/pkg-split/core/debian/mailman.config
===================================================================
--- branches/pkg-split/core/debian/mailman.config	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.config	2004-05-30 16:57:12 UTC (rev 164)
@@ -25,8 +25,6 @@
 #  Exception class and convenience constants
 from debconf import DebconfError, LOW, MEDIUM, HIGH, CRITICAL
 
-print >>sys.stderr, '>>>', sys.argv
-
 mm_inst  = '/usr/lib/mailman'
 mm_home  = '/var/lib/mailman'
 mm_lists = os.path.join(mm_home, 'lists')

Modified: branches/pkg-split/core/debian/mailman.links
===================================================================
--- branches/pkg-split/core/debian/mailman.links	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.links	2004-05-30 16:57:12 UTC (rev 164)
@@ -15,4 +15,4 @@
 usr/lib/mailman/bin/check_perms         usr/sbin/check_perms
 usr/lib/mailman/bin/list_admins         usr/sbin/list_admins
 usr/lib/mailman/bin/withlist            usr/sbin/withlist
-usr/share/mailman/templates             var/lib/mailman/templates/default
\ No newline at end of file
+usr/share/mailman/templates             var/lib/mailman/templates/default

Modified: branches/pkg-split/core/debian/mailman.postinst
===================================================================
--- branches/pkg-split/core/debian/mailman.postinst	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.postinst	2004-05-30 16:57:12 UTC (rev 164)
@@ -9,7 +9,6 @@
 """
 
 import sys, os
-virgin_gbls = globals().copy()
 
 
 # Argl, if the debconf Python interface were well designed, sth like
@@ -59,8 +58,97 @@
     log(' done.')
 
 
+
+class UCF:
+    # Find a better name for this class!
+    def __init__(self, hashfile):
+        self.hashlines = open(hashfile).readlines()
+        self.dirs = {}
+
+    def enum(self, rexp):
+        import re
+        tmpl_re = re.compile(rexp)
+        for line in self.hashlines:
+            words = line.split()
+            if len(words) != 2: continue
+            ucf_md5, path = words
+            if not tmpl_re.match(path): continue
+            yield ucf_md5, path
+
+    def purge(self, path):
+        os.system('ucf --purge %(path)s' % locals())
+        try:
+            os.remove(path)
+        except OSError, e:
+            if e.errno != ENOENT: raise
+        for ext in ('dist', 'old', 'new'):
+            try:
+                os.remove('%(path)s.dpkg-%(ext)s' % locals())
+            except OSError, e:
+                if e.errno != ENOENT: raise
+        self.dirs[os.path.dirname(path)] = True
+
+    def rmdirs(self):
+        for d, p in self.dirs.items():
+            try:
+                if p: os.rmdir(d)
+            except OSError, e:
+                if e.errno == ENOTEMPTY:
+                    log('Directory %(d)s not empty, not removed.' % locals())
+                elif e.errno != ENOENT: raise
+            del self.dirs[d]
+
+        
+
+def templates_from_ucf():
+    """Get templates out of ucf control.
+
+    With mailman's own template overriding there is no need for
+    local templates in /etc/mailman under ucf control.  Locally
+    modified templates are assumed to be site wide modifications.
+    """#
+    import md5
+    from Mailman.Defaults import TEMPLATE_DIR
+
+    def save_site_template(path, data):
+        orig_umask = os.umask(002)
+        try:
+            dst_tmpl = os.path.join(TEMPLATE_DIR, 'site', path[13:])
+            try:
+                stfl = open(dst_tmpl, 'w')
+            except IOError, e:
+                if e.errno <> ENOENT: raise
+                os.makedirs(os.path.dirname(dst_tmpl), 02775)
+                stfl = open(dst_tmpl, 'w')
+        finally:
+            os.umask(orig_umask)
+        try:
+            stfl.write(data)
+        finally:
+            stfl.close()
+
+    ucf = UCF('/var/lib/ucf/hashfile')
+    log_cnt = 0
+    for ucf_md5, path in ucf.enum('^/etc/mailman/.+/'):
+        if log_cnt == 0:
+            log('Moving templates out of ucf control ', nl='')
+        log_cnt += 1
+        try:
+            tmpl = open(path).read()
+            site_md5 = md5.new(tmpl).hexdigest()
+            if site_md5 != ucf_md5:
+                save_site_template(path, tmpl)
+        except IOError, e:
+            if e.errno <> ENOENT: raise
+        ucf.purge(path)
+        log('.', nl='')
+    if log_cnt:
+        log(' done.')
+    ucf.rmdirs()
+
+
 def default_mm_cfg():
-    """Get default configuration.
+    """Get configuration defaults.
     """#
     gbls = {}
     exec 'from Mailman.Defaults import *' in gbls
@@ -169,7 +257,7 @@
         if usr_mod.keys():
             log("User modified variables:", lvl=3)
             for var in usr_mod.keys():
-                log('  %20s: %r\n%20s: %r'
+                log('  %20s: %r\n  %20s: %r'
                     % (var, usr_gbls[var], 'default', def_gbls[var]), lvl=3)
 
         if usr_def.keys():
@@ -332,13 +420,6 @@
 def start_mm_qrunner():
     log('>> entering start_mm_qrunner', lvl=3)
 
-    try:
-        if cfdb['mailman/templates'] in ('mailman-en', 'mailman-i18n'):
-            log('Will start qrunners.', lvl=2)
-    except KeyError:
-        log('Will not start qrunners.', lvl=2)
-        return
-
     from popen2 import Popen4
     runner = Popen4('/bin/sh -e')
     runner.tochild.write("""\
@@ -356,13 +437,14 @@
 
 def setup():
     compile_modules(MM_INST)
+    templates_from_ucf()
     if os.path.exists('/etc/mailman/mm_cfg.py'):
         upgrade_mm_cfg()
     else:
         create_mm_cfg()
     update_cron()
+    fix_perms()
     update_lists()
-    fix_perms()
 
 
 if __name__ == '__main__':
@@ -372,7 +454,6 @@
         if op == 'configure':
             setup()
         if op in ('configure','abort-upgrade','abort-remove','abort-deconfigure'):
-            cfdb['mailman/setup'] = 'ok'
             start_mm_qrunner()
         else:
             log("postinst called with unknown argument %r." % op)

Modified: branches/pkg-split/core/debian/mailman.preinst
===================================================================
--- branches/pkg-split/core/debian/mailman.preinst	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.preinst	2004-05-30 16:57:12 UTC (rev 164)
@@ -1,7 +1,6 @@
 #!/bin/sh -e
 # $URL$
 # $Id$
-echo ">>> $0 $*" >&2
 
 mm_inst=/usr/lib/mailman
 mm_home=/var/lib/mailman
@@ -35,35 +34,18 @@
     fi
 fi
 
-pythonlib=${mm_home}/pythonlib
-
-if [ -d ${pythonlib} ] && [ "$(ls -A ${pythonlib})" != "" ] ; then
-    cat <<EOF 
-You have a non-empty ${pythonlib}, possibly caused by an incomplete
-removal of an ancient mailman version.  In any case it's contents may
-lead to mailman failing in obscure ways.
-
-If you want it to be moved to ${pythonlib}.obsolete.$$ now, answer Y
-to the following question, any other response will abort installation
-and give you the opportunity to examine the situation.
-EOF
-    read -p "Move ${pythonlib} out of the way? [yN] " ans
-    case $ans in
-        y|Y)  mv ${pythonlib} ${pythonlib}.obsolete.$$
-            ;;
-        *) exit 1
-            ;;
-    esac
-fi
-
-# Before unpacking make sure no symlink cruft is left in ${mm_inst}
+# Before unpacking make sure no symlink cruft is left in ${mm_inst} or ${mm_home}
 for d in Mailman bin cron mail pythonlib scripts ; do
     if [ -L ${mm_inst}/${d} ]; then
         rm -f ${mm_inst}/${d}
     fi
 done
+for d in Mailman bin cgi-bin cron icons locks logs mail scripts templates ; do
+    if [ -L ${mm_home}/${d} ]; then
+        rm -f ${mm_home}/${d}
+    fi
+done
 
-
 #DEBHELPER#
 
 exit 0

Modified: branches/pkg-split/core/debian/mailman.prerm
===================================================================
--- branches/pkg-split/core/debian/mailman.prerm	2004-05-30 16:29:41 UTC (rev 163)
+++ branches/pkg-split/core/debian/mailman.prerm	2004-05-30 16:57:12 UTC (rev 164)
@@ -5,21 +5,9 @@
 #
 # $URL$
 # $Id$
-echo ">>> $0 $*" >&2
 
 PACKAGE=mailman
 
-unset_mm_setup () {
-python <<EOF
-import sys; sys.path.insert(0, '/usr/lib/mailman')
-try:
-    from Mailman.Debian import cfdb
-    del cfdb['mailman/setup']
-except:
-    pass
-EOF
-}
-
 mm_shutdown () {
 #DEBHELPER#
 }
@@ -27,7 +15,6 @@
 
 case "$1" in
     upgrade|remove)
-        unset_mm_setup
         mm_shutdown
         ;;
     failed-upgrade)