mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-16 04:33:03 +00:00
trivial: Set the offline trigger using an environment variable
This allows us to build a object that does not have a custom FU_OFFLINE_DESTDIR.
This commit is contained in:
parent
9b36a370ae
commit
afdba37644
@ -34,7 +34,6 @@ shared_module('fu_plugin_dell',
|
||||
if get_option('tests')
|
||||
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
||||
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||
e = executable(
|
||||
'dell-self-test',
|
||||
|
@ -50,7 +50,6 @@ executable(
|
||||
)
|
||||
|
||||
if get_option('tests')
|
||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
||||
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
||||
|
@ -31,7 +31,6 @@ shared_module('fu_plugin_synapticsmst',
|
||||
)
|
||||
|
||||
if get_option('tests')
|
||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||
cargs += '-DSOURCEDIR="' + meson.current_source_dir() + '"'
|
||||
e = executable(
|
||||
|
@ -50,7 +50,6 @@ install_data(['thunderbolt.conf'],
|
||||
)
|
||||
# we use functions from 2.52 in the tests
|
||||
if get_option('tests') and umockdev.found() and gio.version().version_compare('>= 2.52')
|
||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||
e = executable(
|
||||
'thunderbolt-self-test',
|
||||
|
@ -1044,6 +1044,11 @@ fu_common_get_path (FuPathKind path_kind)
|
||||
return g_build_filename (tmp, NULL);
|
||||
basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR);
|
||||
return g_build_filename (basedir, "cache", PACKAGE_NAME, NULL);
|
||||
case FU_PATH_KIND_OFFLINE_TRIGGER:
|
||||
tmp = g_getenv ("FWUPD_OFFLINE_TRIGGER");
|
||||
if (tmp != NULL)
|
||||
return g_strdup (tmp);
|
||||
return g_strdup ("/system-update");
|
||||
case FU_PATH_KIND_POLKIT_ACTIONS:
|
||||
#ifdef POLKIT_ACTIONDIR
|
||||
return g_strdup (POLKIT_ACTIONDIR);
|
||||
|
@ -54,6 +54,7 @@ typedef guint FuEndianType;
|
||||
* @FU_PATH_KIND_SYSFSDIR_DRIVERS: The platform sysfs directory (IE /sys/bus/platform/drivers)
|
||||
* @FU_PATH_KIND_SYSFSDIR_TPM: The TPM sysfs directory (IE /sys/class/tpm)
|
||||
* @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/)
|
||||
* @FU_PATH_KIND_OFFLINE_TRIGGER: The file for the offline trigger (IE /system-update)
|
||||
*
|
||||
* Path types to use when dynamically determining a path at runtime
|
||||
**/
|
||||
@ -70,6 +71,7 @@ typedef enum {
|
||||
FU_PATH_KIND_SYSFSDIR_DRIVERS,
|
||||
FU_PATH_KIND_SYSFSDIR_TPM,
|
||||
FU_PATH_KIND_POLKIT_ACTIONS,
|
||||
FU_PATH_KIND_OFFLINE_TRIGGER,
|
||||
/*< private >*/
|
||||
FU_PATH_KIND_LAST
|
||||
} FuPathKind;
|
||||
|
@ -141,6 +141,7 @@ main (int argc, char *argv[])
|
||||
guint cnt = 0;
|
||||
g_autofree gchar *link = NULL;
|
||||
g_autofree gchar *target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
|
||||
g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER);
|
||||
g_autoptr(FuHistory) history = NULL;
|
||||
g_autoptr(FwupdClient) client = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
@ -154,14 +155,14 @@ main (int argc, char *argv[])
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
/* verify this is pointing to our cache */
|
||||
link = g_file_read_link (FU_OFFLINE_TRIGGER_FILENAME, NULL);
|
||||
link = g_file_read_link (trigger, NULL);
|
||||
if (link == NULL)
|
||||
return EXIT_SUCCESS;
|
||||
if (g_strcmp0 (link, target) != 0)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
/* do this first to avoid a loop if this tool segfaults */
|
||||
g_unlink (FU_OFFLINE_TRIGGER_FILENAME);
|
||||
g_unlink (trigger);
|
||||
|
||||
/* ensure root user */
|
||||
#ifdef HAVE_GETUID
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "fu-plugin.h"
|
||||
#include "fu-smbios.h"
|
||||
|
||||
#define FU_OFFLINE_TRIGGER_FILENAME FU_OFFLINE_DESTDIR "/system-update"
|
||||
|
||||
FuPlugin *fu_plugin_new (void);
|
||||
gboolean fu_plugin_is_open (FuPlugin *self);
|
||||
void fu_plugin_set_usb_context (FuPlugin *self,
|
||||
|
@ -1011,12 +1011,13 @@ fu_plugin_runner_startup (FuPlugin *self, GError **error)
|
||||
static gboolean
|
||||
fu_plugin_runner_offline_invalidate (GError **error)
|
||||
{
|
||||
g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER);
|
||||
g_autoptr(GError) error_local = NULL;
|
||||
g_autoptr(GFile) file1 = NULL;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
file1 = g_file_new_for_path (FU_OFFLINE_TRIGGER_FILENAME);
|
||||
file1 = g_file_new_for_path (trigger);
|
||||
if (!g_file_query_exists (file1, NULL))
|
||||
return TRUE;
|
||||
if (!g_file_delete (file1, NULL, &error_local)) {
|
||||
@ -1024,7 +1025,7 @@ fu_plugin_runner_offline_invalidate (GError **error)
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INTERNAL,
|
||||
"Cannot delete %s: %s",
|
||||
FU_OFFLINE_TRIGGER_FILENAME,
|
||||
trigger,
|
||||
error_local->message);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1037,25 +1038,26 @@ fu_plugin_runner_offline_setup (GError **error)
|
||||
gint rc;
|
||||
g_autofree gchar *filename = NULL;
|
||||
g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
|
||||
g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER);
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* does already exist */
|
||||
filename = fu_common_realpath (FU_OFFLINE_TRIGGER_FILENAME, NULL);
|
||||
filename = fu_common_realpath (trigger, NULL);
|
||||
if (g_strcmp0 (filename, symlink_target) == 0) {
|
||||
g_debug ("%s already points to %s, skipping creation",
|
||||
FU_OFFLINE_TRIGGER_FILENAME, symlink_target);
|
||||
trigger, symlink_target);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* create symlink for the systemd-system-update-generator */
|
||||
rc = symlink (symlink_target, FU_OFFLINE_TRIGGER_FILENAME);
|
||||
rc = symlink (symlink_target, trigger);
|
||||
if (rc < 0) {
|
||||
g_set_error (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INTERNAL,
|
||||
"Failed to create symlink %s to %s: %s",
|
||||
FU_OFFLINE_TRIGGER_FILENAME,
|
||||
trigger,
|
||||
"/var/lib", strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -4187,6 +4187,7 @@ main (int argc, char **argv)
|
||||
g_setenv ("FWUPD_PLUGINDIR", TESTDATADIR_SRC, TRUE);
|
||||
g_setenv ("FWUPD_SYSCONFDIR", TESTDATADIR_SRC, TRUE);
|
||||
g_setenv ("FWUPD_SYSFSFWDIR", TESTDATADIR_SRC, TRUE);
|
||||
g_setenv ("FWUPD_OFFLINE_TRIGGER", "/tmp/fwupd-self-test/system-update", TRUE);
|
||||
g_setenv ("FWUPD_LOCALSTATEDIR", "/tmp/fwupd-self-test/var", TRUE);
|
||||
|
||||
/* ensure empty tree */
|
||||
|
@ -106,9 +106,6 @@ fwupdmgr = executable(
|
||||
fwupd,
|
||||
libfwupdprivate,
|
||||
],
|
||||
c_args : [
|
||||
'-DFU_OFFLINE_DESTDIR=""',
|
||||
],
|
||||
install : true,
|
||||
install_dir : bindir
|
||||
)
|
||||
@ -164,9 +161,6 @@ fwupdagent = executable(
|
||||
fwupd,
|
||||
libfwupdprivate,
|
||||
],
|
||||
c_args : [
|
||||
'-DFU_OFFLINE_DESTDIR=""',
|
||||
],
|
||||
install : true,
|
||||
install_dir : join_paths(libexecdir, 'fwupd')
|
||||
)
|
||||
@ -230,9 +224,6 @@ fwupdtool = executable(
|
||||
fwupd,
|
||||
libfwupdprivate,
|
||||
],
|
||||
c_args : [
|
||||
'-DFU_OFFLINE_DESTDIR=""',
|
||||
],
|
||||
install : true,
|
||||
install_dir : join_paths(libexecdir, 'fwupd')
|
||||
)
|
||||
@ -359,7 +350,6 @@ if get_option('tests')
|
||||
'-DTESTDATADIR_DST="' + testdatadir_dst + '"',
|
||||
'-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"',
|
||||
'-DPLUGINBUILDDIR="' + pluginbuilddir + '"',
|
||||
'-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"',
|
||||
],
|
||||
)
|
||||
test('fu-self-test', e, is_parallel:false, timeout:180)
|
||||
|
Loading…
Reference in New Issue
Block a user