launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10105
[Merge] lp:~gz/launchpad/buildmailman_1020181 into lp:launchpad
Martin Packman has proposed merging lp:~gz/launchpad/buildmailman_1020181 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1020181 in Launchpad itself: "Mailman tests fail due to missing dirs in /var/tmp/mailman"
https://bugs.launchpad.net/launchpad/+bug/1020181
For more details, see:
https://code.launchpad.net/~gz/launchpad/buildmailman_1020181/+merge/115798
Modifies the buildmailman.py script to detect when /var/tmp/mailman is not present and do the install, rather than always skipping it if the import is successful.
My first stab did a lot more rearranging of things, but given it's a pain to test and risks breaking stuff, this branch is more conservative. Basically it just addresses the case where the launchpad code is stored on a persistent volume and used with multiple instances, rather than trying to make the script more robust in general.
Also removes some old hardy compatibility junk to get LOC credit.
--
https://code.launchpad.net/~gz/launchpad/buildmailman_1020181/+merge/115798
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gz/launchpad/buildmailman_1020181 into lp:launchpad.
=== modified file 'buildmailman.py'
--- buildmailman.py 2012-06-29 08:40:05 +0000
+++ buildmailman.py 2012-07-19 18:03:19 +0000
@@ -34,21 +34,25 @@
mailman_bin = os.path.join(mailman_path, 'bin')
var_dir = os.path.abspath(config.mailman.build_var_dir)
- # If we can import the package, we assume Mailman is properly built and
- # installed. This does not catch re-installs that might be necessary
+ # If we can import the package, we assume Mailman is properly built at
+ # the least. This does not catch re-installs that might be necessary
# should our copy in sourcecode be updated. Do that manually.
sys.path.append(mailman_path)
try:
import Mailman
+ except ImportError:
+ need_build = need_install = True
+ else:
+ need_build = need_install = False
# Also check for Launchpad-specific bits stuck into the source tree by
# monkey_patch(), in case this is half-installed. See
# <https://bugs.launchpad.net/launchpad-registry/+bug/683486>.
- from Mailman.Queue import XMLRPCRunner
- from Mailman.Handlers import LPModerate
- except ImportError:
- pass
- else:
- return 0
+ try:
+ from Mailman.Queue import XMLRPCRunner
+ from Mailman.Handlers import LPModerate
+ except ImportError:
+ # Monkey patches not present, redo install and patch steps.
+ need_install = True
# sys.path_importer_cache is a mapping of elements of sys.path to importer
# objects used to handle them. In Python2.5+ when an element of sys.path
@@ -82,9 +86,16 @@
except OSError as e:
if e.errno != errno.EEXIST:
raise
+ else:
+ # Just created the var directory, will need to install mailmain bits.
+ need_install = True
os.chown(var_dir, uid, gid)
os.chmod(var_dir, 02775)
+ # Skip mailman setup if nothing so far has shown a reinstall needed.
+ if not need_install:
+ return 0
+
mailman_source = os.path.join('sourcecode', 'mailman')
if config.mailman.build_host_name:
build_host_name = config.mailman.build_host_name
@@ -105,40 +116,17 @@
'--with-mailhost=' + build_host_name,
'--with-urlhost=' + build_host_name,
)
- # Configure.
- retcode = subprocess.call(configure_args, cwd=mailman_source)
- if retcode:
- print >> sys.stderr, 'Could not configure Mailman:'
- sys.exit(retcode)
- # Make.
- retcode = subprocess.call(('make', ), cwd=mailman_source)
- if retcode:
- print >> sys.stderr, 'Could not make Mailman.'
- sys.exit(retcode)
- # We have a brief interlude before we install. Hardy will not
- # accept a script as the executable for the shebang line--it will
- # treat the file as a shell script instead. The ``bin/by``
- # executable that we specified in '--with-python' above is a script
- # so this behavior causes problems for us. Our work around is to
- # prefix the ``bin/py`` script with ``/usr/bin/env``, which makes
- # Hardy happy. We need to do this before we install because the
- # installation will call Mailman's ``bin/update``, which is a script
- # that needs this fix.
- build_dir = os.path.join(mailman_source, 'build')
- original = '#! %s\n' % (executable, )
- modified = '#! /usr/bin/env %s\n' % (executable, )
- for (dirpath, dirnames, filenames) in os.walk(build_dir):
- for filename in filenames:
- filename = os.path.join(dirpath, filename)
- f = open(filename, 'r')
- if f.readline() == original:
- rest = f.read()
- f.close()
- f = open(filename, 'w')
- f.write(modified)
- f.write(rest)
- f.close()
- # Now we actually install.
+ if need_build:
+ # Configure.
+ retcode = subprocess.call(configure_args, cwd=mailman_source)
+ if retcode:
+ print >> sys.stderr, 'Could not configure Mailman:'
+ sys.exit(retcode)
+ # Make.
+ retcode = subprocess.call(('make', ), cwd=mailman_source)
+ if retcode:
+ print >> sys.stderr, 'Could not make Mailman.'
+ sys.exit(retcode)
retcode = subprocess.call(('make', 'install'), cwd=mailman_source)
if retcode:
print >> sys.stderr, 'Could not install Mailman.'
Follow ups