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
//! Build the individual `.network`, `.volume` and `.container` units.
pub use build_unit;
pub use ;
pub use network_unit;
pub use volume_unit;
// Shared helpers from the sibling `render`/`warnings` modules and the parent
// `QuadletUnit` type, re-exported so the unit submodules import them from here.
use ;
use collect_warnings;
use QuadletUnit;
/// The ownership marker every generated unit carries as its literal first
/// line: a `#` comment, ignored by systemd, naming the project that owns the
/// unit.
///
/// This is deliberately separate from the `Label=podup.project=<project>`
/// line each unit also carries (kept for runtime scoping — Podman uses it for
/// container/secret lookups). A compose service's user-supplied `labels:` are
/// rendered into the same section as that `Label=` line, in the same
/// `Key=Value` shape, so a service declaring `labels: {podup.project: other}`
/// produces an indistinguishable forged `Label=podup.project=other` line
/// ahead of the real one. A `#`-prefixed line cannot be forged the same way:
/// compose labels only ever become `Label=key=value` entries, never a
/// comment, so this marker is the line ownership checks (`unit_owner` in
/// `crate::autostart::quadlet`) must read instead.
/// Resolve a compose-relative path against the compose base directory.
///
/// Compose interprets a relative path against the compose file's directory.
/// systemd interprets one against **the unit file's** directory — units are
/// installed under `~/.config/containers/systemd`, which is not where the
/// project lives. Any path a generated unit carries must therefore be made
/// absolute here, or it silently resolves somewhere else once installed.
///
/// An already-absolute path is returned untouched, and `.` means the base
/// directory itself. A leading `./` is stripped so the result stays clean
/// (`/base/src`, not `/base/./src`) — cosmetic, both resolve identically.