1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
{ "file":
{ "doc": ["Replace a file, logically in place, by a patched version"]
, "target_fields": ["src", "patch"]
, "string_fields": ["patch-part"]
, "config_vars": ["PATCH", "ENV"]
, "field_doc":
{ "src":
["The single source file to patch, typically an explict file reference."]
, "patch": ["The patch to apply."]
, "patch-part":
[ "If the patch contains hunks for multiple files, only apply hunks for"
, "the specified file path. Individual directory components are joined"
, "with \"/\". Note that the patch must be provided in unified format."
]
}
, "artifacts_doc":
["The patched file, staged to the position the of the original file"]
, "runfiles_doc": ["Same as artifacts"]
, "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"}
}
]
, [ "patch-part"
, { "type": "join"
, "separator": "\\/"
, "$1": {"type": "FIELD", "name": "patch-part"}
}
]
, [ "splitpatch"
, { "type": "BLOB"
, "data":
{ "type": "join"
, "separator": "\n"
, "$1":
[ "set -e"
, { "type": "join"
, "$1":
[ { "type": "join_cmd"
, "$1":
[ "sed"
, "-n"
, { "type": "join"
, "$1":
[ "/^--- "
, {"type": "var", "name": "patch-part"}
, "/,"
, "/^[^-+@\\ ]\\|^---\\ /p"
]
}
]
}
, " $1 | sed '$d' > patch"
]
}
]
}
}
]
, [ "patch"
, { "type": "if"
, "cond": {"type": "var", "name": "patch-part"}
, "then":
{ "type": "ACTION"
, "inputs":
{ "type": "map_union"
, "$1":
[ { "type": "to_subdir"
, "subdir": "in"
, "$1": {"type": "var", "name": "patch"}
}
, { "type": "singleton_map"
, "key": "splitpatch"
, "value": {"type": "var", "name": "splitpatch"}
}
]
}
, "outs": ["patch"]
, "cmd": ["sh", "./splitpatch", "in/patch"]
, "env":
{"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
}
, "else": {"type": "var", "name": "patch"}
}
]
, [ "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"}
}
}
}
}
|