mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 12:25:38 +00:00
Change the DBus method for installing firmware to 'Install'
It seems a little odd to call it 'Update' when it's being used for downgrading and reinstalling as well. As we're making things simpler, just use a single 'install' action in fwupdmgr rather than 'install', 'update-online', 'update-offline'. We can use the flags and fallbacks to do the right thing in all cases, and make the typical case (installing a local file to any matching hardware) simple. Fixes half of https://github.com/hughsie/fwupd/pull/23
This commit is contained in:
parent
7708a0f3fd
commit
63a407ab34
@ -6,7 +6,7 @@ SUBDIRS = \
|
|||||||
libfwupd \
|
libfwupd \
|
||||||
po \
|
po \
|
||||||
data \
|
data \
|
||||||
man \
|
docs \
|
||||||
policy \
|
policy \
|
||||||
src
|
src
|
||||||
|
|
||||||
|
@ -184,10 +184,11 @@ Makefile
|
|||||||
libfwupd/fwupd-version.h
|
libfwupd/fwupd-version.h
|
||||||
libfwupd/fwupd.pc
|
libfwupd/fwupd.pc
|
||||||
libfwupd/Makefile
|
libfwupd/Makefile
|
||||||
man/Makefile
|
|
||||||
data/Makefile
|
data/Makefile
|
||||||
data/pki/Makefile
|
data/pki/Makefile
|
||||||
data/tests/Makefile
|
data/tests/Makefile
|
||||||
|
docs/Makefile
|
||||||
|
docs/man/Makefile
|
||||||
policy/Makefile
|
policy/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
src/Makefile
|
src/Makefile
|
||||||
|
4
docs/Makefile.am
Normal file
4
docs/Makefile.am
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
SUBDIRS = \
|
||||||
|
man
|
||||||
|
|
||||||
|
-include $(top_srcdir)/git.mk
|
@ -70,10 +70,26 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--force</option>
|
<option>--allow-reinstall</option>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Force the installation of firmware.</para>
|
<para>Allow re-installing existing firmware versions.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>--allow-older</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Allow downgrading firmware versions.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>--offline</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Perform the installation offline where possible.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
@ -118,27 +134,7 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>update-offline</option>
|
<option>install-prepared</option>
|
||||||
<parameter>guid</parameter>
|
|
||||||
<parameter>filename</parameter>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>Install the update the next time the computer is rebooted.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<option>update-online</option>
|
|
||||||
<parameter>guid</parameter>
|
|
||||||
<parameter>filename</parameter>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>Install the update now, if possible.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<option>update-prepared</option>
|
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Install prepared updates now.</para>
|
<para>Install prepared updates now.</para>
|
@ -935,7 +935,7 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return '' */
|
/* return '' */
|
||||||
if (g_strcmp0 (method_name, "Update") == 0) {
|
if (g_strcmp0 (method_name, "Install") == 0) {
|
||||||
FuDeviceItem *item = NULL;
|
FuDeviceItem *item = NULL;
|
||||||
FuMainAuthHelper *helper;
|
FuMainAuthHelper *helper;
|
||||||
FuProviderFlags flags = FU_PROVIDER_UPDATE_FLAG_NONE;
|
FuProviderFlags flags = FU_PROVIDER_UPDATE_FLAG_NONE;
|
||||||
@ -1412,7 +1412,7 @@ main (int argc, char *argv[])
|
|||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
/* TRANSLATORS: program name */
|
/* TRANSLATORS: program name */
|
||||||
g_set_application_name (_("Firmware Update"));
|
g_set_application_name (_("Firmware Update Daemon"));
|
||||||
context = g_option_context_new (NULL);
|
context = g_option_context_new (NULL);
|
||||||
g_option_context_add_main_entries (context, options, NULL);
|
g_option_context_add_main_entries (context, options, NULL);
|
||||||
g_option_context_add_group (context, fu_debug_get_option_group ());
|
g_option_context_add_group (context, fu_debug_get_option_group ());
|
||||||
|
116
src/fu-util.c
116
src/fu-util.c
@ -419,11 +419,11 @@ fu_util_update_cb (GObject *source_object, GAsyncResult *res, gpointer user_data
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_util_update:
|
* fu_util_install_internal:
|
||||||
**/
|
**/
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_update (FuUtilPrivate *priv, const gchar *id, const gchar *filename,
|
fu_util_install_internal (FuUtilPrivate *priv, const gchar *id,
|
||||||
FuProviderFlags flags, GError **error)
|
const gchar *filename, GError **error)
|
||||||
{
|
{
|
||||||
GVariant *body;
|
GVariant *body;
|
||||||
GVariantBuilder builder;
|
GVariantBuilder builder;
|
||||||
@ -438,15 +438,15 @@ fu_util_update (FuUtilPrivate *priv, const gchar *id, const gchar *filename,
|
|||||||
"reason", g_variant_new_string ("user-action"));
|
"reason", g_variant_new_string ("user-action"));
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
"filename", g_variant_new_string (filename));
|
"filename", g_variant_new_string (filename));
|
||||||
if (flags & FU_PROVIDER_UPDATE_FLAG_OFFLINE) {
|
if (priv->flags & FU_PROVIDER_UPDATE_FLAG_OFFLINE) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
"offline", g_variant_new_boolean (TRUE));
|
"offline", g_variant_new_boolean (TRUE));
|
||||||
}
|
}
|
||||||
if (flags & FU_PROVIDER_UPDATE_FLAG_ALLOW_OLDER) {
|
if (priv->flags & FU_PROVIDER_UPDATE_FLAG_ALLOW_OLDER) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
"allow-older", g_variant_new_boolean (TRUE));
|
"allow-older", g_variant_new_boolean (TRUE));
|
||||||
}
|
}
|
||||||
if (flags & FU_PROVIDER_UPDATE_FLAG_ALLOW_REINSTALL) {
|
if (priv->flags & FU_PROVIDER_UPDATE_FLAG_ALLOW_REINSTALL) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
"allow-reinstall", g_variant_new_boolean (TRUE));
|
"allow-reinstall", g_variant_new_boolean (TRUE));
|
||||||
}
|
}
|
||||||
@ -469,7 +469,7 @@ fu_util_update (FuUtilPrivate *priv, const gchar *id, const gchar *filename,
|
|||||||
request = g_dbus_message_new_method_call (FWUPD_DBUS_SERVICE,
|
request = g_dbus_message_new_method_call (FWUPD_DBUS_SERVICE,
|
||||||
FWUPD_DBUS_PATH,
|
FWUPD_DBUS_PATH,
|
||||||
FWUPD_DBUS_INTERFACE,
|
FWUPD_DBUS_INTERFACE,
|
||||||
"Update");
|
"Install");
|
||||||
g_dbus_message_set_unix_fd_list (request, fd_list);
|
g_dbus_message_set_unix_fd_list (request, fd_list);
|
||||||
|
|
||||||
/* g_unix_fd_list_append did a dup() already */
|
/* g_unix_fd_list_append did a dup() already */
|
||||||
@ -501,38 +501,28 @@ fu_util_update (FuUtilPrivate *priv, const gchar *id, const gchar *filename,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* fu_util_update_online:
|
|
||||||
**/
|
|
||||||
static gboolean
|
|
||||||
fu_util_update_online (FuUtilPrivate *priv, gchar **values, GError **error)
|
|
||||||
{
|
|
||||||
if (g_strv_length (values) != 2) {
|
|
||||||
g_set_error_literal (error,
|
|
||||||
FWUPD_ERROR,
|
|
||||||
FWUPD_ERROR_INTERNAL,
|
|
||||||
"Invalid arguments: expected 'id' 'filename'");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return fu_util_update (priv, values[0], values[1],
|
|
||||||
priv->flags, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_util_install:
|
* fu_util_install:
|
||||||
**/
|
**/
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error)
|
fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
if (g_strv_length (values) != 1) {
|
const gchar *id;
|
||||||
|
|
||||||
|
/* handle both forms */
|
||||||
|
if (g_strv_length (values) == 1) {
|
||||||
|
id = FWUPD_DEVICE_ID_ANY;
|
||||||
|
} else if (g_strv_length (values) == 2) {
|
||||||
|
id = values[1];
|
||||||
|
} else {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INTERNAL,
|
FWUPD_ERROR_INTERNAL,
|
||||||
"Invalid arguments: expected 'filename'");
|
"Invalid arguments: expected 'filename' [id]");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return fu_util_update (priv, FWUPD_DEVICE_ID_ANY,
|
|
||||||
values[0], priv->flags, error);
|
return fu_util_install_internal (priv, id, values[0], error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -668,10 +658,10 @@ fu_util_offline_update_reboot (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_util_update_prepared:
|
* fu_util_install_prepared:
|
||||||
**/
|
**/
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_update_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
gint vercmp;
|
gint vercmp;
|
||||||
guint cnt = 0;
|
guint cnt = 0;
|
||||||
@ -743,10 +733,10 @@ fu_util_update_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
fu_device_get_metadata (device, FU_DEVICE_KEY_VERSION_OLD),
|
fu_device_get_metadata (device, FU_DEVICE_KEY_VERSION_OLD),
|
||||||
fu_device_get_metadata (device, FU_DEVICE_KEY_VERSION_NEW));
|
fu_device_get_metadata (device, FU_DEVICE_KEY_VERSION_NEW));
|
||||||
}
|
}
|
||||||
if (!fu_util_update (priv,
|
if (!fu_util_install_internal (priv,
|
||||||
fu_device_get_id (device),
|
fu_device_get_id (device),
|
||||||
fu_device_get_metadata (device, FU_DEVICE_KEY_FILENAME_CAB),
|
fu_device_get_metadata (device, FU_DEVICE_KEY_FILENAME_CAB),
|
||||||
priv->flags, error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
@ -767,24 +757,6 @@ fu_util_update_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* fu_util_update_offline:
|
|
||||||
**/
|
|
||||||
static gboolean
|
|
||||||
fu_util_update_offline (FuUtilPrivate *priv, gchar **values, GError **error)
|
|
||||||
{
|
|
||||||
if (g_strv_length (values) != 2) {
|
|
||||||
g_set_error_literal (error,
|
|
||||||
FWUPD_ERROR,
|
|
||||||
FWUPD_ERROR_INTERNAL,
|
|
||||||
"Invalid arguments: expected 'id' 'filename'");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return fu_util_update (priv, values[0], values[1],
|
|
||||||
priv->flags | FU_PROVIDER_UPDATE_FLAG_OFFLINE,
|
|
||||||
error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_util_clear_results:
|
* fu_util_clear_results:
|
||||||
**/
|
**/
|
||||||
@ -1335,8 +1307,10 @@ int
|
|||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FuUtilPrivate *priv;
|
FuUtilPrivate *priv;
|
||||||
|
gboolean allow_older = FALSE;
|
||||||
|
gboolean allow_reinstall = FALSE;
|
||||||
|
gboolean offline = FALSE;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
gboolean force = FALSE;
|
|
||||||
gboolean verbose = FALSE;
|
gboolean verbose = FALSE;
|
||||||
guint retval = 1;
|
guint retval = 1;
|
||||||
_cleanup_error_free_ GError *error = NULL;
|
_cleanup_error_free_ GError *error = NULL;
|
||||||
@ -1345,9 +1319,15 @@ main (int argc, char *argv[])
|
|||||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||||
/* TRANSLATORS: command line option */
|
/* TRANSLATORS: command line option */
|
||||||
_("Show extra debugging information"), NULL },
|
_("Show extra debugging information"), NULL },
|
||||||
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force,
|
{ "offline", '\0', 0, G_OPTION_ARG_NONE, &offline,
|
||||||
/* TRANSLATORS: command line option */
|
/* TRANSLATORS: command line option */
|
||||||
_("Force the installation of firmware"), NULL },
|
_("Perform the installation offline where possible"), NULL },
|
||||||
|
{ "allow-reinstall", '\0', 0, G_OPTION_ARG_NONE, &allow_reinstall,
|
||||||
|
/* TRANSLATORS: command line option */
|
||||||
|
_("Allow re-installing existing firmware versions"), NULL },
|
||||||
|
{ "allow-older", '\0', 0, G_OPTION_ARG_NONE, &allow_older,
|
||||||
|
/* TRANSLATORS: command line option */
|
||||||
|
_("Allow downgrading firmware versions"), NULL },
|
||||||
{ NULL}
|
{ NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1370,23 +1350,11 @@ main (int argc, char *argv[])
|
|||||||
_("Get all devices that support firmware updates"),
|
_("Get all devices that support firmware updates"),
|
||||||
fu_util_get_devices);
|
fu_util_get_devices);
|
||||||
fu_util_add (priv->cmd_array,
|
fu_util_add (priv->cmd_array,
|
||||||
"update-offline",
|
"install-prepared",
|
||||||
NULL,
|
|
||||||
/* TRANSLATORS: command description */
|
|
||||||
_("Install the update the next time the computer is rebooted"),
|
|
||||||
fu_util_update_offline);
|
|
||||||
fu_util_add (priv->cmd_array,
|
|
||||||
"update-online",
|
|
||||||
NULL,
|
|
||||||
/* TRANSLATORS: command description */
|
|
||||||
_("Install the update now"),
|
|
||||||
fu_util_update_online);
|
|
||||||
fu_util_add (priv->cmd_array,
|
|
||||||
"update-prepared",
|
|
||||||
NULL,
|
NULL,
|
||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Install prepared updates now"),
|
_("Install prepared updates now"),
|
||||||
fu_util_update_prepared);
|
fu_util_install_prepared);
|
||||||
fu_util_add (priv->cmd_array,
|
fu_util_add (priv->cmd_array,
|
||||||
"install",
|
"install",
|
||||||
NULL,
|
NULL,
|
||||||
@ -1452,7 +1420,7 @@ main (int argc, char *argv[])
|
|||||||
g_option_context_set_summary (priv->context, cmd_descriptions);
|
g_option_context_set_summary (priv->context, cmd_descriptions);
|
||||||
|
|
||||||
/* TRANSLATORS: program name */
|
/* TRANSLATORS: program name */
|
||||||
g_set_application_name (_("Firmware Update"));
|
g_set_application_name (_("Firmware Utility"));
|
||||||
g_option_context_add_main_entries (priv->context, options, NULL);
|
g_option_context_add_main_entries (priv->context, options, NULL);
|
||||||
ret = g_option_context_parse (priv->context, &argc, &argv, &error);
|
ret = g_option_context_parse (priv->context, &argc, &argv, &error);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@ -1470,11 +1438,13 @@ main (int argc, char *argv[])
|
|||||||
fu_util_ignore_cb, NULL);
|
fu_util_ignore_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we're feeling naughty */
|
/* set flags */
|
||||||
if (force) {
|
if (offline)
|
||||||
priv->flags = FU_PROVIDER_UPDATE_FLAG_ALLOW_REINSTALL |
|
priv->flags |= FU_PROVIDER_UPDATE_FLAG_OFFLINE;
|
||||||
FU_PROVIDER_UPDATE_FLAG_ALLOW_OLDER;
|
if (allow_reinstall)
|
||||||
}
|
priv->flags |= FU_PROVIDER_UPDATE_FLAG_ALLOW_REINSTALL;
|
||||||
|
if (allow_older)
|
||||||
|
priv->flags |= FU_PROVIDER_UPDATE_FLAG_ALLOW_OLDER;
|
||||||
|
|
||||||
/* connect to the daemon */
|
/* connect to the daemon */
|
||||||
priv->conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
priv->conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
Gets a list of all the devices that support UEFI firmware upgrading.
|
Gets a list of all the devices that are supported.
|
||||||
</doc:para>
|
</doc:para>
|
||||||
</doc:description>
|
</doc:description>
|
||||||
</doc:doc>
|
</doc:doc>
|
||||||
@ -101,11 +101,11 @@
|
|||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!--***********************************************************-->
|
<!--***********************************************************-->
|
||||||
<method name='Update'>
|
<method name='Install'>
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
Schedules an update to be done offline.
|
Schedules a firmware to be installed.
|
||||||
</doc:para>
|
</doc:para>
|
||||||
</doc:description>
|
</doc:description>
|
||||||
</doc:doc>
|
</doc:doc>
|
||||||
|
Loading…
Reference in New Issue
Block a user