mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 21:36:16 +00:00
Allow to filter get-updates on device-id
This change allows to get available updates for a given device. This is similar to what is done for the update and activate commands.
This commit is contained in:
parent
c53940e7d7
commit
9fbd7fe65d
@ -98,7 +98,7 @@ _fwupdmgr()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case $command in
|
case $command in
|
||||||
activate|clear-results|downgrade|get-releases|get-results|unlock|verify|verify-update)
|
activate|clear-results|downgrade|get-releases|get-results|unlock|verify|verify-update|get-updates)
|
||||||
if [[ "$prev" = "$command" ]]; then
|
if [[ "$prev" = "$command" ]]; then
|
||||||
_show_device_ids
|
_show_device_ids
|
||||||
else
|
else
|
||||||
|
@ -109,7 +109,7 @@ _fwupdtool()
|
|||||||
_show_modifiers
|
_show_modifiers
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
attach|detach|activate|verify-update|reinstall)
|
attach|detach|activate|verify-update|reinstall|get-updates)
|
||||||
if [[ "$prev" = "$command" ]]; then
|
if [[ "$prev" = "$command" ]]; then
|
||||||
_show_device_ids
|
_show_device_ids
|
||||||
#modifiers
|
#modifiers
|
||||||
|
@ -328,10 +328,26 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
title = fu_util_get_tree_title (priv);
|
title = fu_util_get_tree_title (priv);
|
||||||
|
|
||||||
/* get devices from daemon */
|
/* parse arguments */
|
||||||
devices = fu_engine_get_devices (priv->engine, error);
|
if (g_strv_length (values) == 0) {
|
||||||
if (devices == NULL)
|
devices = fu_engine_get_devices (priv->engine, error);
|
||||||
|
if (devices == NULL)
|
||||||
|
return FALSE;
|
||||||
|
} else if (g_strv_length (values) == 1) {
|
||||||
|
FuDevice *device;
|
||||||
|
device = fu_engine_get_device_by_id (priv->engine, values[0], error);
|
||||||
|
if (device == NULL)
|
||||||
|
return FALSE;
|
||||||
|
devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||||
|
g_ptr_array_add (devices, device);
|
||||||
|
} else {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid arguments");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
fwupd_device_array_ensure_parents (devices);
|
fwupd_device_array_ensure_parents (devices);
|
||||||
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
for (guint i = 0; i < devices->len; i++) {
|
||||||
@ -2499,7 +2515,7 @@ main (int argc, char *argv[])
|
|||||||
fu_util_get_history);
|
fu_util_get_history);
|
||||||
fu_util_cmd_array_add (cmd_array,
|
fu_util_cmd_array_add (cmd_array,
|
||||||
"get-updates,get-upgrades",
|
"get-updates,get-upgrades",
|
||||||
NULL,
|
"[DEVICE-ID|GUID]",
|
||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Gets the list of updates for connected hardware"),
|
_("Gets the list of updates for connected hardware"),
|
||||||
fu_util_get_updates);
|
fu_util_get_updates);
|
||||||
|
@ -1376,10 +1376,27 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
if (!fu_util_perhaps_refresh_remotes (priv, error))
|
if (!fu_util_perhaps_refresh_remotes (priv, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* get devices from daemon */
|
/* handle both forms */
|
||||||
devices = fwupd_client_get_devices (priv->client, NULL, error);
|
if (g_strv_length (values) == 0) {
|
||||||
if (devices == NULL)
|
devices = fwupd_client_get_devices (priv->client, NULL, error);
|
||||||
|
if (devices == NULL)
|
||||||
|
return FALSE;
|
||||||
|
} else if (g_strv_length (values) == 1) {
|
||||||
|
FwupdDevice *device = fwupd_client_get_device_by_id (priv->client,
|
||||||
|
values[0],
|
||||||
|
NULL,
|
||||||
|
error);
|
||||||
|
if (device == NULL)
|
||||||
|
return FALSE;
|
||||||
|
devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||||
|
g_ptr_array_add (devices, device);
|
||||||
|
} else {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid arguments");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
for (guint i = 0; i < devices->len; i++) {
|
||||||
FwupdDevice *dev = g_ptr_array_index (devices, i);
|
FwupdDevice *dev = g_ptr_array_index (devices, i);
|
||||||
@ -2601,7 +2618,7 @@ main (int argc, char *argv[])
|
|||||||
fu_util_get_details);
|
fu_util_get_details);
|
||||||
fu_util_cmd_array_add (cmd_array,
|
fu_util_cmd_array_add (cmd_array,
|
||||||
"get-updates,get-upgrades",
|
"get-updates,get-upgrades",
|
||||||
NULL,
|
"[DEVICE-ID|GUID]",
|
||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Gets the list of updates for connected hardware"),
|
_("Gets the list of updates for connected hardware"),
|
||||||
fu_util_get_updates);
|
fu_util_get_updates);
|
||||||
|
Loading…
Reference in New Issue
Block a user