Skip to content

Commit 242bef3

Browse files
committed
core: Use source root for repos and dnf vars
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]>
1 parent 3ac642e commit 242bef3

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/app/rpmostree-compose-builtin-tree.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ set_repos_dir (DnfContext *dnfctx, rpmostreecxx::Treefile &treefile, int workdir
297297
if (!repovars.empty ())
298298
g_ptr_array_add (var_dirs, (char *)repovars.c_str ());
299299

300+
g_autofree char *source_vars = NULL;
301+
if (opt_source_root)
302+
{
303+
source_vars = g_build_filename (opt_source_root, "etc/dnf/vars", NULL);
304+
g_ptr_array_add (var_dirs, (char*) source_vars);
305+
}
306+
300307
g_ptr_array_add (var_dirs, NULL);
301308
dnf_context_set_vars_dir (dnfctx, (const gchar *const *)var_dirs->pdata);
302309

src/libpriv/rpmostree-core.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,14 @@ rpmostree_context_setup (RpmOstreeContext *self, const char *install_root, const
668668

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

672680
/* Hackaround libdnf logic, ensuring that `/etc/dnf/vars` gets sourced
673681
* from the host environment instead of the install_root:

tests/compose-rootfs/Containerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# In theory this can skew from the builder
2-
FROM quay.io/fedora/fedora:41 as repos
1+
# Demonstrate skew from the builder
2+
FROM quay.io/centos/centos:stream10 as repos
33

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

0 commit comments

Comments
 (0)