From e1b4b2097820b79054117b3ddc1f7d89f0c759d7 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 30 Apr 2019 10:01:19 -0500 Subject: [PATCH] Dynamically read path to use for /system-update This allows `fwupdoffline` to work in installations that don't use `/var/lib/fwupd`. --- data/fwupd-offline-update.service.in | 2 +- src/fu-offline.c | 3 ++- src/fu-plugin.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/fwupd-offline-update.service.in b/data/fwupd-offline-update.service.in index 26eb9cb15..ee44b6581 100644 --- a/data/fwupd-offline-update.service.in +++ b/data/fwupd-offline-update.service.in @@ -1,7 +1,7 @@ [Unit] Description=Updates device firmware whilst offline Documentation=man:fwupdmgr -ConditionPathExists=/var/lib/fwupd/pending.db +ConditionPathExists=@localstatedir@/lib/fwupd/pending.db DefaultDependencies=false Requires=sysinit.target dbus.socket After=sysinit.target system-update-pre.target dbus.socket systemd-journald.socket diff --git a/src/fu-offline.c b/src/fu-offline.c index 1cd4bc1f2..f66699271 100644 --- a/src/fu-offline.c +++ b/src/fu-offline.c @@ -141,6 +141,7 @@ main (int argc, char *argv[]) gint vercmp; guint cnt = 0; g_autofree gchar *link = NULL; + g_autofree gchar *target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); g_autoptr(FuHistory) history = NULL; g_autoptr(FwupdClient) client = NULL; g_autoptr(GError) error = NULL; @@ -157,7 +158,7 @@ main (int argc, char *argv[]) link = g_file_read_link (FU_OFFLINE_TRIGGER_FILENAME, NULL); if (link == NULL) return EXIT_SUCCESS; - if (g_strcmp0 (link, "/var/lib/fwupd") != 0) + if (g_strcmp0 (link, target) != 0) return EXIT_SUCCESS; /* do this first to avoid a loop if this tool segfaults */ diff --git a/src/fu-plugin.c b/src/fu-plugin.c index ee85af14b..cc8c5147f 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -863,9 +863,9 @@ fu_plugin_runner_offline_invalidate (GError **error) static gboolean fu_plugin_runner_offline_setup (GError **error) { - const gchar *symlink_target = "/var/lib/fwupd"; gint rc; g_autofree gchar *filename = NULL; + g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);