diff options
Diffstat (limited to 'rules')
-rw-r--r-- | rules/EXPRESSIONS | 50 | ||||
-rw-r--r-- | rules/patch/RULES | 68 |
2 files changed, 118 insertions, 0 deletions
diff --git a/rules/EXPRESSIONS b/rules/EXPRESSIONS index d9b85620..8c536124 100644 --- a/rules/EXPRESSIONS +++ b/rules/EXPRESSIONS @@ -95,4 +95,54 @@ } } } +, "stage_artifact_to_singleton_field": + { "vars": ["artifact", "fieldname", "transition"] + , "expression": + { "type": "let*" + , "bindings": + [ [ "location" + , { "type": "++" + , "$1": + { "type": "foreach" + , "var": "src" + , "range": + {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}} + , "body": + { "type": "keys" + , "$1": + { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "src"} + , "transition": + { "type": "var" + , "name": "transition" + , "default": {"type": "empty_map"} + } + } + } + } + } + ] + , [ "staged_artifact" + , { "type": "foreach_map" + , "range": {"type": "var", "name": "artifact"} + , "var_val": "val" + , "body": + { "type": "foreach" + , "range": {"type": "var", "name": "location"} + , "var": "pos" + , "body": + { "type": "singleton_map" + , "key": {"type": "var", "name": "pos"} + , "value": {"type": "var", "name": "val"} + } + } + } + ] + ] + , "body": + { "type": "disjoint_map_union" + , "$1": {"type": "++", "$1": {"type": "var", "name": "staged_artifact"}} + } + } + } } diff --git a/rules/patch/RULES b/rules/patch/RULES new file mode 100644 index 00000000..87bf5750 --- /dev/null +++ b/rules/patch/RULES @@ -0,0 +1,68 @@ +{ "file": + { "doc": ["Replace a file, logically in pace, by a patched version"] + , "target_fields": ["src", "patch"] + , "config_vars": ["PATCH"] + , "field_doc": + { "src": + ["The single source file to patch, typically an explict file reference."] + , "patch": ["The patch to apply."] + } + , "imports": + { "stage_field": ["./", "..", "stage_singleton_field"] + , "stage_artifact": ["./", "..", "stage_artifact_to_singleton_field"] + } + , "expression": + { "type": "let*" + , "bindings": + [ [ "orig" + , { "type": "let*" + , "bindings": [["fieldname", "src"], ["location", "orig"]] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , [ "patch" + , { "type": "let*" + , "bindings": [["fieldname", "patch"], ["location", "patch"]] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , [ "inputs" + , { "type": "map_union" + , "$1": + [{"type": "var", "name": "orig"}, {"type": "var", "name": "patch"}] + } + ] + , [ "patched" + , { "type": "ACTION" + , "inputs": {"type": "var", "name": "inputs"} + , "outs": ["patched"] + , "cmd": + [ {"type": "var", "name": "PATCH", "default": "patch"} + , "-s" + , "--read-only=ignore" + , "--follow-symlinks" + , "-o" + , "patched" + , "orig" + , "patch" + ] + } + ] + , [ "result" + , { "type": "let*" + , "bindings": + [ ["artifact", {"type": "var", "name": "patched"}] + , ["fieldname", "src"] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_artifact"} + } + ] + ] + , "body": + { "type": "RESULT" + , "artifacts": {"type": "var", "name": "result"} + , "runfiles": {"type": "var", "name": "result"} + } + } + } +} |