[Pkg-mailman-hackers] Pkg-mailman commit - rev 109 - in branches/pkg-split/core/debian: . snippets
Bernd S. Brentrup
bsb@haydn.debian.org
Wed, 05 May 2004 12:52:48 -0600
Author: bsb
Date: 2004-05-05 12:52:46 -0600 (Wed, 05 May 2004)
New Revision: 109
Added:
branches/pkg-split/core/debian/snippets/ucf_to_cfdb.py
Modified:
branches/pkg-split/core/debian/postinst
branches/pkg-split/core/debian/postrm
Log:
Move files currently under ucf control to Mailman.Debian.cfdb
Modified: branches/pkg-split/core/debian/postinst
===================================================================
--- branches/pkg-split/core/debian/postinst 2004-05-05 18:47:03 UTC (rev 108)
+++ branches/pkg-split/core/debian/postinst 2004-05-05 18:52:46 UTC (rev 109)
@@ -37,6 +37,52 @@
MM_BIN = os.path.join(MM_HOME, 'bin')
MM_INST = '/usr/share/mailman'
+
+def ucf_to_cfdb():
+ """Import templates under ucf control.
+
+ All Debian releases up to now that used ucf have only registered
+ files under /etc/mailman/LANG and /etc/mailman/qmail-to-mailman.py
+ with ucf, allowing this simplistic approach at moving to our own
+ conffile database.
+ """#
+ from Mailman.Debian import cfdb, mm_languages
+
+ UCF_CACHE = '/var/lib/ucf/cache'
+ ETC_DIR = '/etc/mailman/'
+ ETC_LEN = len(ETC_DIR)
+
+ prev_lang = None
+
+ ucf_list = [ fn for fn in os.listdir(UCF_CACHE)
+ if fn.startswith(':etc:mailman:') ]
+ if not ucf_list: return
+
+ log('Moving files out of ucf control ', nl='')
+
+ for cached in ucf_list:
+ path = '/'.join(cached.split(':'))
+ ucf_cached = os.path.join(UCF_CACHE, cached)
+ tmpl = open(ucf_cached).read()
+ try:
+ reg_key = path[ETC_LEN:]
+ lang, tmpl = reg_key.split('/')
+ if lang in mm_languages:
+ if lang != prev_lang:
+ if prev_lang: cfdb.sync()
+ prev_lang = lang
+ cfdb.register(reg_key, tmpl)
+ except ValueError:
+ cfdb.register(path, tmpl)
+
+ os.system('ucf --purge --three-way %(path)s' % locals())
+ os.remove(ucf_cached)
+ log('.', nl='')
+
+ cfdb.sync()
+ log(' done.')
+
+
def compile_modules(directory):
"""Compiles all python modules in the specified directory.
@@ -57,6 +103,7 @@
os.system(cmd)
log(' done.')
+
def create_mm_cfg():
"""Create an initial /etc/mailman/mm_cfg.py
@@ -85,6 +132,7 @@
except DebconfError, exc:
log.exception()
+
def update_cron():
"""Update mailman crontab according to debconf setting.
@@ -139,6 +187,7 @@
def setup():
compile_modules(MM_HOME)
+ ucf_to_cfdb()
create_mm_cfg()
update_cron()
run_debhelper_additions()
Modified: branches/pkg-split/core/debian/postrm
===================================================================
--- branches/pkg-split/core/debian/postrm 2004-05-05 18:47:03 UTC (rev 108)
+++ branches/pkg-split/core/debian/postrm 2004-05-05 18:52:46 UTC (rev 109)
@@ -5,20 +5,9 @@
#DEBHELPER#
if [ "$1" = purge ]; then
- # 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
- ucf --purge /etc/cron.d/mailman 2>/dev/null
- echo ". done." >&2
-fi
-
-if [ "$1" = purge ]; then
rm -f /etc/cron.d/mailman
rm -rf /etc/mailman
rm -rf /var/log/mailman
+ rm -f /var/lib/mailman/data/debcf.db
# rm -rf /var/lib/mailman
fi
Added: branches/pkg-split/core/debian/snippets/ucf_to_cfdb.py
===================================================================
--- branches/pkg-split/core/debian/snippets/ucf_to_cfdb.py 2004-05-05 18:47:03 UTC (rev 108)
+++ branches/pkg-split/core/debian/snippets/ucf_to_cfdb.py 2004-05-05 18:52:46 UTC (rev 109)
@@ -0,0 +1,50 @@
+#! /usr/bin/python -O
+# $URL$
+# $Id$
+
+"""Moves old templates from the ucf cache to our conffile database.
+
+This is needed when upgrading from a MM release that uses ucf.
+"""
+
+import sys, os
+
+
+sys.path.insert(0, '/var/lib/mailman')
+
+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".split()
+
+
+def ucf_to_cfdb():
+ from Mailman.Debian import cfdb
+
+ UCF_CACHE = '/var/lib/ucf/cache'
+ ETC_DIR = '/etc/mailman/'
+ ETC_LEN = len(ETC_DIR)
+
+ prev_lang = None
+
+ for cached in os.listdir(UCF_CACHE):
+ path = '/'.join(cached.split(':'))
+ if not path.startswith(ETC_DIR):
+ continue
+ try:
+ reg_key = path[ETC_LEN:]
+ lang, tmpl = reg_key.split('/')
+ if lang in mm_languages:
+ if lang != prev_lang:
+ if prev_lang: db.sync()
+ prev_lang = lang
+ cfdb.register(lang, None)
+ tmpl = open(os.path.join(UCF_CACHE, cached)).read()
+ cfdb.register(reg_key, tmpl)
+ except ValueError:
+ tmpl = open(os.path.join(UCF_CACHE, cached)).read()
+ cfdb.register(path, tmpl)
+
+ os.system('ucf --purge %(path)s' % locals())
+
+ cfdb.close()
+
+if __name__ == '__main__':
+ ucf_to_cfdb()
Property changes on: branches/pkg-split/core/debian/snippets/ucf_to_cfdb.py
___________________________________________________________________
Name: svn:keywords
+ Id URL