mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 09:00:55 +00:00
Allow running offline updates when in system-update.target
This commit is contained in:
parent
3dbacdf541
commit
f517c9aa09
@ -1467,8 +1467,9 @@ fu_engine_install (FuEngine *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* just schedule this for the next reboot */
|
||||
if (flags & FWUPD_INSTALL_FLAG_OFFLINE)
|
||||
/* schedule this for the next reboot if not in system-update.target */
|
||||
if ((self->app_flags & FU_ENGINE_LOAD_FLAG_IS_OFFLINE) == 0 &&
|
||||
(flags & FWUPD_INSTALL_FLAG_OFFLINE) > 0)
|
||||
return fu_plugin_runner_schedule_update (plugin, device, blob_cab, error);
|
||||
|
||||
/* install firmware blob */
|
||||
@ -4403,6 +4404,13 @@ fu_engine_add_runtime_version (FuEngine *self,
|
||||
g_strdup (version));
|
||||
}
|
||||
|
||||
void
|
||||
fu_engine_add_app_flag (FuEngine *self, FuAppFlags app_flags)
|
||||
{
|
||||
g_return_if_fail (FU_IS_ENGINE (self));
|
||||
self->app_flags |= app_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
fu_engine_idle_status_notify_cb (FuIdle *idle, GParamSpec *pspec, FuEngine *self)
|
||||
{
|
||||
|
@ -25,10 +25,13 @@ G_DECLARE_FINAL_TYPE (FuEngine, fu_engine, FU, ENGINE, GObject)
|
||||
typedef enum {
|
||||
FU_ENGINE_LOAD_FLAG_NONE = 0,
|
||||
FU_ENGINE_LOAD_FLAG_READONLY_FS = 1 << 0,
|
||||
FU_ENGINE_LOAD_FLAG_IS_OFFLINE = 1 << 1,
|
||||
FU_ENGINE_LOAD_FLAG_LAST
|
||||
} FuEngineLoadFlags;
|
||||
|
||||
FuEngine *fu_engine_new (FuAppFlags app_flags);
|
||||
void fu_engine_add_app_flag (FuEngine *self,
|
||||
FuAppFlags app_flags);
|
||||
void fu_engine_add_plugin_filter (FuEngine *self,
|
||||
const gchar *plugin_glob);
|
||||
void fu_engine_idle_reset (FuEngine *self);
|
||||
|
@ -1322,6 +1322,29 @@ fu_main_daemon_get_property (GDBusConnection *connection_, const gchar *sender,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fu_main_is_running_offline_update (FuMainPrivate *priv)
|
||||
{
|
||||
const gchar *default_target = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(GVariant) val = NULL;
|
||||
|
||||
val = g_dbus_connection_call_sync (priv->connection,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"GetDefaultTarget",
|
||||
NULL, NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
1500, NULL, &error);
|
||||
if (val == NULL) {
|
||||
g_warning ("failed to get default.target: %s", error->message);
|
||||
return FALSE;
|
||||
}
|
||||
g_variant_get (val, "(&s)", &default_target);
|
||||
return g_strcmp0 (default_target, "system-update.target") == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
fu_main_on_bus_acquired_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
@ -1346,6 +1369,10 @@ fu_main_on_bus_acquired_cb (GDBusConnection *connection,
|
||||
NULL); /* GError** */
|
||||
g_assert (registration_id > 0);
|
||||
|
||||
/* are we running in the offline target */
|
||||
if (fu_main_is_running_offline_update (priv))
|
||||
fu_engine_add_app_flag (priv->engine, FU_ENGINE_LOAD_FLAG_IS_OFFLINE);
|
||||
|
||||
/* connect to D-Bus directly */
|
||||
priv->proxy_uid =
|
||||
g_dbus_proxy_new_sync (priv->connection,
|
||||
|
@ -111,7 +111,8 @@ main (int argc, char *argv[])
|
||||
if (!fwupd_client_install (client,
|
||||
fwupd_device_get_id (dev),
|
||||
fwupd_release_get_filename (rel),
|
||||
FWUPD_INSTALL_FLAG_ALLOW_REINSTALL,
|
||||
FWUPD_INSTALL_FLAG_ALLOW_REINSTALL |
|
||||
FWUPD_INSTALL_FLAG_OFFLINE,
|
||||
NULL,
|
||||
&error)) {
|
||||
/* TRANSLATORS: we could not install for some reason */
|
||||
|
Loading…
Reference in New Issue
Block a user