Skip to content
Snippets Groups Projects
Verified Commit 2a67fa06 authored by Manuel Mendez's avatar Manuel Mendez Committed by Rasmus Thomsen
Browse files

community/lshw: Add upstream patches to fix json output

parent 07eceeed
2 merge requests!11958community/rclone: upgrade to 1.52.3,!11607community/lshw: Add upstream patches to fix json output
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;
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");
......@@ -3,7 +3,7 @@
pkgname=lshw
pkgver=02.19.2
_pkgver="B.$pkgver"
pkgrel=0
pkgrel=1
pkgdesc="Hardware Lister"
url="https://ezix.org/project/wiki/HardwareLiSter"
arch="all"
......@@ -13,6 +13,8 @@ subpackages="$pkgname-doc $pkgname-lang"
source="https://ezix.org/software/files/lshw-$_pkgver.tar.gz
fix-musl-sc_long_bit.patch
wrapper-for-basename.patch
2b1c730b493d647bbab4854713571458e82a81e7.patch
15565229509455527de9ce7cbb9530e2b31d043b.patch
"
builddir="$srcdir"/$pkgname-$_pkgver
......@@ -30,4 +32,6 @@ package() {
sha512sums="f3abc6241fe7912740f11b5b97a1f7778cb7cc69f5209b83063cbc1d3aa7b082dedb3aac4119ce100391547400ed6bb2d413ca47de50794e1066f31961be41a5 lshw-B.02.19.2.tar.gz
21d5692b50086018685232261e4851cd6dcd84660512dde58317c06a3b10d73d04d7f0b164264cb9c4dd4154947672dbbf1f288291bab5ec952e57458b71ab42 fix-musl-sc_long_bit.patch
7adbb35c9ba0af3ba698c472226781ae1a518deb1f85f6cb8b53ac05c84b40ae94cbfd5761b58709b1d5726660f9eb159cf1233a77b2fa6565010dde17167b7d wrapper-for-basename.patch"
7adbb35c9ba0af3ba698c472226781ae1a518deb1f85f6cb8b53ac05c84b40ae94cbfd5761b58709b1d5726660f9eb159cf1233a77b2fa6565010dde17167b7d wrapper-for-basename.patch
58bbdda190b245460bf67d94e407a3a8aa9741a8f43df2b8fee157d2619bd55f1fd69cfb06318f750caa307cf484b52803e5d6222c8332107936ae44a43aea24 2b1c730b493d647bbab4854713571458e82a81e7.patch
42ec43bca9455d91f6c3cdf8fe023d78e09a0b94fdf9d149b6784edbfef406fc66a081efca56d5dea6c186abb2723341b6c716cf63c46561ba2d749a3e4088bf 15565229509455527de9ce7cbb9530e2b31d043b.patch"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment