Skip to content

Commit

Permalink
libpriv/core: teach core to use deployment for yum repos
Browse files Browse the repository at this point in the history
Add a function in the core that knows how to take a deployment and point
its passwd dir and libdnf's repos dir to it. We call it the
"configuration deployment", because those are configuration files which
should be inherited from the config merge, not the origin merge.

Prep for `makecache`.
  • Loading branch information
jlebon committed Oct 5, 2017
1 parent f920f36 commit 8713f1f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
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);

/* 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
30 changes: 22 additions & 8 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
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

0 comments on commit 8713f1f

Please sign in to comment.