[Pkg-mailman-hackers] Pkg-mailman commit - rev 25 - in trunk/debian: . patches

Bernd S. Brentrup bsb@haydn.debian.org
Sun, 21 Mar 2004 11:56:49 -0700


Author: bsb
Date: 2004-03-21 11:56:46 -0700 (Sun, 21 Mar 2004)
New Revision: 25

Modified:
   trunk/debian/
   trunk/debian/changelog
   trunk/debian/config
   trunk/debian/patches/00list
   trunk/debian/postinst
   trunk/debian/postrm
   trunk/debian/rules
   trunk/debian/templates
Log:
Added debconf variable mailman/site_languages,
Backed out 05_config_list_member_options.dpatch.



Property changes on: trunk/debian
___________________________________________________________________
Name: mergeWithUpstream
   + 1

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/changelog	2004-03-21 18:56:46 UTC (rev 25)
@@ -23,8 +23,12 @@
     (by GCS, closes: #236666)
   * Change obsolete MAILMAN_OWNER to MAILMAN_SITE_LIST, note that this
     invalidate #232273 and #232452 (by GCS, closes: #235913)
+  * Add debconf question for languages supported at a site reducing space
+    required in /etc (bsb).
+  * Backed out hack in 05_config_list_member_options.dpatch since it
+    breaks config_list in mm 2.1.4 (bsb, closes: #231967).
 
- -- Siggy Brentrup <bsb@debian.org>  Thu, 18 Mar 2004 10:41:34 +0100
+ -- Siggy Brentrup <bsb@debian.org>  Sun, 21 Mar 2004 17:50:04 +0100
 
 mailman (2.1.4-1) unstable; urgency=medium
 

Modified: trunk/debian/config
===================================================================
--- trunk/debian/config	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/config	2004-03-21 18:56:46 UTC (rev 25)
@@ -2,8 +2,35 @@
 
 . /usr/share/debconf/confmodule
 
-if [ -f "/etc/cron.d/mailman" ]; then
-    COMMENT=`awk '/^.*gate_news/ { print substr($1,1,1) } ' < /etc/cron.d/mailman`
+crontab=/etc/cron.d/mailman
+site_languages=/etc/mailman/site-languages
+
+function 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'
+EOF
+    ) | python -W ignore::DeprecationWarning
+  done | sort | uniq
+}
+
+if [ -x "/usr/sbin/list_lists" ]; then
+    echo -n "Looking for enabled languages (this may take some time) ..."
+    used_languages="$(get_used_languages)"
+    echo " done."
+    db_set mailman/site_languages "$(echo ${used_languages} | sed -e 's/  */, /g')"
+else
+    db_set mailman/site_languages "en"
+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
@@ -11,12 +38,12 @@
     fi
 fi
 
+db_input low mailman/gate_news || true
+
 if [ ! -e /etc/mailman/mm_cfg.py -o ! -x /var/lib/mailman/bin/list_lists ] || \
     [ "$(/var/lib/mailman/bin/list_lists -b | grep ^mailman$ )" = "" ]; then
     db_input critical mailman/create_site_list || true
-    db_go || true
 fi
 
-db_input low mailman/gate_news || true
 db_go || true
 

Modified: trunk/debian/patches/00list
===================================================================
--- trunk/debian/patches/00list	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/patches/00list	2004-03-21 18:56:46 UTC (rev 25)
@@ -1,6 +1,5 @@
 00_stolen_from_HEAD
 01_defaults.debian
-05_config_list_member_options
 07_snooze
 10_wrapper_uid
 11_handle_propfind

Modified: trunk/debian/postinst
===================================================================
--- trunk/debian/postinst	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/postinst	2004-03-21 18:56:46 UTC (rev 25)
@@ -10,10 +10,76 @@
 DIRLIST="/usr/lib/mailman/Mailman /usr/lib/mailman/bin /usr/lib/mailman/cron /usr/lib/mailman/scripts"
 PYLIBDIR="/usr/lib/python`python -c 'import sys; print sys.version[:3]'`"
 
-#UCF#
-
 if [ "$1" = "configure" ]; then
 
+    mm_etc=/etc/mailman
+    mm_dist=/usr/share/mailman
+
+    # Install only languages selected by the administrator
+    # forcing english to be always available.
+    db_get mailman/site_languages
+    site_languages="$(echo $RET | sed -e 's/, */ /g')"
+    need_languages=${site_languages}
+    for lang in ${used_languages} ; do
+      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
+
+    # At present ALL directories in /etc/mailman are language directories
+    # but this may change in the future, better check.
+    for dir in $(find ${mm_etc} -type d -maxdepth 1 -mindepth 1 | sed -e "s;^${mm_etc}/;;g"); do
+      if [ -f ${mm_dist}/${dir}/options.html ]; then
+        old_languages="${old_languages} ${dir}"
+      fi
+    done
+
+    # Remove languages no longer used, but purging modified files
+    # is a bad thing.  Since ucf doesn't support conditional removal
+    # we must compare with the /usr/share/mailman copy.
+    for lang in ${old_languages}; do
+      if  echo " ${site_languages} " | grep -v -q " ${lang} " ; then
+        echo -n "Removing unmodified files from ${mm_etc}/${lang} "
+        for file in $(cd /etc && find mailman/${lang} -type f -a ! -name \*.dpkg-\* ); do
+          if cmp -s /etc/${file} /usr/share/${file}; then
+            ucf --debconf-ok --purge /etc/${file}
+            rm -f /etc/${file} /etc/${file}.dpkg-dist
+            echo -n .
+          fi
+        done
+        echo " done."
+        rmdir ${mm_etc}/${lang} 2>/dev/null \
+          || echo "Directory ${mm_etc}/${lang} not empty, not removed."
+      fi
+    done
+
+    for lang in ${site_languages}; do
+      echo -n "Installing site language ${lang} "
+      mkdir -p ${mm_etc}/${lang}
+      for file in $(ls ${mm_dist}/${lang}); do
+        echo -n .
+        langfile=${lang}/${file}
+        ucf --debconf-ok --three-way ${mm_dist}/${langfile} ${mm_etc}/${langfile} \
+          </dev/tty >/dev/tty
+        # Upon install ucf leaves a duplicate in .dpkg-dist (Bug #238730), remove it
+        cmp -s ${mm_etc}/${langfile} ${mm_etc}/${langfile}.dpkg-dist \
+          && rm ${mm_etc}/${langfile}.dpkg-dist
+      done
+      echo " done."
+    done
+    # Done with site language stuff
+
+    # Don't forget the qmail specific stuff (but why support non-free?)
+    ucf --debconf-ok --three-way ${mm_dist}/qmail-to-mailman.py ${mm_etc}/qmail-to-mailman.py
+    # Upon install ucf leaves a duplicate in .dpkg-dist (Bug #238730), remove it
+    cmp -s ${mm_etc}/qmail-to-mailman.py ${mm_etc}/qmail-to-mailman.py.dpkg-dist \
+      && rm ${mm_etc}/qmail-to-mailman.py.dpkg-dist
+
+    # Configure Mailman crontab
+
     # Ensure the file exists before we awk it.
     if [ ! -f /etc/cron.d/mailman ]; then
     cat > /etc/cron.d/mailman <<EOF

Modified: trunk/debian/postrm
===================================================================
--- trunk/debian/postrm	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/postrm	2004-03-21 18:56:46 UTC (rev 25)
@@ -2,8 +2,21 @@
 
 #DEBHELPER#
 
-#UCF#
+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
+  done
+  # Don't forget this one
+  ucf --debconf-ok --purge /etc/mailman/qmail-to-mailman.py
+fi
+
 if [ "$1" = purge ]; then
   rm -f /etc/cron.d/mailman 
   rm -rf /etc/mailman

Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/rules	2004-03-21 18:56:46 UTC (rev 25)
@@ -180,26 +180,26 @@
 #	dh_suidregister
 	dh_installdeb
 
-	echo 'if [ "$$1" = purge ]; then' >> debian/mailman.postrm.ucf
-	for f in `cat debian/ucffiles`; do \
-		echo -e "\techo Removing $$f" >> debian/mailman.postrm.ucf; \
-		echo -e "\tucf --debconf-ok --purge $$f" >> debian/mailman.postrm.ucf ; \
-	done
-	echo 'fi' >> debian/mailman.postrm.ucf
+#	echo 'if [ "$$1" = purge ]; then' >> debian/mailman.postrm.ucf
+#	for f in `cat debian/ucffiles`; do \
+#		echo -e "\techo Removing $$f" >> debian/mailman.postrm.ucf; \
+#		echo -e "\tucf --debconf-ok --purge $$f" >> debian/mailman.postrm.ucf ; \
+#	done
+#	echo 'fi' >> debian/mailman.postrm.ucf
 
-	echo 'if [ "$$1" = "configure" ]; then'>> debian/mailman.postinst.ucf
-	for dir in $$(for f in $$(cat debian/ucffiles); do dirname "$$f" ; done | sort | uniq); do echo -e "\tmkdir -p $$dir" >> debian/mailman.postinst.ucf ; done
+#	echo 'if [ "$$1" = "configure" ]; then'>> debian/mailman.postinst.ucf
+#	for dir in $$(for f in $$(cat debian/ucffiles); do dirname "$$f" ; done | sort | uniq); do echo -e "\tmkdir -p $$dir" >> debian/mailman.postinst.ucf ; done
 
-	echo -e "\techo -n 'Checking/installing config files (this takes time)': " >> debian/mailman.postinst.ucf
-	for f in `cat debian/ucffiles`; do \
-		echo -e "\techo -n ." >> debian/mailman.postinst.ucf ; \
-		echo -e "\tucf `echo $$f | sed s,/etc/mailman,/usr/share/mailman,` $$f < /dev/tty > /dev/tty" >> debian/mailman.postinst.ucf ; \
-	done
-	echo 'fi' >> debian/mailman.postinst.ucf
-	echo -e "\techo \" done!\"" >> debian/mailman.postinst.ucf
+#	echo -e "\techo -n 'Checking/installing config files (this takes time)': " >> debian/mailman.postinst.ucf
+#	for f in `cat debian/ucffiles`; do \
+#		echo -e "\techo -n ." >> debian/mailman.postinst.ucf ; \
+#		echo -e "\tucf `echo $$f | sed s,/etc/mailman,/usr/share/mailman,` $$f < /dev/tty > /dev/tty" >> debian/mailman.postinst.ucf ; \
+#	done
+#	echo 'fi' >> debian/mailman.postinst.ucf
+#	echo -e "\techo \" done!\"" >> debian/mailman.postinst.ucf
 
-	perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postinst.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postinst
-	perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postrm.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postrm
+#	perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postinst.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postinst
+#	perl -pi -e '/#UCF#/ and do { open F, "debian/mailman.postrm.ucf"; local $$/ ; $$_ = <F> };' debian/mailman/DEBIAN/postrm
 
 	dh_shlibdeps
 	dh_gencontrol

Modified: trunk/debian/templates
===================================================================
--- trunk/debian/templates	2004-03-18 22:23:21 UTC (rev 24)
+++ trunk/debian/templates	2004-03-21 18:56:46 UTC (rev 25)
@@ -1,3 +1,19 @@
+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
+Default: en
+_Description: Which languages to support?  
+ For each supported language Debian Mailman stores default language
+ specific texts in /etc/mailman/LANG/ giving them conffile like
+ treatment with the help of ucf.  This means approximately 150kB for
+ each supported language on the root FS.
+ .
+ If you need a different set of languages at a later time, just run
+ dpkg-reconfigure mailman.
+ .
+ NOTE: Languages enabled on existing mailing lists are forcibly re-
+ enabled when deselected.
+
 Template: mailman/gate_news
 Type: boolean
 Default: false