mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 10:29:47 +00:00
trivial: Allow compiling without <sys/utsname.h>
This commit is contained in:
parent
17957ebf13
commit
fc1e267d33
@ -13,7 +13,9 @@
|
|||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#endif
|
||||||
#include <json-glib/json-glib.h>
|
#include <json-glib/json-glib.h>
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION(2,54,0)
|
#if !GLIB_CHECK_VERSION(2,54,0)
|
||||||
@ -222,12 +224,15 @@ fwupd_build_user_agent_os_release (void)
|
|||||||
static gchar *
|
static gchar *
|
||||||
fwupd_build_user_agent_system (void)
|
fwupd_build_user_agent_system (void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
struct utsname name_tmp;
|
struct utsname name_tmp;
|
||||||
|
#endif
|
||||||
g_autofree gchar *locale = NULL;
|
g_autofree gchar *locale = NULL;
|
||||||
g_autofree gchar *os_release = NULL;
|
g_autofree gchar *os_release = NULL;
|
||||||
g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (g_free);
|
g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (g_free);
|
||||||
|
|
||||||
/* system, architecture and kernel, e.g. "Linux i686 4.14.5" */
|
/* system, architecture and kernel, e.g. "Linux i686 4.14.5" */
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
memset (&name_tmp, 0, sizeof(struct utsname));
|
memset (&name_tmp, 0, sizeof(struct utsname));
|
||||||
if (uname (&name_tmp) >= 0) {
|
if (uname (&name_tmp) >= 0) {
|
||||||
g_ptr_array_add (ids, g_strdup_printf ("%s %s %s",
|
g_ptr_array_add (ids, g_strdup_printf ("%s %s %s",
|
||||||
@ -235,6 +240,7 @@ fwupd_build_user_agent_system (void)
|
|||||||
name_tmp.machine,
|
name_tmp.machine,
|
||||||
name_tmp.release));
|
name_tmp.release));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* current locale, e.g. "en-gb" */
|
/* current locale, e.g. "en-gb" */
|
||||||
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
||||||
|
@ -222,6 +222,10 @@ if build_standalone and get_option('plugin_altos')
|
|||||||
libelf = dependency('libelf')
|
libelf = dependency('libelf')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if cc.has_header('sys/utsname.h')
|
||||||
|
conf.set('HAVE_UTSNAME_H', '1')
|
||||||
|
endif
|
||||||
|
|
||||||
if build_standalone and get_option('plugin_uefi')
|
if build_standalone and get_option('plugin_uefi')
|
||||||
cairo = dependency('cairo')
|
cairo = dependency('cairo')
|
||||||
fontconfig = cc.find_library('fontconfig')
|
fontconfig = cc.find_library('fontconfig')
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
#include <gudev/gudev.h>
|
#include <gudev/gudev.h>
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "fwupd-common-private.h"
|
#include "fwupd-common-private.h"
|
||||||
#include "fwupd-enums-private.h"
|
#include "fwupd-enums-private.h"
|
||||||
@ -1380,7 +1382,9 @@ fu_engine_get_report_metadata (FuEngine *self)
|
|||||||
{
|
{
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
gchar *btime;
|
gchar *btime;
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
struct utsname name_tmp;
|
struct utsname name_tmp;
|
||||||
|
#endif
|
||||||
g_autoptr(GList) compile_keys = g_hash_table_get_keys (self->compile_versions);
|
g_autoptr(GList) compile_keys = g_hash_table_get_keys (self->compile_versions);
|
||||||
g_autoptr(GList) runtime_keys = g_hash_table_get_keys (self->runtime_versions);
|
g_autoptr(GList) runtime_keys = g_hash_table_get_keys (self->runtime_versions);
|
||||||
|
|
||||||
@ -1402,12 +1406,14 @@ fu_engine_get_report_metadata (FuEngine *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* kernel version is often important for debugging failures */
|
/* kernel version is often important for debugging failures */
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
memset (&name_tmp, 0, sizeof (struct utsname));
|
memset (&name_tmp, 0, sizeof (struct utsname));
|
||||||
if (uname (&name_tmp) >= 0) {
|
if (uname (&name_tmp) >= 0) {
|
||||||
g_hash_table_insert (hash,
|
g_hash_table_insert (hash,
|
||||||
g_strdup ("CpuArchitecture"),
|
g_strdup ("CpuArchitecture"),
|
||||||
g_strdup (name_tmp.machine));
|
g_strdup (name_tmp.machine));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* add the kernel boot time so we can detect a reboot */
|
/* add the kernel boot time so we can detect a reboot */
|
||||||
btime = fu_engine_get_boot_time ();
|
btime = fu_engine_get_boot_time ();
|
||||||
@ -4947,7 +4953,9 @@ fu_engine_idle_status_notify_cb (FuIdle *idle, GParamSpec *pspec, FuEngine *self
|
|||||||
static void
|
static void
|
||||||
fu_engine_init (FuEngine *self)
|
fu_engine_init (FuEngine *self)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
struct utsname uname_tmp;
|
struct utsname uname_tmp;
|
||||||
|
#endif
|
||||||
self->percentage = 0;
|
self->percentage = 0;
|
||||||
self->status = FWUPD_STATUS_IDLE;
|
self->status = FWUPD_STATUS_IDLE;
|
||||||
self->config = fu_config_new ();
|
self->config = fu_config_new ();
|
||||||
@ -4983,9 +4991,11 @@ fu_engine_init (FuEngine *self)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* optional kernel version */
|
/* optional kernel version */
|
||||||
|
#ifdef HAVE_UTSNAME_H
|
||||||
memset (&uname_tmp, 0, sizeof(uname_tmp));
|
memset (&uname_tmp, 0, sizeof(uname_tmp));
|
||||||
if (uname (&uname_tmp) >= 0)
|
if (uname (&uname_tmp) >= 0)
|
||||||
fu_engine_add_runtime_version (self, "org.kernel", uname_tmp.release);
|
fu_engine_add_runtime_version (self, "org.kernel", uname_tmp.release);
|
||||||
|
#endif
|
||||||
|
|
||||||
g_hash_table_insert (self->compile_versions,
|
g_hash_table_insert (self->compile_versions,
|
||||||
g_strdup ("com.redhat.fwupdate"),
|
g_strdup ("com.redhat.fwupdate"),
|
||||||
|
Loading…
Reference in New Issue
Block a user