mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 02:26:26 +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
|
||||
|
||||
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
|
||||
_show_device_ids
|
||||
else
|
||||
|
@ -109,7 +109,7 @@ _fwupdtool()
|
||||
_show_modifiers
|
||||
fi
|
||||
;;
|
||||
attach|detach|activate|verify-update|reinstall)
|
||||
attach|detach|activate|verify-update|reinstall|get-updates)
|
||||
if [[ "$prev" = "$command" ]]; then
|
||||
_show_device_ids
|
||||
#modifiers
|
||||
|
@ -328,10 +328,26 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
return FALSE;
|
||||
title = fu_util_get_tree_title (priv);
|
||||
|
||||
/* get devices from daemon */
|
||||
devices = fu_engine_get_devices (priv->engine, error);
|
||||
if (devices == NULL)
|
||||
/* parse arguments */
|
||||
if (g_strv_length (values) == 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
fwupd_device_array_ensure_parents (devices);
|
||||
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
||||
for (guint i = 0; i < devices->len; i++) {
|
||||
@ -2499,7 +2515,7 @@ main (int argc, char *argv[])
|
||||
fu_util_get_history);
|
||||
fu_util_cmd_array_add (cmd_array,
|
||||
"get-updates,get-upgrades",
|
||||
NULL,
|
||||
"[DEVICE-ID|GUID]",
|
||||
/* TRANSLATORS: command description */
|
||||
_("Gets the list of updates for connected hardware"),
|
||||
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))
|
||||
return FALSE;
|
||||
|
||||
/* get devices from daemon */
|
||||
devices = fwupd_client_get_devices (priv->client, NULL, error);
|
||||
if (devices == NULL)
|
||||
/* handle both forms */
|
||||
if (g_strv_length (values) == 0) {
|
||||
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;
|
||||
}
|
||||
g_ptr_array_sort (devices, fu_util_sort_devices_by_flags_cb);
|
||||
for (guint i = 0; i < devices->len; i++) {
|
||||
FwupdDevice *dev = g_ptr_array_index (devices, i);
|
||||
@ -2601,7 +2618,7 @@ main (int argc, char *argv[])
|
||||
fu_util_get_details);
|
||||
fu_util_cmd_array_add (cmd_array,
|
||||
"get-updates,get-upgrades",
|
||||
NULL,
|
||||
"[DEVICE-ID|GUID]",
|
||||
/* TRANSLATORS: command description */
|
||||
_("Gets the list of updates for connected hardware"),
|
||||
fu_util_get_updates);
|
||||
|
Loading…
Reference in New Issue
Block a user