Composing an Environment
ppk compose-env lays out an environment's whole root in a new directory:
the closure of the packages you name as its usr, and whatever else you
give it outside usr. Do this when a tool needs the environment as files,
such as an image builder making an initramfs from it. For how environments
work, see Environments.
Before you start #
- Install
ppk. - Have every package in your artifact directory.
- Choose a directory for the root that doesn't exist yet. Every file in the root is a hard link to its blob, so the directory must be on the same mount as the artifact directory, unless you compose on another mount.
Compose the root #
-
Describe the environment in a profile, such as
env.toml. For the format, see Environments:= "noarch" [] = "1.0-1" = "2.0-1" -
Run
ppk compose-envwith the profile and--out:
ppk resolves the profile's requests against the artifact directory, with
the packages they depend on or require, and prints the identity of the
closure of the packages chosen:
sha256:fe5cf307f0b70379e1ec36b0d8dca659782446b0d13e7140c1257cd855ba61c4
root/usr holds the packages' files, and the links they
claim
under /usr, such as dash's /usr/bin/sh. Nothing is written to the
artifact directory.
root/usr/inventory records the closure identity, and each package's full
ID and identity and what wants it. List them without a store:
To list a store and mark the packages in this root, run:
Each line has * for a package whose ID and identity are in this root, or a
space otherwise, then a space and the full ID. Both commands sort by full
ID. For validation
and missing-inventory behavior, see
Identifying the mounted closure.
To add packages to the profile's, or to compose without a profile, name
them after -p. One -p takes every package after it, up to the next
option, so the profile must come first:
These packages are all for the architecture ppk was built for. To name
another, give it in the package, as dev.peios.hello@1.0-1?arch=noarch, or
give arch in the profile.
Add what lies outside usr #
A package can only place files under /usr. The one exception is a link
it claims elsewhere, such as /init, which the root holds because the
package is in it. Anything else the root needs comes from the profile or
the command line:
- A link, from the profile's
symlinksor--symlink <path>:<target>. The target is written as given, unless it starts with a colon in the profile, or a second colon on the command line, which stands for/usr:"bin" = ":bin"andbin::binboth linkbintousr/bin. - An empty directory, such as a mount point, from the profile's
dirsor--dir <path>. - The packages themselves, from the profile's
include_artifacts = trueor--include-artifacts, in the root's own artifact directory,system/artifacts, as hard links, so thatppkinside the environment finds them. --copy-artifactsdoes the same with copies, checking every manifest and blob asppk fetchdoes, and wins over hard links.
Paths are relative to the root. The options add to what the profile gives:
The root then holds bin, a link to usr/bin, an empty tmp, the
packages' artifacts in system/artifacts, and usr.
For a live image, ppk-live-root composes the root from the medium's
profile and store, then runs skeleton apply on it. That applies the root
skeleton file in the root's own /usr/share/skeleton, which
dev.peios.fsbase ships, so the root gets its directories outside /usr
and the /lib64 link. Without the file the hook warns and continues. It
then copies the medium's /lcl tree into the root if present.
The copy preserves modes and a copy failure fails the boot. This carries
image policy, including registry seed queues and executable autorun
scripts, outside /usr. peinit applies the common and live seed queues
after registryd starts; an installer owns promotion of the install queue.
Share a layout between profiles #
When several environments need the same root layout, write it once as a
fragment, such as layout.toml:
= ["proc", "sys", "dev", "tmp"]
[]
= ":bin"
= ":lib"
Then include it from each profile. The path is relative to the profile's own directory:
= ["layout.toml"]
[]
= "1.0-1"
You can also give several profiles to ppk compose-env, which merges them
in the same way, so a profile that names only packages can be composed with
a layout:
If two of them disagree, ppk names both files and composes nothing:
ppk: other.toml links "bin" to "usr/sbin", but layout.toml links it to "usr/bin"
Compose on another mount #
A hard link can't cross a mount, even between two mounts of one filesystem. To compose a root on another mount than the artifact directory, such as a fresh tmpfs, or in a sandboxed build step that has the artifact directory as a read-only input, copy what would be linked:
-
If the root has no artifact directory of its own, pass
--copy-files.root/usrthen holds a copy of each file, checked against its hash, and the root holds nothing else from the store: -
If it needs one, pass
--copy-artifacts, which copies the packages into the root'ssystem/artifacts.usrthen hard links to that.
To see what a copy changes, including for security descriptors, see Copied files.
If ppk refuses #
ppk compose-env leaves nothing behind when it refuses. It checks all but
the hard links before it writes anything. It refuses a root that already
exists:
ppk: root: already exists
It refuses a path under a link you also gave, because creating it would follow the link out of the root:
ppk: "bin/extra": under "bin", which is a symlink
It refuses another version of a package the profile holds, since an environment holds one version of each:
ppk: dev.peios.hello@2.0-1?arch=x86_64: the environment holds dev.peios.hello@1.0-1?arch=x86_64 already
It refuses two packages that claim one path, even as links to one target, since a claim says which package provides the name. Choose one of them:
ppk: "/usr/bin/sh": claimed by both org.git.kernel.dash@0.5.13.5-1?arch=x86_64 and net.busybox.busybox@1.37.0-1?arch=x86_64
It refuses a claimed link outside usr that the profile or the options
also give as a link or a directory, or that a path given lies under:
ppk: "init": claimed by org.git.kernel.dash@0.5.13.5-1?arch=x86_64, but the environment links it
It also refuses packages that conflict, in the same way as
ppk closure, including a claimed
link that is a path in a package's files, and any path that is usr or
lies under it.