core: major rework
This patch prepares RpmOstreeContext for supporting package layering. A relabel operation is added as well to support relabeling imported packages if the sepolicy of the rootfs we're overlaying onto is different from during import. Closes: #289 Approved by: cgwalters
This commit is contained in:
parent
1ccc560c26
commit
a25cdde25c
@ -294,7 +294,7 @@ install_packages_in_root (RpmOstreeTreeComposeContext *self,
|
|||||||
g_autoptr(RpmOstreeTreespec) treespec_value = rpmostree_treespec_new_from_keyfile (treespec, &tmp_error);
|
g_autoptr(RpmOstreeTreespec) treespec_value = rpmostree_treespec_new_from_keyfile (treespec, &tmp_error);
|
||||||
g_assert_no_error (tmp_error);
|
g_assert_no_error (tmp_error);
|
||||||
|
|
||||||
if (!rpmostree_context_setup (ctx, gs_file_get_path_cached (yumroot), treespec_value,
|
if (!rpmostree_context_setup (ctx, gs_file_get_path_cached (yumroot), "/", treespec_value,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ install_packages_in_root (RpmOstreeTreeComposeContext *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --- Downloading packages --- */
|
/* --- Downloading packages --- */
|
||||||
if (!rpmostree_context_download_rpms (ctx, -1, hifinstall, cancellable, error))
|
if (!rpmostree_context_download (ctx, hifinstall, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
{ g_auto(GLnxConsoleRef) console = { 0, };
|
{ g_auto(GLnxConsoleRef) console = { 0, };
|
||||||
|
@ -114,7 +114,7 @@ roc_context_prepare_for_root (ROContainerContext *rocctx,
|
|||||||
if (!rocctx->ctx)
|
if (!rocctx->ctx)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!rpmostree_context_setup (rocctx->ctx, NULL, treespec, cancellable, error))
|
if (!rpmostree_context_setup (rocctx->ctx, NULL, "/", treespec, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
@ -301,19 +301,29 @@ rpmostree_container_builtin_assemble (int argc,
|
|||||||
if (!rpmostree_context_prepare_install (rocctx->ctx, &install, cancellable, error))
|
if (!rpmostree_context_prepare_install (rocctx->ctx, &install, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* --- Download and import as necessary --- */
|
/* --- Download as necessary --- */
|
||||||
if (!rpmostree_context_download_import (rocctx->ctx, install,
|
if (!rpmostree_context_download (rocctx->ctx, install, cancellable, error))
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
{ glnx_fd_close int tmpdir_dfd = -1;
|
/* --- Import as necessary --- */
|
||||||
|
if (!rpmostree_context_import (rocctx->ctx, install, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!glnx_opendirat (rocctx->userroot_dfd, "tmp", TRUE, &tmpdir_dfd, error))
|
{ g_autofree char *tmprootfs = g_strdup ("tmp/rpmostree-commit-XXXXXX");
|
||||||
|
glnx_fd_close int tmprootfs_dfd = -1;
|
||||||
|
|
||||||
|
if (!glnx_mkdtempat (rocctx->userroot_dfd, tmprootfs, 0755, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!rpmostree_context_assemble_commit (rocctx->ctx, tmpdir_dfd, name,
|
if (!glnx_opendirat (rocctx->userroot_dfd, tmprootfs, TRUE,
|
||||||
&commit, cancellable, error))
|
&tmprootfs_dfd, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (!rpmostree_context_assemble_commit (rocctx->ctx, tmprootfs_dfd, NULL,
|
||||||
|
NULL, &commit, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
glnx_shutil_rm_rf_at (rocctx->userroot_dfd, tmprootfs, cancellable, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("Checking out %s @ %s...\n", name, commit);
|
g_print ("Checking out %s @ %s...\n", name, commit);
|
||||||
@ -507,20 +517,30 @@ rpmostree_container_builtin_upgrade (int argc, char **argv, GCancellable *cancel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Download and import as necessary --- */
|
/* --- Download as necessary --- */
|
||||||
if (!rpmostree_context_download_import (rocctx->ctx, install,
|
if (!rpmostree_context_download (rocctx->ctx, install, cancellable, error))
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
{ glnx_fd_close int tmpdir_dfd = -1;
|
/* --- Import as necessary --- */
|
||||||
|
if (!rpmostree_context_import (rocctx->ctx, install, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!glnx_opendirat (rocctx->userroot_dfd, "tmp", TRUE, &tmpdir_dfd, error))
|
{ g_autofree char *tmprootfs = g_strdup ("tmp/rpmostree-commit-XXXXXX");
|
||||||
|
glnx_fd_close int tmprootfs_dfd = -1;
|
||||||
|
|
||||||
|
if (!glnx_mkdtempat (rocctx->userroot_dfd, tmprootfs, 0755, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!rpmostree_context_assemble_commit (rocctx->ctx, tmpdir_dfd, name,
|
if (!glnx_opendirat (rocctx->userroot_dfd, tmprootfs, TRUE,
|
||||||
&new_commit_checksum,
|
&tmprootfs_dfd, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!rpmostree_context_assemble_commit (rocctx->ctx, tmprootfs_dfd, NULL,
|
||||||
|
NULL, &new_commit_checksum,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
glnx_shutil_rm_rf_at (rocctx->userroot_dfd, tmprootfs, cancellable, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("Checking out %s @ %s...\n", name, new_commit_checksum);
|
g_print ("Checking out %s @ %s...\n", name, new_commit_checksum);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -57,12 +57,15 @@ const char *rpmostree_treespec_get_ref (RpmOstreeTreespec *spec);
|
|||||||
|
|
||||||
gboolean rpmostree_context_setup (RpmOstreeContext *self,
|
gboolean rpmostree_context_setup (RpmOstreeContext *self,
|
||||||
const char *install_root,
|
const char *install_root,
|
||||||
|
const char *source_root,
|
||||||
RpmOstreeTreespec *treespec,
|
RpmOstreeTreespec *treespec,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void rpmostree_context_set_repo (RpmOstreeContext *self,
|
void rpmostree_context_set_repo (RpmOstreeContext *self,
|
||||||
OstreeRepo *repo);
|
OstreeRepo *repo);
|
||||||
|
void rpmostree_context_set_sepolicy (RpmOstreeContext *self,
|
||||||
|
OstreeSePolicy *sepolicy);
|
||||||
|
|
||||||
void rpmostree_hif_add_checksum_goal (GChecksum *checksum, HyGoal goal);
|
void rpmostree_hif_add_checksum_goal (GChecksum *checksum, HyGoal goal);
|
||||||
char *rpmostree_context_get_state_sha512 (RpmOstreeContext *self);
|
char *rpmostree_context_get_state_sha512 (RpmOstreeContext *self);
|
||||||
@ -80,20 +83,27 @@ gboolean rpmostree_context_prepare_install (RpmOstreeContext *self,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean rpmostree_context_download_rpms (RpmOstreeContext *self,
|
gboolean rpmostree_context_download (RpmOstreeContext *self,
|
||||||
int target_dfd,
|
RpmOstreeInstall *install,
|
||||||
RpmOstreeInstall *install,
|
GCancellable *cancellable,
|
||||||
GCancellable *cancellable,
|
GError **error);
|
||||||
GError **error);
|
|
||||||
|
|
||||||
gboolean rpmostree_context_download_import (RpmOstreeContext *self,
|
gboolean rpmostree_context_import (RpmOstreeContext *self,
|
||||||
RpmOstreeInstall *install,
|
RpmOstreeInstall *install,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean rpmostree_context_assemble_commit (RpmOstreeContext *self,
|
gboolean rpmostree_context_relabel (RpmOstreeContext *self,
|
||||||
int tmpdir_dfd,
|
RpmOstreeInstall *install,
|
||||||
const char *name,
|
GCancellable *cancellable,
|
||||||
char **out_commit,
|
GError **error);
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error);
|
/* NB: tmprootfs_dfd is allowed to have pre-existing data */
|
||||||
|
/* devino_cache can be NULL if no previous cache established */
|
||||||
|
gboolean rpmostree_context_assemble_commit (RpmOstreeContext *self,
|
||||||
|
int tmprootfs_dfd,
|
||||||
|
OstreeRepoDevInoCache *devino_cache,
|
||||||
|
const char *parent,
|
||||||
|
char **out_commit,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
Loading…
Reference in New Issue
Block a user