mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-16 13:41:26 +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')
|
if get_option('tests')
|
||||||
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
||||||
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
||||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
|
||||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||||
e = executable(
|
e = executable(
|
||||||
'dell-self-test',
|
'dell-self-test',
|
||||||
|
@ -50,7 +50,6 @@ executable(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if get_option('tests')
|
if get_option('tests')
|
||||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
|
||||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||||
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
testdatadir = join_paths(meson.current_source_dir(), 'tests')
|
||||||
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
cargs += '-DTESTDATADIR="' + testdatadir + '"'
|
||||||
|
@ -31,7 +31,6 @@ shared_module('fu_plugin_synapticsmst',
|
|||||||
)
|
)
|
||||||
|
|
||||||
if get_option('tests')
|
if get_option('tests')
|
||||||
cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"'
|
|
||||||
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||||
cargs += '-DSOURCEDIR="' + meson.current_source_dir() + '"'
|
cargs += '-DSOURCEDIR="' + meson.current_source_dir() + '"'
|
||||||
e = executable(
|
e = executable(
|
||||||
|
@ -50,7 +50,6 @@ install_data(['thunderbolt.conf'],
|
|||||||
)
|
)
|
||||||
# we use functions from 2.52 in the tests
|
# we use functions from 2.52 in the tests
|
||||||
if get_option('tests') and umockdev.found() and gio.version().version_compare('>= 2.52')
|
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() + '"'
|
cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"'
|
||||||
e = executable(
|
e = executable(
|
||||||
'thunderbolt-self-test',
|
'thunderbolt-self-test',
|
||||||
|
@ -1044,6 +1044,11 @@ fu_common_get_path (FuPathKind path_kind)
|
|||||||
return g_build_filename (tmp, NULL);
|
return g_build_filename (tmp, NULL);
|
||||||
basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR);
|
basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR);
|
||||||
return g_build_filename (basedir, "cache", PACKAGE_NAME, NULL);
|
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:
|
case FU_PATH_KIND_POLKIT_ACTIONS:
|
||||||
#ifdef POLKIT_ACTIONDIR
|
#ifdef POLKIT_ACTIONDIR
|
||||||
return g_strdup (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_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_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_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
|
* 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_DRIVERS,
|
||||||
FU_PATH_KIND_SYSFSDIR_TPM,
|
FU_PATH_KIND_SYSFSDIR_TPM,
|
||||||
FU_PATH_KIND_POLKIT_ACTIONS,
|
FU_PATH_KIND_POLKIT_ACTIONS,
|
||||||
|
FU_PATH_KIND_OFFLINE_TRIGGER,
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
FU_PATH_KIND_LAST
|
FU_PATH_KIND_LAST
|
||||||
} FuPathKind;
|
} FuPathKind;
|
||||||
|
@ -141,6 +141,7 @@ main (int argc, char *argv[])
|
|||||||
guint cnt = 0;
|
guint cnt = 0;
|
||||||
g_autofree gchar *link = NULL;
|
g_autofree gchar *link = NULL;
|
||||||
g_autofree gchar *target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
|
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(FuHistory) history = NULL;
|
||||||
g_autoptr(FwupdClient) client = NULL;
|
g_autoptr(FwupdClient) client = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
@ -154,14 +155,14 @@ main (int argc, char *argv[])
|
|||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
/* verify this is pointing to our cache */
|
/* 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)
|
if (link == NULL)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
if (g_strcmp0 (link, target) != 0)
|
if (g_strcmp0 (link, target) != 0)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
/* do this first to avoid a loop if this tool segfaults */
|
/* do this first to avoid a loop if this tool segfaults */
|
||||||
g_unlink (FU_OFFLINE_TRIGGER_FILENAME);
|
g_unlink (trigger);
|
||||||
|
|
||||||
/* ensure root user */
|
/* ensure root user */
|
||||||
#ifdef HAVE_GETUID
|
#ifdef HAVE_GETUID
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
#include "fu-plugin.h"
|
#include "fu-plugin.h"
|
||||||
#include "fu-smbios.h"
|
#include "fu-smbios.h"
|
||||||
|
|
||||||
#define FU_OFFLINE_TRIGGER_FILENAME FU_OFFLINE_DESTDIR "/system-update"
|
|
||||||
|
|
||||||
FuPlugin *fu_plugin_new (void);
|
FuPlugin *fu_plugin_new (void);
|
||||||
gboolean fu_plugin_is_open (FuPlugin *self);
|
gboolean fu_plugin_is_open (FuPlugin *self);
|
||||||
void fu_plugin_set_usb_context (FuPlugin *self,
|
void fu_plugin_set_usb_context (FuPlugin *self,
|
||||||
|
@ -1011,12 +1011,13 @@ fu_plugin_runner_startup (FuPlugin *self, GError **error)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_runner_offline_invalidate (GError **error)
|
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(GError) error_local = NULL;
|
||||||
g_autoptr(GFile) file1 = NULL;
|
g_autoptr(GFile) file1 = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
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))
|
if (!g_file_query_exists (file1, NULL))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (!g_file_delete (file1, NULL, &error_local)) {
|
if (!g_file_delete (file1, NULL, &error_local)) {
|
||||||
@ -1024,7 +1025,7 @@ fu_plugin_runner_offline_invalidate (GError **error)
|
|||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INTERNAL,
|
FWUPD_ERROR_INTERNAL,
|
||||||
"Cannot delete %s: %s",
|
"Cannot delete %s: %s",
|
||||||
FU_OFFLINE_TRIGGER_FILENAME,
|
trigger,
|
||||||
error_local->message);
|
error_local->message);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1037,25 +1038,26 @@ fu_plugin_runner_offline_setup (GError **error)
|
|||||||
gint rc;
|
gint rc;
|
||||||
g_autofree gchar *filename = NULL;
|
g_autofree gchar *filename = NULL;
|
||||||
g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
|
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);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
/* does already exist */
|
/* 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) {
|
if (g_strcmp0 (filename, symlink_target) == 0) {
|
||||||
g_debug ("%s already points to %s, skipping creation",
|
g_debug ("%s already points to %s, skipping creation",
|
||||||
FU_OFFLINE_TRIGGER_FILENAME, symlink_target);
|
trigger, symlink_target);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create symlink for the systemd-system-update-generator */
|
/* create symlink for the systemd-system-update-generator */
|
||||||
rc = symlink (symlink_target, FU_OFFLINE_TRIGGER_FILENAME);
|
rc = symlink (symlink_target, trigger);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INTERNAL,
|
FWUPD_ERROR_INTERNAL,
|
||||||
"Failed to create symlink %s to %s: %s",
|
"Failed to create symlink %s to %s: %s",
|
||||||
FU_OFFLINE_TRIGGER_FILENAME,
|
trigger,
|
||||||
"/var/lib", strerror (errno));
|
"/var/lib", strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -4187,6 +4187,7 @@ main (int argc, char **argv)
|
|||||||
g_setenv ("FWUPD_PLUGINDIR", TESTDATADIR_SRC, TRUE);
|
g_setenv ("FWUPD_PLUGINDIR", TESTDATADIR_SRC, TRUE);
|
||||||
g_setenv ("FWUPD_SYSCONFDIR", TESTDATADIR_SRC, TRUE);
|
g_setenv ("FWUPD_SYSCONFDIR", TESTDATADIR_SRC, TRUE);
|
||||||
g_setenv ("FWUPD_SYSFSFWDIR", 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);
|
g_setenv ("FWUPD_LOCALSTATEDIR", "/tmp/fwupd-self-test/var", TRUE);
|
||||||
|
|
||||||
/* ensure empty tree */
|
/* ensure empty tree */
|
||||||
|
@ -106,9 +106,6 @@ fwupdmgr = executable(
|
|||||||
fwupd,
|
fwupd,
|
||||||
libfwupdprivate,
|
libfwupdprivate,
|
||||||
],
|
],
|
||||||
c_args : [
|
|
||||||
'-DFU_OFFLINE_DESTDIR=""',
|
|
||||||
],
|
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : bindir
|
install_dir : bindir
|
||||||
)
|
)
|
||||||
@ -164,9 +161,6 @@ fwupdagent = executable(
|
|||||||
fwupd,
|
fwupd,
|
||||||
libfwupdprivate,
|
libfwupdprivate,
|
||||||
],
|
],
|
||||||
c_args : [
|
|
||||||
'-DFU_OFFLINE_DESTDIR=""',
|
|
||||||
],
|
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : join_paths(libexecdir, 'fwupd')
|
install_dir : join_paths(libexecdir, 'fwupd')
|
||||||
)
|
)
|
||||||
@ -230,9 +224,6 @@ fwupdtool = executable(
|
|||||||
fwupd,
|
fwupd,
|
||||||
libfwupdprivate,
|
libfwupdprivate,
|
||||||
],
|
],
|
||||||
c_args : [
|
|
||||||
'-DFU_OFFLINE_DESTDIR=""',
|
|
||||||
],
|
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : join_paths(libexecdir, 'fwupd')
|
install_dir : join_paths(libexecdir, 'fwupd')
|
||||||
)
|
)
|
||||||
@ -359,7 +350,6 @@ if get_option('tests')
|
|||||||
'-DTESTDATADIR_DST="' + testdatadir_dst + '"',
|
'-DTESTDATADIR_DST="' + testdatadir_dst + '"',
|
||||||
'-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"',
|
'-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"',
|
||||||
'-DPLUGINBUILDDIR="' + pluginbuilddir + '"',
|
'-DPLUGINBUILDDIR="' + pluginbuilddir + '"',
|
||||||
'-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"',
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
test('fu-self-test', e, is_parallel:false, timeout:180)
|
test('fu-self-test', e, is_parallel:false, timeout:180)
|
||||||
|
Loading…
Reference in New Issue
Block a user