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

Proposed by Lee Trager
Status: Merged
Merged at revision: 327
Proposed branch: lp:~ltrager/maas-images/lp1618709
Merge into: lp:maas-images
Diff against target: 155 lines (+39/-50)
2 files modified
meph2/commands/cloudimg_sync.py (+0/-34)
meph2/stream.py (+39/-16)
To merge this branch: bzr merge lp:~ltrager/maas-images/lp1618709
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Review via email: mp+304439@code.launchpad.net

Description of the change

Read the meph yaml config value 'squashfs' in stream.py to determine whether to include the root-image and manifest or the squashfs image in the product version. This ensures both meph2-build and meph2-cloudimg-sync publish the correct files for the configuration file they are given.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

one comment.
we should publish the manifest for the squashfs path. even if we're building everything we could eitehr take it as a '--manifest' argument or we could generate it from
  mount-image-callback <image> -- chroot _MOUNTPOINT_ dpkg-query --show

lp:~ltrager/maas-images/lp1618709 updated
328. By Lee Trager

Add manifest for SquashFS image

Revision history for this message
Lee Trager (ltrager) wrote :

Updated to include a manifest for SquashFS images generated with the --manifest argument. This works when using the meph2-build or meph2-cloudimg-sync command.

Revision history for this message
Scott Moser (smoser) wrote :

looks good. thank you, Lee.

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-24 05:05:47 +0000
3+++ meph2/commands/cloudimg_sync.py 2016-09-02 01:23:15 +0000
4@@ -11,7 +11,6 @@
5 from meph2.stream import CONTENT_ID, create_version
6
7 import argparse
8-import glob
9 import copy
10 import os
11 import sys
12@@ -146,39 +145,6 @@
13
14 for prodname, items in cvret.items():
15 for i in items:
16- filename = os.path.join(self.out_d, items[i]['path'])
17- if i == 'squashfs':
18- # Verify upstream SHA256 of SquashFS image.
19- if items[i]['sha256'] != flat['sha256']:
20- raise ValueError(
21- 'Expected SHA256 %s got %s on %s' %
22- (flat['sha256'], items[i]['sha256'], filename))
23- if not self.squashfs:
24- # If we're not publishing the SquashFS image but one
25- # was used to generate root-image.gz delete it.
26- if os.path.exists(filename):
27- os.remove(filename)
28- continue
29- elif i == 'root-image.gz' and self.squashfs:
30- # If we're publishing the SquashFS image we don't need the
31- # root-image after its been used to extract the kernels.
32- # Older Ubuntu releases (<16.04) don't have SquashFS images
33- # published, so only remove if a SquashFS file exists.
34- squashfs_image = os.path.join(
35- os.path.dirname(filename), '*squashfs')
36- if len(glob.glob(squashfs_image)) > 0:
37- if os.path.exists(filename):
38- os.remove(filename)
39- continue
40- elif i == 'manifest' and self.squashfs:
41- # If we're publishing the SquashFS image we don't need the
42- # root-image manifest either.
43- squashfs_image = os.path.join(
44- os.path.dirname(filename), '*squashfs')
45- if len(glob.glob(squashfs_image)) > 0:
46- if os.path.exists(filename):
47- os.remove(filename)
48- continue
49 sutil.products_set(
50 self.content_t, items[i], (prodname, vername, i))
51
52
53=== modified file 'meph2/stream.py'
54--- meph2/stream.py 2016-08-25 02:38:40 +0000
55+++ meph2/stream.py 2016-09-02 01:23:15 +0000
56@@ -19,8 +19,10 @@
57 DI_COMMON = PATH_COMMON + "di/%(di_version)s/%(krel)s/%(flavor)s"
58 PATH_FORMATS = {
59 'root-image.gz': PATH_COMMON + "%(version_name)s/root-image.gz",
60- 'manifest': PATH_COMMON + "%(version_name)s/root-image.manifest",
61+ 'root-image.manifest': (
62+ PATH_COMMON + "%(version_name)s/root-image.manifest"),
63 'squashfs': PATH_COMMON + "%(version_name)s/squashfs",
64+ 'squashfs.manifest': PATH_COMMON + "%(version_name)s/squashfs.manifest",
65 'boot-dtb': BOOT_COMMON + "/boot-dtb%(suffix)s",
66 'boot-kernel': BOOT_COMMON + "/boot-kernel%(suffix)s",
67 'boot-initrd': BOOT_COMMON + "/boot-initrd%(suffix)s",
68@@ -120,16 +122,24 @@
69 'version_name': version_name, 'version': version}
70
71 rootimg_path = PATH_FORMATS['root-image.gz'] % subs
72- manifest_path = PATH_FORMATS['manifest'] % subs
73+
74+ krd_packs = []
75+ squashfs = cfgdata.get('squashfs', False)
76+ boot_keys = ['boot-kernel', 'boot-initrd']
77+ if squashfs and img_url.endswith('.squashfs'):
78+ base_ikeys = boot_keys + ['squashfs', 'squashfs.manifest']
79+ manifest_path = PATH_FORMATS['squashfs.manifest'] % subs
80+ newpaths = set((PATH_FORMATS['squashfs'] % subs, manifest_path))
81+ else:
82+ base_ikeys = boot_keys + ['root-image.gz', 'root-image.manifest']
83+ manifest_path = PATH_FORMATS['root-image.manifest'] % subs
84+ newpaths = set((rootimg_path, manifest_path))
85
86 gencmd = ([mci2e] + mci2e_flags +
87 [bkparm, "--arch=%s" % arch,
88 "--manifest=%s" % os.path.join(out_d, manifest_path),
89 img_url, os.path.join(out_d, rootimg_path)])
90
91- krd_packs = []
92- newpaths = set((rootimg_path, manifest_path,))
93-
94 kdata_defaults = {'suffix': "", 'di-format': "default", 'dtb': ""}
95
96 for info in rdata['kernels']:
97@@ -158,11 +168,7 @@
98 'psubarch': product_psubarch,
99 'suffix': kdata["suffix"]})
100
101- boot_keys = ['boot-kernel', 'boot-initrd']
102- ikeys = boot_keys + ['root-image.gz', 'manifest']
103- if img_url.endswith('.squashfs'):
104- ikeys += ['squashfs']
105- newpaths.add(PATH_FORMATS['squashfs'] % subs)
106+ ikeys = base_ikeys
107
108 dtb = kdata.get('dtb')
109 if dtb:
110@@ -204,9 +210,15 @@
111
112 items = {}
113 for i in ikeys:
114- items[i] = {'ftype': i, 'path': PATH_FORMATS[i] % subs,
115- 'size': None, 'sha256': None}
116- items[i].update(common)
117+ # Allow root-image.manifest and squashfs.image to have different
118+ # filenames but keep the same ftype.
119+ if 'manifest' in i:
120+ ftype = 'manifest'
121+ else:
122+ ftype = i
123+ items[ftype] = {'ftype': ftype, 'path': PATH_FORMATS[i] % subs,
124+ 'size': None, 'sha256': None}
125+ items[ftype].update(common)
126
127 for key in di_keys:
128 items[key]['sha256'] = curdi[key]['sha256']
129@@ -248,12 +260,23 @@
130 subprocess.check_call(gencmd)
131 LOG.info("finished: %s" % gencmd)
132
133- # If we're downloading a SquashFS file rename it to its filetype
134 if img_url.endswith('squashfs'):
135 base_dir = os.path.join(out_d, release, arch, version_name)
136 src_squash = os.path.join(base_dir, os.path.basename(img_url))
137- dst_squash = os.path.join(base_dir, 'squashfs')
138- os.rename(src_squash, dst_squash)
139+ if squashfs:
140+ # If we're publishing a SquashFS file rename it to its filetype.
141+ dst_squash = os.path.join(base_dir, 'squashfs')
142+ os.rename(src_squash, dst_squash)
143+ # The root-img is used to generate the kernels and initrds. If
144+ # we're publishing the SquashFS image then we don't want to publish
145+ # the root-img, we can safely clean it up.
146+ src_rootimg_path = os.path.join(
147+ base_dir, os.path.basename(rootimg_path))
148+ os.remove(src_rootimg_path)
149+ else:
150+ # If we're not publishing the SquashFS image but used it to
151+ # generate the root-img clean it up.
152+ os.remove(src_squash)
153
154 # get checksum and size of new files created
155 file_info = {}

Subscribers

People subscribed via source and target branches