mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
admin: allow multiple args for pin subcommand
Fixes #1816 Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com> Closes: #1874 Approved by: rfairley
This commit is contained in:
parent
d916383953
commit
2db79fb398
@ -52,24 +52,39 @@ ot_admin_builtin_pin (int argc, char **argv, OstreeCommandInvocation *invocation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char *deploy_index_str = argv[1];
|
||||
const int deploy_index = atoi (deploy_index_str);
|
||||
|
||||
g_autoptr(OstreeDeployment) target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
|
||||
if (!target_deployment)
|
||||
return FALSE;
|
||||
|
||||
|
||||
gboolean current_pin = ostree_deployment_is_pinned (target_deployment);
|
||||
const gboolean desired_pin = !opt_unpin;
|
||||
if (current_pin == desired_pin)
|
||||
g_print ("Deployment is already %s\n", current_pin ? "pinned" : "unpinned");
|
||||
else
|
||||
unsigned int nsuccess = 0;
|
||||
for (unsigned int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin, error))
|
||||
return FALSE;
|
||||
g_print ("Deployment is now %s\n", desired_pin ? "pinned" : "unpinned");
|
||||
const char *deploy_index_str = argv[i];
|
||||
const int deploy_index = atoi (deploy_index_str);
|
||||
|
||||
g_autoptr(GError) e = NULL;
|
||||
g_autoptr(OstreeDeployment) target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, &e);
|
||||
if (!target_deployment)
|
||||
{
|
||||
g_print ("Invalid deployment %s: %s\n", deploy_index_str, e->message);
|
||||
continue;
|
||||
}
|
||||
|
||||
gboolean current_pin = ostree_deployment_is_pinned (target_deployment);
|
||||
const gboolean desired_pin = !opt_unpin;
|
||||
if (current_pin == desired_pin)
|
||||
{
|
||||
g_print ("Deployment %s is already %s\n", deploy_index_str, current_pin ? "pinned" : "unpinned");
|
||||
nsuccess++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autoptr(GError) e = NULL;
|
||||
if (ostree_sysroot_deployment_set_pinned (sysroot, target_deployment, desired_pin, &e))
|
||||
{
|
||||
g_print ("Deployment %s is now %s\n", deploy_index_str, desired_pin ? "pinned" : "unpinned");
|
||||
nsuccess++;
|
||||
}
|
||||
else
|
||||
g_print ("Failed to %s deployment %s: %s\n", desired_pin ? "pin" : "unpin", deploy_index_str, e->message);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return nsuccess > 0;
|
||||
}
|
||||
|
@ -102,8 +102,7 @@ ${CMD_PREFIX} ostree admin pin -u 0
|
||||
assert_n_pinned 0
|
||||
echo "ok pin unpin"
|
||||
|
||||
${CMD_PREFIX} ostree admin pin 0
|
||||
${CMD_PREFIX} ostree admin pin 1
|
||||
${CMD_PREFIX} ostree admin pin 0 1
|
||||
assert_n_pinned 2
|
||||
assert_n_deployments 2
|
||||
os_repository_new_commit
|
||||
|
Loading…
Reference in New Issue
Block a user