Update to commit 6cc0581

Rebase cmake patch on top 6cc0581
Add NVME patch from PR#45
This commit is contained in:
Terje Røsten 2019-05-28 19:45:04 +02:00
parent dddb74d70f
commit c207aaec36
5 changed files with 133946 additions and 63534 deletions

File diff suppressed because it is too large Load Diff

133549
lshw-B.02.18-6cc0581.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,29 @@
From a43ffe12212e1a4dd7b0038197b53798d7a3dfb1 Mon Sep 17 00:00:00 2001
From c8a08ccb9a268c4d55bf80a236cd0ad2d149ce20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terje.rosten@ntnu.no>
Date: Mon, 2 Apr 2018 14:51:55 +0200
Date: Tue, 28 May 2019 19:32:24 +0200
Subject: [PATCH] cmakeify
---
CMakeLists.txt | 42 ++++++
Makefile | 20 ---
README.md | 47 ++++---
lshw.spec.in | 52 ++------
src/CMakeLists.txt | 103 +++++++++++++++
src/Makefile | 144 ---------------------
src/core/Makefile | 80 ------------
src/core/{config.h => config.h.in} | 28 ++--
src/core/db.cc | 8 ++
src/core/dump.cc | 2 +-
src/core/version.h | 2 +
src/gui/CMakeLists.txt | 67 ++++++++++
src/gui/Makefile | 61 ---------
.../{gtk-lshw.desktop => gtk-lshw.desktop.in} | 7 +-
src/gui/integration/lshw-gui.in | 5 +
src/gui/integration/org.ezix.lshw.gui.policy.in | 20 +++
src/gui/stock.c | 1 +
src/po/CMakeLists.txt | 16 +++
src/po/Makefile | 23 ----
19 files changed, 317 insertions(+), 411 deletions(-)
CMakeLists.txt | 43 ++++++
Makefile | 20 ---
README.md | 51 ++++---
lshw.spec.in | 62 +++-----
src/CMakeLists.txt | 102 +++++++++++++
src/Makefile | 144 ------------------
src/core/Makefile | 80 ----------
src/core/{config.h => config.h.in} | 28 +---
src/core/db.cc | 8 +
src/core/dump.cc | 2 +-
src/core/version.h | 2 +
src/gui/CMakeLists.txt | 67 ++++++++
src/gui/Makefile | 61 --------
.../{gtk-lshw.desktop => gtk-lshw.desktop.in} | 7 +-
src/gui/integration/lshw-gui.in | 5 +
.../integration/org.ezix.lshw.gui.policy.in | 20 +++
src/gui/stock.c | 1 +
src/po/CMakeLists.txt | 16 ++
src/po/Makefile | 23 ---
19 files changed, 327 insertions(+), 415 deletions(-)
create mode 100644 CMakeLists.txt
delete mode 100644 Makefile
create mode 100644 src/CMakeLists.txt
@ -40,17 +40,18 @@ Subject: [PATCH] cmakeify
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6c69c37
index 0000000..d14a65c
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,42 @@
@@ -0,0 +1,43 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(lshw)
+set(VERSION "B.012.18")
+set(VERSION "B.02.18")
+
+IF(EXISTS "${PROJECT_SOURCE_DIR}/.git")
+ find_package(Git)
+find_package(Git)
+
+if(EXISTS "${PROJECT_SOURCE_DIR}/.git" AND "${MAKE_RELEASE}" STREQUAL "")
+ if(GIT_FOUND)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe --tags
@ -113,10 +114,10 @@ index 8fe665e..0000000
- tar --transform s!^!$(PACKAGENAME)-$(VERSION)/! -rf $(PACKAGENAME)-$(VERSION).tar $^
- gzip -f $(PACKAGENAME)-$(VERSION).tar
diff --git a/README.md b/README.md
index 7afcae6..393da0f 100644
index 30feaf1..294888c 100644
--- a/README.md
+++ b/README.md
@@ -15,27 +15,25 @@ Installation
@@ -15,27 +15,29 @@ Installation
1. Requirements
- Linux 2.4.x, 2.6.x, 3.x or 4.x (2.2.x might work, though)
- a PA-RISC-, Alpha-, IA-64- (Itanium-), PowerPC-, ARM- or x86- based machine
@ -128,13 +129,17 @@ index 7afcae6..393da0f 100644
+ - for optional zlib feature install zlib and gzip
- 2. To compile it, just use:
+ 2. Use cmake options to adjust non default set:
+ -DGUI=OFF, -DZLIB=ON, -DSQLITE=ON and/or -DNOLOGO=ON
+ 2. Use cmake options to decide feature set:
+ - -DGUI=OFF - disable graphical user interface version og lshw
+ - -DZLIB=ON - enable reading of gzipped datafiles
+ - -DSQLITE=ON - enable SQLite support
+ - -DPOLICYKIT=ON - enable PolicyKit integration
+ - -DNOLOGO=ON - don't install logos with copyright
- $ make
+ 3. Do configuration and build by
- To complile with zlib support (see below), use:
- To compile with zlib support (see below), use:
-
- $ make ZLIB=1
-
@ -154,7 +159,7 @@ index 7afcae6..393da0f 100644
Getting help
------------
@@ -61,12 +59,27 @@ If compiled with zlib support, lshw will look for `file`.gz first, then for `fil
@@ -61,12 +63,27 @@ If compiled with zlib support, lshw will look for `file`.gz first, then for `fil
Statically-linked and/or compressed binaries can be built by using
@ -172,8 +177,8 @@ index 7afcae6..393da0f 100644
+Building compressed binaries requires `upx` (cf. https://upx.github.io/).
-in the `src/` directory
+Release and maintenance
+-----------------------
+Release management and data files maintenance
+---------------------------------------------
-Building compressed binaries requires `upx` (cf. https://upx.github.io/).
+Create release tarball,
@ -181,17 +186,40 @@ index 7afcae6..393da0f 100644
+ 1. Edit CMakeLists.txt to set version
+ 2. Run
+ $ mkdir build && cd build
+ $ cmake .. -GNinja
+ $ ninja release
+ $ cmake .. -DMAKE_RELEASE=ON
+ $ make release
+
+Update hwdata files:
+
+ $ ninja refresh_hwdata
+ $ make refresh_hwdata
diff --git a/lshw.spec.in b/lshw.spec.in
index c597379..a7655f5 100644
index f7f88b3..3fe23c2 100644
--- a/lshw.spec.in
+++ b/lshw.spec.in
@@ -52,49 +52,17 @@ http://lshw.ezix.org/
@@ -7,9 +7,11 @@ Version: @VERSION@
Release: 2
Source: http://www.ezix.org/software/files/%{name}-%{version}.tar.gz
URL: http://lshw.ezix.org/
-License: GPL
+License: GPLv2
Group: Applications/System
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: gcc
+BuildRequires: gcc-c++
+BuildRequires: cmake
%description
lshw (Hardware Lister) is a small tool to provide detailed information on
@@ -37,7 +39,7 @@ lshw (Hardware Lister) is a small tool to provide detailed informaton on
the hardware configuration of the machine. It can report exact memory
configuration, firmware version, mainboard configuration, CPU version
and speed, cache configuration, bus speed, etc. on DMI-capable x86s
- systems and on some PowerPC machines (PowerMac G4 is known to work).
+systems and on some PowerPC machines (PowerMac G4 is known to work).
This package provides a graphical user interface to display hardware
information.
@@ -52,59 +54,29 @@ http://lshw.ezix.org/
%setup -q
%build
@ -244,11 +272,12 @@ index c597379..a7655f5 100644
-%defattr(-,root,root, 0555)
-%doc README.md COPYING docs/TODO docs/Changelog docs/lshw.xsd
+%license COPYING
+%doc COPYING docs/TODO docs/Changelog docs/lshw.xsd
+%doc docs/TODO docs/Changelog docs/lshw.xsd
%{_sbindir}/lshw
%doc %{_mandir}/man?/*
-%doc %{_mandir}/man?/*
+%{_mandir}/man?/*
%{_datadir}/lshw/
@@ -102,9 +70,11 @@ http://lshw.ezix.org/
%{_datadir}/locale/*/*/*
%if %{!?_without_gui:1}0
%files gui
@ -264,10 +293,10 @@ index c597379..a7655f5 100644
%changelog
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..ab559d9
index 0000000..8b97a16
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,103 @@
@@ -0,0 +1,102 @@
+if(STATIC)
+ set(ZLIB OFF)
+ set(SQLITE OFF)
@ -370,10 +399,9 @@ index 0000000..ab559d9
+
+install(FILES lshw.1 DESTINATION ${MANDIR}/man1 COMPONENT doc)
+install(TARGETS lshw DESTINATION sbin)
+
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 917bf6b..0000000
index 7ae8218..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,144 +0,0 @@
@ -399,7 +427,7 @@ index 917bf6b..0000000
-export SQLITE
-export ZLIB
-
-CXX?=c++
-CXX?=$(CROSS_COMPILE)c++
-INCLUDES=-I./core/
-DEFINES=-DPREFIX=\"$(PREFIX)\" -DSBINDIR=\"$(SBINDIR)\" -DMANDIR=\"$(MANDIR)\" -DDATADIR=\"$(DATADIR)\" -DVERSION=\"$(VERSION)\"
-CXXFLAGS=-g -Wall -g $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
@ -409,7 +437,7 @@ index 917bf6b..0000000
-ifeq ($(ZLIB), 1)
- CXXFLAGS+= -DZLIB $(shell pkg-config --cflags zlib)
-endif
-LDFLAGS=-L./core/ -g
-LDFLAGS+=-L./core/ -g
-ifneq ($(shell $(LD) --help 2| grep -- --as-needed), )
- LDFLAGS+= -Wl,--as-needed
-endif
@ -523,13 +551,13 @@ index 917bf6b..0000000
-# DO NOT DELETE
diff --git a/src/core/Makefile b/src/core/Makefile
deleted file mode 100644
index 884a963..0000000
index fbf6027..0000000
--- a/src/core/Makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-PACKAGENAME?=lshw
-
-CXX=c++
-CXX?=$(CROSS_COMPILE)c++
-INCLUDES=
-DEFINES=-DPREFIX=\"$(PREFIX)\" -DSBINDIR=\"$(SBINDIR)\" -DMANDIR=\"$(MANDIR)\" -DDATADIR=\"$(DATADIR)\"
-CXXFLAGS?=-g -Wall $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
@ -699,7 +727,7 @@ index 91e039a..5cecdda 100644
#else
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
new file mode 100644
index 0000000..48bd3f5
index 0000000..3489053
--- /dev/null
+++ b/src/gui/CMakeLists.txt
@@ -0,0 +1,67 @@
@ -756,7 +784,7 @@ index 0000000..48bd3f5
+
+install(FILES ${LOGOS} DESTINATION ${PROJECT_DATADIR}/artwork)
+install(FILES gtk-lshw.ui DESTINATION ${PROJECT_DATADIR}/ui)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.desktop
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.desktop
+ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications)
+install(FILES integration/gtk-lshw.appdata.xml DESTINATION
+ ${CMAKE_INSTALL_FULL_DATADIR}/appdata)
@ -772,14 +800,14 @@ index 0000000..48bd3f5
+endif()
diff --git a/src/gui/Makefile b/src/gui/Makefile
deleted file mode 100644
index 2526c18..0000000
index 74be693..0000000
--- a/src/gui/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-PACKAGENAME?=lshw
-
-CXX?=c++
-CC?=cc
-CXX?=$(CROSS_COMPILE)c++
-CC?=$(CROSS_COMPILE)cc
-STRIP?=strip
-OBJCOPY?=objcopy
-
@ -956,5 +984,5 @@ index 36fbdb7..0000000
-clean:
- rm -f $(CATALOGS) $(PACKAGENAME).pot
--
2.13.6
2.21.0

303
lshw-B.02.18-nvme.patch Normal file
View File

@ -0,0 +1,303 @@
From 16e1d7b9e9a1aa69a59867de0aad6411c953fbfc Mon Sep 17 00:00:00 2001
From: Harry Mallon <harry.mallon@codex.online>
Date: Mon, 25 Mar 2019 19:44:14 +0000
Subject: [PATCH] add support for /dev/nvmeX NVMe controllers
* Added nvme scanning for controllers /dev/nvme[0-9]+
* Added nvme scanning for namespaces /dev/nvme[0-9]+n[0-9]+
* Fill in namespaces as disks
* Teach partition scanning about nvme partitions /dev/nvme[0-9]+n[0-9]+p[0-9]+
---
src/core/main.cc | 4 ++
src/core/nvme.cc | 156 +++++++++++++++++++++++++++++++++++++++++
src/core/nvme.h | 7 ++
src/core/partitions.cc | 17 +++--
src/core/sysfs.cc | 15 ++++
src/core/sysfs.h | 3 +
7 files changed, 199 insertions(+), 8 deletions(-)
create mode 100644 src/core/nvme.cc
create mode 100644 src/core/nvme.h
diff --git a/src/core/main.cc b/src/core/main.cc
index c9a6e44..1dd109c 100644
--- a/src/core/main.cc
+++ b/src/core/main.cc
@@ -29,6 +29,7 @@
#include "pcmcia-legacy.h"
#include "ide.h"
#include "scsi.h"
+#include "nvme.h"
#include "spd.h"
#include "network.h"
#include "isapnp.h"
@@ -132,6 +133,9 @@ bool scan_system(hwNode & system)
status("SCSI");
if (enabled("scsi"))
scan_scsi(computer);
+ status("NVMe");
+ if (enabled("nvme"))
+ scan_nvme(computer);
status("S/390 devices");
if (enabled("s390"))
scan_s390_devices(computer);
diff --git a/src/core/nvme.cc b/src/core/nvme.cc
new file mode 100644
index 0000000..872d221
--- /dev/null
+++ b/src/core/nvme.cc
@@ -0,0 +1,156 @@
+#include "version.h"
+#include "disk.h"
+#include "osutils.h"
+#include "sysfs.h"
+#include "hw.h"
+#include <glob.h>
+#include <libgen.h>
+
+#include <string>
+
+__ID("@(#) $Id$");
+
+#define CLASS_NVME "nvme"
+#define NVMEX "/dev/nvme[0-9]*"
+#define NVMEXNX "/dev/nvme[0-9]*n[0-9]*"
+
+static void scan_controllers(hwNode & n)
+{
+ glob_t entries;
+ size_t j;
+
+ if(glob(NVMEX, 0, NULL, &entries) == 0)
+ {
+ for(j=0; j < entries.gl_pathc; j++)
+ {
+ if(matches(entries.gl_pathv[j], "^/dev/nvme[[:digit:]]+$"))
+ {
+ string businfo = "";
+ string logicalname = "";
+ hwNode *device = NULL;
+
+ logicalname = basename(entries.gl_pathv[j]);
+ if (logicalname.empty())
+ continue;
+
+ businfo = sysfs::entry::byClass(CLASS_NVME, logicalname).businfo();
+
+ if (!businfo.empty())
+ device = n.findChildByBusInfo(businfo);
+
+ if (!device)
+ device = n.findChildByLogicalName(logicalname);
+
+ if (!device)
+ {
+ hwNode *core = n.getChild("core");
+
+ if (core)
+ device = n.getChild("nvme");
+
+ if (core && !device)
+ device = core->addChild(hwNode("nvme", hw::storage));
+ }
+
+ if (!device)
+ device = n.addChild(hwNode("nvme", hw::storage));
+
+ if (device)
+ {
+ if(device->getBusInfo().empty())
+ device->setBusInfo(businfo);
+ device->setLogicalName(logicalname);
+ device->claim();
+ }
+ }
+ }
+
+ globfree(&entries);
+ }
+}
+
+static void scan_namespaces(hwNode & n)
+{
+ glob_t entries;
+ size_t j;
+
+ if(glob(NVMEXNX, 0, NULL, &entries) == 0)
+ {
+ for(j=0; j < entries.gl_pathc; j++)
+ {
+ if(matches(entries.gl_pathv[j], "^/dev/nvme[[:digit:]]+n[[:digit:]]+$"))
+ {
+ // We get this information from sysfs rather than doing an NVMe Identify command
+ // so they may not all be available from all kernels.
+ string path = entries.gl_pathv[j];
+ string logicalname = "";
+ string parentlogicalname = "";
+ string model;
+ string serial;
+ string firmware_rev;
+ hwNode *parent = NULL;
+ hwNode device = hwNode("disk", hw::disk);
+
+ logicalname = basename(entries.gl_pathv[j]);
+ if (logicalname.empty())
+ continue;
+
+ parentlogicalname = path.substr(0, path.find_last_of("n"));
+
+ sysfs::entry e = sysfs::entry::byClass("block", logicalname);
+
+ model = e.model();
+ serial = e.serial();
+ firmware_rev = e.firmware_rev();
+
+ device.setDescription("NVMe disk");
+ device.setLogicalName(logicalname);
+ device.claim();
+
+ if (!model.empty())
+ device.setProduct(model);
+ if (!serial.empty())
+ device.setSerial(serial);
+ if (!firmware_rev.empty())
+ device.setVersion(firmware_rev);
+
+ scan_disk(device);
+
+ if (!parentlogicalname.empty())
+ parent = n.findChildByLogicalName(parentlogicalname);
+
+ if (!parent)
+ {
+ hwNode *core = n.getChild("core");
+
+ if (core)
+ parent = n.getChild("nvme");
+
+ if (core && !parent)
+ parent = core->addChild(hwNode("nvme", hw::storage));
+ }
+
+ if (!parent)
+ parent = n.addChild(hwNode("nvme", hw::storage));
+
+ if (parent)
+ {
+ parent->addChild(device);
+ parent->claim();
+ }
+ }
+ }
+
+ globfree(&entries);
+ }
+
+}
+
+bool scan_nvme(hwNode & n)
+{
+ scan_controllers(n);
+
+ scan_namespaces(n);
+
+ return false;
+}
diff --git a/src/core/nvme.h b/src/core/nvme.h
new file mode 100644
index 0000000..0b89acd
--- /dev/null
+++ b/src/core/nvme.h
@@ -0,0 +1,7 @@
+#ifndef _NVME_H_
+#define _NVME_H_
+
+#include "hw.h"
+
+bool scan_nvme(hwNode & n);
+#endif
diff --git a/src/core/partitions.cc b/src/core/partitions.cc
index 5682ee5..88a7188 100644
--- a/src/core/partitions.cc
+++ b/src/core/partitions.cc
@@ -295,6 +295,7 @@ static bool guess_logicalname(source & s, const hwNode & disk, unsigned int n, h
struct stat buf;
char name[10];
int dev = 0;
+ string devname;
snprintf(name, sizeof(name), "%d", n);
if(disk.getBusInfo()!="")
@@ -304,9 +305,16 @@ static bool guess_logicalname(source & s, const hwNode & disk, unsigned int n, h
if(!S_ISBLK(buf.st_mode)) return false;
if(s.diskname!="")
- dev = open_dev(buf.st_rdev + n, S_IFBLK, s.diskname+string(name));
+ devname = s.diskname;
else
- dev = open_dev(buf.st_rdev + n, S_IFBLK, disk.getLogicalName()+string(name));
+ devname = disk.getLogicalName();
+
+ // NVMe partitions are like /dev/nvme0n1p2
+ if(matches(devname, "^/dev/nvme[[:digit:]]+n[[:digit:]]+$"))
+ devname += "p";
+ devname += string(name);
+
+ dev = open_dev(buf.st_rdev + n, S_IFBLK, devname);
if(dev>=0)
{
@@ -330,10 +338,7 @@ static bool guess_logicalname(source & s, const hwNode & disk, unsigned int n, h
if(memcmp(buffer1, buffer2, BLOCKSIZE)==0)
{
partition.claim();
- if(s.diskname!="")
- partition.setLogicalName(s.diskname+string(name));
- else
- partition.setLogicalName(disk.getLogicalName()+string(name));
+ partition.setLogicalName(devname);
return true;
}
}
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
index 06bce8e..d6b7511 100644
--- a/src/core/sysfs.cc
+++ b/src/core/sysfs.cc
@@ -368,6 +368,21 @@ string entry::vendor() const
return get_string(This->devpath+"/vendor");
}
+string entry::model() const
+{
+ return get_string(This->devpath+"/model");
+}
+
+string entry::serial() const
+{
+ return get_string(This->devpath+"/serial");
+}
+
+string entry::firmware_rev() const
+{
+ return get_string(This->devpath+"/firmware_rev");
+}
+
vector < entry > sysfs::entries_by_bus(const string & busname)
{
vector < entry > result;
diff --git a/src/core/sysfs.h b/src/core/sysfs.h
index 5f28d0c..d814c47 100644
--- a/src/core/sysfs.h
+++ b/src/core/sysfs.h
@@ -28,6 +28,9 @@ namespace sysfs
string modalias() const;
string device() const;
string vendor() const;
+ string model() const;
+ string serial() const;
+ string firmware_rev() const;
entry parent() const;
string name_in_class(const string &) const;
string string_attr(const string & name, const string & def = "") const;
--
2.21.0

View File

@ -1,15 +1,16 @@
Summary: Hardware lister
Name: lshw
Version: B.02.18
Release: 20%{?dist}
Release: 21%{?dist}
License: GPLv2
URL: http://ezix.org/project/wiki/HardwareLiSter
Source0: http://www.ezix.org/software/files/lshw-%{version}.tar.gz
Source1: https://salsa.debian.org/openstack-team/third-party/lshw/raw/debian/stein/debian/patches/lshw-gtk.1
Patch1: lshw-B.02.18-scandir.patch
Patch2: lshw-B.02.18-20cda77.patch
Patch2: lshw-B.02.18-6cc0581.patch
Patch3: lshw-B.02.18-revert-json.patch
Patch4: lshw-B.02.18-cmake.patch
Patch5: lshw-B.02.18-nvme.patch
BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: gcc
@ -44,6 +45,7 @@ format.
%patch02 -p1
%patch03 -R -p1
%patch04 -p1
%patch05 -p1
%build
mkdir build && pushd build
@ -93,6 +95,11 @@ src/lshw -json \
%{_datadir}/polkit-1/actions/org.ezix.lshw.gui.policy
%changelog
* Tue May 28 2019 Terje Rosten <terje.rosten@ntnu.no> - B.02.18-21
- Update to commit 6cc0581
- Rebase cmake patch on top 6cc0581
- Add NVME patch from PR#45
* Sat May 25 2019 Terje Rosten <terje.rosten@ntnu.no> - B.02.18-20
- Add lshw-gui man page (from Debian, thanks!)