Merge lp:~frankban/launchpad/setuplxc-add-apt-repository into lp:launchpad

Proposed by Francesco Banconi
Status: Merged
Approved by: Francesco Banconi
Approved revision: no longer in the source branch.
Merged at revision: 14897
Proposed branch: lp:~frankban/launchpad/setuplxc-add-apt-repository
Merge into: lp:launchpad
Prerequisite: lp:~benji/launchpad/add-sudoers-to-lxcsetup
Diff against target: 106 lines (+22/-23)
1 file modified
utilities/setuplxc.py (+22/-23)
To merge this branch: bzr merge lp:~frankban/launchpad/setuplxc-add-apt-repository
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+94761@code.launchpad.net

Description of the change

== Changes ==

- add-apt-repository is now used to set up APT repositories to be used by
  the container.

- Apt --allow-unauthenticated no longer needed.

- Backported a fix to `get_args_from_namespace`: actions are now correctly
  parsed.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Looks good Francesco.

* Typo: s/apt_reposirory/apt_repository -- appears in a few places ... at least it was used consistently!

I'll note I tried to merge your changes with Benji's branch and got conflicts and a warning of a criss-cross merge.

Thanks for adding the repos properly and getting rid of --allow-unauthenticated.

review: Approve (code)
Revision history for this message
Francesco Banconi (frankban) wrote :

Thanks Brad, I will fix that typo and try to merge branches.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utilities/setuplxc.py'
2--- utilities/setuplxc.py 2012-02-27 14:36:38 +0000
3+++ utilities/setuplxc.py 2012-02-27 14:36:38 +0000
4@@ -39,7 +39,13 @@
5 import sys
6 import time
7
8-
9+APT_REPOSITORIES = (
10+ 'deb http://archive.ubuntu.com/ubuntu {distro} multiverse',
11+ 'deb http://archive.ubuntu.com/ubuntu {distro}-updates multiverse',
12+ 'deb http://archive.ubuntu.com/ubuntu {distro}-security multiverse',
13+ 'ppa:launchpad/ppa',
14+ 'ppa:bzr/ppa',
15+ )
16 DEPENDENCIES_DIR = '~/dependencies'
17 DHCP_FILE = '/etc/dhcp/dhclient.conf'
18 HOST_PACKAGES = ['ssh', 'lxc', 'libvirt-bin', 'bzr', 'language-pack-en']
19@@ -81,16 +87,6 @@
20 lxc.network.flags = up
21 """
22 LXC_PATH = '/var/lib/lxc/'
23-LXC_REPOS = (
24- 'deb http://archive.ubuntu.com/ubuntu '
25- 'lucid main universe multiverse',
26- 'deb http://archive.ubuntu.com/ubuntu '
27- 'lucid-updates main universe multiverse',
28- 'deb http://archive.ubuntu.com/ubuntu '
29- 'lucid-security main universe multiverse',
30- 'deb http://ppa.launchpad.net/launchpad/ppa/ubuntu lucid main',
31- 'deb http://ppa.launchpad.net/bzr/ppa/ubuntu lucid main',
32- )
33 RESOLV_FILE = '/etc/resolv.conf'
34
35
36@@ -297,7 +293,7 @@
37 sshcmd = (
38 'ssh',
39 '-t',
40- '-t', # Yes, this second -t is deliberate. See `man ssh`.
41+ '-t', # Yes, this second -t is deliberate. See `man ssh`.
42 '-o', 'StrictHostKeyChecking=no',
43 '-o', 'UserKnownHostsFile=/dev/null',
44 location,
45@@ -373,8 +369,9 @@
46 if option_strings:
47 args.append(option_strings[0])
48 if isinstance(value, list):
49- value = ','.join(value)
50- args.append(value)
51+ args.extend(value)
52+ elif not isinstance(value, bool):
53+ args.append(value)
54 return args
55
56 def _validate(self, namespace):
57@@ -727,8 +724,8 @@
58 uid = pwd.getpwnam(user)[2]
59 script.write('#!/bin/sh\n')
60 script.write(
61- 'lxc-execute -n lptests --' # Run the named LXC container.
62- ' /usr/bin/sudo -u#{} -i'.format(uid)+ # Drop root privileges.
63+ 'lxc-execute -n lptests --' # Run the named LXC container.
64+ ' /usr/bin/sudo -u#{} -i'.format(uid) + # Drop root privileges.
65 ' make -C /var/lib/buildbot/lp schema\n')
66 os.chmod(build_script_file, 0555)
67 # Add a file to sudoers.d that will let the buildbot user run the above.
68@@ -812,9 +809,11 @@
69 root_sshcall = ssh(lxcname)
70 sshcall = ssh(lxcname, user)
71 # APT repository update.
72- sources = get_container_path(lxcname, '/etc/apt/sources.list')
73- with open(sources, 'w') as f:
74- f.write('\n'.join(LXC_REPOS))
75+ for apt_repository in APT_REPOSITORIES:
76+ repository = apt_repository.format(distro=LXC_GUEST_OS)
77+ assume_yes = '' if LXC_GUEST_OS == 'lucid' else '-y'
78+ root_sshcall('add-apt-repository {} "{}"'.format(
79+ assume_yes, repository))
80 # XXX frankban 2012-01-13 - Bug 892892: upgrading mountall in LXC
81 # containers currently does not work.
82 root_sshcall("echo 'mountall hold' | dpkg --set-selections")
83@@ -822,10 +821,10 @@
84 root_sshcall(
85 'apt-get update && '
86 'DEBIAN_FRONTEND=noninteractive '
87- 'apt-get -y --allow-unauthenticated install language-pack-en')
88+ 'apt-get -y install language-pack-en')
89 root_sshcall(
90 'DEBIAN_FRONTEND=noninteractive apt-get -y '
91- '--allow-unauthenticated install {}'.format(LP_DEB_DEPENDENCIES))
92+ 'install {}'.format(LP_DEB_DEPENDENCIES))
93 # We install lxc in the guest so that lxc-execute will work on the
94 # container. We use --no-install-recommends at the recommendation
95 # of the Canonical lxc maintainers because all we need is a file
96@@ -843,8 +842,8 @@
97 # Set up Launchpad dependencies.
98 checkout_dir = os.path.join(directory, LP_CHECKOUT)
99 sshcall(
100- 'cd {} && utilities/update-sourcecode --use-http "{}/sourcecode"'.format(
101- checkout_dir, dependencies_dir))
102+ 'cd {} && utilities/update-sourcecode --use-http '
103+ '"{}/sourcecode"'.format(checkout_dir, dependencies_dir))
104 sshcall(
105 'cd {} && utilities/link-external-sourcecode "{}"'.format(
106 checkout_dir, dependencies_dir))