Commit graph

14 commits

Author SHA1 Message Date
Achilleas Koutsou
07a597481b util: move get_host_storage() to a separate module
Add a new util module called host which is used for functions that are
meant for interactions with the host.  These functions should not be
used in stages.

The containers.get_host_storage() function is renamed to
host.get_container_storage() for clarity, since it is no longer
namespaced under containers.
2024-08-21 19:26:31 +02:00
Achilleas Koutsou
bce908e4a2 util: replace toml imports with our util module 2024-08-21 19:26:31 +02:00
Gianluca Zuccarelli
8b601d146b util/containers: remount containers store as rw 2024-03-11 18:15:24 +02:00
Gianluca Zuccarelli
36d1187c35 util/containers: update storage location
Change the contianers store from `/containers/storage` to
`/var/tmp/containers/storage` since technically `/containers/storage`
isn't ostree compatible.
2024-03-11 18:15:24 +02:00
Gianluca Zuccarelli
6c0973238d utils/mnt: fix mount permissions
This is a follow up to #1550 where we enabled a `rw` permissions mode,
which is not ideal since it would theoretically be possible to set both
`ro` and `rw` modes at the same time. This commit fixes the issue by only
allowing one option at a time.

Fixes #1588
2024-03-07 13:01:47 +00:00
Michael Vogt
c219160b8f osbuild: add warning when lazy umount in containers_storage_source fails 2024-02-27 15:07:42 +01:00
Achilleas Koutsou
423819a80e util/containers: add the checksum to the image data
When parsing a container input, add the checksum to the data as well.

Usually with other inputs, the stage only needs to know the filepath
where it can find the source content.  In most (all, so far) cases, this
is a checksum appended to the content type.

In this case, the filepath is the location of the storage bind mount and
the checksum is needed to retrieve the container.  The name might only
be a destination name (a name to use for storing the container in the
image), so we can't rely on it being valid in the source.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
6572b1b8e7 util: remove storage_conf arg from get_host_storage()
Let the caller decide if a reload of the storage configuration is needed
and simplify the storage configuration reader.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
2d779a14e4 util: fall back to /usr/share for storage.conf if no /etc config
The system-wide location for the containers storage.conf is
/usr/share/containers.  The existence of a file in /etc/containers
completely overrides this (see containers-storage.conf(5)).
If no file is found at /etc/containers/storage.conf then fall back to
reading the config from /usr/share/containers/storage.conf.

If neither file exists, this is an error since the default config should
be packaged with any tool that requires it (skopeo, podman, etc).
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
06801bb442 util/containers: mount storage
Containers with the `containers-storage` are bind mounted to
the osbuild store. This helper function bind mounts the
containers-storage from the store into the `/containers/storage`
so that stages that require containers can then make use of these
containers.
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
26aac90eb4 util/containers: read host config
Add utility function to read the host's container storage config.
2024-02-21 17:55:37 +01:00
Dusty Mabe
4e5de3808e osbuild/util: add containers_source helper
This will hoist even more code into util out of the skopeo stage.
Now a caller can call:

    with containers.container_source(image) as (image_name, image_source):
        print(f"{image_name}, {image_source}")

to process containers inputs.
2023-09-30 02:29:05 +02:00
Dusty Mabe
4cd9af47d0 osbuild/util: hoist container handling code into util/containers
This hoists container handling code from the skopeo stage into
util/containers. It is prep for adding another stage that accepts
containers as an input. The code is common so we should share it
amongst all stages that use containers as input.
2023-09-30 02:29:05 +02:00
Achilleas Koutsou
b83fd8650c osbuild-mpp: extract is_manifest_list() function
Extract the is_manifest_list() function from the ImageManifest object in
osbuild-mpp into a util function to be reused by the skopeo source.
2023-03-31 14:57:26 +02:00