← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/more-integration into lp:launchpad

 

Benji York has proposed merging lp:~benji/launchpad/more-integration into lp:launchpad with lp:~frankban/launchpad/setuplxc-scripts-shh-keys as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~benji/launchpad/more-integration/+merge/96211

This branch fixes a couple of small issues in the setuplxc.py utilities script.
-- 
https://code.launchpad.net/~benji/launchpad/more-integration/+merge/96211
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/more-integration into lp:launchpad.
=== modified file 'utilities/setuplxc.py'
--- utilities/setuplxc.py	2012-03-06 18:33:22 +0000
+++ utilities/setuplxc.py	2012-03-06 18:33:23 +0000
@@ -35,11 +35,12 @@
 import os
 import platform
 import pwd
+import re
 import shutil
 import subprocess
 import sys
+import textwrap
 import time
-import textwrap
 
 APT_REPOSITORIES = (
     'deb http://archive.ubuntu.com/ubuntu {distro} multiverse',
@@ -50,7 +51,8 @@
     )
 DEPENDENCIES_DIR = '~/dependencies'
 DHCP_FILE = '/etc/dhcp/dhclient.conf'
-HOST_PACKAGES = ['ssh', 'lxc', 'libvirt-bin', 'bzr', 'testrepository']
+HOST_PACKAGES = ['ssh', 'lxc', 'libvirt-bin', 'bzr', 'testrepository',
+    'python-shell-toolbox']
 HOSTS_FILE = '/etc/hosts'
 LP_APACHE_MODULES = 'proxy proxy_http rewrite ssl deflate headers'
 LP_APACHE_ROOTS = (
@@ -771,14 +773,14 @@
     # root (see below) but drops root once inside the LXC container.
     build_script_file = '/usr/local/bin/launchpad-lxc-build'
     with open(build_script_file, 'w') as script:
-        script.write(textwrap.dedent("""
+        script.write(textwrap.dedent("""\
             #!/bin/sh
             set -uex
             lxc-start -n {lxcname} -d
             lxc-wait -n {lxcname} -s RUNNING
             sleep 30  # aparently RUNNING isn't quite enough
             su {user} -c "/usr/bin/ssh -o StrictHostKeyChecking=no \\
-                -i '{ssh_key_path}' {lxcname} make -C {checkout_dir} schema"
+                -i '{ssh_key_path}' {lxcname} make -C $PWD schema"
             lxc-stop -n {lxcname}
             lxc-wait -n {lxcname} -s STOPPED
             """.format(**mapping)))
@@ -786,14 +788,19 @@
     # We need a script to test launchpad using LXC ephemeral instances.
     test_script_file = '/usr/local/bin/launchpad-lxc-test'
     with open(test_script_file, 'w') as script:
-        script.write(textwrap.dedent("""
+        # We intentionally generate a very long line for the
+        # lxc-start-ephemeral command below because ssh does not propagate
+        # quotes the way we want.  E.g.,
+        #     touch a; touch b; ssh localhost -- ls "a b"
+        # succeeds, when it should say that the file "a b" does not exist.
+        script.write(textwrap.dedent(re.sub(' {2,}', ' ', """\
             #!/bin/sh
             set -uex
-            lxc-start-ephemeral -u {user} -S '{ssh_key_path}' -o {lxcname} \\
-                -b $PWD -- xvfb-run --error-file=/var/tmp/xvfb-errors.log \\
-                --server-args='-screen 0 1024x768x24' \\
-                -a $PWD/bin/test --subunit $@
-            """.format(**mapping)))
+            lxc-start-ephemeral -u {user} -S '{ssh_key_path}' -o {lxcname} \
+                -b $PWD -- "xvfb-run --error-file=/var/tmp/xvfb-errors.log \
+                --server-args='-screen 0 1024x768x24' \
+                -a $PWD/bin/test --subunit $@"
+            """).format(**mapping)))
         os.chmod(test_script_file, 0555)
     # Add a file to sudoers.d that will let the buildbot user run the above.
     sudoers_file = '/etc/sudoers.d/launchpad-' + user