Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose: If repos is unset, use global ones #5118

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ paste = "1.0"
phf = { version = "0.11", features = ["macros"] }
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.11"
regex = "1.10"
reqwest = { version = "0.12", features = ["native-tls", "blocking", "gzip"] }
rpmostree-client = { path = "rust/rpmostree-client", version = "0.1.0" }
rust-ini = "0.21.1"
Expand Down
4 changes: 2 additions & 2 deletions docs/treefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ It supports the following parameters:
secret key must be in the home directory of the building user. Defaults to
none.

* `repos`: array of strings, mandatory: Names of yum repositories to
* `repos`: array of strings, optional: Names of yum repositories to
use, from any files that end in `.repo`, in the same directory as
the treefile. `rpm-ostree compose tree` does not use the system
the treefile. If specified, `rpm-ostree compose tree` does not use the system
`/etc/yum.repos.d`, because it's common to want to compose a target
system distinct from the one the host sytem is running.

Expand Down
5 changes: 0 additions & 5 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,11 +1383,6 @@ impl Treefile {

/// Do some upfront semantic checks we can do beyond just the type safety serde provides.
fn validate_base_config(config: &TreeComposeConfig) -> Result<()> {
if config.base.repos.is_none() && config.base.lockfile_repos.is_none() {
return Err(anyhow!(
r#"Treefile has neither "repos" nor "lockfile-repos""#
));
}
if config
.base
.repovars
Expand Down
20 changes: 17 additions & 3 deletions src/app/rpmostree-compose-builtin-tree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,21 @@ install_packages (RpmOstreeTreeComposeContext *self, gboolean *out_unmodified,
rpmlogSetFile (NULL);
}

if (!set_repos_dir (dnfctx, **self->treefile_rs, self->workdir_dfd, cancellable, error))
return FALSE;
const char *source_root;
auto repos = (*self->treefile_rs)->get_repos ();
if (!repos.empty ())
{
g_print ("Using rpm-md repositories from context directory\n");
if (!set_repos_dir (dnfctx, **self->treefile_rs, self->workdir_dfd, cancellable, error))
return FALSE;
source_root = NULL;
}
else
{
g_print ("Using global rpm-md repositories\n");
source_root = "/";
dnf_context_set_repo_dir (dnfctx, "/etc/yum.repos.d");
}

/* By default, retain packages in addition to metadata with --cachedir, unless
* we're doing unified core, in which case the pkgcache repo is the cache.
Expand All @@ -340,7 +353,8 @@ install_packages (RpmOstreeTreeComposeContext *self, gboolean *out_unmodified,

{
g_autofree char *tmprootfs_abspath = glnx_fdrel_abspath (rootfs_dfd, ".");
if (!rpmostree_context_setup (self->corectx, tmprootfs_abspath, NULL, cancellable, error))
if (!rpmostree_context_setup (self->corectx, tmprootfs_abspath, source_root, cancellable,
error))
return FALSE;
}

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 @@ -505,6 +505,7 @@ static void
disable_all_repos (RpmOstreeContext *context)
{
GPtrArray *sources = dnf_context_get_repos (context->dnfctx);
g_debug ("Disabling %u known repos", sources->len);
for (guint i = 0; i < sources->len; i++)
{
auto src = static_cast<DnfRepo *> (sources->pdata[i]);
Expand Down Expand Up @@ -659,7 +660,9 @@ rpmostree_context_setup (RpmOstreeContext *self, const char *install_root, const
else if (releasever.length () > 0)
dnf_context_set_release_ver (self->dnfctx, releasever.c_str ());

g_debug ("install_root: %s", install_root);
dnf_context_set_install_root (self->dnfctx, install_root);
g_debug ("source_root: %s", source_root);
dnf_context_set_source_root (self->dnfctx, source_root);

/* Hackaround libdnf logic, ensuring that `/etc/dnf/vars` gets sourced
Expand Down Expand Up @@ -724,6 +727,11 @@ rpmostree_context_setup (RpmOstreeContext *self, const char *install_root, const
if (!enable_repos (self, repos, error))
return FALSE;
}
else
{
GPtrArray *sources = dnf_context_get_repos (self->dnfctx);
g_debug ("global repositories known: %u", sources->len);
}

/* only enable lockfile-repos if we actually have a lockfile so we don't even waste
* time fetching metadata */
Expand Down
Loading