Compare commits

...

No commits in common. "c8" and "c8-beta" have entirely different histories.
c8 ... c8-beta

5 changed files with 111 additions and 190 deletions

View File

@ -1,49 +0,0 @@
From 2b1c730b493d647bbab4854713571458e82a81e7 Mon Sep 17 00:00:00 2001
From: Lyonel Vincent <lyonel@ezix.org>
Date: Tue, 26 May 2020 01:00:37 +0200
Subject: [PATCH] JSON output clean-up (list/object)
---
src/core/hw.cc | 5 ++---
src/lshw.cc | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/hw.cc b/src/core/hw.cc
index aca424c..ab345fe 100644
--- a/src/core/hw.cc
+++ b/src/core/hw.cc
@@ -1400,7 +1400,7 @@ string hwNode::asJSON(unsigned level)
config = getConfigKeys();
resources = getResources("\" value=\"");
- if (level == 0)
+ if (::enabled("output:list") && level == 0)
{
out << "[" << endl;
}
@@ -1665,9 +1665,8 @@ string hwNode::asJSON(unsigned level)
out << "}";
}
- if (level == 0)
+ if (::enabled("output:list") && level == 0)
{
- out.seekp(-2, std::ios_base::end);
out << endl << "]" << endl;
}
diff --git a/src/lshw.cc b/src/lshw.cc
index 219a008..571b1c3 100644
--- a/src/lshw.cc
+++ b/src/lshw.cc
@@ -84,6 +84,7 @@ char **argv)
disable("isapnp");
+ disable("output:list");
disable("output:json");
disable("output:db");
disable("output:xml");
--
2.47.0

View File

@ -1,62 +0,0 @@
From 15565229509455527de9ce7cbb9530e2b31d043b Mon Sep 17 00:00:00 2001
From: Lyonel Vincent <lyonel@ezix.org>
Date: Wed, 27 May 2020 01:07:16 +0200
Subject: [PATCH] clean-up JSON output
---
src/core/hw.cc | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/core/hw.cc b/src/core/hw.cc
index ab345fe..6aea7cf 100644
--- a/src/core/hw.cc
+++ b/src/core/hw.cc
@@ -1650,13 +1650,20 @@ string hwNode::asJSON(unsigned level)
resources.clear();
}
- for (unsigned int i = 0; i < countChildren(); i++)
+ if(!::enabled("output:list") && countChildren()>0)
{
- out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
- if (visible(getChild(i)->getClassName()))
+ out << "," << endl;
+ out << spaces(2*level+2);
+ out << "\"children\" : [";
+ for (unsigned int i = 0; i < countChildren(); i++)
{
- out << "," << endl;
+ out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
+ if (visible(getChild(i)->getClassName()) && i<countChildren()-1)
+ {
+ out << "," << endl;
+ }
}
+ out << "]";
}
if(visible(getClassName()))
@@ -1665,6 +1672,20 @@ string hwNode::asJSON(unsigned level)
out << "}";
}
+ if(::enabled("output:list") && countChildren()>0)
+ {
+ bool needcomma = visible(getClassName());
+ for (unsigned int i = 0; i < countChildren(); i++)
+ {
+ string json = getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
+
+ if(needcomma && strip(json)!="")
+ out << "," << endl;
+ out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
+ needcomma |= strip(json)!="";
+ }
+ }
+
if (::enabled("output:list") && level == 0)
{
out << endl << "]" << endl;
--
2.47.0

View File

@ -1,27 +0,0 @@
From befc2e215ab1b86af1af63fbfc26b56cd212339d Mon Sep 17 00:00:00 2001
From: Lyonel Vincent <lyonel@ezix.org>
Date: Wed, 12 Jun 2024 13:50:01 +0200
Subject: [PATCH] escape '\' in JSON output
some DMI/SMBIOS contain '\' at the end of their strings (#807)
---
src/core/osutils.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/core/osutils.cc b/src/core/osutils.cc
index cfa09ca..a3d8c12 100644
--- a/src/core/osutils.cc
+++ b/src/core/osutils.cc
@@ -526,6 +526,9 @@ string escapeJSON(const string & s)
case '"':
result += "\\\"";
break;
+ case '\\':
+ result += "\\\\";
+ break;
default:
result += s[i];
}
--
2.47.0

View File

@ -0,0 +1,66 @@
commit 135a853c60582b14c5b67e5cd988a8062d9896f4
Author: Lyonel Vincent <lyonel@ezix.org>
Date: Fri Apr 28 16:54:42 2017 +0200
Fix JSON output format
cf. https://github.com/lyonel/lshw/pull/28
diff --git a/src/core/hw.cc b/src/core/hw.cc
index 68e5912..9defd26 100644
--- a/src/core/hw.cc
+++ b/src/core/hw.cc
@@ -1368,9 +1368,14 @@ string hwNode::asJSON(unsigned level)
config = getConfigKeys();
resources = getResources("\" value=\"");
+ if (level == 0)
+ {
+ out << "[" << endl;
+ }
+
if(visible(getClassName()))
{
- out << "{" << endl;
+ out << spaces(2*level) << "{" << endl;
out << spaces(2*level+2) << "\"id\" : \"" << getId() << "\"," << endl;
out << spaces(2*level+2) << "\"class\" : \"" << getClassName() << "\"";
@@ -1613,20 +1618,13 @@ string hwNode::asJSON(unsigned level)
resources.clear();
}
-
- if(countChildren()>0)
+ for (unsigned int i = 0; i < countChildren(); i++)
{
- if(visible(getClassName()))
- out << "," << endl << spaces(2*level+2) << "\"children\" : [" << endl;
-
- for (unsigned int i = 0; i < countChildren(); i++)
+ out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
+ if (visible(getChild(i)->getClassName()))
{
- out << spaces(2*level+4) << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
- if(visible(getChild(i)->getClassName()) && (i < countChildren()-1)) out << "," << endl;
+ out << "," << endl;
}
-
- if(visible(getClassName()))
- out << endl << spaces(2*level+2) << "]";
}
if(visible(getClassName()))
@@ -1635,6 +1633,12 @@ string hwNode::asJSON(unsigned level)
out << "}";
}
+ if (level == 0)
+ {
+ out.seekp(-2, std::ios_base::end);
+ out << endl << "]" << endl;
+ }
+
return out.str();
}

View File

@ -1,12 +1,13 @@
Summary: Hardware lister
Name: lshw
Version: B.02.19.2
Release: 6%{?dist}.1
Release: 6%{?dist}
License: GPLv2
Group: Applications/System
URL: http://ezix.org/project/wiki/HardwareLiSter
Source0: http://www.ezix.org/software/files/lshw-%{version}.tar.gz
Patch1: lshw-B.02.18-scandir.patch
Patch2: lshw-B.02.18-revert-json.patch
Patch3: lshw-B.02.19.2-cmake.patch
Patch4: lshw-B.02.19.2-Add-the-FindPkgConfig-to-CMakeLists.patch
Patch5: 0001-report-CPU-family-model-stepping.patch
@ -48,9 +49,6 @@ Patch40: rhelonly-cleanup-remove-unused-support.c-support.h-generated-.pat
Patch41: 0001-Report-correct-memory-size-on-SMBIOS-2.7.patch
Patch42: 0001-devtree-Add-UUID-property.patch
Patch43: 0001-Fix-getting-size-of-memory-banks-32GiB.patch
Patch44: 0001-JSON-output-clean-up-list-object.patch
Patch45: 0001-clean-up-JSON-output.patch
Patch46: 0001-escape-in-JSON-output.patch
BuildRequires: cmake
BuildRequires: desktop-file-utils
@ -86,51 +84,49 @@ format.
%prep
%setup -q
%patch -P1 -p1
%patch -P3 -p1
%patch -P4 -p1
%patch -P5 -p1
%patch -P6 -p1
%patch -P7 -p1
%patch -P8 -p1
%patch -P9 -p1
%patch -P10 -p1
%patch -P11 -p1
%patch -P12 -p1
%patch -P13 -p1
%patch -P14 -p1
%patch -P15 -p1
%patch -P16 -p1
%patch -P17 -p1
%patch -P18 -p1
%patch -P19 -p1
%patch -P20 -p1
%patch -P21 -p1
%patch -P22 -p1
%patch -P23 -p1
%patch -P24 -p1
%patch -P25 -p1
%patch -P26 -p1
%patch -P27 -p1
%patch -P28 -p1
%patch -P29 -p1
%patch -P30 -p1
%patch -P31 -p1
%patch -P32 -p1
%patch -P33 -p1
%patch -P34 -p1
%patch -P35 -p1
%patch -P36 -p1
%patch -P37 -p1
%patch -P38 -p1
%patch -P39 -p1
%patch -P40 -p1
%patch -P41 -p1
%patch -P42 -p1
%patch -P43 -p1
%patch -P44 -p1
%patch -P45 -p1
%patch -P46 -p1
%patch01 -p1
%patch02 -R -p1
%patch03 -p1
%patch04 -p1
%patch05 -p1
%patch06 -p1
%patch07 -p1
%patch08 -p1
%patch09 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%build
mkdir build && pushd build
@ -178,9 +174,6 @@ src/lshw -json \
%{_datadir}/polkit-1/actions/org.ezix.lshw.gui.policy
%changelog
* Wed May 14 2025 Tao Liu <ltao@redhat.com> - B.02.19.2-6.1
- Resolves: RHEL-91281
* Tue Jun 08 2021 Tao Liu <ltao@redhat.com> - B.02.19.2-6
- Fix getting size of memory banks <32GiB