diff options
52 files changed, 763 insertions, 655 deletions
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index dab6eec1..0bb77f10 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: - name: Install system dependencies run: | sudo apt update - sudo apt install -y libjson-glib-dev zlib1g-dev libsoup2.4-dev libgtk-3-dev libglib2.0-dev gettext + sudo apt install -y libjson-glib-dev zlib1g-dev libsoup2.4-dev libsoup-3.0-dev libgtk-3-dev libglib2.0-dev gettext # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 176bae37..d8c22fe2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: - name: Install system dependencies run: | sudo apt update - sudo apt install -y libjson-glib-dev zlib1g-dev libsoup2.4-dev libgtk-3-dev libglib2.0-dev gettext + sudo apt install -y libjson-glib-dev zlib1g-dev libsoup2.4-dev libsoup-3.0-dev libgtk-3-dev libglib2.0-dev gettext - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. diff --git a/CMakeLists.txt b/CMakeLists.txt index b03ef737..ed157d2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,17 +2,10 @@ cmake_minimum_required(VERSION 3.0.0) cmake_policy(VERSION 3.0.0) project(hardinfo2) -set(HARDINFO2_VERSION "2.0.15") +set(HARDINFO2_VERSION "2.0.17") 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) - -#old/unused deprecated - lets us know if anyone uses these below -set(DISTRO "" CACHE STRING "Distro build version eg. 1.el(rpm) or 1(deb)") -set(MAINTAINER "" CACHE STRING "Distro maintainer 'name <email>'") -set(OVRARCH "" CACHE STRING "Override HARDINFO2_ARCH value") -set(OVRCPUINFO "" CACHE STRING "Specify a different file for /proc/cpuinfo") -set(OVRDTRROOT "" CACHE STRING "Specify a different path for /proc/device-tree") +option(HARDINFO2_LIBSOUP3 "Build for libsoup-3.0 (0/off for libsoup-2.4)" 1) SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(GNUInstallDirs) @@ -57,17 +50,6 @@ else() message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() -if (OVRARCH) - set(HARDINFO2_ARCH ${OVRARCH}) -endif() -if (OVRCPUINFO) - add_definitions(-DPROC_CPUINFO=${OVRCPUINFO}) - message(STATUS "/proc/cpuinfo override: ${OVRCPUINFO}") -endif() -if (OVRDTRROOT) - add_definitions(-DDTR_ROOT=${OVRDTRROOT}) - message(STATUS "/proc/device-tree override: ${OVRDTRROOT}") -endif() add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}") message(STATUS "LOCALEDIR = ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}") @@ -83,8 +65,7 @@ add_definitions("-Wformat-security") set(PACKAGE_LIBSOUP2_MINVERSION 2.42) set(PACKAGE_LIBGLIB2_MINVERSION 2.24) -###################################DISTRO CHANGES############################### -#Please add all distro relates stuff here +#########################CPack PACKAGING SETUP############################### set(RPM 0) file(STRINGS /etc/os-release distro REGEX "^NAME=") string(REGEX REPLACE "NAME=" "" distro "${distro}") @@ -93,11 +74,18 @@ string(REGEX REPLACE "/" "" distro "${distro}") string(REGEX REPLACE " " "" distro "${distro}") file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") string(REGEX REPLACE "VERSION_ID=" "" disversion "${disversion}") +string(COMPARE EQUAL "${disversion}" "" result) +if(result) + #sid/rawhide with no version - use project name + message("-- Found no distro version - Using codename") + file(STRINGS /etc/os-release disversion REGEX "^VERSION_CODENAME=") + string(REGEX REPLACE "VERSION_CODENAME=" "" disversion "99_${disversion}") +endif() 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*" OR ${distro} MATCHES "openSUSE*") +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*" OR ${distro} MATCHES "SUSE*") set(RPM 1) endif() #Package architecture @@ -111,83 +99,72 @@ else() set(PACKAGE_ARCHITECTURE "_amd64") endif() endif() -#Package Distro build version - part of package name set(PACKAGE_DISTRO ${HARDINFO2_VERSION}-${distro}-${disversion}${CPACK_SYSTEM_NAME}) SET(CPACK_PACKAGE_VERSION ${HARDINFO2_VERSION}) -if(DISTRO) - message("-- DISTRO BUILD") - string(REGEX REPLACE "[.].*" "" DISTRO_BUILD_VER ${DISTRO}) - set(CPACK_PACKAGE_VERSION "${HARDINFO2_VERSION}-${DISTRO_BUILD_VER}") - set(PACKAGE_DISTRO "${HARDINFO2_VERSION}-${DISTRO}") - if(${DISTRO_BUILD_VER} MATCHES "src") - SET(CPACK_RPM_USER_BINARY_SPECFILE "hardinfo2.spec") - set(CPACK_PACKAGE_VERSION "${HARDINFO2_VERSION}") - set(PACKAGE_DISTRO "${HARDINFO2_VERSION}") - endif() - if(${HARDINFO2_GTK3}) - else() - message(FATAL_ERROR "Distro-Building not supported with GTK2!!") - endif() - if(MAINTAINER) - set(PACKAGE_MAINTAINER ${MAINTAINER}) - else() - set(PACKAGE_MAINTAINER "hwspeedy <hardinfo2@bigbear.dk>") - endif() -else() - set(PACKAGE_MAINTAINER "hwspeedy <hardinfo2@bigbear.dk>") -endif() #Put it together string(REPLACE " " "${PACKAGE_DELIMITER}" CPACK_PACKAGE_FILE_NAME "hardinfo2${PACKAGE_DELIMITER}${PACKAGE_DISTRO}${PACKAGE_ARCHITECTURE}") -if(${RPM}) - string(REPLACE " " "-" CPACK_SOURCE_PACKAGE_FILE_NAME "hardinfo2-${PACKAGE_DISTRO}") -else() - string(REPLACE " " "_" CPACK_SOURCE_PACKAGE_FILE_NAME "hardinfo2-${HARDINFO2_VERSION}") -endif() -message("-- Found Package Target ${CPACK_PACKAGE_FILE_NAME}") +string(REPLACE " " "${PACKAGE_DELIMITER}" CPACK_SOURCE_PACKAGE_FILE_NAME "hardinfo2${PACKAGE_DELIMITER}${PACKAGE_DISTRO}${PACKAGE_ARCHITECTURE}") message("-- Found Package Version ${CPACK_PACKAGE_VERSION}") +message("-- Found distro description ${distro}${disversion}") #flavour output set(HARDINFO2_OS ${distro}) -# currently all RPM flavours uses libsoup-2.4 -if(${RPM}) - set(HARDINFO2_LIBSOUP3 0) +#fedora ->35 +if(${disversion} LESS 35.99) + if(${distro} MATCHES "Fedora*") + message("Fedora ->35 - LS24") + set(HARDINFO2_LIBSOUP3 0) + endif() endif() -#oracle 6 -if(${distro}${disversion} MATCHES "Oracle6*") +#centos/redhat/oracle/opensuse/suse ->9 +if(${disversion} LESS 9.99) + if(${distro} MATCHES "Red*" OR ${distro} MATCHES "CentOS*" OR ${distro} MATCHES "Oracle*" OR ${distro} MATCHES "openSUSE*" OR ${distro} MATCHES "Alma*" OR ${distro} MATCHES "Rocky*") + message("Centos/Redhat/oracle/opensuse/suse/rocky/alma ->9 - LS24") set(HARDINFO2_LIBSOUP3 0) + endif() +endif() + +#centos/redhat/oracle/opensuse/suse 6 +if(${disversion} LESS 6.99) + if((${distro} MATCHES "Red*" OR ${distro} MATCHES "CentOS*" OR ${distro} MATCHES "Oracle*" OR ${distro} MATCHES "openSUSE*" OR ${distro} MATCHES "SUSE*")) + message("RPM EL6 - GTK2 - deprecated - support will end at any time") + message("RPM EL6 - LS24 - deprecated version 2.34.3 - but ok") set(HARDINFO2_GTK3 0) - #old deprecated version - but ok set(PACKAGE_LIBSOUP2_MINVERSION 2.34.3) + endif() endif() #debian 7 if(${distro}${disversion} MATCHES "DebianGNULinux7") - set(HARDINFO2_LIBSOUP3 0) + message("DEB 7 - GTK2 to avoid c11 for ubergraph - deprecated - support will end at any time") + message("DEB 7 - LS24 - deprecated version 2.34.3 - but ok") set(HARDINFO2_GTK3 0) - #old deprecated version - but ok set(PACKAGE_LIBSOUP2_MINVERSION 2.34.3) endif() -#debian 8 -if(${distro}${disversion} MATCHES "DebianGNULinux8") +#debian ->11 +if(${disversion} LESS 11.99) + if(${distro} MATCHES "DebianGNULinux") + message("DEB ->11 - LS24") set(HARDINFO2_LIBSOUP3 0) + endif() endif() #ubuntu 20.04 -if(${distro}${disversion} MATCHES "Ubuntu20.04") +if(${disversion} LESS 20.99) + if(${distro} MATCHES "Ubuntu") + message("Ubuntu ->20.xx - LS24") set(HARDINFO2_LIBSOUP3 0) + endif() endif() -#Debian 11 -if(${distro}${disversion} MATCHES "DebianGNULinux11") - set(HARDINFO2_LIBSOUP3 0) -endif() #Fedora 39 - bug with man pages - upgrade cmake to 3.28.x ################################################################################ + if(${CMAKE_BUILD_TYPE} MATCHES [Dd]ebug) set(HARDINFO2_DEBUG 1) if(${distro}${disversion} MATCHES "DebianGNULinux7") @@ -208,7 +185,7 @@ else() pkg_check_modules(GTK REQUIRED gtk+-2.0>=2.10 gthread-2.0>=2.10 gmodule-export-2.0>=2.10) endif() -if (HARDINFO2_LIBSOUP3) +if (${HARDINFO2_LIBSOUP3}) pkg_check_modules(LIBSOUP REQUIRED libsoup-3.0>=3.00) else() pkg_check_modules(LIBSOUP REQUIRED libsoup-2.4>=${PACKAGE_LIBSOUP2_MINVERSION}) @@ -305,7 +282,7 @@ set(MODULE_network_SOURCES modules/network/nfs.c modules/network/samba.c ) -set(MODULE_benchmark_SOURCES_GTKANY +set(MODULE_benchmark_SOURCES modules/benchmark.c modules/benchmark/bench_util.c modules/benchmark/blowfish.c @@ -322,16 +299,9 @@ set(MODULE_benchmark_SOURCES_GTKANY modules/benchmark/zlib.c modules/benchmark/sysbench.c modules/benchmark/iperf3.c -) -set(MODULE_benchmark_SOURCES_GTK2 modules/benchmark/drawing.c modules/benchmark/guibench.c ) -if (HARDINFO2_GTK3) - set(MODULE_benchmark_SOURCES ${MODULE_benchmark_SOURCES_GTKANY}) -else() - set(MODULE_benchmark_SOURCES ${MODULE_benchmark_SOURCES_GTKANY} ${MODULE_benchmark_SOURCES_GTK2}) -endif() set_source_files_properties( modules/benchmark/blowfish.c @@ -496,7 +466,7 @@ configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h @ONLY) configure_file(hardinfo2.desktop.cmake ${CMAKE_BINARY_DIR}/hardinfo2.desktop @ONLY) install(TARGETS hardinfo2 ${HARDINFO2_MODULES} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/hardinfo2/modules PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) @@ -522,8 +492,8 @@ install(FILES pixmaps/hardinfo2.png PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) -########################PACKAGE BUILDING FOR DISTROS########################### -#Please update here for building packages +########################CPack PACKAGE BUILDING########################### + SET(CPACK_PACKAGE_HOMEPAGE_URL "https://www.hardinfo2.org") if(${RPM}) set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") @@ -540,14 +510,13 @@ endif() #RPM SET(CPACK_RPM_PACKAGE_OBSOLETES "hardinfo") -SET(CPACK_RPM_PACKAGE_MAINTAINER ${PACKAGE_MAINTAINER}) +SET(CPACK_RPM_PACKAGE_MAINTAINER "hwspeedy <hardinfo2@bigbear.dk>") SET(CPACK_RPM_PACKAGE_DESCRIPTION "Hardinfo2 - System Information and Benchmark") SET(CPACK_RPM_PACKAGE_RECOMMENDS "sysbench, udisks2, mesa-utils, lsscsi, lm-sensors, xdg-utils, iperf3") SET(CPACK_RPM_PACKAGE_LICENSE "GPL2+") SET(CPACK_RPM_PACKAGE_HOMEPAGE "https://github.com/hardinfo2/hardinfo2") SET(CPACK_RPM_PACKAGE_URL "https://www.hardinfo2.org") -#SET(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DDISTRO=1") -if(HARDINFO2_LIBSOUP3) +if(${HARDINFO2_LIBSOUP3}) SET(PACKAGE_LS "libsoup (>=3.0)") else() SET(PACKAGE_LS "libsoup (>=${PACKAGE_LIBSOUP2_MINVERSION})") @@ -562,12 +531,12 @@ SET(CPACK_RPM_PACKAGE_DEPENDS "libjson-glib-1.0-0, zlib, ${PACKAGE_LS}, ${PACKAG #DEB SET(CPACK_DEBIAN_PACKAGE_REPLACES "hardinfo") SET(CPACK_DEBIAN_PACKAGE_BREAKS "hardinfo") -SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${PACKAGE_MAINTAINER}) +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "hwspeedy <hardinfo2@bigbear.dk>") SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Hardinfo2 - System Information and Benchmark") SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sysbench, udisks2, mesa-utils, lsscsi, lm-sensors, xdg-utils, iperf3") SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/hardinfo2/hardinfo2") -if(HARDINFO2_LIBSOUP3) - SET(PACKAGE_LS "libsoup-3.0.0 (>=3.0)") +if(${HARDINFO2_LIBSOUP3}) + SET(PACKAGE_LS "libsoup-3.0-0 (>=3.0)") else() SET(PACKAGE_LS "libsoup2.4-1 (>=${PACKAGE_LIBSOUP2_MINVERSION})") if(${distro}${disversion} MATCHES "Debian GNU/Linux11") @@ -19,7 +19,7 @@ Status ------ - Capabilities: Hardinfo2 currently detects most software and hardware detected by the OS. - Features: Online database for exchanging benchmark results. -- Development: Currently done by contributors, hwspeedy maintains +- Development: Currently done by community, hwspeedy maintains Server code can be found here: [https://github.com/hardinfo2/server](https://github.com/hardinfo2/server) @@ -29,15 +29,17 @@ Dependencies - GLib >=2.24 - Zlib - glib JSON -- Libsoup2.4 >=2.42 or Libsoup-3.0 (EXPERIMENTAL) (LS3: cmake -DHARDINFO2_LIBSOUP3=1 ..) +- Libsoup3 >=3.00 or Libsoup24>=2.42 (LS24: cmake -DHARDINFO2_LIBSOUP3=0 ..) Building and installing ----------------------- **Debian/Ubuntu/Mint/PopOS** -- sudo apt install git cmake build-essential gettext +- sudo apt install git cmake build-essential gettext curl - sudo apt install libjson-glib-dev zlib1g-dev libsoup2.4-dev libgtk-3-dev libglib2.0-dev +- sudo apt install libsoup-3.0-dev (might fail if not available on distro - OK) - git clone https://github.com/hardinfo2/hardinfo2 - cd hardinfo2 +- ./tools/git_latest_release.sh (Switch to latest stable release, tools/git_unstable_master.sh for developers) - mkdir build - cd build - cmake .. @@ -49,10 +51,12 @@ Building and installing **Fedore/Centos/RedHat/Rocky/Alma/Oracle** * NOTE: Centos 7 needs epel-release and cmake3 instead of cmake - use cmake3 instead of cmake - sudo yum install epel-release (only CentOS 7) -- sudo yum install git cmake gcc gcc-c++ gettext rpmdevtools +- sudo yum install git cmake gcc gcc-c++ gettext rpmdevtools curl - sudo yum install json-glib-devel zlib-devel libsoup-devel gtk3-devel +- sudo yum install libsoup3-devel (might fail if not available on distro - OK) - git clone https://github.com/hardinfo2/hardinfo2 - cd hardinfo2 +- ./tools/git_latest_release.sh (Switch to latest stable release, tools/git_unstable_master.sh for developers) - mkdir build - cd build - cmake .. @@ -61,10 +65,10 @@ Building and installing - sudo yum install lm_sensors sysbench lsscsi glx-utils dmidecode udisks2 xdg-utils iperf3 - hardinfo2 -**openSUSE**: use zypper instead of yum, use libsoup2-devel instead of libsoup-devel +**openSUSE**: use zypper instead of yum, zypper --no-gpg-checks install ./hardinfo2-* **ArchLinux/Garuda/Manjaro - AUR Package** - - git clone https://aur.archlinux.org/hardinfo2.git (hardinfo2-git.git for unstable master only developers) + - git clone https://aur.archlinux.org/hardinfo2 (hardinfo2-git for unstable master for developers) - cd hardinfo2 - makepkg -cis - hardinfo2 @@ -92,7 +96,7 @@ License ------ The Project License has been changed in 2024 from GPL2 to **GPL2 or later** -Because we use LGPL2.1+ and GPL3 code. To future proof the project, lpereira and other developers has agreed to change license of source code also to GPL2+. (https://github.com/lpereira/hardinfo/issues/530) (https://github.com/lpereira/hardinfo/issues/707). +Because we use LGPL2.1+ and GPL3+ code. To future proof the project, lpereira and other developers have agreed to change license of source code also to GPL2+. (https://github.com/lpereira/hardinfo/issues/530) (https://github.com/lpereira/hardinfo/issues/707). It is all about open source and creating together - Read more about GPL license here: https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility diff --git a/config.h.cmake b/config.h.cmake index d0b22a2e..2bcd8455 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -15,14 +15,27 @@ #define PREFIX "@CMAKE_INSTALL_DATAROOTDIR@/hardinfo2" #cmakedefine HARDINFO2_DEBUG @HARDINFO2_DEBUG@ +#cmakedefine CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@ +#cmakedefine HARDINFO2_LIBSOUP3 @HARDINFO2_LIBSOUP3@ + +#define ON 1 +#define OFF 0 + +#if !defined(HARDINFO2_LIBSOUP3) + #define HARDINFO2_LIBSOUP3 0 +#endif #if defined(HARDINFO2_DEBUG) && (HARDINFO2_DEBUG==1) - #define RELEASE 0 #define DEBUG(msg,...) fprintf(stderr, "*** %s:%d (%s) *** " msg "\n", \ __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) + #define RELEASE -1 #else - #define RELEASE 1 #define DEBUG(msg,...) + #if (CMAKE_BUILD_TYPE==Release) + #define RELEASE 1 + #else + #define RELEASE 0 + #endif #endif /* HARDINFO2_DEBUG */ #define ENABLE_BINRELOC 1 diff --git a/deps/sysobj_early/src/nice_name.c b/deps/sysobj_early/src/nice_name.c index e5e15a46..fdb4557c 100644 --- a/deps/sysobj_early/src/nice_name.c +++ b/deps/sysobj_early/src/nice_name.c @@ -34,11 +34,15 @@ gboolean str_shorten(gchar *str, const gchar *find, const gchar *replace) { long unsigned lr = strlen(replace); gchar *p = strstr(str, find); if (p) { - if (lr > lf) lr = lf; - gchar *buff = g_strnfill(lf, ' '); - strncpy(buff, replace, lr); - strncpy(p, buff, lf); - g_free(buff); + if(lr==lf){ + strncpy(p, replace, lf); + } else { + if (lr > lf) lr = lf; + gchar *buff = g_strnfill(lf, ' '); + if(lr) strncpy(buff, replace, lr); + strncpy(p, buff, lf); + g_free(buff); + } return TRUE; } return FALSE; @@ -50,11 +54,15 @@ gboolean str_shorten_anycase(gchar *str, const gchar *find, const gchar *replace long unsigned lr = strlen(replace); gchar *p = strcasestr(str, find); if (p) { - if (lr > lf) lr = lf; - gchar *buff = g_strnfill(lf, ' '); - strncpy(buff, replace, lr); - strncpy(p, buff, lf); - g_free(buff); + if(lr==lf){ + strncpy(p, replace, lf); + } else { + if (lr > lf) lr = lf; + gchar *buff = g_strnfill(lf, ' '); + if(lr) strncpy(buff, replace, lr); + strncpy(p, buff, lf); + g_free(buff); + } return TRUE; } return FALSE; diff --git a/deps/sysobj_early/src/util_ids.c b/deps/sysobj_early/src/util_ids.c index 197b1ed3..9546a8b7 100644 --- a/deps/sysobj_early/src/util_ids.c +++ b/deps/sysobj_early/src/util_ids.c @@ -243,7 +243,7 @@ GSList *ids_file_all_get_all(const gchar *file, split_loc_function split_loc_fun ids_query_result *working = g_new0(ids_query_result, 1); gchar **qparts = g_new0(gchar*, IDS_LOOKUP_MAX_DEPTH + 1); for(tabs = IDS_LOOKUP_MAX_DEPTH-1; tabs>=0; tabs--) - qparts[tabs] = g_malloc0(IDS_LOOKUP_BUFF_SIZE); + qparts[tabs] = g_malloc0(IDS_LOOKUP_BUFF_SIZE+1); tabs = 0; if (!split_loc_func) split_loc_func = split_loc_default; @@ -290,7 +290,7 @@ GSList *ids_file_all_get_all(const gchar *file, split_loc_function split_loc_fun // now p = id, name = name // ids_msg("p: %s -- name: %s", p, name); - strncpy(qparts[tabs], p, IDS_LOOKUP_BUFF_SIZE-1); + strncpy(qparts[tabs], p, IDS_LOOKUP_BUFF_SIZE); ids_query_result_set_str(working, tabs, name); if (tabs < tabs_last) for(;tabs_last > tabs; tabs_last--) { diff --git a/hardinfo2.1 b/hardinfo2.1 index e1125e62..094318d4 100644 --- a/hardinfo2.1 +++ b/hardinfo2.1 @@ -1,6 +1,6 @@ .\" Manpage for hardinfo. .\" https://github.com/hwspeedy/hardinfo2/. -.TH HARDINFO "1" "January 2024" "2.0" "User Commands" +.TH HARDINFO "1" "Marts 2024" "2.0" "User Commands" .SH NAME \fBHardinfo2\fR \- System Information and Benchmark for Linux Systems. .SH USAGE @@ -20,11 +20,35 @@ creates a report and prints to standard output \fB\-f\fR, \fB\-\-report\-format\fR chooses a report format (text, html) .TP +\fB\-g\fR, \fB\-\-result\-format\fR +chooses a result format (short, conf, shell) +.TP \fB\-b\fR, \fB\-\-run\-benchmark\fR -run benchmark +run a specific benchmark eg. -b 'FPU FFT' (Default all benchmarks runs when generate report) +.TP +\fB\-s\fR, \fB\-\-skip\-benchmark\fR +Disables all benchmark runs. +.TP +\fB\-u\fR, \fB\-\-user\-note\fR +adds a user note to data send to server. When added eg. -u 1 synchronization is activated. .TP \fB\-v\fR, \fB\-\-version\fR shows program version and quit +.SH EXAMPLES +examples of CLI command usage:\fR +.TP +hardinfo2 -b 'FPU FFT' +runs only FPU FFT benchmark +.TP +hardinfo2 -u 1 +enable updates at startup and starts gui (can also be set in gui) +.TP +hardinfo2 -u SBC-DK -r +updates data from server, generate CLI report and sends benchmark with user-note +.TP +hardinfo2 -r +generates CLI report + .SH COPYRIGHT -\fBHardinfo2\fR its Copyright \(co 2003-2023 L. A. F. Pereira, 2024- Hardinfo2 Project\fR. +\fBHardinfo2\fR is Copyright \(co 2003-2023 L. A. F. Pereira, 2024- Hardinfo2 Project\fR. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/hardinfo2/binreloc.c b/hardinfo2/binreloc.c index f47a3fae..d0a00570 100644 --- a/hardinfo2/binreloc.c +++ b/hardinfo2/binreloc.c @@ -1,13 +1,20 @@ /* * BinReloc - a library for creating relocatable executables * Written by: Hongli Lai <h.lai@chello.nl> + * Copyright: hardinfo2 project * http://autopackage.org/ * - * This source code is public domain. You can relicense this code - * under whatever license you want. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2.0 or later. * - * See http://autopackage.org/docs/binreloc/ for - * more information and how to use this. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __BINRELOC_C__ diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index e2f11cdf..218b4298 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -2,9 +2,9 @@ * HardInfo - Displays System Information * Copyright (C) 2003-2009 L. A. F. Pereira <l@tia.mat.br> * + * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 or later. + * it under the terms of the GNU General Public License v2.0 or later. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include <config.h> #include <shell.h> @@ -58,16 +59,17 @@ int main(int argc, char **argv) g_print(_("Compile-time options:\n" " Release version: %s (%s)\n" + " LibSoup version: %s\n" " BinReloc enabled: %s\n" " Data prefix: %s\n" " Library prefix: %s\n" " Compiled for: %s\n"), - RELEASE ? _("Yes") : "No (" VERSION ")", ARCH, + RELEASE==1 ? "Yes (" VERSION ")" : (RELEASE==0?"No (" VERSION ")":"Debug (" VERSION ")"), ARCH, + HARDINFO2_LIBSOUP3 ? _("3.0") : "2.4", ENABLE_BINRELOC ? _("Yes") : _("No"), PREFIX, LIBPREFIX, PLATFORM); - DEBUG(" Debugging is enabled."); - + return 0; } /* initialize the binreloc library, so we can load program data */ @@ -106,7 +108,7 @@ int main(int argc, char **argv) result = module_call_method_param("benchmark::runBenchmark", params.run_benchmark); if (!result) { - fprintf(stderr, _("Unknown benchmark ``%s''"), params.run_benchmark); + fprintf(stderr, _("Unknown benchmark ``%s''\n"), params.run_benchmark); exit_code = 1; } else { fprintf(stderr, "\n"); @@ -127,6 +129,10 @@ int main(int argc, char **argv) /* generate report */ gchar *report; + if(params.bench_user_note) {//synchronize without sending benchmarks + sync_manager_update_on_startup(0); + } + DEBUG("generating report"); report = report_create_from_module_list_format(modules, @@ -134,6 +140,11 @@ int main(int argc, char **argv) report_format); g_print("%s", report); + if(params.bench_user_note) {//synchronize + if(!params.skip_benchmarks) + sync_manager_update_on_startup(1); + } + g_free(report); } else { g_error(_("Don't know what to do. Exiting.")); diff --git a/hardinfo2/socket.c b/hardinfo2/socket.c index b94e43c2..1acd86de 100644 --- a/hardinfo2/socket.c +++ b/hardinfo2/socket.c @@ -40,7 +40,7 @@ Socket *sock_connect(gchar * host, gint port) if (sock > 0) { memset(&server, 0, sizeof(server)); server.sin_family = AF_INET; - server.sin_addr.s_addr = inet_addr(host); + inet_pton(AF_INET,host,&server.sin_addr.s_addr); server.sin_port = htons(port); if (connect(sock, (struct sockaddr *) (void *) &server, sizeof(server)) < 0) { diff --git a/hardinfo2/util.c b/hardinfo2/util.c index cbabcc53..516ddb0c 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -90,7 +90,7 @@ gchar *seconds_to_string(unsigned int seconds) { unsigned int hours, minutes, days; const gchar *days_fmt, *hours_fmt, *minutes_fmt, *seconds_fmt; - gchar *full_fmt, *ret = g_strdup(""); + gchar *full_fmt=NULL, *ret = g_strdup(""); minutes = seconds / 60; seconds %= 60; @@ -416,13 +416,13 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) .short_name = 'b', .arg = G_OPTION_ARG_STRING, .arg_data = &run_benchmark, - .description = N_("run benchmark eg. -b 'FPU FFT'")}, + .description = N_("run single benchmark eg. -b 'FPU FFT' (Default all Benchmarks runs)")}, { .long_name = "user-note", .short_name = 'u', .arg = G_OPTION_ARG_STRING, .arg_data = &bench_user_note, - .description = N_("note attached to benchmark results")}, + .description = N_("user note attached to benchmark results. (updating/synchronize with server)")}, { .long_name = "result-format", .short_name = 'g', diff --git a/hardinfo2/x_util.c b/hardinfo2/x_util.c index 2a7febb4..95e3274d 100644 --- a/hardinfo2/x_util.c +++ b/hardinfo2/x_util.c @@ -156,7 +156,7 @@ gboolean fill_xrr_info(xrr_info *xrr) { x_screen ts; x_output to; - char output_id[128]; + char output_id[64]; char status[128]; char alist[512]; @@ -195,7 +195,7 @@ gboolean fill_xrr_info(xrr_info *xrr) { /* looking for: * <output_id> (connected|disconnected|unknown connection) (primary|?) <%dx%d+%d+%d> (attribute_list) mm x mm */ - ec = sscanf(p, "%127s %127[^(](%511[^)]", output_id, status, alist); + ec = sscanf(p, "%63s %127[^(](%511[^)]", output_id, status, alist); if (ec == 3) { int is_output = 0, found_rect = 0, n = 0; gchar **ot = g_strsplit(status, " ", 0); @@ -228,7 +228,7 @@ gboolean fill_xrr_info(xrr_info *xrr) { } g_strfreev(ot); if (is_output) { - strncpy(to.name, output_id, 63); + strncpy(to.name, output_id, 64); xrr->output_count++; if (xrr->outputs == NULL) xrr->outputs = malloc(xrr->output_count * sizeof(x_output)); diff --git a/includes/binreloc.h b/includes/binreloc.h index 3bf48bc6..5c7074a8 100644 --- a/includes/binreloc.h +++ b/includes/binreloc.h @@ -1,13 +1,20 @@ /* * BinReloc - a library for creating relocatable executables * Written by: Hongli Lai <h.lai@chello.nl> + * Copyright by: hardinfo2 project * http://autopackage.org/ * - * This source code is public domain. You can relicense this code - * under whatever license you want. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2.0 or later. * - * See http://autopackage.org/docs/binreloc/ for - * more information and how to use this. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __BINRELOC_H__ diff --git a/includes/blowfish.h b/includes/blowfish.h index 3f33e945..2d0dae1a 100644 --- a/includes/blowfish.h +++ b/includes/blowfish.h @@ -1,20 +1,18 @@ /*
-blowfish.h: Header file for blowfish.c
-
-Copyright (C) 1997 by Paul Kocher
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
+ * blowfish.h: Header file for blowfish.c
+ * Copyright (C) 1997 by Paul Kocher
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
See blowfish.c for more information about this file.
*/
diff --git a/includes/guibench.h b/includes/guibench.h index 16f34218..da223452 100644 --- a/includes/guibench.h +++ b/includes/guibench.h @@ -19,6 +19,6 @@ #ifndef __GUIBENCH_H__ #define __GUIBENCH_H__ -double guibench(void); +double guibench(double *frameTime, int *frameCount); -#endif /* __GUIBENCH_H__ */
\ No newline at end of file +#endif /* __GUIBENCH_H__ */ diff --git a/includes/loadgraph.h b/includes/loadgraph.h index d176e816..16181cd9 100644 --- a/includes/loadgraph.h +++ b/includes/loadgraph.h @@ -11,10 +11,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with the Simple Load Graph; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ diff --git a/includes/loongarch64/processor-platform.h b/includes/loongarch64/processor-platform.h index 006b762a..cc4b7fa6 100644 --- a/includes/loongarch64/processor-platform.h +++ b/includes/loongarch64/processor-platform.h @@ -3,8 +3,7 @@ * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 or Later. + * it under the terms of the GNU General Public License v2.0 or later. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/includes/sha1.h b/includes/sha1.h index 8b5c0b2f..ae22a0f5 100644 --- a/includes/sha1.h +++ b/includes/sha1.h @@ -1,7 +1,19 @@ /* * SHA-1 in C * By Steve Reid <steve@edmweb.com> - * 100% Public Domain + * Copyright by: hardinfo2 project + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2.0 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __SHA1_H__ diff --git a/includes/syncmanager.h b/includes/syncmanager.h index c17601da..a385dea0 100644 --- a/includes/syncmanager.h +++ b/includes/syncmanager.h @@ -38,6 +38,6 @@ void sync_manager_clear_entries(void); void sync_manager_show(GtkWidget *parent); gint sync_manager_count_entries(void); -void sync_manager_update_on_startup(void); +void sync_manager_update_on_startup(int send_benchmark); #endif /* __SYNCMANAGER_H__ */ diff --git a/modules/benchmark.c b/modules/benchmark.c index 511c984e..d4a39677 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -518,7 +518,7 @@ static gchar *benchmark_include_results_internal(bench_value this_machine_value, ShellOrderType order_type) { bench_result *this_machine; - GSList *result_list, *li; + GSList *result_list=NULL, *li; gchar *results = g_strdup(""); gchar *output; gchar *path; @@ -603,6 +603,7 @@ do_benchmark_handler(GIOChannel *source, GIOCondition condition, gpointer data) GIOStatus status; gchar *result; bench_value r = EMPTY_BENCH_VALUE; + status = g_io_channel_read_line(source, &result, NULL, NULL, NULL); if (status != G_IO_STATUS_NORMAL) { DEBUG("error while reading benchmark result"); @@ -657,8 +658,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) bench_dialog = gtk_dialog_new_with_buttons ("Benchmarking...", GTK_WINDOW(shell_get_main_shell()->transient_dialog), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - "Stop", - GTK_BUTTONS_CLOSE, + _("Stop"), GTK_RESPONSE_ACCEPT, NULL); gtk_widget_set_sensitive(GTK_WIDGET(shell_get_main_shell()->transient_dialog), FALSE); @@ -670,8 +670,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) #else box = gtk_hbox_new(FALSE, 1); #endif - label = gtk_label_new ("Please do not move your mouse\n" - "or press any keys."); + label = gtk_label_new ("Please do not move your mouse\nor press any keys."); gtk_widget_show (bench_image); @@ -681,11 +680,6 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) gtk_misc_set_alignment(GTK_MISC(bench_image), 0.0, 0.0); #endif - g_signal_connect_swapped (bench_dialog, - "response", - G_CALLBACK (gtk_widget_destroy), - bench_dialog); - gtk_box_pack_start (GTK_BOX(box), bench_image, TRUE, TRUE, 10); gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 10); gtk_container_add (GTK_CONTAINER(content_area), box); @@ -720,16 +714,15 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) switch (gtk_dialog_run(GTK_DIALOG(bench_dialog))) { case GTK_RESPONSE_NONE: DEBUG("benchmark finished"); + bench_results[entry] = benchmark_dialog->r; break; case GTK_RESPONSE_ACCEPT: DEBUG("cancelling benchmark"); - gtk_widget_destroy(bench_dialog); g_source_remove(watch_id); kill(bench_pid, SIGINT); } - bench_results[entry] = benchmark_dialog->r; g_io_channel_unref(channel); shell_view_set_enabled(TRUE); @@ -835,7 +828,8 @@ static gchar *get_benchmark_results(gsize *len) ADD_JSON_VALUE(int, "MachineDataVersion", this_machine->machine_data_version); ADD_JSON_VALUE(string, "MachineType", this_machine->machine_type); - + ADD_JSON_VALUE(string, "LinuxKernel", this_machine->linux_kernel); + ADD_JSON_VALUE(string, "LinuxOS", this_machine->linux_os); ADD_JSON_VALUE(boolean, "Legacy", FALSE); ADD_JSON_VALUE(string, "ExtraInfo", bench_results[i].extra); ADD_JSON_VALUE(string, "UserNote", bench_results[i].user_note); @@ -867,7 +861,7 @@ static gchar *run_benchmark(gchar *name) { int i; - DEBUG("name = %s", name); + DEBUG("run_benchmark = %s", name); for (i = 0; entries[i].name; i++) { if (g_str_equal(entries[i].name, name)) { diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index e0557fc2..83c308bc 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -51,6 +51,8 @@ typedef struct { char *ram_types; int machine_data_version; char *machine_type; + char *linux_kernel; /*kernelarch*/ + char *linux_os; /*distroversion*/ } bench_machine; typedef struct { @@ -185,6 +187,8 @@ bench_machine *bench_machine_this() m->memory_phys_MiB = memory_devices_get_system_memory_MiB(); m->ram_types = memory_devices_get_system_memory_types_str(); m->machine_type = module_call_method("computer::getMachineType"); + m->linux_kernel = module_call_method("computer::getOSKernel"); + m->linux_os = module_call_method("computer::getOS"); free(tmp); cpu_procs_cores_threads_nodes(&m->processors, &m->cores, &m->threads, &m->nodes); @@ -203,6 +207,8 @@ void bench_machine_free(bench_machine *s) free(s->mid); free(s->ram_types); free(s->machine_type); + free(s->linux_kernel); + free(s->linux_os); free(s); } } @@ -426,7 +432,7 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name, .result = json_get_double(machine, "BenchmarkResult"), .elapsed_time = json_get_double(machine, "ElapsedTime"), .threads_used = json_get_int(machine, "UsedThreads"), - .revision = json_get_int(machine, "BenchmarkRevision"), + .revision = json_get_int(machine, "BenchmarkVersion"),//Revision }; snprintf(b->bvalue.extra, sizeof(b->bvalue.extra), "%s", @@ -556,6 +562,8 @@ static char *bench_result_more_info_complete(bench_result *b) "[%s]\n" /* board */ "%s=%s\n" /* machine_type */ "%s=%s\n" + /* linux_kernel */ "%s=%s\n" + /* linux_os */ "%s=%s\n" /* cpu */ "%s=%s\n" /* cpudesc */ "%s=%s\n" /* cpucfg */ "%s=%s\n" @@ -584,6 +592,8 @@ static char *bench_result_more_info_complete(bench_result *b) _("Machine"), _("Board"), (b->machine->board != NULL) ? b->machine->board : _(unk), _("Machine Type"), (b->machine->machine_type != NULL) ? b->machine->machine_type : _(unk), + _("Linux Kernel"), (b->machine->linux_kernel != NULL) ? b->machine->linux_kernel : _(unk), + _("Linux OS"), (b->machine->linux_os != NULL) ? b->machine->linux_os : _(unk), _("CPU Name"), b->machine->cpu_name, _("CPU Description"), (b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : _(unk), diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c index 0b57ac1c..34ed5983 100644 --- a/modules/benchmark/benches.c +++ b/modules/benchmark/benches.c @@ -28,7 +28,7 @@ gchar *CN() { \ #define BENCH_SCAN_SIMPLE(SN, BF, BID) \ void SN(gboolean reload) { \ - SCAN_START(); \ + static gboolean scanned = FALSE; if (reload || bench_results[BID].result<=0.0) scanned = FALSE;if (scanned) return; \ do_benchmark(BF, BID); \ SCAN_END(); \ } @@ -56,17 +56,17 @@ BENCH_SIMPLE(BENCHMARK_MEMORY_DUAL, "SysBench Memory (Two threads)", benchmark_m BENCH_SIMPLE(BENCHMARK_MEMORY_QUAD, "SysBench Memory (Quad threads)", benchmark_memory_quad, 1); BENCH_SIMPLE(BENCHMARK_MEMORY_ALL, "SysBench Memory (Multi-thread)", benchmark_memory_all, 1); -#if !GTK_CHECK_VERSION(3,0,0) -BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1); -void scan_gui(gboolean reload) +BENCH_CALLBACK(callback_benchmark_gui, "GPU Drawing", BENCHMARK_GUI, 1); +void scan_benchmark_gui(gboolean reload) { - SCAN_START(); + static gboolean scanned = FALSE; + if (reload || bench_results[BENCHMARK_GUI].result<=0.0) scanned = FALSE; + if (scanned) return; bench_value er = EMPTY_BENCH_VALUE; if (params.run_benchmark) { int argc = 0; - ui_init(&argc, NULL); } @@ -77,7 +77,6 @@ void scan_gui(gboolean reload) } SCAN_END(); } -#endif //Note: Same order as entries, used for json to server static char *entries_english_name[] = { @@ -238,18 +237,14 @@ static ModuleEntry entries[] = { scan_benchmark_memory_all, MODULE_FLAG_NONE, }, -#if !GTK_CHECK_VERSION(3, 0, 0) [BENCHMARK_GUI] = { N_("GPU Drawing"), - "module.png", - callback_gui, - scan_gui, - MODULE_FLAG_NO_REMOTE | MODULE_FLAG_HIDE, + "monitor.png", + callback_benchmark_gui, + scan_benchmark_gui, + MODULE_FLAG_NO_REMOTE, }, -#else - [BENCHMARK_GUI] = {"#"}, -#endif {NULL}}; const gchar *hi_note_func(gint entry) diff --git a/modules/benchmark/blowfish.c b/modules/benchmark/blowfish.c index f8d2e14a..9cfacc81 100644 --- a/modules/benchmark/blowfish.c +++ b/modules/benchmark/blowfish.c @@ -1,23 +1,21 @@ /* -blowfish.c: C implementation of the Blowfish algorithm. - -Copyright (C) 1997 by Paul Kocher - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + * blowfish.c: C implementation of the Blowfish algorithm. + * Copyright (C) 1997 by Paul Kocher + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +/* COMMENTS ON USING THIS CODE: Normal usage is as follows: diff --git a/modules/benchmark/drawing.c b/modules/benchmark/drawing.c index e92b9d62..1b1419be 100644 --- a/modules/benchmark/drawing.c +++ b/modules/benchmark/drawing.c @@ -19,15 +19,25 @@ #include "benchmark.h" #include "guibench.h" +#define BENCH_REVISION 3 + void benchmark_gui(void) { bench_value r = EMPTY_BENCH_VALUE; + double frametime[5]; + int framecount[5]; shell_view_set_enabled(FALSE); - shell_status_update("Running drawing benchmark..."); + shell_status_update("Running GPU Drawing..."); - r.result = guibench(); //TODO: explain in code comments + r.result = guibench(frametime,framecount); + r.revision = BENCH_REVISION; +#if GTK_CHECK_VERSION(3,0,0) + snprintf(r.extra, 255, "g:3 f:%0.4f/%0.4f/%0.4f/%0.4f/%0.4f c:%d/%d/%d/%d/%d",frametime[0],frametime[1],frametime[2],frametime[3],frametime[4],framecount[0],framecount[1],framecount[2],framecount[3],framecount[4]); +#else + snprintf(r.extra, 255, "g:2 f:%0.4f/%0.4f/%0.4f/%0.4f/%0.4f c:%d/%d/%d/%d/%d",frametime[0],frametime[1],frametime[2],frametime[3],frametime[4],framecount[0],framecount[1],framecount[2],framecount[3],framecount[4]); +#endif bench_results[BENCHMARK_GUI] = r; } diff --git a/modules/benchmark/fft.c b/modules/benchmark/fft.c index 503a7aaf..47acc369 100644 --- a/modules/benchmark/fft.c +++ b/modules/benchmark/fft.c @@ -21,7 +21,7 @@ #include "fftbench.h" /* if anything changes in this block, increment revision */ -#define BENCH_REVISION 2 +#define BENCH_REVISION 3 #define CRUNCH_TIME 5 static gpointer fft_for(void *in_data, gint thread_number) diff --git a/modules/benchmark/fftbench.c b/modules/benchmark/fftbench.c index 9449cffd..a531e276 100644 --- a/modules/benchmark/fftbench.c +++ b/modules/benchmark/fftbench.c @@ -69,7 +69,7 @@ static void lup_decompose(FFTBench *fftbench) double p, temp, **a; int *perm = (int *) malloc(sizeof(double) * N); - + free(fftbench->p); fftbench->p = perm; a = fftbench->a; @@ -181,6 +181,7 @@ FFTBench *fft_bench_new(void) } fftbench->b = (double *) malloc(sizeof(double) * N); + fftbench->p = NULL; for (i = 0; i < N; ++i) fftbench->b[i] = random_double(); diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c index 2bec8bed..557c1b13 100644 --- a/modules/benchmark/fib.c +++ b/modules/benchmark/fib.c @@ -43,7 +43,6 @@ static gpointer fib_for(void *in_data, gint thread_number) void benchmark_fib(void) { - GTimer *timer = g_timer_new(); bench_value r = EMPTY_BENCH_VALUE; shell_view_set_enabled(FALSE); diff --git a/modules/benchmark/guibench.c b/modules/benchmark/guibench.c index e0f8351e..1ca9f632 100644 --- a/modules/benchmark/guibench.c +++ b/modules/benchmark/guibench.c @@ -1,6 +1,6 @@ /* - * HardInfo - Displays System Information - * Copyright (C) 2003-2009 L. A. F. Pereira <l@tia.mat.br> + * hardinfo2 - System Information and Benchmark + * Copyright (C) 2024-2024 hwspeedy - hardinfo2 project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,337 +17,154 @@ */ #include <gtk/gtk.h> +#include <cairo.h> #include "iconcache.h" #include "config.h" -#define N_ITERATIONS 100000 -#define PHRASE "I \342\231\245 HardInfo" - -typedef double (*BenchCallback)(GtkWindow *window); - -static double test_lines(GtkWindow *window); -static double test_shapes(GtkWindow *window); -static double test_filled_shapes(GtkWindow *window); -static double test_text(GtkWindow *window); -static double test_icons(GtkWindow *window); - -/* -Results on a AMD Athlon 3200+ (Barton), 1GB RAM, -nVidia Geforce 6200 with nvidia Xorg driver, -running Linux 2.6.28, Xorg 1.6.0, Ubuntu 9.04 -desktop, GNOME 2.26.1, composite enabled. - -Test Time Iter/Sec -Line Drawing 3.9570 25271.7663 -Shape Drawing 22.2499 4494.4065 -Filled Shape Drawing 4.0377 24766.2806 -Text Drawing 59.1565 1690.4309 -Icon Blitting 51.720941 1933.4528 - -Results are normalized according to these values. -A guibench() result of 1000.0 is roughly equivalent -to this same setup. -*/ - -static struct { - BenchCallback callback; - gchar *title; - gdouble weight; -} tests[] = { - { test_lines, "Line Drawing", 25271.77 }, - { test_shapes, "Shape Drawing", 4494.49 }, - { test_filled_shapes, "Filled Shape Drawing", 24766.28 }, - { test_text, "Text Drawing", 1690.43 }, - { test_icons, "Icon Blitting", 1933.45 }, - { NULL, NULL } -}; - -static gchar *phrase = NULL; - -static gboolean keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data) -{ - const int magic[] = { 0x1b, 0x33, 0x3a, 0x35, 0x51 }; - const unsigned int states[] = { 0xff52, 0xff52, 0xff54, 0xff54, - 0xff51, 0xff53, 0xff51, 0xff53, - 0x62, 0x61 }; - static int state = 0; - - if (event->keyval == states[state]) { - state++; - } else { - state = 0; - } - - if (state == G_N_ELEMENTS(states)) { - unsigned int i; - - for (i = 0; i < G_N_ELEMENTS(magic); i++) { - phrase[i + 6] = magic[i] ^ (states[i] & (states[i] >> 8)); - } +#define CRUNCH_TIME 3 + +static int count=0; +static int testnumber=0; +static GTimer *timer,*frametimer; +static gdouble score = 0.0f; +static GdkPixbuf *pixbufs[3]; +static GRand *r; +double *frametime; +int *framecount; + +gboolean on_draw (GtkWidget *widget, GdkEventExpose *event, gpointer data) { +#if GTK_CHECK_VERSION(3,0,0) + const int divfactor[5]={2231,2122,2113,2334,2332}; +#else //Note: OLD GTK does not do the same amount of work + const int divfactor[5]={12231,12122,12113,12334,12332}; +#endif + const int iterations[5]={100,300,100,300,100}; + int i; + cairo_t * cr; + GdkWindow* window = gtk_widget_get_window(widget); + + +#if GTK_CHECK_VERSION(3,22,0) + cairo_region_t * cairoRegion = cairo_region_create(); + GdkDrawingContext * drawingContext; - state = 0; - } - - return FALSE; + drawingContext = gdk_window_begin_draw_frame (window,cairoRegion); + cr = gdk_drawing_context_get_cairo_context (drawingContext); +#else + cr = gdk_cairo_create(window); +#endif + + g_timer_continue(frametimer); + for (i = iterations[testnumber]; i >= 0; i--) { + switch(testnumber) { + case 0 : //Line Drawing + cairo_move_to(cr, g_rand_int_range(r,0,1024), g_rand_int_range(r,0,800)); + cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1)); + cairo_line_to(cr, g_rand_int_range(r,0,1024), g_rand_int_range(r,0,800)); + cairo_stroke(cr); + break; + case 1 : //Shape Drawing + cairo_rectangle(cr,g_rand_int_range(r,0,1024-200),g_rand_int_range(r,0,800-200),g_rand_int_range(r,0,400),g_rand_int_range(r,0,300)); + cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1)); + cairo_stroke(cr); + break; + case 2 : //Filled Shape Drawing + cairo_rectangle(cr,g_rand_int_range(r,0,1024-200),g_rand_int_range(r,0,800-200),g_rand_int_range(r,0,400),g_rand_int_range(r,0,300)); + cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1)); + cairo_fill(cr); + break; + case 3 : //Text Drawing + cairo_move_to(cr,g_rand_int_range(r,0,1024-100),g_rand_int_range(r,0,800)); + cairo_set_font_size(cr,25); + cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1)); + cairo_show_text(cr, "I \342\231\245 hardinfo2"); + break; + // + case 4 : //Icon Blitting + gdk_cairo_set_source_pixbuf (cr, pixbufs[g_rand_int_range(r,0,3)],g_rand_int_range(r,0,1024-64), g_rand_int_range(r,0,800-64)); + cairo_paint(cr); + break; + } + } + g_timer_stop(frametimer); +#if GTK_CHECK_VERSION(3,22,0) + gdk_window_end_draw_frame(window,drawingContext); +#endif + count++; + if(g_timer_elapsed(timer, NULL)<CRUNCH_TIME) { + gtk_widget_queue_draw_area(widget,0,0,1024,800); + } else { + score += ((double)iterations[testnumber]*count/g_timer_elapsed(frametimer,NULL)) / divfactor[testnumber]; + frametime[testnumber]=g_timer_elapsed(frametimer,NULL); + framecount[testnumber]=count; + DEBUG("GPU Test %d => %d =>score:%f (frametime=%f)",testnumber,count,score,g_timer_elapsed(frametimer,NULL)); + count=0; + testnumber++; + //Done + if(testnumber>=5){ + gtk_main_quit(); + } else { + g_timer_start(frametimer); + g_timer_stop(frametimer); + g_timer_start(timer); + gtk_widget_queue_draw_area(widget,0,0,1024,800); + } + } + + // cleanup +#if GTK_CHECK_VERSION(3,22,0) + cairo_region_destroy(cairoRegion); +#endif + + return FALSE; } -static double test_icons(GtkWindow *window) -{ - GdkPixbuf *pixbufs[3]; - GdkGC *gc; - GRand *rand; - GTimer *timer; - double time; - GdkWindow *gdk_window = GTK_WIDGET(window)->window; - int icons; - - gdk_window_clear(gdk_window); - - rand = g_rand_new(); - gc = gdk_gc_new(GDK_DRAWABLE(gdk_window)); - timer = g_timer_new(); - - pixbufs[0] = icon_cache_get_pixbuf("hardinfo2.png"); - pixbufs[1] = icon_cache_get_pixbuf("syncmanager.png"); - pixbufs[2] = icon_cache_get_pixbuf("report-large.png"); - - g_timer_start(timer); - for (icons = N_ITERATIONS; icons >= 0; icons--) { - int x, y; - x = g_rand_int_range(rand, 0, 800); - y = g_rand_int_range(rand, 0, 600); - - gdk_draw_pixbuf(GDK_DRAWABLE(gdk_window), gc, - pixbufs[icons % G_N_ELEMENTS(pixbufs)], - 0, 0, x, y, 48, 48, - GDK_RGB_DITHER_NONE, 0, 0); - - while (gtk_events_pending()) { - gtk_main_iteration(); - } - } - g_timer_stop(timer); - - time = g_timer_elapsed(timer, NULL); - - g_rand_free(rand); - gdk_gc_destroy(gc); - g_timer_destroy(timer); - - return time; -} - -static double test_text(GtkWindow *window) +double guibench(double *frameTime, int *frameCount) { - GRand *rand; - GTimer *timer; - GdkGC *gc; - double time; - PangoLayout *layout; - PangoFontDescription *font; - GdkWindow *gdk_window = GTK_WIDGET(window)->window; - int strings; - - gdk_window_clear(gdk_window); - - rand = g_rand_new(); - gc = gdk_gc_new(GDK_DRAWABLE(gdk_window)); - timer = g_timer_new(); - - font = pango_font_description_new(); - layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(window))); - pango_layout_set_text(layout, phrase, -1); - - g_timer_start(timer); - for (strings = N_ITERATIONS; strings >= 0; strings--) { - int x, y, size; - - x = g_rand_int_range(rand, 0, 800); - y = g_rand_int_range(rand, 0, 600); - size = g_rand_int_range(rand, 1, 96) * PANGO_SCALE; - - pango_font_description_set_size(font, size); - pango_layout_set_font_description(layout, font); - gdk_draw_layout(GDK_DRAWABLE(gdk_window), gc, x, y, layout); - - gdk_rgb_gc_set_foreground(gc, strings << 8); - - while (gtk_events_pending()) { - gtk_main_iteration(); - } - - } - g_timer_stop(timer); - - time = g_timer_elapsed(timer, NULL); - - g_rand_free(rand); - gdk_gc_destroy(gc); - g_timer_destroy(timer); - g_object_unref(layout); - pango_font_description_free(font); - - return time; -} - -static double test_filled_shapes(GtkWindow *window) -{ - GRand *rand; - GTimer *timer; - GdkGC *gc; - double time; - GdkWindow *gdk_window = GTK_WIDGET(window)->window; - int lines; - - gdk_window_clear(gdk_window); - - rand = g_rand_new(); - gc = gdk_gc_new(GDK_DRAWABLE(gdk_window)); - timer = g_timer_new(); - - g_timer_start(timer); - for (lines = N_ITERATIONS; lines >= 0; lines--) { - int x1, y1; - - x1 = g_rand_int_range(rand, 0, 800); - y1 = g_rand_int_range(rand, 0, 600); - - gdk_rgb_gc_set_foreground(gc, lines << 8); - - gdk_draw_rectangle(GDK_DRAWABLE(gdk_window), gc, TRUE, - x1, y1, - g_rand_int_range(rand, 0, 400), - g_rand_int_range(rand, 0, 300)); - - while (gtk_events_pending()) { - gtk_main_iteration(); - } - } - g_timer_stop(timer); - - time = g_timer_elapsed(timer, NULL); - - g_rand_free(rand); - gdk_gc_destroy(gc); - g_timer_destroy(timer); - - return time; -} - -static double test_shapes(GtkWindow *window) -{ - GRand *rand; - GTimer *timer; - GdkGC *gc; - double time; - GdkWindow *gdk_window = GTK_WIDGET(window)->window; - int lines; - - gdk_window_clear(gdk_window); - - rand = g_rand_new(); - gc = gdk_gc_new(GDK_DRAWABLE(gdk_window)); - timer = g_timer_new(); - - g_timer_start(timer); - for (lines = N_ITERATIONS; lines >= 0; lines--) { - int x1, y1; - - x1 = g_rand_int_range(rand, 0, 800); - y1 = g_rand_int_range(rand, 0, 600); - - gdk_rgb_gc_set_foreground(gc, lines << 8); - - gdk_draw_rectangle(GDK_DRAWABLE(gdk_window), gc, FALSE, - x1, y1, - g_rand_int_range(rand, 0, 400), - g_rand_int_range(rand, 0, 300)); - while (gtk_events_pending()) { - gtk_main_iteration(); - } - } - g_timer_stop(timer); - - time = g_timer_elapsed(timer, NULL); - - g_rand_free(rand); - gdk_gc_destroy(gc); - g_timer_destroy(timer); - - return time; -} - -static double test_lines(GtkWindow *window) -{ - GRand *rand; - GTimer *timer; - GdkGC *gc; - double time; - GdkWindow *gdk_window = GTK_WIDGET(window)->window; - int lines; - - gdk_window_clear(gdk_window); - - rand = g_rand_new(); - gc = gdk_gc_new(GDK_DRAWABLE(gdk_window)); - timer = g_timer_new(); - - g_timer_start(timer); - for (lines = N_ITERATIONS; lines >= 0; lines--) { - int x1, y1, x2, y2; - - x1 = g_rand_int_range(rand, 0, 800); - y1 = g_rand_int_range(rand, 0, 600); - x2 = g_rand_int_range(rand, 0, 800); - y2 = g_rand_int_range(rand, 0, 600); - - gdk_draw_line(GDK_DRAWABLE(gdk_window), gc, x1, y1, x2, y2); - gdk_rgb_gc_set_foreground(gc, lines << 8); - - while (gtk_events_pending()) { - gtk_main_iteration(); - } - } - g_timer_stop(timer); - - time = g_timer_elapsed(timer, NULL); - - g_rand_free(rand); - gdk_gc_destroy(gc); - g_timer_destroy(timer); - - return time; -} - -double guibench(void) -{ - GtkWidget *window; - gdouble score = 0.0f; - gint i; - - phrase = g_strdup(PHRASE); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - 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_ON_PARENT); - gtk_widget_show(window); - - g_signal_connect(window, "key-press-event", G_CALLBACK(keypress_event), NULL); + GtkWindow * window; + cairo_t *cr; - for (i = 0; tests[i].title; i++) { - double time; + frametime=frameTime; + framecount=frameCount; - gtk_window_set_title(GTK_WINDOW(window), tests[i].title); - time = tests[i].callback(GTK_WINDOW(window)); - score += (N_ITERATIONS / time) / tests[i].weight; - } - - gtk_widget_destroy(window); - g_free(phrase); - - return (score / i) * 1000.0f; + DEBUG("GUIBENCH"); + pixbufs[0] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("hardinfo2.png"),64,64,GDK_INTERP_BILINEAR); + pixbufs[1] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("syncmanager.png"),64,64,GDK_INTERP_BILINEAR); + pixbufs[2] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("report-large.png"),64,64,GDK_INTERP_BILINEAR); + + r = g_rand_new(); + + // window setup + window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size (window, 1024, 800); + gtk_window_set_position (window, GTK_WIN_POS_CENTER); + gtk_window_set_title (window, "GPU Benchmarking..."); + g_signal_connect(window, "destroy", gtk_main_quit, NULL); + + // create the are we can draw in + GtkDrawingArea* drawingArea; + drawingArea = (GtkDrawingArea*) gtk_drawing_area_new(); + gtk_container_add(GTK_CONTAINER(window), (GtkWidget*)drawingArea); +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect((GtkWidget*)drawingArea, "draw", G_CALLBACK(on_draw), NULL); +#else + g_signal_connect((GtkWidget*)drawingArea, "expose-event", G_CALLBACK(on_draw), NULL); +#endif + frametimer = g_timer_new(); + g_timer_stop(frametimer); + timer = g_timer_new(); + gtk_widget_show_all ((GtkWidget*)window); + + gtk_main(); + + g_timer_destroy(timer); + g_timer_destroy(frametimer); + g_rand_free(r); + g_object_unref(pixbufs[0]); + g_object_unref(pixbufs[1]); + g_object_unref(pixbufs[2]); + + return score; } diff --git a/modules/benchmark/md5.c b/modules/benchmark/md5.c index f4032ddd..8cb22d93 100644 --- a/modules/benchmark/md5.c +++ b/modules/benchmark/md5.c @@ -2,27 +2,22 @@ * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. + * Copyright by: hardinfo2 project + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to - not require an integer type which is exactly 32 bits. This work - draws on the changes for the same purpose by Tatu Ylonen - <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use - that code, there is no copyright issue. I hereby disclaim - copyright in any changes I have made; this code remains in the - public domain. */ - #include <string.h> /* for memcpy() and memset() */ /* Add prototype support. */ diff --git a/modules/benchmark/sha1.c b/modules/benchmark/sha1.c index 3b213218..8cbf0f6a 100644 --- a/modules/benchmark/sha1.c +++ b/modules/benchmark/sha1.c @@ -1,8 +1,22 @@ /* -SHA-1 in C -By Steve Reid <steve@edmweb.com> -100% Public Domain + * SHA-1 in C + * Written by Steve Reid <steve@edmweb.com> + * Copyright by: hardinfo2 project + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2.0 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +/* Test Vectors (from FIPS PUB 180-1) "abc" A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D diff --git a/modules/computer/alsa.c b/modules/computer/alsa.c index f74d2752..de20a0ad 100644 --- a/modules/computer/alsa.c +++ b/modules/computer/alsa.c @@ -63,7 +63,7 @@ computer_get_alsainfo(void) ai->cards = g_slist_append(ai->cards, ac); g_strfreev(tmp); - (void)fgets(buffer, 128, cards); /* skip next line */ + char *c=fgets(buffer, 128, cards); /* skip next line */ } fclose(cards); diff --git a/modules/computer/filesystem.c b/modules/computer/filesystem.c index e9c84811..2aa31f67 100644 --- a/modules/computer/filesystem.c +++ b/modules/computer/filesystem.c @@ -17,7 +17,9 @@ * * Some code from xfce4-mount-plugin, version 0.4.3 * Copyright (C) 2005 Jean-Baptiste jb_dul@yahoo.com - * Distributed under the terms of GNU GPL 2. + * Distributed under the terms of GNU GPL 2+ - + * https://gitlab.xfce.org/panel-plugins/xfce4-mount-plugin/-/blob/master/panel-plugin/mount-plugin.c +.* */ #include <string.h> diff --git a/modules/computer/modules.c b/modules/computer/modules.c index cec2d42e..e3423ed8 100644 --- a/modules/computer/modules.c +++ b/modules/computer/modules.c @@ -265,7 +265,7 @@ void scan_modules_do(void) { return; } - (void)fgets(buffer, 1024, lsmod); /* Discards the first line */ + char *c=fgets(buffer, 1024, lsmod); /* Discards the first line */ //Sort modules while (fgets(buffer, 1024, lsmod)) { diff --git a/modules/computer/uptime.c b/modules/computer/uptime.c index 8aef1530..f213442f 100644 --- a/modules/computer/uptime.c +++ b/modules/computer/uptime.c @@ -26,7 +26,7 @@ computer_get_uptime(void) gulong minutes; if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { - (void)fscanf(procuptime, "%lu", &minutes); + int c=fscanf(procuptime, "%lu", &minutes); ui->minutes = minutes / 60; fclose(procuptime); } else { diff --git a/modules/devices/battery.c b/modules/devices/battery.c index e356c14a..784a6cc5 100644 --- a/modules/devices/battery.c +++ b/modules/devices/battery.c @@ -312,7 +312,7 @@ __scan_battery_apm(void) if ((procapm = fopen("/proc/apm", "r"))) { int old_percentage = percentage; - (void)fscanf(procapm, "%s %s %s 0x%x %s %s %d%%", + int c=fscanf(procapm, "%s %s %s 0x%x %s %s %d%%", apm_drv_ver, apm_bios_ver, trash, &ac_bat, trash, trash, &percentage); fclose(procapm); diff --git a/modules/devices/dmi.c b/modules/devices/dmi.c index 34374fbe..af02e6d4 100644 --- a/modules/devices/dmi.c +++ b/modules/devices/dmi.c @@ -73,7 +73,7 @@ gboolean dmi_get_info(void) DMIInfo *info; gboolean dmi_succeeded = FALSE; guint i; - gchar *value; + gchar *value=NULL; const gchar *vendor; if (dmi_info) { diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c index cf4c89d7..7cfc688c 100644 --- a/modules/devices/spd-decode.c +++ b/modules/devices/spd-decode.c @@ -20,8 +20,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <ctype.h> diff --git a/modules/devices/spd-vendors.c b/modules/devices/spd-vendors.c index 80b2a6a4..7a646758 100644 --- a/modules/devices/spd-vendors.c +++ b/modules/devices/spd-vendors.c @@ -20,8 +20,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* from decode-dimms, in the i2c-tools package: diff --git a/modules/devices/storage.c b/modules/devices/storage.c index bbf9b195..c0bee0d2 100644 --- a/modules/devices/storage.c +++ b/modules/devices/storage.c @@ -632,7 +632,7 @@ void __scan_ide_devices(void) if (!proc_ide) continue; - (void) fgets(buf, 128, proc_ide); + char *cc=fgets(buf, 128, proc_ide); fclose(proc_ide); buf[strlen(buf) - 1] = 0; @@ -648,7 +648,7 @@ void __scan_ide_devices(void) continue; } - (void) fgets(buf, 128, proc_ide); + char *c=fgets(buf, 128, proc_ide); fclose(proc_ide); buf[strlen(buf) - 1] = 0; @@ -717,7 +717,7 @@ void __scan_ide_devices(void) if (g_file_test(device, G_FILE_TEST_EXISTS)) { proc_ide = fopen(device, "r"); if (proc_ide) { - (void) fscanf(proc_ide, "%d", &cache); + int c=fscanf(proc_ide, "%d", &cache); fclose(proc_ide); } else { cache = 0; @@ -731,7 +731,7 @@ void __scan_ide_devices(void) proc_ide = fopen(device, "r"); if (proc_ide) { - (void) fgets(buf, 64, proc_ide); + char *c=fgets(buf, 64, proc_ide); for (tmp = buf; *tmp; tmp++) { if (*tmp >= '0' && *tmp <= '9') break; @@ -739,7 +739,7 @@ void __scan_ide_devices(void) pgeometry = g_strdup(g_strstrip(tmp)); - (void) fgets(buf, 64, proc_ide); + char *cc=fgets(buf, 64, proc_ide); for (tmp = buf; *tmp; tmp++) { if (*tmp >= '0' && *tmp <= '9') break; diff --git a/modules/network.c b/modules/network.c index 4b65e0aa..e89e1b6b 100644 --- a/modules/network.c +++ b/modules/network.c @@ -151,7 +151,7 @@ void scan_dns(gboolean reload) ip = g_strstrip(buffer + sizeof("nameserver")); sa.sin_family = AF_INET; - sa.sin_addr.s_addr = inet_addr(ip); + inet_pton(AF_INET,ip,&sa.sin_addr.s_addr); if (getnameinfo((struct sockaddr *)&sa, sizeof(sa), hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD)) { __nameservers = h_strdup_cprintf("%s=\n", @@ -196,8 +196,8 @@ void scan_route(gboolean reload) if ((route = popen(command_line, "r"))) { /* eat first two lines */ - (void)fgets(buffer, 256, route); - (void)fgets(buffer, 256, route); + char *c=fgets(buffer, 256, route); + char *cc=fgets(buffer, 256, route); while (fgets(buffer, 256, route)) { buffer[15] = '\0'; @@ -236,7 +236,7 @@ void scan_arp(gboolean reload) if ((arp = fopen("/proc/net/arp", "r"))) { /* eat first line */ - (void)fgets(buffer, 256, arp); + char *c=fgets(buffer, 256, arp); while (fgets(buffer, 256, arp)) { buffer[15] = '\0'; diff --git a/modules/network/net.c b/modules/network/net.c index 9a5cb5f1..f584362b 100644 --- a/modules/network/net.c +++ b/modules/network/net.c @@ -200,9 +200,9 @@ void get_net_info(char *if_name, NetInfo * netinfo) if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { netinfo->ip[0] = 0; } else { - snprintf(netinfo->ip, sizeof(netinfo->ip), "%s", - inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)-> - sin_addr)); + char ipstr[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr, ipstr, INET_ADDRSTRLEN); + snprintf(netinfo->ip, sizeof(netinfo->ip), "%s",ipstr); } /* Mask Address */ diff --git a/shell/callbacks.c b/shell/callbacks.c index c60487d9..89fe4e32 100644 --- a/shell/callbacks.c +++ b/shell/callbacks.c @@ -18,6 +18,8 @@ #include <stdlib.h> #include <gtk/gtk.h> +#include <glib.h> +#include <glib/gstdio.h> #include "hardinfo.h" #include "callbacks.h" diff --git a/shell/loadgraph.c b/shell/loadgraph.c index 0290d1f1..a84f6d33 100644 --- a/shell/loadgraph.c +++ b/shell/loadgraph.c @@ -17,10 +17,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with the Simple Load Graph; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "loadgraph.h" diff --git a/shell/shell.c b/shell/shell.c index e3f64891..31434c43 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -334,6 +334,7 @@ void shell_do_reload(void) void shell_status_update(const gchar * message) { + DEBUG("Shell_status_update %s",message); if (params.gui_running) { gtk_label_set_markup(GTK_LABEL(shell->status), message); gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress)); @@ -684,8 +685,9 @@ check_for_updates(void) g_free(conf_path); g_key_file_free(key_file); - if (setting) { - sync_manager_update_on_startup(); + //fetching data -u is used + if (setting || params.bench_user_note) { + sync_manager_update_on_startup(0); } } @@ -1737,6 +1739,7 @@ module_selected_show_info(ShellModuleEntry *entry, gboolean reload) shell_set_note_from_entry(entry); gdk_window_thaw_updates(gdk_window); + } static void info_selected_show_extra(const gchar *tag) @@ -2021,7 +2024,6 @@ static void module_selected(gpointer data) shell_show_detail_view(); } } - current = entry; updating = FALSE; } diff --git a/shell/syncmanager.c b/shell/syncmanager.c index 4608eb7d..1558bea5 100644 --- a/shell/syncmanager.c +++ b/shell/syncmanager.c @@ -23,6 +23,9 @@ #include <libsoup/soup.h> +#include <glib.h> +#include <glib/gstdio.h> + #include <stdarg.h> #include <string.h> #include <fcntl.h> @@ -178,7 +181,20 @@ static SyncNetAction *sync_manager_get_selected_actions(gint *n) return actions; } -#if !SOUP_CHECK_VERSION(3,0,0) +#if SOUP_CHECK_VERSION(3,0,0) +static const char *sync_manager_get_proxy(void) +{ + const gchar *conf; + + if (!(conf = g_getenv("HTTP_PROXY"))) { + if (!(conf = g_getenv("http_proxy"))) { + return NULL; + } + } + + return conf; +} +#else static SoupURI *sync_manager_get_proxy(void) { const gchar *conf; @@ -191,17 +207,18 @@ static SoupURI *sync_manager_get_proxy(void) return soup_uri_new(conf); } + #endif static void ensure_soup_session(void) { if (!session) { #if SOUP_CHECK_VERSION(3,0,0) - session = soup_session_new_with_options("timeout", 10, NULL); + const char *proxy=sync_manager_get_proxy(); + session = soup_session_new_with_options("timeout", 10,"proxy-resolver", proxy, NULL); #else #if SOUP_CHECK_VERSION(2,42,0) SoupURI *proxy = sync_manager_get_proxy(); - session = soup_session_new_with_options( SOUP_SESSION_TIMEOUT, 10, SOUP_SESSION_PROXY_URI, proxy, NULL); #else @@ -230,7 +247,7 @@ static void sync_dialog_start_sync(SyncDialog *sd) fd = open(path,O_RDONLY); } if(fd>=0){ - read(fd,buf,100); + int c=read(fd,buf,100); sscanf(buf,"{\"update-version\":\"%u\",",&our_blobs_update_version); close(fd); } @@ -262,6 +279,53 @@ static void sync_dialog_start_sync(SyncDialog *sd) g_main_loop_unref(loop); } + +static void got_msg(const guint8 *buf,int len, gpointer user_data) +{ + SyncNetAction *sna = user_data; + GInputStream *is; + gchar *path; + int fd,updateversion=0; + gchar buffer[101]; + gsize datawritten; + + if (sna->entry->file_name != NULL) { + //check for missing config dirs + g_mkdir(g_get_user_config_dir(), 0766); + g_mkdir(g_build_filename(g_get_user_config_dir(),"hardinfo2",NULL), 0766); + if(strncmp(sna->entry->file_name,"blobs-update-version.json",25)==0){ + updateversion=1; + } + path = g_build_filename(g_get_user_config_dir(), "hardinfo2", + sna->entry->file_name, NULL); + GFile *file = g_file_new_for_path(path); + GFileOutputStream *output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, + NULL, &sna->error); + + if(buf){ + DEBUG("got file with len: %u", (unsigned int)len); + if(len>0){ + g_output_stream_write_all(G_OUTPUT_STREAM(output),buf,len,&datawritten,NULL,&sna->error); + } + } + + if(updateversion){ + fd = open(path,O_RDONLY); + if(fd){ + int c=read(fd,buffer,100); + sscanf(buffer,"{\"update-version\":\"%u\",",&server_blobs_update_version); + DEBUG("SERVER_BLOBS_UPDATE_VERSION=%u",server_blobs_update_version); + close(fd); + } + } + + g_free(path); + g_object_unref(file); + } + +} + + #if SOUP_CHECK_VERSION(2,42,0) static void got_response(GObject *source, GAsyncResult *res, gpointer user_data) #else @@ -298,9 +362,8 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da path = g_build_filename(g_get_user_config_dir(), "hardinfo2", sna->entry->file_name, NULL); GFile *file = g_file_new_for_path(path); - GFileOutputStream *output = - g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, - NULL, &sna->error); + GFileOutputStream *output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, + NULL, &sna->error); if (output != NULL) { #if SOUP_CHECK_VERSION(2,42,0) @@ -314,7 +377,7 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da DEBUG("got file with len: %u", (unsigned int)len); if(len>0){ g_output_stream_write_all(G_OUTPUT_STREAM(output),buf,len,&datawritten,NULL,&sna->error); - soup_buffer_free(soupmsg); + soup_buffer_free(soupmsg); } } #endif @@ -323,7 +386,7 @@ static void got_response(SoupSession *source, SoupMessage *res, gpointer user_da if(updateversion){ fd = open(path,O_RDONLY); if(fd){ - read(fd,buffer,100); + int c=read(fd,buffer,100); sscanf(buffer,"{\"update-version\":\"%u\",",&server_blobs_update_version); DEBUG("SERVER_BLOBS_UPDATE_VERSION=%u",server_blobs_update_version); close(fd); @@ -346,40 +409,79 @@ static gboolean send_request_for_net_action(SyncNetAction *sna) gchar *uri; SoupMessage *msg; guint response_code; + const guint8 *buf=NULL; + gsize len; + gchar *contents=NULL; + gsize size; +#if !SOUP_CHECK_VERSION(3, 0, 0) + SoupBuffer *soupmsg=NULL; +#endif if(!sna->entry->optional || (our_blobs_update_version<server_blobs_update_version)){ if(strncmp(sna->entry->file_name,"blobs-update-version.json",25)==0){ - uri = g_strdup_printf("%s/%s?ver=%s&blobver=%d", API_SERVER_URI, sna->entry->file_name,VERSION,our_blobs_update_version); - }else{ + uri = g_strdup_printf("%s/%s?ver=%s&blobver=%d&rel=%d", API_SERVER_URI, sna->entry->file_name,VERSION,our_blobs_update_version,RELEASE); + } else if(strncmp(sna->entry->file_name,"benchmark.json",14)==0){ + if (sna->entry->generate_contents_for_upload == NULL) {//GET/Fetch + if(params.bench_user_note){ + uri = g_strdup_printf("%s/%s?ver=%s&L=%d&rel=%d&MT=%s&BUN=%s", API_SERVER_URI, + sna->entry->file_name, VERSION, + params.max_bench_results,RELEASE, + module_call_method("computer::getMachineType"), + params.bench_user_note); + } else { + uri = g_strdup_printf("%s/%s?ver=%s&L=%d&rel=%d&&MT=%s", API_SERVER_URI, + sna->entry->file_name, VERSION, + params.max_bench_results, RELEASE, + module_call_method("computer::getMachineType")); + } + } else {//POST/Send + uri = g_strdup_printf("%s/%s?ver=%s&rel=%d", API_SERVER_URI, + sna->entry->file_name, VERSION, RELEASE); + } + } else { uri = g_strdup_printf("%s/%s", API_SERVER_URI, sna->entry->file_name); } if (sna->entry->generate_contents_for_upload == NULL) { msg = soup_message_new("GET", uri); } else { - gsize size; - gchar *contents = sna->entry->generate_contents_for_upload(&size); + contents = sna->entry->generate_contents_for_upload(&size); msg = soup_message_new("POST", uri); #if SOUP_CHECK_VERSION(3, 0, 0) - GBytes *cont = g_bytes_new_static(contents,size); - soup_message_set_request_body_from_bytes(msg, "application/octet-stream", cont); + soup_message_set_request_body_from_bytes(msg, "application/octet-stream", g_bytes_new_static(contents,size)); #else soup_message_set_request(msg, "application/octet-stream", SOUP_MEMORY_TAKE, contents, size); #endif } - + if(params.gui_running){ #if SOUP_CHECK_VERSION(3, 0, 0) - soup_session_send_async(session, msg, G_PRIORITY_DEFAULT, NULL, got_response, sna); + soup_session_send_async(session, msg, G_PRIORITY_DEFAULT, NULL, got_response, sna); #else #if SOUP_CHECK_VERSION(2,42,0) - soup_session_send_async(session, msg, NULL, got_response, sna); + soup_session_send_async(session, msg, NULL, got_response, sna); #else - soup_session_queue_message(session, msg, got_response, sna); + soup_session_queue_message(session, msg, got_response, sna); +#endif #endif + + } else {//Blocking/Sync sending when no gui + +#if SOUP_CHECK_VERSION(3, 0, 0) + buf=g_bytes_unref_to_data(soup_session_send_and_read(session, msg, NULL, NULL), &len); + got_msg(buf,len,sna); +#else + soup_session_send_message(session, msg); + soupmsg=soup_message_body_flatten(msg->response_body); + if(soupmsg){ + soup_buffer_get_data(soupmsg,&buf,&len); + got_msg(buf,len,sna); + } #endif - g_main_loop_run(loop); + } + if(params.gui_running) + g_main_loop_run(loop); g_object_unref(msg); g_free(uri); @@ -722,17 +824,19 @@ static void sync_dialog_destroy(SyncDialog *sd) static gboolean sync_one(gpointer data) { SyncNetAction *sna = data; - - if (sna->entry->generate_contents_for_upload) - goto out; - + if (sna->entry->generate_contents_for_upload){ + if(params.gui_running){ + goto out; + } + } DEBUG("Syncronizing: %s", sna->entry->name); - gchar *msg = g_strdup_printf(_("Synchronizing: %s"), _(sna->entry->name)); - shell_status_update(msg); - shell_status_pulse(); - g_free(msg); - + if(params.gui_running){ + gchar *msg = g_strdup_printf(_("Synchronizing: %s"), _(sna->entry->name)); + shell_status_update(msg); + shell_status_pulse(); + g_free(msg); + } send_request_for_net_action(sna); out: @@ -741,7 +845,7 @@ out: return FALSE; } -void sync_manager_update_on_startup(void) +void sync_manager_update_on_startup(int send_benchmark)//0:normal only get, 1:send benchmark { GSList *entry; gchar *path; @@ -756,7 +860,7 @@ void sync_manager_update_on_startup(void) fd = open(path,O_RDONLY); } if(fd>=0){ - read(fd,buf,100); + int c=read(fd,buf,100); sscanf(buf,"{\"update-version\":\"%u\",",&our_blobs_update_version); close(fd); } @@ -767,12 +871,25 @@ void sync_manager_update_on_startup(void) loop = g_main_loop_new(NULL, FALSE); + if(!params.gui_running) entries=g_slist_reverse(entries);//wrong direction for sync sending for (entry = entries; entry; entry = entry->next) { SyncNetAction *action = g_new0(SyncNetAction, 1); action->entry = entry->data; - loop = g_main_loop_ref(loop); - - g_idle_add(sync_one, action); + if(params.gui_running){ + loop = g_main_loop_ref(loop); + g_idle_add(sync_one, action); + } else { + //if send benchmark - only send benchmark + //if not send benchmark - sync everything else + if( ((strncmp(action->entry->file_name,"benchmark.json",14)==0) && + (action->entry->generate_contents_for_upload) && send_benchmark) || + ((!(strncmp(action->entry->file_name,"benchmark.json",14)==0) || + (!action->entry->generate_contents_for_upload)) && (!send_benchmark)) ){ + loop = g_main_loop_ref(loop); + sync_one(action); + } + } } + if(!params.gui_running) entries=g_slist_reverse(entries);//wrong direction for sync sending } diff --git a/tools/check_license.sh b/tools/check_license.sh new file mode 100755 index 00000000..794fd7bb --- /dev/null +++ b/tools/check_license.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +cd .. +rm -rf build +mkdir build +cd build + +licensecheck -r .. | grep '\.c: \|\.h: ' >licenses_all.txt + +echo "LGPL2.0+ & GPL2+:" +cat licenses_all.txt| grep 'hardinfo2/util.c' +echo "" + +echo "LGPL2.0+:" +cat licenses_all.txt| grep 'hardinfo2/gg_strescape.c\|deps/uber-graph/uber-frame-source.\|deps/update-graph/uber-timeout-interval' +echo "" + +echo "GPL2.0+:" +cat licenses_all.txt| grep -v 'hardinfo2/gg_strescape.c\|hardinfo2/util.c\|deps/uber-graph/uber-frame-source.\|deps/update-graph/uber-timeout-interval' | grep 'General Public License v2.0 or later\|GNU Library General Public License v2 or later' +echo "" + +echo "LGPL2.1+:" +cat licenses_all.txt| grep 'GNU Lesser General Public License v2.1 or later' +echo "" + +echo "LGPL2.1:" +cat licenses_all.txt| grep -v 'GNU Lesser General Public License v2.1 or later' | grep 'GNU Lesser General Public License, Version 2.1' +echo "" + +echo "GPL3.0+:" +cat licenses_all.txt| grep 'General Public License v3.0 or later' +echo "" + +echo "No copyright:" +cat licenses_all.txt| grep '*No copyright*' +echo "" + +#remaining licenses +echo "Others:" +cat licenses_all.txt| grep 'Lesser General Public License v2.0 or later' \ + | grep -v 'hardinfo2/gg_strescape.c\|hardinfo2/util.c\|deps/uber-graph/uber-frame-source.\|deps/update-graph/uber-timeout-interval' \ + | grep -v 'General Public License v2.0 or later\|GNU Library General Public License v2 or later' \ + | grep -v 'GNU Lesser General Public License v2.1 or later' \ + | grep -v 'GNU Lesser General Public License, Version 2.1' \ + | grep -v 'General Public License v3.0 or later' \ + | grep -v '*No copyright*' + +echo "" diff --git a/tools/create_debian_source.sh b/tools/create_debian_source.sh index 3c7ae780..c6bbf7ce 100755 --- a/tools/create_debian_source.sh +++ b/tools/create_debian_source.sh @@ -1,5 +1,11 @@ #!/bin/bash +#tool script used by project maintainer to test debian releases +# WIP - needs maintainer to create .dsc and debian directory - current takes from CPack + VERSION=$(cat ../CMakeLists.txt |grep set\(HARDINFO2_VERSION|cut -d '"' -f 2) +ARCH=$(uname -m) +if [ $ARCH=="x86_64" ]; then ARCH=amd64; fi + cd .. rm -rf build sudo apt -y remove hardinfo @@ -7,20 +13,27 @@ sudo apt -y remove hardinfo2 mkdir build cd build -cmake -DDISTRO=src .. +cmake .. make package_source -#rename cpack file -mv hardinfo2-$VERSION.deb hardinfo2-$VERSION.src.deb +#rename cpack files +mv hardinfo2_$VERSION*.deb hardinfo2-$VERSION.src.deb +rm hardinfo2_$VERSION*.tar.gz #extract CPack source package mkdir cpacksrc dpkg-deb -R hardinfo2-$VERSION.src.deb cpacksrc +#create source package (NOTE: We use github tags as release-$VERSION) +cd ../.. +tar -czf hardinfo2-$VERSION.tar.gz hardinfo2 --transform s/hardinfo2/hardinfo2-$VERSION/ +mv hardinfo2-$VERSION.tar.gz hardinfo2/build/ +cd hardinfo2/build + #extract source tar -xzf hardinfo2-$VERSION.tar.gz cd hardinfo2-$VERSION debmake -#fixup +#fixup source from cpack - FIXME cd debian grep Maintainer ../../cpacksrc/DEBIAN/control >control.fixed grep -v Homepage control |grep -v Description|grep -v auto-gen|grep -v Section|grep -v debmake |grep -v Maintainer >>control.fixed @@ -35,7 +48,7 @@ cd .. #create debian tar.gz tar -czf ../hardinfo2-$VERSION.debian.tar.gz debian cd .. -#rename cpack file +#rename source file mv hardinfo2-$VERSION.tar.gz hardinfo2-$VERSION.orig.tar.gz #create dsc @@ -54,14 +67,13 @@ Package-List: hardinfo2 deb x11 optional arch=any Checksums-Sha1:" >./hardinfo2-$VERSION.dsc sha1sum hardinfo2-$VERSION.*.tar.gz >>./hardinfo2-$VERSION.dsc -echo "Checksums-Sha256:">>./hardinfo-$VERSION.dsc +echo "Checksums-Sha256:">>./hardinfo2-$VERSION.dsc sha256sum hardinfo2-$VERSION.*.tar.gz >>./hardinfo2-$VERSION.dsc echo "Files:">>./hardinfo2-$VERSION.dsc md5sum hardinfo2-$VERSION.*.tar.gz >>./hardinfo2-$VERSION.dsc echo "Debian Source Package Files ready in build:" -ls -l hardinfo2-$VERSION.src.deb -ls -l hardinfo2-$VERSION.*.tar.gz +ls -l hardinfo2-$VERSION*.tar.gz ls -l hardinfo2-$VERSION.dsc #build from source @@ -70,6 +82,6 @@ cd hardinfo2-$VERSION debuild -b -uc -us #test package -ls ../hardinfo_*.deb -sudo apt -y install ../hardinfo2_*.deb +ls ../hardinfo2_*.deb +sudo apt -y install ../hardinfo2_$VERSION-1_$ARCH.deb apt info hardinfo2 diff --git a/tools/create_fedora_source.sh b/tools/create_fedora_source.sh index 6dc1f860..eff6b190 100755 --- a/tools/create_fedora_source.sh +++ b/tools/create_fedora_source.sh @@ -1,7 +1,8 @@ #!/bin/bash +#tool script used by project maintainer to test fedora/redhat releases + VERSION=$(cat ../CMakeLists.txt |grep set\(HARDINFO2_VERSION|cut -d '"' -f 2) ARCH=$(uname -m) -DIST=$(uname -r|cut -d '.' -f 4) #clean and prep yum -y install ninja-build @@ -9,25 +10,29 @@ cd .. rm -rf build sudo yum -y remove hardinfo2 rm -rf ~/rpmbuild - -#build source mkdir build -cd build -cmake -DDISTRO=src .. -#fix for local build -cat ../tools/hardinfo2.spec |grep -v Patch|sed '/URL:/c\URL: ./'|sed '/Source0:/c\Source0: hardinfo2-%{version}.tar.gz' |sed 's/hardinfo2-release/hardinfo2/g' >./hardinfo2.spec -make package_source -cp -f ../tools/hardinfo2.spec . - -echo "Fedora Source Package Files ready in build:" -ls -l hardinfo2-$VERSION*.src.rpm +#create source package +cd .. +tar -czf hardinfo2-release-$VERSION.tar.gz hardinfo2 --transform s/hardinfo2/hardinfo2-release-$VERSION/ +mv hardinfo2-release-$VERSION.tar.gz hardinfo2/build/ +cd hardinfo2/build +wget https://src.fedoraproject.org/rpms/hardinfo2/raw/rawhide/f/hardinfo2.spec +cp hardinfo2.spec ../tools/ +cat hardinfo2.spec |grep -v Patch|sed '/URL:/c\URL: ./'|sed '/Source0:/c\Source0: hardinfo2-release-%{version}.tar.gz' |sed '/Version:/c\Version: '"$VERSION"'' >./hardinfo2.spec + +echo "Fedora/redhat Source Package Files ready in build:" +ls -l hardinfo2-release-$VERSION*.tar.gz ls -l hardinfo2.spec sleep 3 #install src package -sudo rpm --nomd5 -i ./hardinfo2-$VERSION-1.$DIST.src.rpm +mkdir ~/rpmbuild +mkdir ~/rpmbuild/SPECS +mkdir ~/rpmbuild/SOURCES +cp hardinfo2.spec ~/rpmbuild/SPECS/ +cp hardinfo2-release-$VERSION.tar.gz ~/rpmbuild/SOURCES/ #create package from srpm cd ~/rpmbuild/SPECS diff --git a/tools/git_latest_release.sh b/tools/git_latest_release.sh new file mode 100755 index 00000000..c2a265dd --- /dev/null +++ b/tools/git_latest_release.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Changing to latest git release..." +git pull +git checkout $(curl -s https://hardinfo2.org/github/?latest_git_release) diff --git a/tools/git_unstable_master.sh b/tools/git_unstable_master.sh new file mode 100755 index 00000000..66642a2d --- /dev/null +++ b/tools/git_unstable_master.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Changing to unstable master..." +git checkout master +git pull diff --git a/tools/hardinfo2.spec b/tools/hardinfo2.spec index 8f235f64..3aaa440d 100644 --- a/tools/hardinfo2.spec +++ b/tools/hardinfo2.spec @@ -1,13 +1,28 @@ +%if 0%{?rhel} <= 8 +%undefine __cmake_in_source_build +%undefine __cmake3_in_source_build +%endif + Name: hardinfo2 -Version: 2.0.12 +Version: 2.0.15 Release: %autorelease Summary: System Information and Benchmark for Linux Systems # most of the source code is GPL-2.0-or-later license, except: -# includes/blowfish.h - LGPL-2.1-or-later -# includes/loadgraph.h - LGPL-2.0-only + +# hardinfo2/gg_key_file_parse_string_as_value.c: LGPL-2.1-or-later +# includes/blowfish.h: LGPL-2.1-or-later # deps/uber-graph/g-ring.c: LGPL-2.1-or-later # deps/uber-graph/g-ring.h: LGPL-2.1-or-later +# modules/benchmark/blowfish.c: LGPL-2.1-or-later + +# hardinfo2/gg_strescape.c: LGPL-2.0-or-later +# hardinfo2/util.c: GPL-2.0-or-later AND LGPL-2.0-or-later +# deps/uber-graph/uber-frame-source.c: LGPL-2.0-or-later +# deps/uber-graph/uber-frame-source.h: LGPL-2.0-or-later +# deps/uber-graph/uber-timeout-interval.c: LGPL-2.0-or-later +# deps/uber-graph/uber-timeout-interval.h: LGPL-2.0-or-later + # deps/uber-graph/uber-graph.c: GPL-3.0-or-later # deps/uber-graph/uber-graph.h: GPL-3.0-or-later # deps/uber-graph/uber-heat-map.c: GPL-3.0-or-later @@ -25,16 +40,20 @@ Summary: System Information and Benchmark for Linux Systems # deps/uber-graph/uber-window.c: GPL-3.0-or-later # deps/uber-graph/uber-window.h: GPL-3.0-or-later # deps/uber-graph/uber.h: GPL-3.0-or-later -# modules/benchmark/blowfish.c - LGPL-2.1-or-later -License: GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-only AND GPL-3.0-or-later + +# includes/loadgraph.h: LGPL-2.1-only +# shell/loadgraph.c: LGPL-2.1-only + +License: GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-only URL: https://github.com/hardinfo2/hardinfo2 Source0: %{url}/archive/release-%{version}/hardinfo2-release-%{version}.tar.gz -Patch0: https://github.com/hardinfo2/hardinfo2/pull/14.patch - BuildRequires: gcc-c++ +%if 0%{?rhel} < 8 +BuildRequires: cmake3 +%else BuildRequires: cmake -BuildRequires: ninja-build +%endif BuildRequires: pkgconfig(gtk+-3.0) BuildRequires: pkgconfig(cairo) @@ -46,11 +65,11 @@ BuildRequires: pkgconfig(libsoup-2.4) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(json-glib-1.0) BuildRequires: pkgconfig(x11) +BuildRequires: zlib-devel BuildRequires: desktop-file-utils -Obsoletes: hardinfo - +%if 0%{?rhel} >= 8 || 0%{?fedora} Recommends: lm_sensors Recommends: sysbench Recommends: lsscsi @@ -59,6 +78,7 @@ Recommends: dmidecode Recommends: udisks2 Recommends: xdg-utils Recommends: iperf3 +%endif %description Hardinfo2 is based on hardinfo, which have not been released >10 years. @@ -76,22 +96,28 @@ Features include: %autosetup -p1 -n hardinfo2-release-%{version} %build -%cmake \ - -GNinja \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - +%if 0%{?rhel} < 8 +%cmake3 -DCMAKE_BUILD_TYPE=Release +%cmake3_build +%else +%cmake -DCMAKE_BUILD_TYPE=Release %cmake_build +%endif %install +%if 0%{?rhel} < 8 +%cmake3_install +%else %cmake_install +%endif %find_lang %{name} %check -desktop-file-validate %{buildroot}/%{_datadir}/applications/*.desktop +desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %files -f %{name}.lang -%license +%license LICENSE %doc README.md %{_bindir}/hardinfo2 %dir %{_libdir}/hardinfo2 @@ -101,6 +127,7 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/*.desktop %{_libdir}/hardinfo2/modules/devices.so %{_libdir}/hardinfo2/modules/network.so %{_datadir}/applications/hardinfo2.desktop +%dir %{_datadir}/hardinfo2 %{_datadir}/hardinfo2/*.ids %{_datadir}/hardinfo2/benchmark.data %{_datadir}/hardinfo2/*.json @@ -109,4 +136,10 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/*.desktop %{_mandir}/man1/hardinfo2.1* %changelog +%if %{defined autochangelog} %autochangelog +%else +* Mon May 01 2023 RH Container Bot <rhcontainerbot@fedoraproject.org> +- Placeholder changelog for envs that are not autochangelog-ready +%endif + |