165
165
"destination channel.")
167
167
# Generate a list of required deltas
170
# If channel not configured, use dest channel as a deltabase by default
171
conf_deltabase = (conf.channels[args.destination_channel].deltabase
172
if args.destination_channel in conf.channels
173
else [args.destination_channel])
175
for base_channel in conf_deltabase:
176
# Skip missing channels
177
if base_channel not in pub.list_channels():
180
# Skip missing devices
181
if args.device not in (pub.list_channels()
182
[base_channel]['devices']):
185
# Extract the latest full image
186
base_device = pub.get_device(base_channel, args.device)
187
base_images = sorted([image
188
for image in base_device.list_images()
189
if image['type'] == "full"],
190
key=lambda image: image['version'])
192
# Check if the version is valid and add it
193
if base_images and base_images[-1]['version'] in full_images:
194
if full_images[base_images[-1]['version']] not in delta_base:
195
delta_base.append(full_images
196
[base_images[-1]['version']])
197
logging.debug("Source version for delta: %s" %
198
base_images[-1]['version'])
168
delta_base = tools.get_required_deltas(
169
conf, pub, args.destination_channel, args.device)
200
171
# Create new empty entries
201
172
new_images = {'full': {'files': []}}
203
174
new_images['delta_%s' % delta['version']] = {'files': []}
205
176
# Extract current version_detail and files
207
for entry in source_image['files']:
208
path = os.path.realpath("%s/%s" % (conf.publish_path, entry['path']))
210
filename = path.split("/")[-1]
212
# Look for version-X.tar.xz
213
if filename == "version-%s.tar.xz" % args.version:
214
# Extract the metadata
215
if os.path.exists(path.replace(".tar.xz", ".json")):
216
with open(path.replace(".tar.xz", ".json"), "r") as fd:
217
metadata = json.loads(fd.read())
218
if "channel.ini" in metadata:
219
version_detail = metadata['channel.ini'].get(
220
"version_detail", None)
222
new_images['full']['files'].append(path)
223
logging.debug("Source version_detail is: %s" % version_detail)
177
version_detail = tools.extract_files_and_version(
178
conf, source_image['files'], args.version, new_images['full']['files'])
225
180
# Generate new version tarball
236
191
# Add new tag if requested
238
for detail in environment['version_detail']:
239
if detail.startswith("tag="):
240
environment['version_detail'].remove(detail)
242
environment['version_detail'].append("tag=%s" % args.tag)
193
tools.set_tag_on_version_detail(
194
environment['version_detail'], args.tag)
243
195
logging.info("Setting tag for image to '%s'" % args.tag)
245
197
logging.info("Generating new version tarball for '%s' (%s)"