Merge lp:~townsend/unity8-preview-lxc/fix-lxc-image into lp:unity8-preview-lxc

Proposed by Christopher Townsend
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 80
Merged at revision: 79
Proposed branch: lp:~townsend/unity8-preview-lxc/fix-lxc-image
Merge into: lp:unity8-preview-lxc
Diff against target: 80 lines (+22/-11)
2 files modified
bin/unity8-lxc-setup (+21/-10)
debian/control (+1/-1)
To merge this branch: bzr merge lp:~townsend/unity8-preview-lxc/fix-lxc-image
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+275880@code.launchpad.net

Commit message

Instead of hardcoding 'wily' as the LXC image release, query the LXC download template database and parse the output to determine the latest image available.

To post a comment you must log in.
80. By Christopher Townsend

Some more cleanup.

Revision history for this message
Stephen M. Webb (bregma) wrote :

Great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/unity8-lxc-setup'
--- bin/unity8-lxc-setup 2015-10-23 12:38:28 +0000
+++ bin/unity8-lxc-setup 2015-10-27 16:29:38 +0000
@@ -25,9 +25,7 @@
25import subprocess25import subprocess
26import sys26import sys
27import time27import time
28import platform
2928
30from distro_info import UbuntuDistroInfo, DistroDataOutdated
3129
32CONTAINER_NAME = "unity8-lxc"30CONTAINER_NAME = "unity8-lxc"
33SKIP_JOB = ["bluetooth", "lightdm", "plymouth", "plymouth-upstart-bridge",31SKIP_JOB = ["bluetooth", "lightdm", "plymouth", "plymouth-upstart-bridge",
@@ -58,11 +56,10 @@
58container_path = "%s/%s" % (lxc.default_config_path, CONTAINER_NAME)56container_path = "%s/%s" % (lxc.default_config_path, CONTAINER_NAME)
59rootfs_path = "%s/rootfs" % container_path57rootfs_path = "%s/rootfs" % container_path
6058
61(distro, version, codename) = platform.linux_distribution()
62
63# Actions59# Actions
64generate_rootfs = True60generate_rootfs = True
6561
62
66def start_container(wait_for_network=True):63def start_container(wait_for_network=True):
67 if not container.running:64 if not container.running:
68 print("Starting the container")65 print("Starting the container")
@@ -74,6 +71,24 @@
74 print("Not able to connect to the network.")71 print("Not able to connect to the network.")
75 sys.exit(0)72 sys.exit(0)
7673
74
75def get_latest_lxc_image(arch):
76 cmd = ['/usr/share/lxc/templates/lxc-download', '-d', 'ubuntu', '-a', arch, '-l']
77
78 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
79 output = proc.communicate()[0]
80
81 lxc_output = output.split(b'\n')
82
83 for line in lxc_output:
84 if line.decode().startswith('ubuntu'):
85 last_line = line
86
87 release = last_line.decode().split('\t')
88
89 return release[1]
90
91
77# Destroy a container entirely92# Destroy a container entirely
78if args.destroy and container.defined:93if args.destroy and container.defined:
79 container.stop()94 container.stop()
@@ -110,13 +125,9 @@
110125
111 architecture = dpkg.stdout.read().strip()126 architecture = dpkg.stdout.read().strip()
112127
113 try:128 print("Determining latest LXC image release...")
114 current_release = UbuntuDistroInfo().devel()129 current_release = get_latest_lxc_image(architecture)
115 except DistroDataOutdated:
116 current_release = UbuntuDistroInfo().stable()
117130
118 # FIXME: Hard code wily for now since xenial lxc images have not been built yet.
119 current_release = 'wily'
120 print("Creating the new unity8-lxc container...")131 print("Creating the new unity8-lxc container...")
121 container.create("download", 0,132 container.create("download", 0,
122 {"dist": "ubuntu",133 {"dist": "ubuntu",
123134
=== modified file 'debian/control'
--- debian/control 2015-10-22 13:54:12 +0000
+++ debian/control 2015-10-27 16:29:38 +0000
@@ -8,7 +8,7 @@
88
9Package: unity8-lxc9Package: unity8-lxc
10Architecture: all10Architecture: all
11Depends: python3, python3-lxc, sudo, python3-distro-info, ${misc:Depends}11Depends: python3, python3-lxc, sudo, ${misc:Depends}
12Description: Unity8 LXC integration12Description: Unity8 LXC integration
13 This package contains the scripts required to setup and run a Unity813 This package contains the scripts required to setup and run a Unity8
14 desktop inside an LXC container.14 desktop inside an LXC container.

Subscribers

People subscribed via source and target branches