summaryrefslogtreecommitdiff
path: root/rules/patch/RULES
diff options
context:
space:
mode:
Diffstat (limited to 'rules/patch/RULES')
-rw-r--r--rules/patch/RULES68
1 files changed, 68 insertions, 0 deletions
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"}
+ }
+ }
+ }
+}