Skip to content
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
53 changes: 17 additions & 36 deletions src/libostree/ostree-sysroot-cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,7 @@ ostree_sysroot_cleanup (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
OstreeSysrootCleanupFlags flags;

/* Do everything. */
flags = OSTREE_SYSROOT_CLEANUP_ALL;

return _ostree_sysroot_piecemeal_cleanup (self, flags, cancellable, error);
return _ostree_sysroot_cleanup_internal (self, TRUE, cancellable, error);
}

/**
Expand All @@ -537,55 +532,41 @@ ostree_sysroot_prepare_cleanup (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
OstreeSysrootCleanupFlags flags;

/* 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);
return _ostree_sysroot_cleanup_internal (self, FALSE, cancellable, error);
}

gboolean
_ostree_sysroot_piecemeal_cleanup (OstreeSysroot *self,
OstreeSysrootCleanupFlags flags,
GCancellable *cancellable,
GError **error)
_ostree_sysroot_cleanup_internal (OstreeSysroot *self,
gboolean do_prune_repo,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object OstreeRepo *repo = NULL;

g_return_val_if_fail (OSTREE_IS_SYSROOT (self), FALSE);
g_return_val_if_fail (self->loaded, FALSE);

if (flags & OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS)
{
if (!cleanup_other_bootversions (self, cancellable, error))
goto out;
}
if (!cleanup_other_bootversions (self, cancellable, error))
return FALSE;

if (flags & OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS)
{
if (!cleanup_old_deployments (self, cancellable, error))
goto out;
}
if (!cleanup_old_deployments (self, cancellable, error))
return FALSE;

if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
goto out;
return FALSE;

if (!generate_deployment_refs (self, repo,
self->bootversion,
self->subbootversion,
self->deployments,
cancellable, error))
goto out;
if (flags & OSTREE_SYSROOT_CLEANUP_PRUNE_REPO)
return FALSE;

if (do_prune_repo)
{
if (!prune_repo (repo, cancellable, error))
goto out;
return FALSE;
}

ret = TRUE;
out:
return ret;
return TRUE;
}
15 changes: 8 additions & 7 deletions src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1730,14 +1730,13 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
GError **error)
{
return _ostree_sysroot_write_deployments_internal (self, new_deployments,
OSTREE_SYSROOT_CLEANUP_ALL,
cancellable, error);
TRUE, cancellable, error);
}

gboolean
_ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
GPtrArray *new_deployments,
OstreeSysrootCleanupFlags cleanup_flags,
gboolean do_clean,
GCancellable *cancellable,
GError **error)
{
Expand Down Expand Up @@ -1965,11 +1964,13 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,

/* And finally, cleanup of any leftover data.
*/
if (!_ostree_sysroot_piecemeal_cleanup (self, cleanup_flags,
cancellable, error))
if (do_clean)
{
g_prefix_error (error, "Performing final cleanup: ");
goto out;
if (!ostree_sysroot_cleanup (self, cancellable, error))
{
g_prefix_error (error, "Performing final cleanup: ");
goto out;
}
}

ret = TRUE;
Expand Down
17 changes: 5 additions & 12 deletions src/libostree/ostree-sysroot-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,14 @@ gboolean _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
gboolean _ostree_sysroot_bump_mtime (OstreeSysroot *sysroot,
GError **error);

typedef enum {
OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS = 1 << 0,
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,
GError **error);
gboolean _ostree_sysroot_cleanup_internal (OstreeSysroot *sysroot,
gboolean prune_repo,
GCancellable *cancellable,
GError **error);

gboolean _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
GPtrArray *new_deployments,
OstreeSysrootCleanupFlags cleanup_flags,
gboolean do_clean,
GCancellable *cancellable,
GError **error);

Expand Down
3 changes: 1 addition & 2 deletions src/libostree/ostree-sysroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,8 +1604,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
}

if (!_ostree_sysroot_write_deployments_internal (sysroot, new_deployments,
postclean ? OSTREE_SYSROOT_CLEANUP_ALL : 0,
cancellable, error))
postclean, cancellable, error))
goto out;

ret = TRUE;
Expand Down