You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/overlays.md
+59-2Lines changed: 59 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ These overlays modify `.spec` files using the structured spec parser, allowing p
21
21
|`spec-prepend-lines`| Prepends lines to the start of a section; **fails if section doesn't exist**|`lines`|
22
22
|`spec-append-lines`| Appends lines to the end of a section; **fails if section doesn't exist**|`lines`|
23
23
|`spec-search-replace`| Regex-based search and replace on spec content |`regex`|
24
+
|`patch-add`| Adds a patch file and registers it in the spec (PatchN tag or %patchlist) |`source`|
25
+
|`patch-remove`| Removes patch files and their spec references matching a glob pattern |`file`|
24
26
25
27
### File Overlays
26
28
@@ -55,8 +57,8 @@ successfully makes a replacement to at least one matching file.
55
57
| Regex |`regex`| Regular expression pattern to match |`spec-search-replace`, `file-search-replace`|
56
58
| Replacement |`replacement`| Literal replacement text; capture group references like `$1` are **not** expanded. Omit or leave empty to delete matched text. |`spec-search-replace`, `file-search-replace`, `file-rename`|
57
59
| Lines |`lines`| Array of text lines to insert |`spec-prepend-lines`, `spec-append-lines`, `file-prepend-lines`|
58
-
| File |`file`| The name of the non-spec file to modify or add |`file-prepend-lines`, `file-search-replace`, `file-add`, `file-remove`, `file-rename`|
59
-
| Source |`source`| Path to source file for `file-add`; relative paths are relative to the config file |`file-add`|
60
+
| File |`file`| The name of the non-spec file to modify or add |`file-prepend-lines`, `file-search-replace`, `file-add`, `file-remove`, `file-rename`, `patch-add` (optional), `patch-remove`|
61
+
| Source |`source`| Path to source file for `file-add` and `patch-add`; relative paths are relative to the config file |`file-add`, `patch-add`|
60
62
61
63
> **Note:** For `file-rename`, the `replacement` field is a **filename only** (not a path). The file is renamed within its current directory.
62
64
@@ -198,6 +200,61 @@ file = "oldname.conf"
198
200
replacement = "newname.conf"
199
201
```
200
202
203
+
### Adding a Patch
204
+
205
+
The `patch-add` overlay copies a patch file into the component's sources and registers it
206
+
in the spec. If the spec has a `%patchlist` section, the filename is appended there; otherwise,
207
+
a `PatchN` tag is added with the next available number.
208
+
209
+
```toml
210
+
[[components.mypackage.overlays]]
211
+
type = "patch-add"
212
+
source = "patches/fix-build-flags.patch"
213
+
description = "Fix compiler flags for our toolchain"
214
+
```
215
+
216
+
By default, the destination filename is the basename of `source`. Use `file` to override:
217
+
218
+
```toml
219
+
[[components.mypackage.overlays]]
220
+
type = "patch-add"
221
+
source = "patches/0001-upstream-fix.patch"
222
+
file = "fix-upstream-bug.patch"
223
+
description = "Rename upstream patch for clarity"
224
+
```
225
+
226
+
### Removing a Patch
227
+
228
+
The `patch-remove` overlay removes patch references from the spec (`PatchN` tags and/or
229
+
`%patchlist` entries) and deletes the matching patch files from the component's sources.
230
+
The `file` field is a glob pattern matched against patch filenames.
231
+
232
+
```toml
233
+
[[components.mypackage.overlays]]
234
+
type = "patch-remove"
235
+
file = "fix-old-bug.patch"
236
+
description = "Remove patch that is no longer needed"
237
+
```
238
+
239
+
Glob patterns can remove multiple patches at once:
240
+
241
+
```toml
242
+
[[components.mypackage.overlays]]
243
+
type = "patch-remove"
244
+
file = "CVE-*.patch"
245
+
description = "Remove CVE patches that are now upstream"
246
+
```
247
+
248
+
> **Note:**`patch-remove` does not remove `%patchN` application lines from `%prep`.
249
+
> If the spec uses individual `%patch` directives rather than `%autosetup`, you may need
250
+
> a `spec-search-replace` overlay to remove those lines as well. Similarly, `%autopatch`
251
+
> has `-m` and `-M` options referencing specific patch numbers and will need targeted
252
+
> adjustments.
253
+
254
+
> **Limitation:**`patch-add` auto-assigns PatchN numbers by scanning existing numeric
255
+
> `PatchN` tags. Macro-based tag numbering (e.g., `Patch%{n}`) is not expanded and may
256
+
> conflict with auto-assigned numbers.
257
+
201
258
## Validation
202
259
203
260
Overlay configurations are validated when the config file is loaded. Validation checks:
0 commit comments