delta: Add --if-not-exists option

I often want to have "idempotent" systems that iterate to a known
state.  If after generating a commit, the system is interrupted, I'd
like the next run to still generate a delta.  But we don't want to
regenerate if one exists, hence this option.

Closes: #375
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2016-07-04 13:27:06 +00:00
1 parent 8933c93a55
commit 0d07c7ecde
6 files changed
+66 -1

No files matched your search

+1
View File
@@ -47,6 +47,7 @@ ostree_cmd__private__ (void)
static OstreeCmdPrivateVTable table = {
impl_ostree_generate_grub2_config,
_ostree_repo_static_delta_dump,
_ostree_repo_static_delta_query_exists,
_ostree_repo_static_delta_delete
};
+1
View File
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
typedef struct {
gboolean (* ostree_generate_grub2_config) (OstreeSysroot *sysroot, int bootversion, int target_fd, GCancellable *cancellable, GError **error);
gboolean (* ostree_static_delta_dump) (OstreeRepo *repo, const char *delta_id, GCancellable *cancellable, GError **error);
gboolean (* ostree_static_delta_query_exists) (OstreeRepo *repo, const char *delta_id, gboolean *out_exists, GCancellable *cancellable, GError **error);
gboolean (* ostree_static_delta_delete) (OstreeRepo *repo, const char *delta_id, GCancellable *cancellable, GError **error);
} OstreeCmdPrivateVTable;
@@ -819,6 +819,39 @@ _ostree_repo_static_delta_delete (OstreeRepo *self,
return ret;
}
gboolean
_ostree_repo_static_delta_query_exists (OstreeRepo *self,
const char *delta_id,
gboolean *out_exists,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
g_autofree char *from = NULL;
g_autofree char *to = NULL;
g_autofree char *superblock_path = NULL;
struct stat stbuf;
_ostree_parse_delta_name (delta_id, &from, &to);
superblock_path = _ostree_get_relative_static_delta_superblock_path (from, to);
if (fstatat (self->repo_dir_fd, superblock_path, &stbuf, 0) < 0)
{
if (errno == ENOENT)
{
*out_exists = FALSE;
return TRUE;
}
else
{
glnx_set_error_from_errno (error);
return FALSE;
}
}
*out_exists = TRUE;
return TRUE;
}
gboolean
_ostree_repo_static_delta_dump (OstreeRepo *self,
const char *delta_id,
@@ -190,6 +190,13 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
GCancellable *cancellable,
GError **error);
gboolean
_ostree_repo_static_delta_query_exists (OstreeRepo *repo,
const char *delta_id,
gboolean *out_exists,
GCancellable *cancellable,
GError **error);
gboolean
_ostree_repo_static_delta_dump (OstreeRepo *repo,
const char *delta_id,