From bea188ba004eb1b8d3057a5cfa2c1a167ef72d14 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 9 Dec 2013 15:41:29 +0000 Subject: Replace chunk 'chunks' field with 'products' I think that it's confusing for both strata and chunk morphologies to have a 'chunks' field, with the former listing sources and the latter listing rules for splitting this source into artifacts. The design for splitting strata has roughly the same idea, but operating on chunk artifact names, rather than file names, so a name that can be used for both was chosen. Splits and artifacts weren't satisfactory names, so they're now called 'products'. It was decided to break backwards compatibility of chunk morphologies being able to specify 'chunks', since the format has changed, so extra code would be required to translate the format, and the only users of the 'chunks' field was the test suite, since there was no way to select from the system, which chunk artifacts were included. --- morphlib/builder2.py | 4 ++-- morphlib/morph2.py | 3 +-- morphlib/morph2_tests.py | 6 +++--- morphlib/morphloader.py | 4 ++-- morphlib/morphloader_tests.py | 4 ++-- morphlib/morphologyfactory.py | 7 ++++--- morphlib/morphologyfactory_tests.py | 16 +++++++++++----- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/morphlib/builder2.py b/morphlib/builder2.py index bab89aa2..34ebaa81 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Codethink Limited +# Copyright (C) 2012-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -423,7 +423,7 @@ class ChunkBuilder(BuilderBase): built_artifacts = [] filenames = [] with self.build_watch('create-chunks'): - specs = self.artifact.source.morphology['chunks'] + specs = self.artifact.source.morphology['products'] if len(specs) == 0: specs = { self.artifact.source.morphology['name']: ['.'], diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 942322ee..fd72aa94 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -14,7 +14,6 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import copy import re import morphlib @@ -45,7 +44,7 @@ class Morphology(object): ('install-commands', None), ('post-install-commands', None), ('devices', None), - ('chunks', []), + ('products', []), ('max-jobs', None), ('build-system', 'manual') ], diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index aaa1d1cc..ba90313f 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Codethink Limited +# Copyright (C) 2012-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(m['install-commands'], None) self.assertEqual(m['post-install-commands'], None) self.assertEqual(m['max-jobs'], None) - self.assertEqual(m['chunks'], []) + self.assertEqual(m['products'], []) if morphlib.got_yaml: def test_parses_simple_yaml_chunk(self): @@ -76,7 +76,7 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(m['install-commands'], None) self.assertEqual(m['post-install-commands'], None) self.assertEqual(m['max-jobs'], None) - self.assertEqual(m['chunks'], []) + self.assertEqual(m['products'], []) def test_sets_stratum_chunks_repo_and_morph_from_name(self): m = Morphology(''' diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index e7c1d9ff..e1ec15bd 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -185,7 +185,7 @@ class MorphologyLoader(object): 'install-commands': [], 'post-install-commands': [], 'devices': [], - 'chunks': [], + 'products': [], 'max-jobs': None, 'build-system': 'manual', }, diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py index 8b87467a..907f3762 100644 --- a/morphlib/morphloader_tests.py +++ b/morphlib/morphloader_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -438,7 +438,7 @@ name: foo 'pre-install-commands': [], 'post-install-commands': [], - 'chunks': [], + 'products': [], 'devices': [], 'max-jobs': None, }) diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index 5afafefb..e6fabd51 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Codethink Limited +# Copyright (C) 2012-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -167,8 +167,9 @@ class MorphologyFactory(object): def _check_and_tweak_chunk(self, morphology, reponame, sha1, filename): '''Check and tweak a chunk morphology.''' - if 'chunks' in morphology and len(morphology['chunks']) > 1: - morphology.builds_artifacts = morphology['chunks'].keys() + if 'products' in morphology and len(morphology['products']) > 1: + morphology.builds_artifacts = [d['artifact'] + for d in morphology['products']] else: morphology.builds_artifacts = [morphology['name']] diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 6e1e67d3..30504e00 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Codethink Limited +# Copyright (C) 2012-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,10 +50,16 @@ class FakeLocalRepo(object): "name": "chunk-split", "kind": "chunk", "build-system": "bar", - "chunks": { - "chunk-split-runtime": [], - "chunk-split-devel": [] - } + "products": [ + { + "artifact": "chunk-split-runtime", + "include": [] + }, + { + "artifact": "chunk-split-devel", + "include": [] + } + ] }''', 'stratum.morph': '''{ "name": "stratum", -- cgit v1.2.1