[Pkg-mailman-hackers] Pkg-mailman commit - rev 39 - trunk/debian

Bernd S. Brentrup bsb@haydn.debian.org
Sun, 28 Mar 2004 14:11:46 -0700


Author: bsb
Date: 2004-03-28 14:11:33 -0700 (Sun, 28 Mar 2004)
New Revision: 39

Modified:
   trunk/debian/changelog
   trunk/debian/config
   trunk/debian/control
   trunk/debian/postinst
   trunk/debian/postrm
   trunk/debian/preinst
   trunk/debian/prerm
   trunk/debian/templates
Log:
- Add URL and Id keywords on maintainer scripts and templates.
- Fix gate_news handling, boolean returns true/false not yes/no.
- Revamp site_language stuff to avoid duplicate scanning.


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/changelog	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,10 +1,17 @@
 mailman (2.1.4-3) UNRELEASED; urgency=low
 
-  * NOT YET RELEASED (svn-buildpackage likes it).
+  * NOT YET RELEASED (svn-buildpackage likes this line).
   * Fix bogus test for empty qfiles/ in preinst (bsb, closes: #240033).
+  * Create group list as a system group if it doesn't exist
+    (bsb, closes: #240672).
+  * Use true/false for mailman/gate_news to make it work (bsb).
+  * Purge all mailman files _in_ucf_database_ on package purge (bsb).
+  * Make 'leftover' notice stand out (bsb).
+  * Added helper debconf template mailman/used_languages to avoid
+    duplicate scanning on preconfigure/setup (bsb).
   * Remove bashism from debian/config (by GCS, closes: #240643).
 
- -- Siggy Brentrup <bsb@debian.org>  Thu, 25 Mar 2004 19:10:17 +0100
+ -- Siggy Brentrup <bsb@debian.org>  Sun, 28 Mar 2004 17:57:08 +0200
 
 mailman (2.1.4-2) unstable; urgency=low
 

Modified: trunk/debian/config
===================================================================
--- trunk/debian/config	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/config	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,29 +1,64 @@
 #! /bin/sh -e
+# $URL$
+# $Id$
 
 . /usr/share/debconf/confmodule
 
 crontab=/etc/cron.d/mailman
-site_languages=/etc/mailman/site-languages
 
 get_used_languages ()
 {
-  for ml in $(/usr/sbin/list_lists -b); do
-    ( /usr/sbin/config_list -o - ${ml} 2>/dev/null
-      cat <<EOF
-try:
-  print '\n'.join(available_languages)
-except: print 'en'
+  # Python being non-essential it may not be available at preconfigure
+  # time, but then no languages are used either.
+  if python </dev/null 2>/dev/null ; then
+    # list_lists may fail if mm_cfg is not yet installed
+    ( for ml in $(/usr/sbin/list_lists -b 2>/dev/null); do
+        ( /usr/sbin/config_list -o - ${ml} 2>/dev/null
+          cat <<EOF
+try: print '\n'.join(available_languages)
+except: pass
 EOF
-    ) | python -W ignore::DeprecationWarning
-  done | sort | uniq
+        ) | python -W ignore::DeprecationWarning
+      done 
+    ) | sort | uniq
+  fi
 }
 
-if [ -f "/etc/mailman/mm_cfg.py" -a -x "/usr/sbin/list_lists" ]; then
-  echo -n "Looking for enabled languages (this may take some time) ..."
-  used_languages="$(get_used_languages)"
-  echo " done."
+# This script will be invoked by apt-get 2 times in a row, once when
+# preconfiguring the package and a second time just before running the
+# postinst script.  OTOH when installing the package with dpkg or when
+# reconfiguring the package, it runs only once.
+#
+# It scans all mailing lists on a system for used languages which may
+# be quite time consuming on systems with many lists; hence we better
+# avoid to run that scan twice in a row.
+# 
+# The debconf template mailman/used_languages holds the result of the
+# scan but is never presented to the user, instead its scanned flag
+# indicates if it holds a fresh value and is reset by the postinst,
+# while its seen flag is mainly used for cosmetical reasons to mark
+# processed values in debconf-show output.
+
+db_get mailman/used_languages
+used_languages="${RET}"
+db_fget mailman/used_languages scanned
+scanned="${RET}"
+
+if [ ! -x "/usr/sbin/list_lists" ]; then
+  db_set mailman/site_languages "en"
+else
+  if [ "${scanned}" != "true" ] ; then
+    echo -n "Looking for enabled languages (this may take some time) ..."
+    for l in $(get_used_languages); do
+      used_languages=${used_languages:+${used_languages} }$l
+    done
+    db_set  mailman/used_languages "${used_languages}"
+    db_fset mailman/used_languages scanned true
+    db_fset mailman/used_languages seen false
+    echo " done."
+  fi
   # Install only languages selected by the administrator
-  # forcing english to be always available.
+  # forcing used languages to be always available.
   db_get mailman/site_languages
   site_languages="$(echo $RET | sed -e 's/, */ /g')"
   need_languages="${site_languages}"
@@ -31,23 +66,21 @@
     if echo " ${site_languages} " | grep -v -q " ${lang} " ; then
       need_languages="${lang} ${need_languages}"
     fi
-    if [ "${need_languages}" != "${site_languages}" ]; then
-      db_set mailman/site_languages "$(echo ${need_languages} | sed -e 's/  */, /g')"
-    fi
   done
-else
-  db_set mailman/site_languages "en"
+  if [ "${need_languages}" != "${site_languages}" ]; then
+    db_set mailman/site_languages "$(echo ${need_languages} | sed -e 's/  */, /g')"
+  fi
 fi
 
 db_input high mailman/site_languages || true
 
 if [ -f "${crontab}" ]; then
-    COMMENT=`awk '/^.*gate_news/ { print substr($1,1,1) } ' < ${crontab}`
-    if [ "$COMMENT" = "#" ]; then
-	db_set mailman/gate_news no
-    else
-	db_set mailman/gate_news yes
-    fi
+  COMMENT=`awk '/^.*gate_news/ { print substr($1,1,1) } ' < ${crontab}`
+  if [ "$COMMENT" = "#" ]; then
+    db_set mailman/gate_news false
+  else
+    db_set mailman/gate_news true
+  fi
 fi
 
 db_input low mailman/gate_news || true


Property changes on: trunk/debian/config
___________________________________________________________________
Name: svn:keywords
   + URL Id

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/control	2004-03-28 21:11:33 UTC (rev 39)
@@ -8,7 +8,7 @@
 
 Package: mailman
 Architecture: any
-Depends: ${shlibs:Depends}, python (>= 2.2.2.91-1), logrotate, cron (>= 3.0pl1-42), exim4 | mail-transport-agent, apache | httpd, debconf (>= 0.2.26), ucf (>= 0.28), pwgen
+Depends: ${shlibs:Depends}, python (>= 2.2.2.91-1), logrotate, cron (>= 3.0pl1-42), exim4 | mail-transport-agent, apache | httpd, debconf (>= 1.4.16), ucf (>= 0.28), pwgen
 Conflicts: suidmanager (<< 0.50), sendmail (<< 8.12.6)
 Recommends: base-passwd (>= 1.3.0)
 Suggests: spamassassin, python2.2-korean-codecs | python2.3-korean-codecs, python-japanese-codecs

Modified: trunk/debian/postinst
===================================================================
--- trunk/debian/postinst	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/postinst	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,9 +1,13 @@
 #! /bin/sh -e
 #
-# postinst script for Debian python packages.
+# postinst script for Debian python packages
 # Written 1998 by Gregor Hoffleit <flight@debian.org>.
 # Updated 2001 by Tollef Fog Heen <tfheen@debian.org>
+# mailman modifications 2004 by Bernd S. Brentrup <bsb@debian.org>
 #
+# $URL$
+# $Id$
+#
 . /usr/share/debconf/confmodule
 
 PACKAGE=mailman
@@ -20,14 +24,17 @@
     db_get mailman/site_languages
     site_languages="$(echo $RET | sed -e 's/, */ /g')"
     need_languages="${site_languages}"
+    db_get  mailman/used_languages
+    db_fset mailman/used_languages seen true
+    db_fset mailman/used_languages scanned false
     for lang in ${used_languages} ; do
       if echo " ${site_languages} " | grep -v -q " ${lang} " ; then
-        need_languages="${lang} ${need_languages}"
+        need_languages="${need_languages:+${need_languages} }${lang}"
       fi
-      if [ "${need_languages}" != "${site_languages}" ]; then
-        db_set mailman/site_languages "$(echo ${need_languages} | sed -e 's/  */, /g')"
-      fi
     done
+    if [ "${need_languages}" != "${site_languages}" ]; then
+      db_set mailman/site_languages "$(echo ${need_languages} | sed -e 's/  */, /g')"
+    fi
 
     # At present ALL directories in /etc/mailman are language directories
     # but this may change in the future, better check.
@@ -83,14 +90,17 @@
 
     if [ -s ${leftover} ]; then
       cat >&2 <<EOF
+
+----------------------------------------------------------------------
 Some templates from unused langugages could not be automatically
 removed since there was no way to find out if they were modified by
 you or the prototype in the package differs from the previous release.
 ${leftover} lists these files; please move them out of the way
-at your discretion.
+at your discretion if you don't want to see this message again.
+----------------------------------------------------------------------
 
 EOF
-      echo -n "Press return to continue." >&2
+      echo -n "Hit return to continue." >&2
       read junk </dev/tty
       echo >&2
     else
@@ -103,9 +113,6 @@
       for file in $(ls ${mm_dist}/${lang}); do
         echo -n . >&2
         langfile=${lang}/${file}
-        # Note that there is no easy way to suppress ucf's chatty output when
-        # creating a config file while keeping --debconf-ok functionality.
-        # cf. Bug#239678
         ucf --debconf-ok --three-way ${mm_dist}/${langfile} ${mm_etc}/${langfile} 2>/dev/null
         # Upon install ucf leaves a duplicate in .dpkg-dist (Bug #238730), remove it
         cmp -s ${mm_etc}/${langfile} ${mm_etc}/${langfile}.dpkg-dist \
@@ -213,7 +220,7 @@
     done
 
     db_get mailman/gate_news || true
-    if [ "$RET" = "no" ]; then
+    if [ "$RET" = "false" ]; then
 	# Comment out any lines containing the words "gate_news"
 	awk '/^[^#]*gate_news/ { print "# " $LINE;next }; //' < /etc/cron.d/mailman > /etc/cron.d/mailman.$$
     else


Property changes on: trunk/debian/postinst
___________________________________________________________________
Name: svn:keywords
   + URL Id

Modified: trunk/debian/postrm
===================================================================
--- trunk/debian/postrm	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/postrm	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,20 +1,19 @@
 #! /bin/sh -e
+# $URL$
+# $Id$
 
 #DEBHELPER#
 
 if [ "$1" = purge ]; then
-  # At present ALL directories in /etc/mailman are language directories
-  # but this may change in the future, cant check in postrm.
-  languages="$(find /etc/mailman -type d -maxdepth 1 -mindepth 1 | sed -e 's;^/etc/mailman/;;g')"
-
-  # Remove all trackings of languages files from the ucf database.
-  for lang in ${languages}; do
-    for file in $(cd /etc && find mailman/${lang} -type f -a ! -name \*.dpkg-\* ); do
-        ucf --debconf-ok --purge /etc/${file}
-    done
+  # HACK: At present there is no way to ask ucf for registered files
+  #       except for directly querying its database.
+  echo -n "Purging files from ucf database " >&2
+  for file in $(sed -e ':/etc/mailman:!d' -e 's:^[0-9a-f]* *::' /var/lib/ucf/hashfile); do
+    ucf --purge ${file} 2>/dev/null
+    echo -n . >&2
   done
-  # Don't forget this one
-  ucf --debconf-ok --purge /etc/mailman/qmail-to-mailman.py
+  ucf --purge /etc/cron.d/mailman 2>/dev/null
+  echo ". done." >&2
 fi
 
 if [ "$1" = purge ]; then


Property changes on: trunk/debian/postrm
___________________________________________________________________
Name: svn:keywords
   + URL Id

Modified: trunk/debian/preinst
===================================================================
--- trunk/debian/preinst	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/preinst	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,8 +1,10 @@
 #!/bin/sh -e
+# $URL$
+# $Id$
 
 if [ "$1" = "install" ]; then
 	if ! id -g list > /dev/null 2>&1 ; then
-		addgroup list
+		addgroup --system list
 	fi
 	if ! id -u list > /dev/null 2>&1 ; then
 		adduser --system --home /var/list --ingroup list list


Property changes on: trunk/debian/preinst
___________________________________________________________________
Name: svn:keywords
   + URL Id

Modified: trunk/debian/prerm
===================================================================
--- trunk/debian/prerm	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/prerm	2004-03-28 21:11:33 UTC (rev 39)
@@ -3,22 +3,35 @@
 # prerm script for Debian python packages.
 # Written 1998 by Gregor Hoffleit <flight@debian.org>.
 #
+# $URL$
+# $Id$
 
 # Hack to allow upgrade from broken 2.1.1 installs where stopping
 # mailman will fail.  This hack can be removed after sarge+1 is released.
 
 if [ "$1" = "failed-upgrade" -a \( "$2" = "2.1.1-1" -o \
      "$2" = "2.1.1-2" -o "$2" = "2.1.1-3" \) ]; then
-    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
+  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
-    chmod -x /usr/lib/mailman/bin/mailmanctl
+  fi
+  chmod -x /usr/lib/mailman/bin/mailmanctl
 fi
 
+if [ "$1" = "failed-upgrade" ] && dpkg --compare-versions "$2" gt "2.1.4-2" ; then
+  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
+  chmod -x /usr/lib/mailman/bin/mailmanctl
+fi
+
 #DEBHELPER#
 
 PACKAGE=mailman


Property changes on: trunk/debian/prerm
___________________________________________________________________
Name: svn:keywords
   + URL Id

Modified: trunk/debian/templates
===================================================================
--- trunk/debian/templates	2004-03-28 20:34:47 UTC (rev 38)
+++ trunk/debian/templates	2004-03-28 21:11:33 UTC (rev 39)
@@ -1,3 +1,6 @@
+# $URL$
+# $Id$
+
 Template: mailman/site_languages
 Type: multiselect
 __Choices: 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
@@ -14,6 +17,10 @@
  NOTE: Languages enabled on existing mailing lists are forcibly re-
  enabled when deselected.
 
+Template: mailman/used_languages
+Type: string
+Description: Internal holding result of scan
+
 Template: mailman/gate_news
 Type: boolean
 Default: false


Property changes on: trunk/debian/templates
___________________________________________________________________
Name: svn:keywords
   + URL Id