Merge lp:~ltrager/maas-images/lp1609804 into lp:maas-images

Proposed by Lee Trager
Status: Merged
Merged at revision: 324
Proposed branch: lp:~ltrager/maas-images/lp1609804
Merge into: lp:maas-images
Diff against target: 63 lines (+7/-21)
2 files modified
meph2/commands/cloudimg_sync.py (+6/-21)
meph2/stream.py (+1/-0)
To merge this branch: bzr merge lp:~ltrager/maas-images/lp1609804
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+303762@code.launchpad.net

Commit message

Take SHA256 and size of squashfs image in create_version.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'meph2/commands/cloudimg_sync.py'
2--- meph2/commands/cloudimg_sync.py 2016-08-18 09:41:53 +0000
3+++ meph2/commands/cloudimg_sync.py 2016-08-24 05:09:03 +0000
4@@ -13,7 +13,6 @@
5 import argparse
6 import glob
7 import copy
8-import hashlib
9 import os
10 import sys
11 import yaml
12@@ -126,19 +125,6 @@
13 self.content_t = my_prods
14 return v2_to_cloudimg_products(my_prods, rebuilds=self.rebuilds)
15
16- def _verify_sha256(self, filename, expected_sha256):
17- sha256 = hashlib.sha256()
18- with open(filename, 'rb') as f:
19- while True:
20- data = f.read(2**18)
21- if not data:
22- break
23- sha256.update(data)
24- if sha256.hexdigest() != expected_sha256:
25- raise ValueError(
26- 'Expected SHA256 %s got %s on %s' %
27- (expected_sha256, sha256.hexdigest(), filename))
28-
29 def insert_item(self, data, src, target, pedigree, contentsource):
30 # create the ephemeral root
31
32@@ -162,13 +148,12 @@
33 for i in items:
34 filename = os.path.join(self.out_d, items[i]['path'])
35 if i == 'squashfs':
36- if self.squashfs:
37- # Verify upstream SHA256 of SquashFS images and add the
38- # SHA256 and size to our stream.
39- self._verify_sha256(filename, flat['sha256'])
40- items[i]['sha256'] = flat['sha256']
41- items[i]['size'] = int(flat['size'])
42- else:
43+ # Verify upstream SHA256 of SquashFS image.
44+ if items[i]['sha256'] != flat['sha256']:
45+ raise ValueError(
46+ 'Expected SHA256 %s got %s on %s' %
47+ (flat['sha256'], items[i]['sha256'], filename))
48+ if not self.squashfs:
49 # If we're not publishing the SquashFS image but one
50 # was used to generate root-image.gz delete it.
51 if os.path.exists(filename):
52
53=== modified file 'meph2/stream.py'
54--- meph2/stream.py 2016-08-18 09:41:53 +0000
55+++ meph2/stream.py 2016-08-24 05:09:03 +0000
56@@ -154,6 +154,7 @@
57 ikeys = boot_keys + ['root-image.gz', 'manifest']
58 if img_url.endswith('.squashfs'):
59 ikeys += ['squashfs']
60+ newpaths.add(PATH_FORMATS['squashfs'] % subs)
61
62 dtb = kdata.get('dtb')
63 if dtb:

Subscribers

People subscribed via source and target branches