summaryrefslogtreecommitdiff
path: root/scripts/edit-morph
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-01-22 16:10:16 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-22 16:10:16 +0000
commit7265acd1440dc898d3ebe9de443a470c3d845b50 (patch)
tree44ad4e0a87c20cfd1635c691dbbb26c99a66bdd9 /scripts/edit-morph
parent28196991ede6bd5ed561fc7dc4a2b0084019df19 (diff)
parente30b0c73cb6805689c58b3ed9d5dd091218e2df3 (diff)
downloadmorph-7265acd1440dc898d3ebe9de443a470c3d845b50.tar.gz
Merge branch 'baserock/richardmaw/S10166/test-key-collision-with-artifact-names-v2' of git://git.baserock.org/baserock/baserock/morph
Reviewed-by: Lars Wirzenius
Diffstat (limited to 'scripts/edit-morph')
-rwxr-xr-xscripts/edit-morph47
1 files changed, 46 insertions, 1 deletions
diff --git a/scripts/edit-morph b/scripts/edit-morph
index 967bbc13..2970cc6e 100755
--- a/scripts/edit-morph
+++ b/scripts/edit-morph
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# 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
@@ -18,6 +18,7 @@
import cliapp
import os
import re
+import yaml
import morphlib
@@ -200,4 +201,48 @@ class EditMorph(cliapp.Application):
return result
+ def cmd_set_system_artifact_depends(self, args):
+ '''Change the artifacts used by a System.
+
+ Usage: MORPHOLOGY_FILE STRATUM_NAME ARTIFACTS
+
+ ARTIFACTS is an English language string describing which artifacts
+ to include, since the primary use of this command is to assist
+ yarn tests.
+
+ Example: edit-morph set-system-artifact-depends system.morph \
+ build-essential "build-essential-minimal,
+ build-essential-runtime and build-essential-devel"
+
+ '''
+
+ file_path = args[0]
+ stratum_name = args[1]
+ artifacts = re.split(r"\s+and\s+|,?\s*", args[2])
+ with open(file_path, "r") as f:
+ d = yaml.load(f)
+ for spec in d["strata"]:
+ if spec.get("alias", spec["name"]) == stratum_name:
+ spec["artifacts"] = artifacts
+ with open(file_path, "w") as f:
+ yaml.dump(d, f)
+
+ def cmd_set_stratum_match_rules(self, (file_path, match_rules)):
+ '''Set a stratum's match rules.
+
+ Usage: FILE_PATH MATCH_RULES_YAML
+
+ This sets the stratum's "products" field, which is used to
+ determine which chunk artifacts go into which stratum artifacts
+ the stratum produces.
+
+ The match rules must be a string that yaml can parse.
+
+ '''
+ with open(file_path, "r") as f:
+ d = yaml.load(f)
+ d['products'] = yaml.load(match_rules)
+ with open(file_path, "w") as f:
+ yaml.dump(d, f)
+
EditMorph().run()