lib/deploy: Port deployment checkout func to new style
Not sure how we missed this one before. No functional changes, just prep for further work. Closes: #1497 Approved by: jlebon
This commit is contained in:
parent
17db0f15a7
commit
792c190a44
|
|
@ -523,38 +523,33 @@ checkout_deployment_tree (OstreeSysroot *sysroot,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
GLNX_AUTO_PREFIX_ERROR ("Checking out deployment tree", error);
|
||||||
OstreeRepoCheckoutAtOptions checkout_opts = { 0, };
|
/* Find the directory with deployments for this stateroot */
|
||||||
const char *csum = ostree_deployment_get_csum (deployment);
|
g_autofree char *osdeploy_path =
|
||||||
g_autofree char *checkout_target_name = NULL;
|
g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL);
|
||||||
g_autofree char *osdeploy_path = NULL;
|
|
||||||
glnx_autofd int osdeploy_dfd = -1;
|
|
||||||
int ret_fd;
|
|
||||||
|
|
||||||
osdeploy_path = g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL);
|
|
||||||
checkout_target_name = g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment));
|
|
||||||
|
|
||||||
if (!glnx_shutil_mkdir_p_at (sysroot->sysroot_fd, osdeploy_path, 0775, cancellable, error))
|
if (!glnx_shutil_mkdir_p_at (sysroot->sysroot_fd, osdeploy_path, 0775, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
|
glnx_autofd int osdeploy_dfd = -1;
|
||||||
if (!glnx_opendirat (sysroot->sysroot_fd, osdeploy_path, TRUE, &osdeploy_dfd, error))
|
if (!glnx_opendirat (sysroot->sysroot_fd, osdeploy_path, TRUE, &osdeploy_dfd, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
|
/* Clean up anything that was there before, from e.g. an interrupted checkout */
|
||||||
|
const char *csum = ostree_deployment_get_csum (deployment);
|
||||||
|
g_autofree char *checkout_target_name =
|
||||||
|
g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment));
|
||||||
if (!glnx_shutil_rm_rf_at (osdeploy_dfd, checkout_target_name, cancellable, error))
|
if (!glnx_shutil_rm_rf_at (osdeploy_dfd, checkout_target_name, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
|
/* Generate hardlink farm, then opendir it */
|
||||||
|
OstreeRepoCheckoutAtOptions checkout_opts = { 0, };
|
||||||
if (!ostree_repo_checkout_at (repo, &checkout_opts, osdeploy_dfd,
|
if (!ostree_repo_checkout_at (repo, &checkout_opts, osdeploy_dfd,
|
||||||
checkout_target_name, csum,
|
checkout_target_name, csum,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, &ret_fd, error))
|
return glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, out_deployment_dfd,
|
||||||
goto out;
|
error);
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
*out_deployment_dfd = ret_fd;
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
@ -2446,10 +2441,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
|
||||||
glnx_autofd int deployment_dfd = -1;
|
glnx_autofd int deployment_dfd = -1;
|
||||||
if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd,
|
if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
{
|
return FALSE;
|
||||||
g_prefix_error (error, "Checking out tree: ");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_autoptr(OstreeKernelLayout) kernel_layout = NULL;
|
g_autoptr(OstreeKernelLayout) kernel_layout = NULL;
|
||||||
if (!get_kernel_from_tree (deployment_dfd, &kernel_layout,
|
if (!get_kernel_from_tree (deployment_dfd, &kernel_layout,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue