summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-07-07 11:37:46 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-07-07 11:37:46 +0100
commit5994728a447e0bf76bf97414891b3f7be01d60b3 (patch)
tree2e144781786ef95f35fe4b7c0043d0a2b35e141f
parent103e708d47fbf8a72205af81679ed599de0d393b (diff)
parent3b574ff5eff53a4ccb9089c33eb4dbda22f2d31b (diff)
downloaddefinitions-5994728a447e0bf76bf97414891b3f7be01d60b3.tar.gz
Merge branch 'sam/auto-update-release.morph'
Reviewed-By: Adam Coldrick <adam.coldrick@codethink.co.uk> Reviewed-By: Richard Maw <richard.maw@codethink.co.uk>
-rw-r--r--release.morph14
-rw-r--r--scripts/do-release.py87
2 files changed, 41 insertions, 60 deletions
diff --git a/release.morph b/release.morph
index 4ec38837..23061b2d 100644
--- a/release.morph
+++ b/release.morph
@@ -2,28 +2,30 @@ name: release
kind: cluster
description: |
Deploy all the systems for we support in a release.
+
+ This cluster morph is used by the tool 'scripts/do-release'. While
+ you can deploy the systems yourself, if you are making a Baserock release
+ then the script should be used.
systems:
- morph: devel-system-x86_32-chroot
deploy:
devel-system-x86_32-chroot:
type: tar
- location: /src/release/baserock-14.26-devel-system-x86_32-chroot.tar
+ location: devel-system-x86_32-chroot.tar
- morph: devel-system-x86_32-generic
deploy:
devel-system-x86_32-generic:
type: rawdisk
- location: /src/release/baserock-14.26-devel-system-x86_32-generic.img
+ location: devel-system-x86_32-generic.img
DISK_SIZE: 4G
- VERSION_LABEL: baserock-14.26
- morph: devel-system-x86_64-chroot
deploy:
devel-system-x86_64-chroot:
type: tar
- location: /src/release/baserock-14.26-devel-system-x86_64-chroot.tar
+ location: devel-system-x86_64-chroot.tar
- morph: devel-system-x86_64-generic
deploy:
devel-system-x86_64-generic:
type: rawdisk
- location: /src/release/baserock-14.26-devel-system-x86_64-generic.img
+ location: devel-system-x86_64-generic.img
DISK_SIZE: 4G
- VERSION_LABEL: baserock-14.26
diff --git a/scripts/do-release.py b/scripts/do-release.py
index e8efe814..43ce7201 100644
--- a/scripts/do-release.py
+++ b/scripts/do-release.py
@@ -137,70 +137,53 @@ class DeployImages(object):
assert morph['kind'] == kind
return morph
- def parse_release_cluster(self, release_cluster):
- '''Validate release cluster and list the systems being released.
-
- This function returns a dict mapping the system name to the location
- of its deployed image.
+ def deploy_single_image(self, system_name, location, version_label):
+ deploy_command = [
+ 'morph', 'deploy', 'release.morph', system_name,
+ '--trove-host=%s' % config.build_trove,
+ '%s.location=%s' % (system_name, location),
+ '%s.VERSION_LABEL=%s' % (system_name, version_label)
+ ]
- It's an open question how we should detect and handle the case where a
- write extension creates more than one file. ARM kernels and GENIVI
- manifest files are possible examples of this.
+ cliapp.runcmd(deploy_command, stdout=sys.stdout)
- '''
+ def deploy_images(self, release_cluster):
+ '''Use `morph deploy` to create the release images.'''
version_label = 'baserock-%s' % config.release_number
-
outputs = {}
+
for system in release_cluster['systems']:
- system_morph = system['morph']
+ system_name = system['morph']
- if system_morph not in system['deploy']:
+ if system_name not in system['deploy']:
raise cliapp.AppException(
'In release.morph: system %s ID should be "%s"' %
- (system_morph, system_morph))
+ (system_name, system_name))
- # We can't override 'location' with a different value. We must use
- # what's already in the morphology, and check that it makes sense.
- location = system['deploy'][system_morph]['location']
- if not os.path.samefile(os.path.dirname(location),
- config.images_dir):
- raise cliapp.AppException(
- 'In release.morph: system location %s is not inside '
- 'configured images_dir %s' % (location, config.images_dir))
- if not os.path.basename(location).startswith(version_label):
- raise cliapp.AppException(
- 'In release.morph: system image name %s does not start '
- 'with version label %s' % (location, version_label))
-
- outputs[system_morph] = location
-
- return outputs
+ # The release.morph cluster must specify a basename for the file,
+ # of system-name + extension. This script knows system-name, but it
+ # can't find out the appropriate file extension without
+ # second-guessing the behaviour of write extensions.
+ basename = system['deploy'][system_name]['location']
- def deploy_images(self, outputs):
- '''Use `morph deploy` to create the release images.'''
-
- # FIXME: once `morph deploy` supports partial deployment, this should
- # deploy only the images which aren't already deployed... it should
- # also check if they need redeploying based on the SHA1 they were
- # deployed from, perhaps. That's getting fancy!
-
- todo = [f for f in outputs.itervalues() if not os.path.exists(f)]
+ if '/' in basename or basename.startswith(version_label):
+ raise cliapp.AppException(
+ 'In release.morph: system %s.location should be just the '
+ 'base name, e.g. "%s.img"' % (system_name, system_name))
- if len(todo) == 0:
- status('Reusing existing release images')
- else:
- logging.debug('Need to deploy images: %s' % ', '.join(todo))
- status('Creating release images from release.morph')
+ filename = '%s-%s' % (version_label, basename)
+ location = os.path.join(config.images_dir, filename)
- version_label = 'baserock-%s' % config.release_number
+ if os.path.exists(location):
+ status('Reusing existing deployment of %s', filename)
+ else:
+ status('Creating %s from release.morph', filename)
+ self.deploy_single_image(system_name, location, version_label)
- morph_config = ['--trove-host=%s' % config.build_trove]
- deploy_config = ['release.VERSION_LABEL=%s' % version_label]
+ outputs[system_name] = location
- cliapp.runcmd(
- ['morph', 'deploy', 'release.morph'] + morph_config +
- deploy_config, stdout=sys.stdout)
+ return outputs
def compress_images(self, outputs):
for name, source_file in outputs.iteritems():
@@ -221,11 +204,7 @@ class DeployImages(object):
with cwd(definitions_dir):
release_cluster = self.read_morph('release.morph', kind='cluster')
-
- outputs = self.parse_release_cluster(release_cluster)
-
- with cwd(definitions_dir):
- self.deploy_images(outputs)
+ outputs = self.deploy_images(release_cluster)
self.compress_images(outputs)