Skip to content

Commit

Permalink
core: Use source root for repos and dnf vars
Browse files Browse the repository at this point in the history
The goal here is to have the new (more container-native) flow
for `experimental compose rootfs` to always operate on a "repos container"
that we've mounted.

I noticed that `rpmostree_find_and_download_packages()` has
similar behavior, but that's apparently only used in override
flows?

The only ugly workaround we need now is for the rpm-gpg stuff.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Feb 7, 2025
1 parent 3ac642e commit 242bef3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/app/rpmostree-compose-builtin-tree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ set_repos_dir (DnfContext *dnfctx, rpmostreecxx::Treefile &treefile, int workdir
if (!repovars.empty ())
g_ptr_array_add (var_dirs, (char *)repovars.c_str ());

g_autofree char *source_vars = NULL;
if (opt_source_root)
{
source_vars = g_build_filename (opt_source_root, "etc/dnf/vars", NULL);
g_ptr_array_add (var_dirs, (char*) source_vars);
}

g_ptr_array_add (var_dirs, NULL);
dnf_context_set_vars_dir (dnfctx, (const gchar *const *)var_dirs->pdata);

Expand Down
8 changes: 8 additions & 0 deletions src/libpriv/rpmostree-core.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,14 @@ rpmostree_context_setup (RpmOstreeContext *self, const char *install_root, const

dnf_context_set_install_root (self->dnfctx, install_root);
dnf_context_set_source_root (self->dnfctx, source_root);
if (source_root)
{
// Override what rpmostree_context_set_cache_root() did.
// TODO disentangle these things so that we only call set_repo_dir if
// we didn't have a source root.
g_autofree char *source_repos = g_build_filename (source_root, "etc/yum.repos.d", NULL);
dnf_context_set_repo_dir (self->dnfctx, source_repos);
}

/* Hackaround libdnf logic, ensuring that `/etc/dnf/vars` gets sourced
* from the host environment instead of the install_root:
Expand Down
12 changes: 4 additions & 8 deletions tests/compose-rootfs/Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# In theory this can skew from the builder
FROM quay.io/fedora/fedora:41 as repos
# Demonstrate skew from the builder
FROM quay.io/centos/centos:stream10 as repos

# You must run this build with `-v /path/to/rpm-ostree:/run/build/rpm-ostree:ro`
FROM quay.io/fedora/fedora:41 as builder
Expand All @@ -17,12 +17,8 @@ COPY . /src
WORKDIR /src
RUN --mount=type=bind,from=repos,src=/,dst=/repos <<EORUN
set -xeuo pipefail
# Synchronize the dnf/rpm configs from the repos container.
for x in etc/dnf etc/yum.repos.d etc/pki/rpm-gpg; do
rm -rf /"$x" && cp -a /repos/${x} /$x
done
# And copy to the workdir; TODO fix this in rpm-ostree
cp /etc/yum.repos.d/*.repo .
# Workaround for https://github.com/coreos/rpm-ostree/issues/5285
cp -a /repos/etc/pki/rpm-gpg/* /etc/pki/rpm-gpg
exec rpm-ostree experimental compose rootfs --source-root=/repos manifest.yaml /target-rootfs
EORUN

Expand Down

0 comments on commit 242bef3

Please sign in to comment.