[Pkg-mailman-hackers] Pkg-mailman commit - rev 151 - in branches/pkg-split/core/debian: . Debian
Bernd S. Brentrup
bsb@haydn.debian.org
Sun, 23 May 2004 03:59:35 -0600
Author: bsb
Date: 2004-05-23 03:59:32 -0600 (Sun, 23 May 2004)
New Revision: 151
Modified:
branches/pkg-split/core/debian/Debian/__init__.py
branches/pkg-split/core/debian/Debian/templates.py
branches/pkg-split/core/debian/mailman.config
branches/pkg-split/core/debian/mailman.postinst
Log:
Support for upgrading /etc/mailman/mm_cfg.py.
Modified: branches/pkg-split/core/debian/Debian/__init__.py
===================================================================
--- branches/pkg-split/core/debian/Debian/__init__.py 2004-05-23 09:26:07 UTC (rev 150)
+++ branches/pkg-split/core/debian/Debian/__init__.py 2004-05-23 09:59:32 UTC (rev 151)
@@ -5,7 +5,8 @@
from cf_db import ConfFileDatabase
try:
- from templates import mm_cfg_defaults, mm_cfg_fillin, mm_cfg_deprecated, mm_crontab
+ from templates import mm_cfg_defaults, mm_cfg_fillin, \
+ mm_cfg_deprecated, mm_cfg_delimiter, mm_crontab
except ImportError:
pass
Modified: branches/pkg-split/core/debian/Debian/templates.py
===================================================================
--- branches/pkg-split/core/debian/Debian/templates.py 2004-05-23 09:26:07 UTC (rev 150)
+++ branches/pkg-split/core/debian/Debian/templates.py 2004-05-23 09:59:32 UTC (rev 151)
@@ -2,7 +2,7 @@
# $URL$
# $Id$
-mm_cfg_defaults = '''\
+mm_cfg_defaults = """\
# Mailman site configuration for Debian automatically generated from
# $URL$
# $Id$
@@ -24,7 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""This is the module which takes your site-specific settings.
+\"\"\"This is the module which takes your site-specific settings.
From a raw distribution it should be copied to mm_cfg.py. If you
already have an mm_cfg.py, be careful to add in only the new settings
@@ -42,7 +42,7 @@
Note also that some of the settings are resolved against the active list
setting by using the value as a format string against the
list-instance-object's dictionary - see the distributed value of
-DEFAULT_MSG_FOOTER for an example."""
+DEFAULT_MSG_FOOTER for an example.\"\"\"
#######################################################
@@ -50,22 +50,22 @@
from Defaults import *
-'''#
+"""#
-mm_cfg_fillin = '''\
-##############################################################
-# Put YOUR site-specific configuration below, in mm_cfg.py . #
-# See Defaults.py for explanations of the values. #
+mm_cfg_fillin = """\
+########################################################################
+# Put YOUR site-specific configuration below, in mm_cfg.py. See #
+# /usr/lib/mailman/Mailman/Defaults.py for explanations of the values. #
-#-------------------------------------------------------------
-# The name of the list Mailman uses to send password reminders
-# and similar. Don't change if you want mailman-owner to be
-# a valid local part.
+#-----------------------------------------------------------------------
+# The name of the list Mailman uses to send password reminders and
+# similar. Don't change if you want mailman-owner to be a valid local
+# part.
MAILMAN_SITE_LIST = %(MAILMAN_SITE_LIST)r
-#-------------------------------------------------------------
-# Virtual host httpd setup, if you don't use a virtual host
-# just copy the ScriptAlias and Alias directives.
+#-----------------------------------------------------------------------
+# Virtual host httpd setup, if you don't use a virtual host just copy
+# the ScriptAlias and Alias directives.
#
# <Virtualhost %(DEFAULT_URL_HOST)s>
# ServerName %(DEFAULT_URL_HOST)s
@@ -73,17 +73,17 @@
# Alias /pipermail/ %(PUBLIC_ARCHIVE_FILE_DIR)s/
# Alias %(IMAGE_LOGOS)s /usr/share/images/mailman/
# </VirtualHost>
-#-------------------------------------------------------------
+#-----------------------------------------------------------------------
DEFAULT_URL_PATTERN = %(DEFAULT_URL_PATTERN)r
IMAGE_LOGOS = %(IMAGE_LOGOS)r
DEFAULT_URL_HOST = %(DEFAULT_URL_HOST)r
DEFAULT_EMAIL_HOST = %(DEFAULT_EMAIL_HOST)r
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)%(virtual_hosts)s
-#-------------------------------------------------------------
-# Depending on your MTA setup, the MTA configuration variable
-# controls how aliases are generated.
-# At the time of this writing legal values are:
+#-----------------------------------------------------------------------
+# Depending on your MTA setup, the MTA configuration variable controls
+# how aliases are generated.
+# Legal values are:
# None - your MTA automatically recognizes new lists
# 'Postfix' - you are using postfix virtual domains
# 'Manual' - default, meaning you have to manually create the
@@ -92,66 +92,73 @@
# /usr/share/doc/mailman before setting this.
MTA = %(MTA)r
-#-------------------------------------------------------------
-# The USE_ENVELOPE_SENDER variable controls the order in which
-# headers are searched when determining if a message originates
-# from a subscriber. When True, the order is Sender:, From:,
-# unixfrom, when False it is From:, Sender:, unixfrom. In both
-# cases the first address encountered is used.
-# Debian default is not to use the envelope address when
-# determining if a message comes from a subscriber.
-# This option applies globally to all mailing lists.
+#-----------------------------------------------------------------------
+# The USE_ENVELOPE_SENDER variable controls the order in which headers
+# are searched when determining if a message originates from a
+# subscriber. When True, the order is Sender:, From:, unixfrom, when
+# False it is From:, Sender:, unixfrom. In both cases the first address
+# encountered is used.
+# Debian default is not to use the envelope address when determining if
+# a message comes from a subscriber. This option applies globally to
+# all mailing lists.
USE_ENVELOPE_SENDER = %(USE_ENVELOPE_SENDER)r
-#-------------------------------------------------------------
-# Debian default is not to send monthly password reminders
-# on newly created lists. This can be changed per list.
+#-----------------------------------------------------------------------
+# Debian default is not to send monthly password reminders on newly
+# created lists. This can be changed per list.
DEFAULT_SEND_REMINDERS = %(DEFAULT_SEND_REMINDERS)r
-#-------------------------------------------------------------
-# The default language for this server (may be changed to a
-# supported language when mailman-i18n is installed).
+#-----------------------------------------------------------------------
+# The default language for this server (may be changed to a supported
+# language when mailman-i18n is installed).
DEFAULT_SERVER_LANGUAGE = %(DEFAULT_SERVER_LANGUAGE)r
-# Note - if you're looking for something that is imported from mm_cfg, but you
-# didn't find it above, it's probably in /usr/lib/mailman/Mailman/Defaults.py.
-'''#
+# Note - if you're looking for something that is imported from mm_cfg,
+# but you didn't find it above, it's probably in
+# /usr/lib/mailman/Mailman/Defaults.py.
+"""#
mm_cfg_deprecated = {
- None : '''\
+ None : """\
#-----------------------------------------------------------------------
# Variables below are deprecated. Where applicable, their values are
# incorporated above.
-''',
- 'DEFAULT_HOST_NAME' : '''
+""",
+ 'DEFAULT_HOST_NAME' : """
# Replaced by DEFAULT_EMAIL_HOST
# DEFAULT_HOST_NAME = %(DEFAULT_HOST_NAME)r
-''',
- 'DEFAULT_URL' : '''\
+""",
+ 'DEFAULT_URL' : """\
# Replaced by DEFAULT_URL_PATTERN.
# DEFAULT_URL = %(DEFAULT_URL)r
-''',
- 'OLD_IMAGE_LOGOS' : '''\
+""",
+ 'OLD_IMAGE_LOGOS' : """\
# Location has changed.
# IMAGE_LOGOS = %(OLD_IMAGE_LOGOS)r
-''',
- 'PRIVATE_ARCHIVE_URL' : '''\
+""",
+ 'PRIVATE_ARCHIVE_URL' : """\
# Private archive access now uses /usr/lib/cgi-bin/mailman/private.
# PRIVATE_ARCHIVE_URL = %(PRIVATE_ARCHIVE_URL)r
-''',
- 'OLD_PUBLIC_ARCHIVE_URL' : '''\
+""",
+ 'OLD_PUBLIC_ARCHIVE_URL' : """\
# Public archive access now uses %(PUBLIC_ARCHIVE_URL)r
# PUBLIC_ARCHIVE_URL = %(OLD_PUBLIC_ARCHIVE_URL)r
-''',
- 'MAILMAN_OWNER' : '''\
-# The mailman-owner@%(DEFAULT_EMAIL_HOST)s is now a special site-list
-# alias and the MAILMAN_OWNER variable is ignored.
+""",
+ 'MAILMAN_OWNER' : """\
+# The mailman-owner@%(DEFAULT_EMAIL_HOST)s address is now a special
+# site-list aliases with the MAILMAN_OWNER variable being ignored.
# MAILMAN_OWNER = %(MAILMAN_OWNER)r
-''',
+""",
}
-mm_crontab = '''\
+mm_cfg_delimiter = """\
+#-----------------------------------------------------------------------
+# Anything below this marker will not be touched by maintainer scripts.
+#=======================================================================
+"""#
+
+mm_crontab = """\
# Mailman crontab for Debian automatically generated from
# $URL$
# $Id$
@@ -180,4 +187,4 @@
# turn this on if the internal archiver is used and
# GZIP_ARCHIVE_TXT_FILES is false in mm_cfg.py
27 3 * * * list /usr/lib/mailman/cron/nightly_gzip
-'''#
+"""#
Modified: branches/pkg-split/core/debian/mailman.config
===================================================================
--- branches/pkg-split/core/debian/mailman.config 2004-05-23 09:26:07 UTC (rev 150)
+++ branches/pkg-split/core/debian/mailman.config 2004-05-23 09:59:32 UTC (rev 151)
@@ -94,21 +94,22 @@
for line in os.popen('egrep "^DEFAULT_[^ =]+ *=" %(mm_cfg)s' % locals()):
try: exec line in gbls
except: pass
- if gbls.has_key('DEFAULT_HOST_NAME') or gbls.has_key('DEFAULT_URL'):
+
+ default_url_host = gbls.get('DEFAULT_URL_HOST', None)
+ default_email_host = gbls.get('DEFAULT_HOST_NAME',
+ gbls.get('DEFAULT_EMAIL_HOST', mailname))
+
+ if gbls.has_key('DEFAULT_URL'):
from urlparse import urlsplit
- default_email_host = gbls.get('DEFAULT_HOST_NAME', mailname)
default_url = gbls.get('DEFAULT_URL', None)
if default_url:
default_url_host = urlsplit(default_url)[1]
- else:
- default_url_host = None
- else:
- default_email_host = gbls.get('DEFAULT_EMAIL_HOST', mailname)
- default_url_host = gbls.get('DEFAULT_URL_HOST', '')
- default_server_language = gbls.get('DEFAULT_SERVER_LANGUAGE', 'en')
if not default_url_host:
default_url_host = default_email_host
+
+ default_server_language = gbls.get('DEFAULT_SERVER_LANGUAGE', 'en')
+
db.set('mailman/url_host', default_url_host)
db_input(MEDIUM, 'mailman/url_host')
Modified: branches/pkg-split/core/debian/mailman.postinst
===================================================================
--- branches/pkg-split/core/debian/mailman.postinst 2004-05-23 09:26:07 UTC (rev 150)
+++ branches/pkg-split/core/debian/mailman.postinst 2004-05-23 09:59:32 UTC (rev 151)
@@ -75,13 +75,15 @@
return gbls
+from Mailman.Debian import mm_cfg_defaults, mm_cfg_fillin, \
+ mm_cfg_delimiter, mm_cfg_deprecated
+
def create_mm_cfg():
"""Create an initial /etc/mailman/mm_cfg.py
This works only for a first time install.
"""#
try:
- from Mailman.Debian import mm_cfg_defaults, mm_cfg_fillin
mm_cfg_fl = open('/etc/mailman/mm_cfg.py', 'w')
# Writing a constant prefix (including the import from Defaults)
# beforehand makes sure there is a formally working mm_cfg.
@@ -102,6 +104,7 @@
exec 'default_url_path = urlsplit(DEFAULT_URL_PATTERN)[2]' in gbls
exec 'virtual_hosts = ""' in gbls
mm_cfg_fl.write(mm_cfg_fillin % gbls)
+ mm_cfg_fl.write(mm_cfg_delimiter)
mm_cfg_fl.close()
except DebconfError, exc:
log.exception()
@@ -119,10 +122,18 @@
usr_gbls = {}
sys.modules['Defaults'] = sys.modules['Mailman.Defaults']
execfile(etc_mm_cfg, usr_gbls)
+
+ # When DEFAULT_URL_HOST has been changed via debconf, its obsolete
+ # VIRTUAL_HOSTS entry would be regenerated further down when
+ # creating add_virtualhost() calls for non-default entries.
+ try: exec 'del VIRTUAL_HOSTS[DEFAULT_URL_HOST]' in usr_gbls
+ except: pass
+
os.rename(etc_mm_cfg, etc_mm_cfg+'.dpkg-old')
+
try:
from Mailman.Debian import mm_cfg_defaults, mm_cfg_fillin
- mm_cfg_fl = open('/etc/mailman/mm_cfg.py', 'w')
+ mm_cfg_fl = open(etc_mm_cfg, 'w')
# Writing a constant prefix (including the import from Defaults)
# beforehand makes sure there is a formally working mm_cfg.
mm_cfg_fl.write(mm_cfg_defaults)
@@ -137,6 +148,11 @@
server_language = db.get('mailman/default_server_language') or 'en'
usr_gbls['DEFAULT_SERVER_LANGUAGE'] = server_language
+ from urlparse import urlsplit, urlunsplit
+ if usr_gbls['DEFAULT_URL'] is not None:
+ scheme, host, path = urlsplit(usr_gbls['DEFAULT_URL'])[:3]
+ usr_gbls['DEFAULT_URL_PATTERN'] = urlunsplit((scheme, '%s', path, '', ''))
+
usr_mod = {}
usr_def = {}
@@ -153,34 +169,21 @@
if usr_mod.keys():
log("User modified variables:", lvl=3)
for var in usr_mod.keys():
- log(' %18s: %r\n%20s: %r'
+ log(' %20s: %r\n%20s: %r'
% (var, usr_gbls[var], 'default', def_gbls[var]), lvl=3)
if usr_def.keys():
log("User defined variables:", lvl=3)
for var in usr_def.keys():
- log(' %18s: %r' % (var, usr_gbls[var]), lvl=3)
+ log(' %20s: %r' % (var, usr_gbls[var]), lvl=3)
- from urlparse import urlsplit, urlunsplit
def_scheme, def_netloc, def_path = urlsplit(def_gbls['DEFAULT_URL_PATTERN'])[:3]
- if 'DEFAULT_URL' in usr_mod.keys():
- usr_scheme, usr_netloc, usr_path = urlsplit(usr_gbls['DEFAULT_URL'])[:3]
- usr_gbls['DEFAULT_URL_HOST'] = usr_netloc
- usr_mod['DEFAULT_URL_HOST'] = 1
- if usr_scheme != def_scheme or usr_path != def_path:
- usr_gbls['DEFAULT_URL_PATTERN'] = urlunsplit((usr_scheme, def_netloc, usr_path,
- None, None))
- usr_mod['DEFAULT_URL_PATTERN'] = 1
- usr_gbls['default_url_path'] = usr_path
- elif 'DEFAULT_URL_PATTERN' in usr_mod.keys():
+ if 'DEFAULT_URL_PATTERN' in usr_mod.keys():
usr_scheme, usr_netloc, usr_path = urlsplit(usr_gbls['DEFAULT_URL_PATTERN'])[:3]
usr_gbls['default_url_path'] = usr_path
else:
usr_gbls['default_url_path'] = def_path
- if 'DEFAULT_HOST_NAME' in usr_mod.keys():
- exec 'DEFAULT_EMAIL_HOST = DEFAULT_HOST_NAME' in usr_gbls
- usr_mod['DEFAULT_EMAIL_HOST'] = 1
if 'IMAGE_LOGOS' in usr_mod.keys():
if usr_gbls['IMAGE_LOGOS'].startswith('/doc/mailman'):
exec 'OLD_IMAGE_LOGOS = IMAGE_LOGOS' in usr_gbls
@@ -198,7 +201,8 @@
# Make sure user added virtual hosts are kept in the new mm_cfg
vhosts = StringIO()
for url_host, email_host in usr_gbls['VIRTUAL_HOSTS'].items():
- if (url_host, email_host) not in ((usr_gbls['DEFAULT_URL_HOST'], usr_gbls['DEFAULT_EMAIL_HOST']),
+ if (url_host, email_host) not in ((usr_gbls['DEFAULT_URL_HOST'],
+ usr_gbls['DEFAULT_EMAIL_HOST']),
('localhost', 'localhost')):
vhosts.write('\nadd_virtualhost(%(url_host)r, %(email_host)r)' % locals())
usr_gbls['virtual_hosts'] = vhosts.getvalue()
@@ -207,6 +211,9 @@
cfl = StringIO()
cfl.write(mm_cfg_fillin % usr_gbls)
+ # Add delimiter indicating end of automatically handled section
+ cfl.write(mm_cfg_delimiter)
+
# Isolate deprecated variables
from Mailman.Debian import mm_cfg_deprecated