Ubuntu 18.04 [ P9 WSP DD2.2 ]: lshw version is displayed as "unknown" and -json option is not available in help message.

Bug #1752523 reported by bugproxy
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
The Ubuntu-power-systems project
Fix Released
Medium
Canonical Foundations Team
lshw (Debian)
Fix Released
Unknown
lshw (Ubuntu)
Fix Released
Medium
Canonical Foundations Team
Bionic
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

 * lshw version is displayed as "unknown"
 * '-json' option is not available in help message although it is a fully supported

The version used to be set and then read from a text file named '.version' inside the upstream source, but since B.02.18 [1] the version is fetched from a shell call that relies on 'git describe'. This causes the version to set to "unknown" during the build. The proposed version fix has been uploaded upstream [2] and relies instead on reading from a 'VERSION' variable inside the makefile. The debdiff takes care of setting the variable to the right value in debian/rules.

The proposed fix also includes the '-json' to the help output and has been uploaded upstream [3], as the json output has been supported and recognized for a while.

[Test Case]

Trusty:
$ lshw -version
Hardware Lister (lshw) - B.02.16

Bionic:
$ lshw -version
unknown

$ lshw -help
Hardware Lister (lshw) - unknown
usage: lshw [-format] [-options ...]
       lshw -version

 -version print program version (unknown)

format can be
 -html output hardware tree as HTML
 -xml output hardware tree as XML
 -short output hardware paths
 -businfo output bus information

options can be
 -class CLASS only show a certain class of hardware
 -C CLASS same as '-class CLASS'
 -c CLASS same as '-class CLASS'
 -disable TEST disable a test (like pci, isapnp, cpuid, etc. )
 -enable TEST enable a test (like pci, isapnp, cpuid, etc. )
 -quiet don't display status
 -sanitize sanitize output (remove sensitive information like serial numbers, etc.)
 -numeric output numeric IDs (for PCI, USB, etc.)
 -notime exclude volatile attributes (timestamps) from output

Bionic patched:
$ lshw -version
B.02.18

$ lshw -help
Hardware Lister (lshw) - B.02.18
usage: lshw [-format] [-options ...]
       lshw -version

 -version print program version (B.02.18)

format can be
 -html output hardware tree as HTML
 -xml output hardware tree as XML
 -json output hardware tree as a JSON object
 -short output hardware paths
 -businfo output bus information

options can be
 -class CLASS only show a certain class of hardware
 -C CLASS same as '-class CLASS'
 -c CLASS same as '-class CLASS'
 -disable TEST disable a test (like pci, isapnp, cpuid, etc. )
 -enable TEST enable a test (like pci, isapnp, cpuid, etc. )
 -quiet don't display status
 -sanitize sanitize output (remove sensitive information like serial numbers, etc.)
 -numeric output numeric IDs (for PCI, USB, etc.)
 -notime exclude volatile attributes (timestamps) from output

[Regression Potential]

 * The version is set through the debian/rules variable VERSION, if set incorrectly it will misreport the actual lshw version being used.

[References]

[1] https://github.com/lyonel/lshw/commit/2d0296cc31eefaba70f35c8b76af7dfc5f21b387
[2] https://github.com/lyonel/lshw/commit/18edc98f9d08883f340087cfefbdf05c585d56f7
[3] https://github.com/lyonel/lshw/commit/503c76a35a9e97a098af7c1ac793a7e13c07ce70

[Original Bug Description]
== Comment: #0 - PAVITHRA R. PRAKASH <email address hidden> - 2018-03-01 00:30:14 ==
---Problem Description---

Ubuntu 18.04 [ P9 WSP DD2.2 ]: lshw version is displayed as "unknown" and -json option is not available in help message.

---Environment--
Kernel Build: Ubuntu 18.04
System Name : wcwsp3
Model/Type : P9
Platform : BML

---Uname output---

root@ltc-wcwsp3:~# uname -a
Linux ltc-wcwsp3 4.15.0-10-generic #11 SMP Thu Feb 22 23:50:53 EST 2018 ppc64le ppc64le ppc64le GNU/Linux

---Steps to reproduce--

1. Run below commands.

# lshw -version
# lshw -h

---Logs----

root@ltc-wcwsp3:~# lshw -version
unknown
root@ltc-wcwsp3:~# lshw -h
Hardware Lister (lshw) - unknown
usage: lshw [-format] [-options ...]
       lshw -version

 -version print program version (unknown)

format can be
 -html output hardware tree as HTML
 -xml output hardware tree as XML
 -short output hardware paths
 -businfo output bus information

options can be
 -class CLASS only show a certain class of hardware
 -C CLASS same as '-class CLASS'
 -c CLASS same as '-class CLASS'
 -disable TEST disable a test (like pci, isapnp, cpuid, etc. )
 -enable TEST enable a test (like pci, isapnp, cpuid, etc. )
 -quiet don't display status
 -sanitize sanitize output (remove sensitive information like serial numbers, etc.)
 -numeric output numeric IDs (for PCI, USB, etc.)
 -notime exclude volatile attributes (timestamps) from output

== Comment: #1 - Chandni Verma <email address hidden> - 2018-03-01 02:48:01 ==
Upstream patches:
https://github.com/lyonel/lshw/commit/18edc98f9d08883f340087cfefbdf05c585d56f7
and
https://github.com/lyonel/lshw/commit/503c76a35a9e97a098af7c1ac793a7e13c07ce70

should fix the version and missing -json option issues respectively.

Kindly cherry pick them and verify.

Thanks!

bugproxy (bugproxy)
tags: added: architecture-ppc64le bugnameltc-165253 severity-medium targetmilestone-inin---
Changed in ubuntu:
assignee: nobody → Ubuntu on IBM Power Systems Bug Triage (ubuntu-power-triage)
affects: ubuntu → lshw (Ubuntu)
Changed in ubuntu-power-systems:
importance: Undecided → Medium
assignee: nobody → Canonical Foundations Team (canonical-foundations)
tags: added: triage-g
Manoj Iyer (manjo)
Changed in lshw (Ubuntu):
assignee: Ubuntu on IBM Power Systems Bug Triage (ubuntu-power-triage) → Canonical Foundations Team (canonical-foundations)
importance: Undecided → Medium
Changed in ubuntu-power-systems:
status: New → Triaged
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2018-03-25 21:35 EDT-------
(In reply to comment #1)
> Upstream patches:
> https://github.com/lyonel/lshw/commit/
> 18edc98f9d08883f340087cfefbdf05c585d56f7
> and
> https://github.com/lyonel/lshw/commit/
> 503c76a35a9e97a098af7c1ac793a7e13c07ce70
>
> should fix the version and missing -json option issues respectively.
>
> Kindly cherry pick them.
>
> Thanks!

Please provide test kernel for Pavithra to validate it internally.

tags: added: targetmilestone-inin1804
removed: targetmilestone-inin---
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2018-03-26 07:33 EDT-------
You don't need a kernel modification for it to work.

It's a user-space issue independent of the kernel.

But yes, I'll try to generate a patched lshw debian package for internal validation tomorrow.

tags: added: id-5ab95bc39c2b15e2cf34d491
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2018-03-28 09:18 EDT-------
I changed the directory names in the patches to match the build tree directory structure.
I made some modifications to the surrounding code lines in Vasant's version patch to make the patch apply successfully.

With the patches applied I build the package and installed it. On running the commands I see:

ubuntu@ubuntu:~/ubuntu-bionic/chandni$ lshw -version
Ubuntu.4.15.0
ubuntu@ubuntu:~/ubuntu-bionic/chandni$ lshw -h
Hardware Lister (lshw) - Ubuntu.4.15.0
usage: lshw [-format] [-options ...]
lshw -version

-version print program version (Ubuntu.4.15.0)

format can be
-html output hardware tree as HTML
-xml output hardware tree as XML
-json output hardware tree as a JSON object
-short output hardware paths
-businfo output bus information

options can be
-class CLASS only show a certain class of hardware
-C CLASS same as '-class CLASS'
-c CLASS same as '-class CLASS'
-disable TEST disable a test (like pci, isapnp, cpuid, etc. )
-enable TEST enable a test (like pci, isapnp, cpuid, etc. )
-quiet don't display status
-sanitize sanitize output (remove sensitive information like serial numbers, etc.)
-numeric output numeric IDs (for PCI, USB, etc.)
-notime exclude volatile attributes (timestamps) from output

I am attaching the build package for Pavithra to test along with the changed patch files and the build log.
Adding Vasant to CC in case there are any issues seen with version-patch after Pavithra's test.

Revision history for this message
bugproxy (bugproxy) wrote : Test lshw build

------- Comment (attachment only) From <email address hidden> 2018-03-28 09:21 EDT-------

Revision history for this message
bugproxy (bugproxy) wrote : Patch adding json option to help output

------- Comment (attachment only) From <email address hidden> 2018-03-28 09:22 EDT-------

Revision history for this message
bugproxy (bugproxy) wrote : Patch fixing unknown version issue

------- Comment (attachment only) From <email address hidden> 2018-03-28 09:23 EDT-------

Revision history for this message
bugproxy (bugproxy) wrote : lshw Build log

------- Comment on attachment From <email address hidden> 2018-03-28 09:27 EDT-------

Snippet from this log (notice the value being assigned to -DVERSION) :

make[1]: Entering directory '/home/ubuntu/ubuntu-bionic/chandni/lshw-02.18/lshw-B.02.18/src'
make -C core all
make[2]: Entering directory '/home/ubuntu/ubuntu-bionic/chandni/lshw-02.18/lshw-B.02.18/src/core'
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"Ubuntu.4.15.0\" -c hw.cc -o hw.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"Ubuntu.4.15.0\" -c main.cc -o main.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"Ubuntu.4.15.0\" -c print.cc -o print.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"Ubuntu.4.15.0\" -c mem.cc -o mem.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"Ubuntu.4.15.0\" -c dmi.cc -o dmi.o

Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla
Download full text (3.4 KiB)

------- Comment From <email address hidden> 2018-04-04 03:13 EDT-------
Hi Pavithra,

From Comment #11 and Comment #12, we see that the VERSION variable is getting the incorrect value...

... which is because one of the parent directories where I was building the backported lshw was a git repository (I didn't check that. I should have created a separate dir in home for the test build of lshw) and the build of lshw was pulling the "git describe" value of that existing dir.

I just built a new custom lshw from a dir which is not inside an existing git repo. and saw in the build that no value was getting pulled this time:

Applying patch Fix-unknown-version-issue.patch
patching file lshw-B.02.18/src/Makefile
Hunk #1 succeeded at 20 with fuzz 2.
patching file lshw-B.02.18/src/core/version.cc

Now at patch Fix-unknown-version-issue.patch
touch debian/stamp-patched
dh_testdir
# Add here commands to compile the package.
/usr/bin/make -C lshw-B.02.18/src core
make[1]: Entering directory '/home/ubuntu/chandni/lshw/lshw-02.18/lshw-B.02.18/src'
make -C core all
fatal: Not a git repository (or any of the parent directories): .git
make[2]: Entering directory '/home/ubuntu/chandni/lshw/lshw-02.18/lshw-B.02.18/src/core'
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"\" -c hw.cc -o hw.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"\" -c main.cc -o main.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"\" -c print.cc -o print.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"\" -c mem.cc -o mem.o
c++ -Wall -g -O2 -I./core/ -DPREFIX=\"/usr\" -DSBINDIR=\"/usr/bin\" -DMANDIR=\"/usr/share/man\" -DDATADIR=\"/usr/share\" -DVERSION=\"\" -c dmi.cc -o dmi.o
In file included from dmi.cc:78:0:

and on running this lshw, I see:

ubuntu@ubuntu:~/chandni/lshw$ lshw -version

ubuntu@ubuntu:~/chandni/lshw$ lshw -h
Hardware Lister (lshw) -
usage: lshw [-format] [-options ...]
lshw -version

-version print program version ()

format can be
-html output hardware tree as HTML
-xml output hardware tree as XML
-json output hardware tree as a JSON object
-short output hardware paths
-businfo output bus information

options can be
-class CLASS only show a certain class of hardware
-C CLASS same as '-class CLASS'
-c CLASS same as '-class CLASS'
-disable TEST disable a test (like pci, isapnp, cpuid, etc. )
-enable TEST enable a test (like pci, isapnp, cpuid, etc. )
-quiet don't display status
-sanitize sanitize output (remove sensitive information like serial numbers, etc.)
-numeric output numeric IDs (for PCI, USB, etc.)
-notime exclude volatile attributes (timestamps) from output

So actually this is not an error. Had we had run the lshw.deb build from an lshw directory, like the package maintainer would build, the correct "git describe" v...

Read more...

Frank Heimes (fheimes)
Changed in lshw (Ubuntu):
status: New → Incomplete
Changed in ubuntu-power-systems:
status: Triaged → Incomplete
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2018-05-17 07:41 EDT-------
>
> So actually this is not an error. Had we had run the lshw.deb build from an
> lshw directory, like the package maintainer would build, the correct "git
> describe" value will be pulled. But since I am not building from a lshw git
> repo, but from a debian source fetched from "apt-get source lshw" its not
> pulling the correct value.
>
> Vasant, please confirm that this is fine and the patche as mentioned in
> Comment #10 is good to go!

Good to go. Please pick these two patches.

-Vasant

Manoj Iyer (manjo)
tags: added: p9 ubuntu-18.04.1
Steve Langasek (vorlon)
Changed in lshw (Ubuntu):
status: Incomplete → Triaged
Frank Heimes (fheimes)
Changed in ubuntu-power-systems:
status: Incomplete → Triaged
Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

debdiff for Cosmic that includes:
- patch for '-json' help parameter
- patch for getting the version from a build variable
- change in debian/rules to set the VERSION variable

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lshw - 02.18-0.1ubuntu7

---------------
lshw (02.18-0.1ubuntu7) cosmic; urgency=medium

  * d/patches/lshw-add-json-option-in-help-output.patch,
  * d/patches/lshw-fix-unknown-version-issue.patch:
    Cherry pick from upstream. (LP: #1752523)
  * d/rules: pass uver as VERSION when building the core module as
    the lshw-fix-unknown-version-issue.patch expects that variable
    to be set, otherwise lshw's version will be set to an empty
    string.

 -- Tiago Stürmer Daitx <email address hidden> Mon, 09 Jul 2018 20:13:29 +0000

Changed in lshw (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

Attaching debdiff containing the fixes for the Bionic SRU.

description: updated
tags: added: patch
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello bugproxy, or anyone else affected,

Accepted lshw into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/lshw/02.18-0.1ubuntu6.18.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in lshw (Ubuntu Bionic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-bionic
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I have approved this upload but I do have one question: does this generally mean that with every new upstream release of lshw the debian/rules uver variable needs to be manually updated? Or is it somehow automatically set with every uupdate? Since it sounds a bit error-prone if it's manual as I'm sure people preparing the new version will keep forgetting bumping it. Still better than 'unknown' but this seems like a suboptimal solution. Is there no other trace of the current version in the source?

Frank Heimes (fheimes)
Changed in ubuntu-power-systems:
status: Triaged → Fix Committed
Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

Hi Lukasz,

I agree that depending on someone setting it manually on the rules file is not optimal while way better than "unknown".

This is not really an issue right now: if you look at the rules file you will notice that 'uver' is used to set the 'srcdir', which would cause the package to FTBFS if set to the wrong version after an update.

So for Bionic this should be well enough.

While investigating this I noticed a couple change that will cause problems in the next package update for Cosmic.

Upstream had a bug [1] where the lshw.spec file would be out of the source tree, thus the sources in the orig tarball were expanded into that lshw-VERSION directory. This is no longer the case and now the sources are all expanded into the package root, so there is no need for the 'uver' variable.

Debian has already packaged a newer version [2] (tagged B.02.18.85) and removed the 'uver' variable.

Until now the upstream tarball used to include a lshw.spec file. That file was was generated when calling the "release" rule in lshw's Makefile to create such tarball. Unfortunately Debian's newer orig tarball seems to have been created differently. Without a generated lshw.spec file there's nothing in lshw source that contains a reference to lshw's version.

For now the only way I see to fetch a version is to use the one from the changelog entry, as in:
VERSION=$(dpkg-parsechangelog -SVersion)

Would that be acceptable for Cosmic? If so I will follow up on Debian to include this fix.

Regards,
Tiago

References:
[1] https://ezix.org/src/pkg/lshw/commit/4af2308ad459924e792f4a09a7374ebae0cde805
[2] https://tracker.debian.org/pkg/lshw

Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

I tested lshw 02.18-0.1ubuntu6.18.04.1 in a Bionic schroot and can confirm that the proposed package fixes both issues reported in this SRU, as per the test case.

tags: added: verification-done-bionic
removed: verification-needed verification-needed-bionic
Changed in lshw (Debian):
status: Unknown → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for lshw has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lshw - 02.18-0.1ubuntu6.18.04.1

---------------
lshw (02.18-0.1ubuntu6.18.04.1) bionic; urgency=medium

  * d/patches/lshw-add-json-option-in-help-output.patch,
  * d/patches/lshw-fix-unknown-version-issue.patch:
    Cherry pick from upstream. (LP: #1752523)
  * d/rules: pass uver as VERSION when building the core module as
    the lshw-fix-unknown-version-issue.patch expects that variable
    to be set, otherwise lshw's version will be set to an empty
    string.

 -- Tiago Stürmer Daitx <email address hidden> Tue, 10 Jul 2018 14:25:42 +0000

Changed in lshw (Ubuntu Bionic):
status: Fix Committed → Fix Released
Changed in ubuntu-power-systems:
status: Fix Committed → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2018-08-06 02:48 EDT-------
Issue is not observed on latest updated kernel/packages.

# uname -a
Linux ltc-wspoon12 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:37:15 UTC 2018 ppc64le ppc64le ppc64le GNU/Linux

# dpkg -l | grep lshw
ii lshw 02.18-0.1ubuntu6.18.04.1 ppc64el information about hardware configuration

# lshw -version
B.02.18

Thanks,
Harish

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.