Add support for ostree static-delta delete
Closes: #245 Approved by: giuseppe
This commit is contained in:
parent
8ff9a48ce3
commit
ddda8e5b8b
|
|
@ -51,6 +51,12 @@ Boston, MA 02111-1307, USA.
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>ostree static-delta list</command>
|
<command>ostree static-delta list</command>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>ostree static-delta show</command>
|
||||||
|
</cmdsynopsis>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>ostree static-delta delete</command>
|
||||||
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>ostree static-delta generate</command> <arg choice="req">--to=REV</arg> <arg choice="opt" rep="repeat">OPTIONS</arg>
|
<command>ostree static-delta generate</command> <arg choice="req">--to=REV</arg> <arg choice="opt" rep="repeat">OPTIONS</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ ostree_cmd__private__ (void)
|
||||||
{
|
{
|
||||||
static OstreeCmdPrivateVTable table = {
|
static OstreeCmdPrivateVTable table = {
|
||||||
impl_ostree_generate_grub2_config,
|
impl_ostree_generate_grub2_config,
|
||||||
_ostree_repo_static_delta_dump
|
_ostree_repo_static_delta_dump,
|
||||||
|
_ostree_repo_static_delta_delete
|
||||||
};
|
};
|
||||||
|
|
||||||
return &table;
|
return &table;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ G_BEGIN_DECLS
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean (* ostree_generate_grub2_config) (OstreeSysroot *sysroot, int bootversion, int target_fd, GCancellable *cancellable, GError **error);
|
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_dump) (OstreeRepo *repo, const char *delta_id, GCancellable *cancellable, GError **error);
|
||||||
|
gboolean (* ostree_static_delta_delete) (OstreeRepo *repo, const char *delta_id, GCancellable *cancellable, GError **error);
|
||||||
} OstreeCmdPrivateVTable;
|
} OstreeCmdPrivateVTable;
|
||||||
|
|
||||||
/* Note this not really "public", we just export the symbol, but not the header */
|
/* Note this not really "public", we just export the symbol, but not the header */
|
||||||
|
|
|
||||||
|
|
@ -782,6 +782,41 @@ _ostree_delta_needs_byteswap (GVariant *superblock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_ostree_repo_static_delta_delete (OstreeRepo *self,
|
||||||
|
const char *delta_id,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
g_autofree char *from = NULL;
|
||||||
|
g_autofree char *to = NULL;
|
||||||
|
g_autofree char *deltadir = NULL;
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
|
_ostree_parse_delta_name (delta_id, &from, &to);
|
||||||
|
deltadir = _ostree_get_relative_static_delta_path (from, to, NULL);
|
||||||
|
|
||||||
|
if (fstatat (self->repo_dir_fd, deltadir, &buf, 0) != 0)
|
||||||
|
{
|
||||||
|
if (errno == ENOENT)
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
|
"Can't find delta %s", delta_id);
|
||||||
|
else
|
||||||
|
glnx_set_error_from_errno (error);
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!glnx_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
|
||||||
|
cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_ostree_repo_static_delta_dump (OstreeRepo *self,
|
_ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
const char *delta_id,
|
const char *delta_id,
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,12 @@ _ostree_repo_static_delta_dump (OstreeRepo *repo,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_ostree_repo_static_delta_delete (OstreeRepo *repo,
|
||||||
|
const char *delta_id,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* Used for static deltas which due to a historical mistake are
|
/* Used for static deltas which due to a historical mistake are
|
||||||
* inconsistent endian.
|
* inconsistent endian.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ static gboolean opt_disable_bsdiff;
|
||||||
|
|
||||||
BUILTINPROTO(list);
|
BUILTINPROTO(list);
|
||||||
BUILTINPROTO(show);
|
BUILTINPROTO(show);
|
||||||
|
BUILTINPROTO(delete);
|
||||||
BUILTINPROTO(generate);
|
BUILTINPROTO(generate);
|
||||||
BUILTINPROTO(apply_offline);
|
BUILTINPROTO(apply_offline);
|
||||||
|
|
||||||
|
|
@ -50,6 +51,7 @@ BUILTINPROTO(apply_offline);
|
||||||
static OstreeCommand static_delta_subcommands[] = {
|
static OstreeCommand static_delta_subcommands[] = {
|
||||||
{ "list", ot_static_delta_builtin_list },
|
{ "list", ot_static_delta_builtin_list },
|
||||||
{ "show", ot_static_delta_builtin_show },
|
{ "show", ot_static_delta_builtin_show },
|
||||||
|
{ "delete", ot_static_delta_builtin_delete },
|
||||||
{ "generate", ot_static_delta_builtin_generate },
|
{ "generate", ot_static_delta_builtin_generate },
|
||||||
{ "apply-offline", ot_static_delta_builtin_apply_offline },
|
{ "apply-offline", ot_static_delta_builtin_apply_offline },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
|
@ -168,6 +170,39 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
GOptionContext *context;
|
||||||
|
glnx_unref_object OstreeRepo *repo = NULL;
|
||||||
|
const char *delta_id = NULL;
|
||||||
|
|
||||||
|
context = g_option_context_new ("DELETE - Remove a delta");
|
||||||
|
|
||||||
|
if (!ostree_option_context_parse (context, list_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"DELTA must be specified");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
delta_id = argv[2];
|
||||||
|
|
||||||
|
if (!ostree_cmd__private__ ()->ostree_static_delta_delete (repo, delta_id, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
out:
|
||||||
|
if (context)
|
||||||
|
g_option_context_free (context);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
|
ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ skip_without_user_xattrs
|
||||||
bindatafiles="bash true ostree"
|
bindatafiles="bash true ostree"
|
||||||
morebindatafiles="false ls"
|
morebindatafiles="false ls"
|
||||||
|
|
||||||
echo '1..7'
|
echo '1..8'
|
||||||
|
|
||||||
mkdir repo
|
mkdir repo
|
||||||
${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
|
${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
|
||||||
|
|
@ -186,3 +186,18 @@ ${CMD_PREFIX} ostree --repo=repo2 fsck
|
||||||
${CMD_PREFIX} ostree --repo=repo2 ls ${newrev} >/dev/null
|
${CMD_PREFIX} ostree --repo=repo2 ls ${newrev} >/dev/null
|
||||||
|
|
||||||
echo 'ok apply offline inline'
|
echo 'ok apply offline inline'
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}-${newrev}$ || exit 1
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}$ || exit 1
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta delete ${origrev} || exit 1
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}-${newrev}$ || exit 1
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}$ && exit 1
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta delete ${origrev}-${newrev} || exit 1
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}-${newrev}$ && exit 1
|
||||||
|
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ^${origrev}$ && exit 1
|
||||||
|
|
||||||
|
echo 'ok delete'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue