From 5bba5c481d7273b475a39eb61e5eacec65d3c8e5 Mon Sep 17 00:00:00 2001 From: Lucas de Castro Borges Date: Mon, 22 Apr 2024 18:07:32 -0300 Subject: New upstream version 2.0.5pre --- CMakeLists.txt | 4 +- README.md | 13 ++-- config.h.cmake | 1 - deps/sysobj_early/src/util_edid.c | 62 +++++++++++++++--- deps/sysobj_early/src/util_sysobj.c | 125 ++++++++++++++++++++++++++++++++++++ hardinfo2/util.c | 19 +++++- modules/benchmark/guibench.c | 2 +- modules/computer/os.c | 30 +++++---- modules/devices.c | 3 + modules/devices/printers.c | 14 +++- modules/devices/x86/x86_data.c | 3 +- shell/syncmanager.c | 12 ++-- 12 files changed, 246 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf88934d..2ef1f78c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.0) cmake_policy(VERSION 3.0.0) project(hardinfo2) -set(HARDINFO2_VERSION "2.0.3") +set(HARDINFO2_VERSION "2.0.5") option(HARDINFO2_GTK3 "Build for GTK3 (0/off for GTK2)" 1) option(HARDINFO2_LIBSOUP3 "Build for libsoup-3.0(EXPERIMENTAL) (0/off for libsoup-2.4)" 0) @@ -103,7 +103,7 @@ string(REGEX REPLACE "\"" "" disversion "${disversion}") string(REGEX REPLACE "/" "" disversion "${disversion}") string(REGEX REPLACE " " "" disversion "${disversion}") #RPM Distro's -if(${distro} MATCHES "Alma*" OR ${distro} MATCHES "Rocky*" OR ${distro} MATCHES "Fedora*" OR ${distro} MATCHES "Red*" OR ${distro} MATCHES "CentOS*" OR ${distro} MATCHES "Oracle*") +if(${distro} MATCHES "Alma*" OR ${distro} MATCHES "Rocky*" OR ${distro} MATCHES "Fedora*" OR ${distro} MATCHES "Red*" OR ${distro} MATCHES "CentOS*" OR ${distro} MATCHES "Oracle*" OR ${distro} MATCHES "openSUSE*") set(RPM 1) endif() #Package architecture diff --git a/README.md b/README.md index 6f714a66..7d383218 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Test](https://github.com/hardinfo2/hardinfo2/actions/workflows/test.yml/badge.svg)](https://github.com/hardinfo2/hardinfo2/actions/workflows/test.yml) [![GitHub release](https://img.shields.io/github/release/hardinfo2/hardinfo2.svg)](https://github.com/hardinfo2/hardinfo2/releases) -[![GitHub release](https://img.shields.io/badge/PreRelease-v2.0.3-blue.svg)](https://github.com/hardinfo2/hardinfo2/releases/tag/release-2.0.3pre) +[![GitHub release](https://img.shields.io/badge/PreRelease-v2.0.5-blue.svg)](https://github.com/hardinfo2/hardinfo2/releases/tag/release-2.0.5pre) HARDINFO2 ========= @@ -41,8 +41,8 @@ Building and installing - mkdir build - cd build - cmake .. -- make package (Creates package so you do not polute your distro and it can be updated by distro releases) -- sudo apt install ./hardinfo2-VERSION-DISTRO-ARCH.deb (Use reinstall instead of install if already inst.) +- make package -j (Creates package so you do not polute your distro and it can be updated by distro releases) +- sudo apt install ./hardinfo_* (Use reinstall instead of install if already inst.) - sudo apt install lm-sensors sysbench lsscsi mesa-utils dmidecode udisks2 xdg-utils - hardinfo2 @@ -56,11 +56,13 @@ Building and installing - mkdir build - cd build - cmake .. -- make package (Creates package so you do not polute your distro and it can be updated by distro releases) -- sudo yum install ./hardinfo2-VERSION-DISTRO-ARCH.rpm (Use reinstall instead of install if already inst.) +- make package -j (Creates package so you do not polute your distro and it can be updated by distro releases) +- sudo yum install ./hardinfo-* (Use reinstall instead of install if already inst.) - sudo yum install lm_sensors sysbench lsscsi glx-utils dmidecode udisks2 xdg-utils - hardinfo2 +**openSUSE**: use zypper instead of yum, use libsoup2-devel instead of libsoup-devel + Distro building --------------- For distribution in the different distros - please use the cmake build system with CPack: @@ -87,6 +89,7 @@ in daemon mode, using the default port. Load with `modprobe eeprom` and refresh the module screen. - **xdg-utils**: xdg_open is used to open your browser for bugs, homepage & links. - **apcaccess**: apcaccess is used for battery information. (optional) +- **lspci/lsusb**: is used for bus information - installed by distro. (optional) License ------ diff --git a/config.h.cmake b/config.h.cmake index 974842a5..d0b22a2e 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -27,7 +27,6 @@ #define ENABLE_BINRELOC 1 #define HAS_LINUX_WE 1 -#define HAS_LIBSOUP 1 #cmakedefine01 HAS_LIBSENSORS diff --git a/deps/sysobj_early/src/util_edid.c b/deps/sysobj_early/src/util_edid.c index 06c5534e..906aeff0 100644 --- a/deps/sysobj_early/src/util_edid.c +++ b/deps/sysobj_early/src/util_edid.c @@ -31,17 +31,55 @@ #include "util_edid_svd_table.c" -// TODO: find a better fix, I've seen a few EDID strings with bogus chars -#if !GLIB_CHECK_VERSION(2,52,0) -__attribute__ ((weak)) -gchar *g_utf8_make_valid(const gchar *s, const gssize l) { - if (l < 0) - return g_strdup(s); - else - return g_strndup(s, (gsize)l); +#if GLIB_CHECK_VERSION(2,52,0) +#else +gchar * +g2_utf8_make_valid (const gchar *str, + gssize len) +{ + GString *string; + const gchar *remainder, *invalid; + gsize remaining_bytes, valid_bytes; + + g_return_val_if_fail (str != NULL, NULL); + + if (len < 0) + len = strlen (str); + + string = NULL; + remainder = str; + remaining_bytes = len; + + while (remaining_bytes != 0) + { + if (g_utf8_validate (remainder, remaining_bytes, &invalid)) + break; + valid_bytes = invalid - remainder; + + if (string == NULL) + string = g_string_sized_new (remaining_bytes); + + g_string_append_len (string, remainder, valid_bytes); + /* append U+FFFD REPLACEMENT CHARACTER */ + g_string_append (string, "\357\277\275"); + + remaining_bytes -= valid_bytes + 1; + remainder = invalid + 1; + } + + if (string == NULL) + return g_strndup (str, len); + + g_string_append_len (string, remainder, remaining_bytes); + g_string_append_c (string, '\0'); + + g_assert (g_utf8_validate (string->str, -1, NULL)); + + return g_string_free (string, FALSE); } #endif + #define NOMASK (~0U) #define BFMASK(LSB, MASK) (MASK << LSB) @@ -89,7 +127,11 @@ char *rstr(edid *e, uint32_t offset, uint32_t len) { char *raw = malloc(len+1), *ret = NULL; strncpy(raw, (char*)&e->u8[offset], len); raw[len] = 0; +#if GLIB_CHECK_VERSION(2,52,0) ret = g_utf8_make_valid(raw, len); +#else + ret = g2_utf8_make_valid(raw, len); +#endif g_free(raw); return ret; } @@ -100,7 +142,11 @@ char *rstr_strip(edid *e, uint32_t offset, uint32_t len) { char *raw = malloc(len+1), *ret = NULL; strncpy(raw, (char*)&e->u8[offset], len); raw[len] = 0; +#if GLIB_CHECK_VERSION(2,52,0) ret = g_strstrip(g_utf8_make_valid(raw, len)); +#else + ret = g_strstrip(g2_utf8_make_valid(raw, len)); +#endif g_free(raw); return ret; } diff --git a/deps/sysobj_early/src/util_sysobj.c b/deps/sysobj_early/src/util_sysobj.c index 94f71944..d0f09a68 100644 --- a/deps/sysobj_early/src/util_sysobj.c +++ b/deps/sysobj_early/src/util_sysobj.c @@ -177,12 +177,137 @@ gchar *util_strchomp_float(gchar* str_float) { return str_float; } + +#if GLIB_CHECK_VERSION(2, 58, 0) +#else +gchar * +g2_canonicalize_filename (const gchar *filename, + const gchar *relative_to) +{ + gchar *canon, *input, *output, *after_root, *output_start; + + g_return_val_if_fail (relative_to == NULL || g_path_is_absolute (relative_to), NULL); + + if (!g_path_is_absolute (filename)) + { + gchar *cwd_allocated = NULL; + const gchar *cwd; + + if (relative_to != NULL) + cwd = relative_to; + else + cwd = cwd_allocated = g_get_current_dir (); + + canon = g_build_filename (cwd, filename, NULL); + g_free (cwd_allocated); + } + else + { + canon = g_strdup (filename); + } + + after_root = (char *)g_path_skip_root (canon); + + if (after_root == NULL) + { + /* This shouldn't really happen, as g_get_current_dir() should + return an absolute pathname, but bug 573843 shows this is + not always happening */ + g_free (canon); + return g_build_filename (G_DIR_SEPARATOR_S, filename, NULL); + } + + /* Find the first dir separator and use the canonical dir separator. */ + for (output = after_root - 1; + (output >= canon) && G_IS_DIR_SEPARATOR (*output); + output--) + *output = G_DIR_SEPARATOR; + + /* 1 to re-increment after the final decrement above (so that output >= canon), + * and 1 to skip the first `/`. There might not be a first `/` if + * the @canon is a Windows `//server/share` style path with no + * trailing directories. @after_root will be '\0' in that case. */ + output++; + if (*output == G_DIR_SEPARATOR) + output++; + + /* POSIX allows double slashes at the start to mean something special + * (as does windows too). So, "//" != "/", but more than two slashes + * is treated as "/". + */ + if (after_root - output == 1) + output++; + + input = after_root; + output_start = output; + while (*input) + { + /* input points to the next non-separator to be processed. */ + /* output points to the next location to write to. */ + g_assert (input > canon && G_IS_DIR_SEPARATOR (input[-1])); + g_assert (output > canon && G_IS_DIR_SEPARATOR (output[-1])); + g_assert (input >= output); + + /* Ignore repeated dir separators. */ + while (G_IS_DIR_SEPARATOR (input[0])) + input++; + + /* Ignore single dot directory components. */ + if (input[0] == '.' && (input[1] == 0 || G_IS_DIR_SEPARATOR (input[1]))) + { + if (input[1] == 0) + break; + input += 2; + } + /* Remove double-dot directory components along with the preceding + * path component. */ + else if (input[0] == '.' && input[1] == '.' && + (input[2] == 0 || G_IS_DIR_SEPARATOR (input[2]))) + { + if (output > output_start) + { + do + { + output--; + } + while (!G_IS_DIR_SEPARATOR (output[-1]) && output > output_start); + } + if (input[2] == 0) + break; + input += 3; + } + /* Copy the input to the output until the next separator, + * while converting it to canonical separator */ + else + { + while (*input && !G_IS_DIR_SEPARATOR (*input)) + *output++ = *input++; + if (input[0] == 0) + break; + input++; + *output++ = G_DIR_SEPARATOR; + } + } + + /* Remove a potentially trailing dir separator */ + if (output > output_start && G_IS_DIR_SEPARATOR (output[-1])) + output--; + + *output = '\0'; + + return canon; +} +#endif + /* resolve . and .., but not symlinks */ gchar *util_normalize_path(const gchar *path, const gchar *relto) { gchar *resolved = NULL; #if GLIB_CHECK_VERSION(2, 58, 0) resolved = g_canonicalize_filename(path, relto); #else + resolved = g2_canonicalize_filename(path, relto); +#endif +#if NOT_DEFINED /* burt's hack version */ gchar *frt = relto ? g_strdup(relto) : NULL; util_null_trailing_slash(frt); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index e12963c0..e573e63e 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -943,6 +943,22 @@ GSList *modules_get_list() return modules_list; } +//Compatibility +#if GLIB_CHECK_VERSION(2,44,0) +#else +static inline gpointer +g2_steal_pointer (gpointer pp) +{ + gpointer *ptr = (gpointer *) pp; + gpointer ref; + + ref = *ptr; + *ptr = NULL; + + return ref; +} +#endif + static GSList *modules_load(gchar ** module_list) { GDir *dir; @@ -975,8 +991,9 @@ static GSList *modules_load(gchar ** module_list) filenames = g_list_delete_link(filenames, item); } #if GLIB_CHECK_VERSION(2,44,0) - //FIXME change this to not use g_steal_pointer g_list_free_full (g_steal_pointer (&filenames), g_object_unref); +#else + g_list_free_full (g2_steal_pointer (&filenames), g_object_unref); #endif g_dir_close(dir); } diff --git a/modules/benchmark/guibench.c b/modules/benchmark/guibench.c index 0faf6b69..2b4f3b11 100644 --- a/modules/benchmark/guibench.c +++ b/modules/benchmark/guibench.c @@ -333,7 +333,7 @@ double guibench(void) gtk_widget_set_size_request(window, 800, 600); gtk_window_set_title(GTK_WINDOW(window), "guibench"); - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ON_PARENT); gtk_widget_show(window); g_signal_connect(window, "key-press-event", G_CALLBACK(keypress_event), NULL); diff --git a/modules/computer/os.c b/modules/computer/os.c index 7648eef3..508f0fa0 100644 --- a/modules/computer/os.c +++ b/modules/computer/os.c @@ -369,8 +369,10 @@ parse_os_release(void) for (line = split; *line; line++) { if (!strncmp(*line, "ID=", sizeof("ID=") - 1)) { id = g_strdup(*line + strlen("ID=")); - } else if (!strncmp(*line, "CODENAME=", sizeof("CODENAME=") - 1)) { + } else if (!strncmp(*line, "CODENAME=", sizeof("CODENAME=") - 1) && codename == NULL) { codename = g_strdup(*line + strlen("CODENAME=")); + } else if (!strncmp(*line, "VERSION_CODENAME=", sizeof("VERSION_CODENAME=") - 1) && codename == NULL) { + codename = g_strdup(*line + strlen("VERSION_CODENAME=")); } else if (!strncmp(*line, "PRETTY_NAME=", sizeof("PRETTY_NAME=") - 1)) { pretty_name = g_strdup(*line + strlen("PRETTY_NAME=\"")); @@ -387,7 +389,7 @@ parse_os_release(void) return (Distro) {}; } -static Distro +/*static Distro parse_lsb_release(void) { gchar *pretty_name = NULL; @@ -395,7 +397,7 @@ parse_lsb_release(void) gchar *codename = NULL; gchar **split, *contents, **line; - if (!hardinfo_spawn_command_line_sync("/usr/bin/lsb_release -di", &contents, NULL, NULL, NULL)) + if (!hardinfo_spawn_command_line_sync("/usr/bin/lsb_release -dic", &contents, NULL, NULL, NULL)) return (Distro) {}; split = g_strsplit(idle_free(contents), "\n", 0); @@ -419,14 +421,14 @@ parse_lsb_release(void) g_free(id); return (Distro) {}; -} + }*/ static Distro detect_distro(void) { static const struct { const gchar *file; - const gchar *codename; + const gchar *id; const gchar *override; } distro_db[] = { #define DB_PREFIX "/etc/" @@ -471,9 +473,9 @@ detect_distro(void) if (distro.distro) return distro; - distro = parse_lsb_release(); + /*distro = parse_lsb_release(); if (distro.distro) - return distro; + return distro;*/ for (i = 0; distro_db[i].file; i++) { if (!g_file_get_contents(distro_db[i].file, &contents, NULL, NULL)) @@ -482,27 +484,27 @@ detect_distro(void) if (distro_db[i].override) { g_free(contents); return (Distro) { .distro = g_strdup(distro_db[i].override), - .codename = g_strdup(distro_db[i].codename) }; + .id = g_strdup(distro_db[i].id) }; } - if (g_str_equal(distro_db[i].codename, "debian")) { + if (g_str_equal(distro_db[i].id, "debian")) { /* HACK: Some Debian systems doesn't include the distribuition * name in /etc/debian_release, so add them here. */ if (isdigit(contents[0]) || contents[0] != 'D') return (Distro) { .distro = g_strdup_printf("Debian GNU/Linux %s", (char*)idle_free(contents)), - .codename = g_strdup(distro_db[i].codename) + .id = g_strdup(distro_db[i].id) }; } - if (g_str_equal(distro_db[i].codename, "fatdog")) { + if (g_str_equal(distro_db[i].id, "fatdog")) { return (Distro) { .distro = g_strdup_printf("Fatdog64 [%.10s]", (char*)idle_free(contents)), - .codename = g_strdup(distro_db[i].codename) + .id = g_strdup(distro_db[i].id) }; } - return (Distro) { .distro = contents, .codename = g_strdup(distro_db[i].codename) }; + return (Distro) { .distro = contents, .id = g_strdup(distro_db[i].id) }; } return (Distro) { .distro = g_strdup(_("Unknown")) }; @@ -542,7 +544,7 @@ computer_get_os(void) os->entropy_avail = computer_get_entropy_avail(); - if (g_strcmp0(os->distrocode, "ubuntu") == 0) { + if (g_strcmp0(os->distroid, "ubuntu") == 0) { GSList *flavs = ubuntu_flavors_scan(); if (flavs) { /* just use the first one */ diff --git a/modules/devices.c b/modules/devices.c index 574896ee..614c43f5 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -37,6 +37,7 @@ #include "udisks2_util.h" #include "storage_util.h" #include "pci_util.h" +#include gchar *callback_processors(); gchar *callback_gpu(); @@ -857,10 +858,12 @@ void hi_module_init(void) .file_name = "sdcard.ids", }, #ifdef ARCH_x86 +#if JSON_CHECK_VERSION(0,20,0) { .name = N_("Update CPU flags database"), .file_name = "cpuflags.json", }, +#endif #endif }; guint i; diff --git a/modules/devices/printers.c b/modules/devices/printers.c index fb9389ac..d880e691 100644 --- a/modules/devices/printers.c +++ b/modules/devices/printers.c @@ -42,7 +42,8 @@ struct _CUPSDest { static int (*cups_dests_get) (CUPSDest **dests) = NULL; static int (*cups_dests_free) (int num_dests, CUPSDest *dests) = NULL; -static gboolean cups_init = FALSE; +static void (*cups_set_server)(const char *server) = NULL; +volatile static gboolean cups_init = FALSE; GModule *cups; @@ -66,9 +67,11 @@ init_cups(void) } if (!g_module_symbol(cups, "cupsGetDests", (gpointer) & cups_dests_get) - || !g_module_symbol(cups, "cupsFreeDests", (gpointer) & cups_dests_free)) { - if(cups) g_module_close(cups); + || !g_module_symbol(cups, "cupsFreeDests", (gpointer) & cups_dests_free) + || !g_module_symbol(cups, "cupsSetServer", (gpointer) & cups_set_server)) { + g_module_close(cups); cups_init = FALSE; + return; } } @@ -190,11 +193,16 @@ scan_printers_do(void) if (!cups_init) { init_cups(); + } + if(!cups_init) { printer_icons = g_strdup(""); printer_list = g_strdup(_("[Printers]\n" "No suitable CUPS library found=")); return; + }else{ + //only list from our own cups, use ip for faster/secure answer + cups_set_server("127.0.0.1"); } /* remove old devices from global device table */ diff --git a/modules/devices/x86/x86_data.c b/modules/devices/x86/x86_data.c index f56e8668..a2f8d7ca 100644 --- a/modules/devices/x86/x86_data.c +++ b/modules/devices/x86/x86_data.c @@ -330,7 +330,7 @@ void cpuflags_x86_init(void) gchar *flag_json = g_build_filename(g_get_user_config_dir(), "hardinfo2", "cpuflags.json", NULL); gboolean use_builtin_table = TRUE; - +#if JSON_CHECK_VERSION(0,20,0) if (!g_file_test(flag_json, G_FILE_TEST_EXISTS)) goto use_builtin_table; @@ -357,6 +357,7 @@ void cpuflags_x86_init(void) use_builtin_table_with_json: g_object_unref(parser); use_builtin_table: +#endif g_free(flag_json); if (use_builtin_table) diff --git a/shell/syncmanager.c b/shell/syncmanager.c index 0f08cf87..9f135ab3 100644 --- a/shell/syncmanager.c +++ b/shell/syncmanager.c @@ -64,7 +64,7 @@ static SoupSession *session = NULL; static GMainLoop *loop; static GQuark err_quark; -//Note there are personal information involved and very old +//Note there are no personal information involved and very old //linux systems does not work with HTTPS so use HTTP for now #define API_SERVER_URI "http://api.hardinfo2.org" @@ -419,24 +419,24 @@ sync_dialog_netarea_start_actions(SyncDialog *sd, SyncNetAction sna[], gint n) gtk_label_set_markup(GTK_LABEL(status_labels[i]), error_str); if (sna[i].error) { - if (sna[i].error->code != 1) { - /* the user has not cancelled something... */ + /* if (sna[i].error->code != 1) { + // the user has not cancelled something... g_warning(_("Failed while performing \"%s\". Please file a " "bug report " "if this problem persists. (Use the " "Help\342\206\222Report" " bug option.)\n\nDetails: %s"), _(sna[i].entry->name), sna[i].error->message); - } + }*/ g_error_free(sna[i].error); } else { - g_warning(_("Failed while performing \"%s\". Please file a bug " + /* g_warning(_("Failed while performing \"%s\". Please file a bug " "report " "if this problem persists. (Use the " "Help\342\206\222Report" " bug option.)"), - _(sna[i].entry->name)); + _(sna[i].entry->name));*/ } break; } -- cgit v1.2.3