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

Pr/config ctx from depl #1038

Closed
wants to merge 2 commits into from
Closed
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
24 changes: 3 additions & 21 deletions src/daemon/rpmostree-sysroot-upgrader.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,27 +774,9 @@ prepare_context_for_assembly (RpmOstreeSysrootUpgrader *self,
GCancellable *cancellable,
GError **error)
{
DnfContext *hifctx = rpmostree_context_get_hif (self->ctx);

const char *sysroot_path =
gs_file_get_path_cached (ostree_sysroot_get_path (self->sysroot));
g_autofree char *merge_deployment_dirpath =
ostree_sysroot_get_deployment_dirpath (self->sysroot,
self->cfg_merge_deployment);
g_autofree char *merge_deployment_root =
g_build_filename (sysroot_path, merge_deployment_dirpath, NULL);

g_autofree char *reposdir = g_build_filename (merge_deployment_root,
"etc/yum.repos.d", NULL);
g_autofree char *passwddir = g_build_filename (merge_deployment_root,
"etc", NULL);

/* point libhif to the yum.repos.d and os-release of the merge deployment */
dnf_context_set_repo_dir (hifctx, reposdir);
dnf_context_set_source_root (hifctx, tmprootfs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're no longer calling _set_source_root()...is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it basically got overridden anyway by the set_source_root() at rpmostree_context_setup time. I think this precedes that functionality being added directly in rpmostree_context_setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind splitting this as a separate commit if you'd prefer!


/* point the core to the passwd & group of the merge deployment */
rpmostree_context_set_passwd_dir (self->ctx, passwddir);
/* make sure yum repos and passwd used are from our cfg merge */
rpmostree_context_configure_from_deployment (self->ctx, self->sysroot,
self->cfg_merge_deployment);

/* load the sepolicy to use during import */
glnx_unref_object OstreeSePolicy *sepolicy = NULL;
Expand Down
39 changes: 30 additions & 9 deletions src/libpriv/rpmostree-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,28 @@ rpmostree_context_ensure_tmpdir (RpmOstreeContext *self,
return TRUE;
}

/* Pick up repos dir and passwd from @cfg_deployment. */
void
rpmostree_context_configure_from_deployment (RpmOstreeContext *self,
OstreeSysroot *sysroot,
OstreeDeployment *cfg_deployment)
{
const char *sysroot_path = gs_file_get_path_cached (ostree_sysroot_get_path (sysroot));
g_autofree char *cfg_deployment_dirpath =
ostree_sysroot_get_deployment_dirpath (sysroot, cfg_deployment);
g_autofree char *cfg_deployment_root =
g_build_filename (sysroot_path, cfg_deployment_dirpath, NULL);

g_autofree char *reposdir = g_build_filename (cfg_deployment_root, "etc/yum.repos.d", NULL);

/* point libhif to the yum.repos.d and os-release of the merge deployment */
dnf_context_set_repo_dir (self->hifctx, reposdir);

/* point the core to the passwd & group of the merge deployment */
g_assert (!self->passwd_dir);
self->passwd_dir = g_build_filename (cfg_deployment_root, "etc", NULL);
}

/* Use this if no packages will be installed, and we just want a "dummy" run.
*/
void
Expand Down Expand Up @@ -438,14 +460,6 @@ rpmostree_context_set_sepolicy (RpmOstreeContext *self,
g_set_object (&self->sepolicy, sepolicy);
}

void
rpmostree_context_set_passwd_dir (RpmOstreeContext *self,
const char *passwd_dir)
{
g_clear_pointer (&self->passwd_dir, g_free);
self->passwd_dir = g_strdup (passwd_dir);
}

DnfContext *
rpmostree_context_get_hif (RpmOstreeContext *self)
{
Expand Down Expand Up @@ -531,7 +545,14 @@ rpmostree_context_setup (RpmOstreeContext *self,
/* This exists (as a canonically empty dir) at least on RHEL7+ */
static const char emptydir_path[] = "/usr/share/empty";

self->spec = g_object_ref (spec);
/* allow NULL for treespec, but canonicalize to an empty keyfile for cleaner queries */
if (!spec)
{
g_autoptr(GKeyFile) kf = g_key_file_new ();
self->spec = rpmostree_treespec_new_from_keyfile (kf, NULL);
}
else
self->spec = g_object_ref (spec);

g_variant_dict_lookup (self->spec->dict, "releasever", "&s", &releasever);

Expand Down
7 changes: 5 additions & 2 deletions src/libpriv/rpmostree-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ gboolean rpmostree_context_setup (RpmOstreeContext *self,
GCancellable *cancellable,
GError **error);

void
rpmostree_context_configure_from_deployment (RpmOstreeContext *self,
OstreeSysroot *sysroot,
OstreeDeployment *cfg_deployment);

void rpmostree_context_set_is_empty (RpmOstreeContext *self);

void rpmostree_context_set_repos (RpmOstreeContext *self,
OstreeRepo *base_repo,
OstreeRepo *pkgcache_repo);
void rpmostree_context_set_sepolicy (RpmOstreeContext *self,
OstreeSePolicy *sepolicy);
void rpmostree_context_set_passwd_dir (RpmOstreeContext *self,
const char *passwd_dir);

void rpmostree_dnf_add_checksum_goal (GChecksum *checksum, HyGoal goal);
char *rpmostree_context_get_state_sha512 (RpmOstreeContext *self);
Expand Down