Skip to content

Commit 361a225

Browse files
committed
docs/packaging: Expand on patterning files into subpackages
Fixes #604. Signed-off-by: Evan Maddock <[email protected]>
1 parent f140b85 commit 361a225

File tree

2 files changed

+69
-9
lines changed

2 files changed

+69
-9
lines changed

docs/packaging/package.yml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Not all fields in `package.yml` are mandatory, but a small selection are. Below
9898
| **rundeps** | `dict(s)` | Specify further runtime dependencies for the packages. You can learn more [here](/docs/packaging/packaging-practices#runtime-dependencies). |
9999
| **checkdeps** | `dict(s)` | Specify build dependencies for the package which will _not_ be considered when determining build order for automatic builds. These dependencies should only be used during the `check` build phase. You can learn more [here](/docs/packaging/packaging-practices#check-dependencies) |
100100
| **replaces** | `dict(s)` | Replace one package with another, used when renaming or deprecating packages for clean upgrade paths. |
101-
| **patterns** | `dict(s)` | Allows fine grained control over file placement within the package or sub-packages. Useful for packages that are development only (i.e. `/usr/bin` files). |
101+
| **patterns** | `dict(s)` | Allows fine grained control over file placement within the package or sub-packages. Useful for packages that are development only (i.e. `/usr/bin` files). You can learn more [here](/docs/packaging/packaging-practices#patterns). |
102102
| **environment** | `unicode` | Specify code that will be exported to all packaging steps of the build (i.e. exporting variables for the entire build). |
103103
| **networking** | `bool` | Set to `yes` to enable networking within solbuild. |
104104

docs/packaging/packaging-practices.md

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,28 +296,88 @@ install -m 0644 $pkgfiles/profile $installdir/etc/profile
296296

297297
## Patterns
298298

299-
In most instances, `ypkg` will assign the correct location for files, whether it be in the main `name` package, or a subpackage. However there may be instances where the default does not match the intended behaviour.
299+
In most instances, `ypkg` will assign the correct location for files, whether it be in the main `name` package, or a subpackage. However, there may be instances where the default does not match the intended behaviour.
300300

301-
In these instances it is possible to override the default assignment by way of patterns. These are simply a list of paths or globs to ensure a particular file, or set of files, end up in the desired location.
301+
In these instances, it is possible to override the default assignment by way of patterns. These are simply a list of paths or globs to ensure a particular file, or set of files, end up in the desired package.
302302

303303
The `patterns` key expects a `dict(s)` argument. The default key for each pattern is assumed to be the `name` of the package, so omitting the name would place files into the main package. The value should be a path or pattern you wish to match, ensuring files go to a specific location.
304304

305-
In this example from `libjpeg-turbo`, we move all documentation into the `docs` subpackage:
305+
### Naming
306+
307+
There are two ways to name a pattern. Say you have a package named `foo`, and you want to create a subpackage `foo-bar`. You can do this by creating a pattern with the key `bar`. The name of the key will be appended to the name of the package.
306308

309+
```yaml
310+
name : foo
311+
patterns :
312+
- bar :
313+
- [ ... ]
307314
```
308-
patterns:
309-
- docs: [/usr/share/man]
315+
316+
If you don't want the name of the subpackage to start with the name of the main package, you can do that, too. Keys starting with a `^` character will not prepend the base package name to the name of the subpackage. If you want to create a package named `bar` from the `foo` package, it would look like this:
317+
318+
```yaml
319+
name : foo
320+
patterns :
321+
- ^bar :
322+
- [ ... ]
310323
```
311324

312-
This example, taken from the `wayland` package, ensures the binaries from `/usr/bin` and the directory `/usr/share/wayland` are located in the `devel` subpackage:
325+
### Customizing subpackages
326+
327+
Often with subpackages, you will want a different component, summary, description, license, or runtime dependencies than the base package. This can be accomplished by turning the keys keys you want to change into lists of `dict(s)`. The key for each entry follows the same rules as the `patterns` key outlined above.
313328

329+
If you have package `foo` and subpackage `foo-bar`, changing the properties would look like this:
330+
331+
```yaml
332+
name : foo
333+
license :
334+
- bar : MIT
335+
- Apache-2.0
336+
component :
337+
- bar : desktop
338+
- desktop.library
339+
summary :
340+
- bar : This summary applies to the bar subpackage
341+
- This summary applies to the foo package
342+
rundeps :
343+
- bar :
344+
- foo
345+
patterns :
346+
- bar :
347+
- [ ... ]
314348
```
315-
patterns:
316-
- devel:
349+
350+
:::note
351+
352+
Usually, packages will automatically depend on created subpackages by default. Consider making the subpackages depend on the base package instead by adding it as a runtime dependency.
353+
354+
:::
355+
356+
### Examples
357+
358+
In this example from `libjpeg-turbo`, we move all documentation into the `docs` subpackage:
359+
360+
```yaml
361+
patterns :
362+
- docs : [/usr/share/man]
363+
```
364+
365+
This example, taken from the `wayland` package, ensures the binaries from `/usr/bin` and the directory `/usr/share/wayland` are located in the `devel` subpackage:
366+
367+
```yaml
368+
patterns :
369+
- devel :
317370
- /usr/bin
318371
- /usr/share/wayland
319372
```
320373

374+
To create a header-only package, like `spirv-headers`, create a pattern that matches all files. This can also be used in cases where you don't want any automatically-generated subpackages.
375+
376+
```yaml
377+
patterns :
378+
- /*
379+
```
380+
321381
## Replace / rename
322382

323383
In some situations, it may be required to replace one package with another, or to rename an existing package. In these instances you should coordinate with a repository maintainer to ensure the replaced package is marked **Obsolete** within the index. This will ensure correct upgrade paths for users.

0 commit comments

Comments
 (0)