[Pkg-mailman-hackers] Pkg-mailman commit - rev 103 - branches/pkg-split/core/debian
Bernd S. Brentrup
bsb@haydn.debian.org
Sun, 02 May 2004 03:31:31 -0600
Author: bsb
Date: 2004-05-02 03:31:29 -0600 (Sun, 02 May 2004)
New Revision: 103
Modified:
branches/pkg-split/core/debian/TODO
branches/pkg-split/core/debian/config
branches/pkg-split/core/debian/postinst
Log:
Fix paths and handle mailman/gate_news in /etc/cron.d/mailman.
Modified: branches/pkg-split/core/debian/TODO
===================================================================
--- branches/pkg-split/core/debian/TODO 2004-05-01 10:19:12 UTC (rev 102)
+++ branches/pkg-split/core/debian/TODO 2004-05-02 09:31:29 UTC (rev 103)
@@ -76,5 +76,9 @@
at hand in /usr/share/mailman/templates, there's no need for an
additional copy by ucf when --three-way is enabled.
+- /etc/cron.d/mailman is treated as a conffile although automatically
+ edited in mailman.postinst. This is suboptimal, find a better
+ solution.
+
This list is by no means meant to be complete.
Modified: branches/pkg-split/core/debian/config
===================================================================
--- branches/pkg-split/core/debian/config 2004-05-01 10:19:12 UTC (rev 102)
+++ branches/pkg-split/core/debian/config 2004-05-02 09:31:29 UTC (rev 103)
@@ -37,14 +37,17 @@
Assume valid crontab(5) format: lines whose first non-space character
is a # are comments, comments on command lines are disallowed.
"""
- gn = os.popen('grep gate_news %(crontab)s' % globals())
+ cmd = 'grep gate_news %(crontab)s' % globals()
+ gn = os.popen(cmd)
result = False
for line in gn.readlines():
line = line.strip()
+ log('GREPPING: %(line)r' % locals(), lvl=2)
result |= line[0] != '#'
- if gn.close() != 0:
- result = False
- return result
+ if gn.close() is None:
+ return result
+ else:
+ return False
def have_list(listname):
@@ -62,10 +65,10 @@
return os.path.isdir(list_dir)
-def main(operation, prev_version):
+def main(operation, inst_version):
log('config main(operation=%(operation)r, '
- 'prev_version=%(prev_version)r)'
+ 'inst_version=%(inst_version)r)'
% locals(), lvl=2)
def db_input(*args):
@@ -118,9 +121,9 @@
if __name__ == '__main__':
if len(sys.argv) == 2:
- operation, prev_version = sys.argv[1], None
+ operation, inst_version = sys.argv[1], None
elif len(sys.argv) == 3:
- operation, prev_version = sys.argv[1:]
+ operation, inst_version = sys.argv[1:]
def dummy_logger(*args, **kw):
pass
@@ -130,9 +133,9 @@
from Mailman.Debian import DebuggingLogger
log = DebuggingLogger('MM_MAINT')
try:
- main(operation, prev_version)
+ main(operation, inst_version)
finally:
log.sys_info()
except ImportError:
log = dummy_logger
- main(operation, prev_version)
+ main(operation, inst_version)
Modified: branches/pkg-split/core/debian/postinst
===================================================================
--- branches/pkg-split/core/debian/postinst 2004-05-01 10:19:12 UTC (rev 102)
+++ branches/pkg-split/core/debian/postinst 2004-05-02 09:31:29 UTC (rev 103)
@@ -67,15 +67,55 @@
log.exception()
def update_cron():
+ """Update mailman crontab according to debconf setting.
+
+ Additionally, if we are upgrading from a MM version using
+ /usr/lib/mailman, change pathes in crontab to
+ /var/lib/mailman.
+ """#
gate_news = db.getBoolean('mailman/gate_news')
+ log('DEBCONF gate_news=%(gate_news)r' % locals(), lvl=2)
+ cron_tab = '/etc/cron.d/mailman'
+ cron_dir = os.path.join(MM_HOME, 'cron')
+ gn_path = os.path.join(cron_dir, 'gate_news')
+ ctf = open(cron_tab, 'r+')
+ changed_pathes = False
+ cron_lines = []
+ for line in ctf.readlines():
+ pos = line.find('/usr/lib/mailman')
+ if pos != -1:
+ changed_pathes = True
+ line = line[:pos] + '/var' + line[pos+4:]
+ if line.find(gn_path) > 0:
+ prefix = ''
+ if not gate_news:
+ prefix = '# '
+ line = prefix + uncomment(line)
+ cron_lines.append(line)
+ ctf.seek(0)
+ ctf.truncate()
+ for line in cron_lines:
+ ctf.write(line)
+ ctf.close()
+ if changed_pathes:
+ log('Changed pathes in %(cron_tab)r to %(cron_dir)r.'
+ % locals())
+ # FIXME: keep track of changes?
+def uncomment(line):
+ line = line.lstrip()
+ while line[0] == '#':
+ line = line[1:].lstrip()
+ return line
+
+
def run_debhelper_additions():
- runit = os.popen('/bin/sh', 'w')
+ runit = os.popen('/bin/sh -e', 'w')
runit.write("""\
-#DEBHELPER#
-""")
- runit.close()
+#DEBHELPER#""")
+ if runit.close() is not None:
+ raise SystemExit(1)
def setup():
@@ -89,7 +129,7 @@
log = DebuggingLogger('MM_MAINT')
try:
function = sys.argv[1]
- old_version = sys.argv[2]
+ inst_version = sys.argv[2]
if function in ('configure',):
setup()
finally: