sysroot: Prep refactoring of cleanup logic
For future work I'm going to tweak how we handle cleanup, and the private cleanup flags didn't really end up being used - we only specify "prune repo or not". So fold that into a boolean for now. The sysroot deploy logic then has a single "do_postclean" boolean, which is all I want to expose as public API. Closes: #744 Approved by: jlebon
This commit is contained in:
parent
ec2f52e625
commit
5d413dff88
|
|
@ -515,12 +515,7 @@ ostree_sysroot_cleanup (OstreeSysroot *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeSysrootCleanupFlags flags;
|
return _ostree_sysroot_cleanup_internal (self, TRUE, cancellable, error);
|
||||||
|
|
||||||
/* Do everything. */
|
|
||||||
flags = OSTREE_SYSROOT_CLEANUP_ALL;
|
|
||||||
|
|
||||||
return _ostree_sysroot_piecemeal_cleanup (self, flags, cancellable, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -537,55 +532,41 @@ ostree_sysroot_prepare_cleanup (OstreeSysroot *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeSysrootCleanupFlags flags;
|
return _ostree_sysroot_cleanup_internal (self, FALSE, cancellable, error);
|
||||||
|
|
||||||
/* Do everything EXCEPT pruning the repository. */
|
|
||||||
flags = OSTREE_SYSROOT_CLEANUP_ALL & ~OSTREE_SYSROOT_CLEANUP_PRUNE_REPO;
|
|
||||||
|
|
||||||
return _ostree_sysroot_piecemeal_cleanup (self, flags, cancellable, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_ostree_sysroot_piecemeal_cleanup (OstreeSysroot *self,
|
_ostree_sysroot_cleanup_internal (OstreeSysroot *self,
|
||||||
OstreeSysrootCleanupFlags flags,
|
gboolean do_prune_repo,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
glnx_unref_object OstreeRepo *repo = NULL;
|
glnx_unref_object OstreeRepo *repo = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (OSTREE_IS_SYSROOT (self), FALSE);
|
g_return_val_if_fail (OSTREE_IS_SYSROOT (self), FALSE);
|
||||||
g_return_val_if_fail (self->loaded, FALSE);
|
g_return_val_if_fail (self->loaded, FALSE);
|
||||||
|
|
||||||
if (flags & OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS)
|
|
||||||
{
|
|
||||||
if (!cleanup_other_bootversions (self, cancellable, error))
|
if (!cleanup_other_bootversions (self, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS)
|
|
||||||
{
|
|
||||||
if (!cleanup_old_deployments (self, cancellable, error))
|
if (!cleanup_old_deployments (self, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
|
if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!generate_deployment_refs (self, repo,
|
if (!generate_deployment_refs (self, repo,
|
||||||
self->bootversion,
|
self->bootversion,
|
||||||
self->subbootversion,
|
self->subbootversion,
|
||||||
self->deployments,
|
self->deployments,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (flags & OSTREE_SYSROOT_CLEANUP_PRUNE_REPO)
|
if (do_prune_repo)
|
||||||
{
|
{
|
||||||
if (!prune_repo (repo, cancellable, error))
|
if (!prune_repo (repo, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1703,14 +1703,13 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return _ostree_sysroot_write_deployments_internal (self, new_deployments,
|
return _ostree_sysroot_write_deployments_internal (self, new_deployments,
|
||||||
OSTREE_SYSROOT_CLEANUP_ALL,
|
TRUE, cancellable, error);
|
||||||
cancellable, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
|
_ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
|
||||||
GPtrArray *new_deployments,
|
GPtrArray *new_deployments,
|
||||||
OstreeSysrootCleanupFlags cleanup_flags,
|
gboolean do_clean,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
|
@ -1938,12 +1937,14 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
|
||||||
|
|
||||||
/* And finally, cleanup of any leftover data.
|
/* And finally, cleanup of any leftover data.
|
||||||
*/
|
*/
|
||||||
if (!_ostree_sysroot_piecemeal_cleanup (self, cleanup_flags,
|
if (do_clean)
|
||||||
cancellable, error))
|
{
|
||||||
|
if (!ostree_sysroot_cleanup (self, cancellable, error))
|
||||||
{
|
{
|
||||||
g_prefix_error (error, "Performing final cleanup: ");
|
g_prefix_error (error, "Performing final cleanup: ");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
|
|
||||||
|
|
@ -109,21 +109,14 @@ gboolean _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
|
||||||
gboolean _ostree_sysroot_bump_mtime (OstreeSysroot *sysroot,
|
gboolean _ostree_sysroot_bump_mtime (OstreeSysroot *sysroot,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
typedef enum {
|
gboolean _ostree_sysroot_cleanup_internal (OstreeSysroot *sysroot,
|
||||||
OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS = 1 << 0,
|
gboolean prune_repo,
|
||||||
OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS = 1 << 1,
|
|
||||||
OSTREE_SYSROOT_CLEANUP_PRUNE_REPO = 1 << 2,
|
|
||||||
OSTREE_SYSROOT_CLEANUP_ALL = 0xffff
|
|
||||||
} OstreeSysrootCleanupFlags;
|
|
||||||
|
|
||||||
gboolean _ostree_sysroot_piecemeal_cleanup (OstreeSysroot *sysroot,
|
|
||||||
OstreeSysrootCleanupFlags flags,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
|
gboolean _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
|
||||||
GPtrArray *new_deployments,
|
GPtrArray *new_deployments,
|
||||||
OstreeSysrootCleanupFlags cleanup_flags,
|
gboolean do_clean,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1604,8 +1604,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_ostree_sysroot_write_deployments_internal (sysroot, new_deployments,
|
if (!_ostree_sysroot_write_deployments_internal (sysroot, new_deployments,
|
||||||
postclean ? OSTREE_SYSROOT_CLEANUP_ALL : 0,
|
postclean, cancellable, error))
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue