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
1=== modified file 'bin/unity8-lxc-setup'
2--- bin/unity8-lxc-setup 2015-10-23 12:38:28 +0000
3+++ bin/unity8-lxc-setup 2015-10-27 16:29:38 +0000
4@@ -25,9 +25,7 @@
5 import subprocess
6 import sys
7 import time
8-import platform
9
10-from distro_info import UbuntuDistroInfo, DistroDataOutdated
11
12 CONTAINER_NAME = "unity8-lxc"
13 SKIP_JOB = ["bluetooth", "lightdm", "plymouth", "plymouth-upstart-bridge",
14@@ -58,11 +56,10 @@
15 container_path = "%s/%s" % (lxc.default_config_path, CONTAINER_NAME)
16 rootfs_path = "%s/rootfs" % container_path
17
18-(distro, version, codename) = platform.linux_distribution()
19-
20 # Actions
21 generate_rootfs = True
22
23+
24 def start_container(wait_for_network=True):
25 if not container.running:
26 print("Starting the container")
27@@ -74,6 +71,24 @@
28 print("Not able to connect to the network.")
29 sys.exit(0)
30
31+
32+def get_latest_lxc_image(arch):
33+ cmd = ['/usr/share/lxc/templates/lxc-download', '-d', 'ubuntu', '-a', arch, '-l']
34+
35+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
36+ output = proc.communicate()[0]
37+
38+ lxc_output = output.split(b'\n')
39+
40+ for line in lxc_output:
41+ if line.decode().startswith('ubuntu'):
42+ last_line = line
43+
44+ release = last_line.decode().split('\t')
45+
46+ return release[1]
47+
48+
49 # Destroy a container entirely
50 if args.destroy and container.defined:
51 container.stop()
52@@ -110,13 +125,9 @@
53
54 architecture = dpkg.stdout.read().strip()
55
56- try:
57- current_release = UbuntuDistroInfo().devel()
58- except DistroDataOutdated:
59- current_release = UbuntuDistroInfo().stable()
60+ print("Determining latest LXC image release...")
61+ current_release = get_latest_lxc_image(architecture)
62
63- # FIXME: Hard code wily for now since xenial lxc images have not been built yet.
64- current_release = 'wily'
65 print("Creating the new unity8-lxc container...")
66 container.create("download", 0,
67 {"dist": "ubuntu",
68
69=== modified file 'debian/control'
70--- debian/control 2015-10-22 13:54:12 +0000
71+++ debian/control 2015-10-27 16:29:38 +0000
72@@ -8,7 +8,7 @@
73
74 Package: unity8-lxc
75 Architecture: all
76-Depends: python3, python3-lxc, sudo, python3-distro-info, ${misc:Depends}
77+Depends: python3, python3-lxc, sudo, ${misc:Depends}
78 Description: Unity8 LXC integration
79 This package contains the scripts required to setup and run a Unity8
80 desktop inside an LXC container.

Subscribers

People subscribed via source and target branches