Merge lp:~rcj/simplestreams/lxd into lp:simplestreams

Proposed by Robert C Jennings
Status: Merged
Merged at revision: 437
Proposed branch: lp:~rcj/simplestreams/lxd
Merge into: lp:simplestreams
Diff against target: 96 lines (+43/-22)
2 files modified
tools/make-test-data (+41/-21)
tools/toolutil.py (+2/-1)
To merge this branch: bzr merge lp:~rcj/simplestreams/lxd
Reviewer Review Type Date Requested Status
Dan Watkins (community) Approve
simplestreams-dev Pending
Review via email: mp+297798@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) wrote :

Overall approach looks good; comments inline.

review: Needs Fixing
Revision history for this message
Dan Watkins (oddbloke) wrote :

Looks much better; one remaining question.

review: Needs Information
Revision history for this message
Robert C Jennings (rcj) wrote :

fixed.

Revision history for this message
Dan Watkins (oddbloke) wrote :

SHIP IT

review: Approve
lp:~rcj/simplestreams/lxd updated
437. By Robert C Jennings

Create chksum for LXD metadata+root for squashfs (LP: #1577922)

This adds a 'combined_sqashfs_sha256' element to items that have
both a LXD metadata tar and a squashfs root. Additionally, we
have 'combined_rootxz_sha256' which wil have the same value as
'combined_sha256' and allow for sunsetting that ambiguous name.

Revision history for this message
Robert C Jennings (rcj) wrote :

I combined the revisions for a clean upstream merge with a good commit message. No code changes. Merging now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/make-test-data'
2--- tools/make-test-data 2016-05-17 13:48:54 +0000
3+++ tools/make-test-data 2016-06-22 19:05:52 +0000
4@@ -288,23 +288,34 @@
5 del fdata['content']
6 FAKE_DATA[item['ftype']].update(fdata)
7
8- # create a combined_sha256 for lxd.tar.xz from the -root.tar.gz also
9+ # create a combined sha256 for lxd.tar.xz (metadata) and the root fs
10+ # - combined_sha256 and combined_rootxz_sha256 for the -root.tar.gz
11+ # - combined_squashfs_sha256 for the squashfs
12 ftype = item['ftype']
13- if ftype == "lxd.tar.xz" and 'combined_sha256' not in FAKE_DATA[ftype]:
14- rootpath = item['path'].replace("-lxd.tar.xz", "-root.tar.xz")
15- # make sure the root.tar.xz exists
16- if not os.path.exists(os.path.join(prefix, rootpath)):
17- rootitem = item.copy()
18- rootitem['ftype'] = "root.tar.xz"
19- rootitem['path'] = rootpath
20- create_fake_file(prefix, rootitem)
21-
22- # and sha256 hash the combined file, .xz first
23- chash = hashlib.new('sha256')
24- for member in [fpath, os.path.join(prefix, rootpath)]:
25- with open(member, "rb") as fp:
26- chash.update(fp.read())
27- data.update({'combined_sha256': chash.hexdigest()})
28+ for name, extension in (('rootxz', '-root.tar.xz'),
29+ ('squashfs', '.squashfs')):
30+ if (ftype == "lxd.tar.xz" and
31+ 'combined_{}_sha256'.format(name) not in FAKE_DATA[ftype]):
32+ rootpath = item['path'].replace("-lxd.tar.xz", extension)
33+ if not os.path.exists(os.path.join(prefix, rootpath)):
34+ rootitem = item.copy()
35+ rootitem['ftype'] = extension.lstrip('-.')
36+ rootitem['path'] = rootpath
37+ create_fake_file(prefix, rootitem)
38+
39+ # and sha256 hash the combined file
40+ chash = hashlib.new('sha256')
41+ for member in [fpath, os.path.join(prefix, rootpath)]:
42+ with open(member, "rb") as fp:
43+ chash.update(fp.read())
44+ data.update(
45+ {'combined_{}_sha256'.format(name): chash.hexdigest()})
46+
47+ # Add legacy combined_sha256 if combined_rootxz_sha256 exists
48+ if (ftype == "lxd.tar.xz" and 'combined_sha256' not in FAKE_DATA[ftype]
49+ and 'combined_rootxz_sha256' in FAKE_DATA[ftype]):
50+ data.update({'combined_sha256':
51+ FAKE_DATA[ftype]['combined_rootxz_sha256']})
52
53 item.update(data)
54
55@@ -545,13 +556,22 @@
56 path = item['path']
57 item.update(get_cloud_images_file_info(path))
58 if path.endswith('-lxd.tar.xz'):
59- # find calculated combined checksum
60 dirname = os.path.dirname(path)
61 lxd = os.path.basename(path)
62- root = lxd.replace('-lxd', '-root')
63- combined = os.path.join(dirname, ','.join([lxd, root]))
64- item.update({'combined_sha256':
65- get_cache_data(combined, 'sha256')})
66+
67+ # find calculated combined checksums
68+ for name, extension in (('rootxz', '-root.tar.xz'),
69+ ('squashfs', '.squashfs')):
70+ root = lxd.replace('-lxd.tar.xz', extension)
71+ combined = os.path.join(dirname, ','.join([lxd, root]))
72+ value = get_cache_data(combined, 'sha256')
73+ if value:
74+ item.update({'combined_{}_sha256'.format(name): value})
75+
76+ # Add legacy combined_sha256 if combined_rootxz_sha256 exists
77+ if 'combined_rootxz_sha256' in item:
78+ value = item['combined_rootxz_sha256']
79+ item.update({'combined_sha256': value})
80
81 cid_fmt = "com.ubuntu.cloud:%s:download"
82 for stream in tree:
83
84=== modified file 'tools/toolutil.py'
85--- tools/toolutil.py 2016-05-20 19:39:13 +0000
86+++ tools/toolutil.py 2016-06-22 19:05:52 +0000
87@@ -101,7 +101,8 @@
88 return False
89 if codename_cmp(rel, "<", "precise"):
90 return False
91- if codename_cmp(rel, ">=", "yakkety"):
92+ # -root.tar.xz is replaced by squashfs for yakkety
93+ if codename_cmp(rel, ">=", "yakkety") and suffix == '-root.tar.xz':
94 return False
95
96 if suffix == '.squashfs' or suffix == '.squashfs.manifest':

Subscribers

People subscribed via source and target branches