From 5f01678daabcd9bc07e3c19e2a12b54c99ba8f59 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 12 Nov 2021 16:31:12 +0000 Subject: [PATCH] Use -Doffline=false to reduce the install size by over 100Kb If there's no SuperIO chip then there's no need to support this. --- contrib/ci/build_windows.sh | 1 + contrib/ci/void.sh | 1 + contrib/freebsd/Makefile | 1 + data/meson.build | 16 +++++++++------- meson.build | 7 +++++++ meson_options.txt | 1 + src/fu-engine.c | 9 +++++++++ src/fu-self-test.c | 2 +- src/meson.build | 2 +- 9 files changed, 31 insertions(+), 9 deletions(-) diff --git a/contrib/ci/build_windows.sh b/contrib/ci/build_windows.sh index 1e150d07a..42950e8ec 100755 --- a/contrib/ci/build_windows.sh +++ b/contrib/ci/build_windows.sh @@ -36,6 +36,7 @@ meson .. \ -Dplugin_platform_integrity=false \ -Dplugin_tpm=false \ -Dsystemd=false \ + -Doffline=false \ -Dplugin_emmc=false \ -Dplugin_amt=false \ -Dplugin_mtd=false \ diff --git a/contrib/ci/void.sh b/contrib/ci/void.sh index 9aa03786f..b4893dd0c 100755 --- a/contrib/ci/void.sh +++ b/contrib/ci/void.sh @@ -16,5 +16,6 @@ meson build \ -Dgcab:docs=false \ -Dconsolekit=false \ -Dsystemd=false \ + -Doffline=false \ -Delogind=true ninja -C build test -v diff --git a/contrib/freebsd/Makefile b/contrib/freebsd/Makefile index 369263d56..f0b1fe774 100644 --- a/contrib/freebsd/Makefile +++ b/contrib/freebsd/Makefile @@ -56,6 +56,7 @@ MESON_ARGS= -Dgudev=false \ -Dplugin_tpm=false \ -Dpolkit=false \ -Dsystemd=false \ + -Doffline=false \ -Dtests=false \ -Ddocs=gtkdoc \ -Defi_binary=false diff --git a/data/meson.build b/data/meson.build index 798e55a68..2ae29ce58 100644 --- a/data/meson.build +++ b/data/meson.build @@ -91,13 +91,15 @@ if get_option('systemd') and build_daemon con2.set('motd_dir', motd_dir) # replace @bindir@ - configure_file( - input : 'fwupd-offline-update.service.in', - output : 'fwupd-offline-update.service', - configuration : con2, - install: true, - install_dir: systemdunitdir, - ) + if get_option('offline') + configure_file( + input : 'fwupd-offline-update.service.in', + output : 'fwupd-offline-update.service', + configuration : con2, + install: true, + install_dir: systemdunitdir, + ) + endif # replace @dynamic_options@ configure_file( diff --git a/meson.build b/meson.build index 4c548cf95..da2b7a81a 100644 --- a/meson.build +++ b/meson.build @@ -289,6 +289,13 @@ endif if valgrind.found() conf.set('HAVE_VALGRIND', '1') endif +if get_option('offline') + if not get_option('systemd') + error('-Doffline=true requires -Dsystemd=true') + endif + conf.set('HAVE_FWUPDOFFLINE', '1') +endif + if build_standalone and get_option('plugin_altos') libelf = dependency('libelf') diff --git a/meson_options.txt b/meson_options.txt index d673871ec..9dbce76d4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -50,3 +50,4 @@ option('efi_binary', type: 'boolean', value : true, description : 'generate uefi option('metainfo', type: 'boolean', value : true, description : 'install the project metainfo.xml information') option('bash_completion', type: 'boolean', value : true, description : 'enable bash completion') option('fish_completion', type: 'boolean', value : true, description : 'enable fish completion') +option('offline', type: 'boolean', value : true, description : 'enable installing firmware using a pre-boot systemd target') diff --git a/src/fu-engine.c b/src/fu-engine.c index 12beda297..4f74bb480 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -2423,6 +2423,15 @@ fu_engine_schedule_update(FuEngine *self, g_autoptr(FuHistory) history = NULL; g_autoptr(GFile) file = NULL; +#ifndef HAVE_FWUPDOFFLINE + /* sanity check */ + g_set_error(error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as compiled without offline support"); + return FALSE; +#endif + /* id already exists */ history = fu_history_new(); if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0) { diff --git a/src/fu-self-test.c b/src/fu-self-test.c index ed3122fc6..ce9ad485a 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -2877,7 +2877,7 @@ fu_plugin_module_func(gconstpointer user_data) g_assert_cmpstr(fu_device_get_name(device), ==, "Integrated Webcam™"); g_signal_handlers_disconnect_by_data(self->plugin, &device); -#ifdef _WIN32 +#ifndef HAVE_FWUPDOFFLINE g_test_skip("No offline update support on Windows"); return; #endif diff --git a/src/meson.build b/src/meson.build index dfaf493f8..3e409a364 100644 --- a/src/meson.build +++ b/src/meson.build @@ -107,7 +107,7 @@ meson.add_install_script( join_paths(get_option('prefix'), get_option('bindir'), 'fwupdagent'))) endif -if get_option('systemd') +if get_option('systemd') and get_option('offline') fwupdoffline = executable( 'fwupdoffline', sources : [