Thu May 6 20:25:15 2021 UTC ()
Improves NetBSD suport: use (and parse) /var/run/dmesg.boot if present,
use pcictl if present, use NetBSD sysctls when present.
Bump PKGREVISION


(bouyer)
diff -r1.19 -r1.20 pkgsrc/net/p5-FusionInventory-Agent/Makefile
diff -r1.6 -r1.7 pkgsrc/net/p5-FusionInventory-Agent/distinfo
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm
diff -r0 -r1.1 pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm

cvs diff -r1.19 -r1.20 pkgsrc/net/p5-FusionInventory-Agent/Makefile (expand / switch to unified diff)

--- pkgsrc/net/p5-FusionInventory-Agent/Makefile 2021/05/03 17:12:23 1.19
+++ pkgsrc/net/p5-FusionInventory-Agent/Makefile 2021/05/06 20:25:15 1.20
@@ -1,17 +1,18 @@ @@ -1,17 +1,18 @@
1# $NetBSD: Makefile,v 1.19 2021/05/03 17:12:23 bouyer Exp $ 1# $NetBSD: Makefile,v 1.20 2021/05/06 20:25:15 bouyer Exp $
2 2
3DISTNAME= FusionInventory-Agent-2.6 3DISTNAME= FusionInventory-Agent-2.6
4PKGNAME= p5-${DISTNAME} 4PKGNAME= p5-${DISTNAME}
 5PKGREVISION= 1
5CATEGORIES= net perl5 6CATEGORIES= net perl5
6MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../../authors/id/G/GB/GBOUGARD/} 7MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../../authors/id/G/GB/GBOUGARD/}
7 8
8MAINTAINER= bouyer@NetBSD.org 9MAINTAINER= bouyer@NetBSD.org
9HOMEPAGE= https://metacpan.org/release/FusionInventory-Agent 10HOMEPAGE= https://metacpan.org/release/FusionInventory-Agent
10COMMENT= Fusion Inventory agent 11COMMENT= Fusion Inventory agent
11LICENSE= gnu-gpl-v2 12LICENSE= gnu-gpl-v2
12 13
13PKG_SYSCONFSUBDIR?= fusioninventory 14PKG_SYSCONFSUBDIR?= fusioninventory
14EGDIR= ${PREFIX}/share/examples/fusioninventory 15EGDIR= ${PREFIX}/share/examples/fusioninventory
15CONF_FILES+= ${EGDIR}/agent.cfg ${PKG_SYSCONFDIR}/agent.cfg 16CONF_FILES+= ${EGDIR}/agent.cfg ${PKG_SYSCONFDIR}/agent.cfg
16CONF_FILES+= ${EGDIR}/inventory-server-plugin.cfg ${PKG_SYSCONFDIR}/inventory-server-plugin.cfg 17CONF_FILES+= ${EGDIR}/inventory-server-plugin.cfg ${PKG_SYSCONFDIR}/inventory-server-plugin.cfg
17CONF_FILES+= ${EGDIR}/server-test-plugin.cfg ${PKG_SYSCONFDIR}/server-test-plugin.cfg 18CONF_FILES+= ${EGDIR}/server-test-plugin.cfg ${PKG_SYSCONFDIR}/server-test-plugin.cfg
@@ -22,26 +23,27 @@ BUILD_DEFS+= VARBASE @@ -22,26 +23,27 @@ BUILD_DEFS+= VARBASE
22OWN_DIRS+= ${VARBASE}/fusioninventory 23OWN_DIRS+= ${VARBASE}/fusioninventory
23 24
24DEPENDS+= p5-HTTP-Server-Simple-Authen-[0-9]*:../../www/p5-HTTP-Server-Simple-Authen 25DEPENDS+= p5-HTTP-Server-Simple-Authen-[0-9]*:../../www/p5-HTTP-Server-Simple-Authen
25DEPENDS+= p5-File-Which-[0-9]*:../../devel/p5-File-Which 26DEPENDS+= p5-File-Which-[0-9]*:../../devel/p5-File-Which
26DEPENDS+= p5-Net-IP-[0-9]*:../../net/p5-Net-IP 27DEPENDS+= p5-Net-IP-[0-9]*:../../net/p5-Net-IP
27DEPENDS+= p5-Text-Template-[0-9]*:../../textproc/p5-Text-Template 28DEPENDS+= p5-Text-Template-[0-9]*:../../textproc/p5-Text-Template
28DEPENDS+= p5-UNIVERSAL-require-[0-9]*:../../devel/p5-UNIVERSAL-require 29DEPENDS+= p5-UNIVERSAL-require-[0-9]*:../../devel/p5-UNIVERSAL-require
29DEPENDS+= p5-XML-TreePP-[0-9]*:../../textproc/p5-XML-TreePP 30DEPENDS+= p5-XML-TreePP-[0-9]*:../../textproc/p5-XML-TreePP
30DEPENDS+= p5-HTTP-Proxy-[0-9]*:../../www/p5-HTTP-Proxy 31DEPENDS+= p5-HTTP-Proxy-[0-9]*:../../www/p5-HTTP-Proxy
31DEPENDS+= p5-HTTP-Server-Simple-[0-9]*:../../www/p5-HTTP-Server-Simple 32DEPENDS+= p5-HTTP-Server-Simple-[0-9]*:../../www/p5-HTTP-Server-Simple
32DEPENDS+= p5-IO-Capture-[0-9]*:../../devel/p5-IO-Capture 33DEPENDS+= p5-IO-Capture-[0-9]*:../../devel/p5-IO-Capture
33DEPENDS+= p5-IPC-Run-[0-9]*:../../devel/p5-IPC-Run 34DEPENDS+= p5-IPC-Run-[0-9]*:../../devel/p5-IPC-Run
34DEPENDS+= p5-YAML-[0-9]*:../../textproc/p5-YAML 35DEPENDS+= p5-YAML-[0-9]*:../../textproc/p5-YAML
 36DEPENDS+= p5-YAML-Tiny-[0-9]*:../../textproc/p5-YAML-Tiny
35DEPENDS+= p5-SUPER-[0-9]*:../../devel/p5-SUPER 37DEPENDS+= p5-SUPER-[0-9]*:../../devel/p5-SUPER
36DEPENDS+= p5-Net-SNMP-[0-9]*:../../net/p5-Net-SNMP 38DEPENDS+= p5-Net-SNMP-[0-9]*:../../net/p5-Net-SNMP
37DEPENDS+= p5-File-Copy-Recursive-[0-9]*:../../sysutils/p5-File-Copy-Recursive 39DEPENDS+= p5-File-Copy-Recursive-[0-9]*:../../sysutils/p5-File-Copy-Recursive
38# TEST_DEPENDS 40# TEST_DEPENDS
39BUILD_DEPENDS+= p5-Test-Deep-[0-9]*:../../devel/p5-Test-Deep 41BUILD_DEPENDS+= p5-Test-Deep-[0-9]*:../../devel/p5-Test-Deep
40BUILD_DEPENDS+= p5-Test-Exception-[0-9]*:../../devel/p5-Test-Exception 42BUILD_DEPENDS+= p5-Test-Exception-[0-9]*:../../devel/p5-Test-Exception
41BUILD_DEPENDS+= p5-Test-MockModule-[0-9]*:../../devel/p5-Test-MockModule 43BUILD_DEPENDS+= p5-Test-MockModule-[0-9]*:../../devel/p5-Test-MockModule
42BUILD_DEPENDS+= p5-Test-MockObject-[0-9]*:../../devel/p5-Test-MockObject 44BUILD_DEPENDS+= p5-Test-MockObject-[0-9]*:../../devel/p5-Test-MockObject
43BUILD_DEPENDS+= p5-Test-NoWarnings-[0-9]*:../../devel/p5-Test-NoWarnings 45BUILD_DEPENDS+= p5-Test-NoWarnings-[0-9]*:../../devel/p5-Test-NoWarnings
44 46
45PERL5_PACKLIST= auto/FusionInventory/Agent/.packlist 47PERL5_PACKLIST= auto/FusionInventory/Agent/.packlist
46 48
47PERL5_MODULE_TYPE= Module::Install::Bundled 49PERL5_MODULE_TYPE= Module::Install::Bundled

cvs diff -r1.6 -r1.7 pkgsrc/net/p5-FusionInventory-Agent/distinfo (expand / switch to unified diff)

--- pkgsrc/net/p5-FusionInventory-Agent/distinfo 2021/05/03 17:12:23 1.6
+++ pkgsrc/net/p5-FusionInventory-Agent/distinfo 2021/05/06 20:25:15 1.7
@@ -1,7 +1,15 @@ @@ -1,7 +1,15 @@
1$NetBSD: distinfo,v 1.6 2021/05/03 17:12:23 bouyer Exp $ 1$NetBSD: distinfo,v 1.7 2021/05/06 20:25:15 bouyer Exp $
2 2
3SHA1 (FusionInventory-Agent-2.6.tar.gz) = 288acf5707e550fa10275f8e6fab70b50aa790aa 3SHA1 (FusionInventory-Agent-2.6.tar.gz) = 288acf5707e550fa10275f8e6fab70b50aa790aa
4RMD160 (FusionInventory-Agent-2.6.tar.gz) = 1d6504f2119bb531c527180c9275bb692b8a1a2a 4RMD160 (FusionInventory-Agent-2.6.tar.gz) = 1d6504f2119bb531c527180c9275bb692b8a1a2a
5SHA512 (FusionInventory-Agent-2.6.tar.gz) = c4d12b17e87f9b7e59c1a7284fb88bb0ab51c22037624f666469c75b993ec5939f3f88752afdab82b5d35972c76fbc36a49c6fd1f5246481efb8adf893b4fa3f 5SHA512 (FusionInventory-Agent-2.6.tar.gz) = c4d12b17e87f9b7e59c1a7284fb88bb0ab51c22037624f666469c75b993ec5939f3f88752afdab82b5d35972c76fbc36a49c6fd1f5246481efb8adf893b4fa3f
6Size (FusionInventory-Agent-2.6.tar.gz) = 2819730 bytes 6Size (FusionInventory-Agent-2.6.tar.gz) = 2819730 bytes
7SHA1 (patch-Makefile.PL) = d01414b74fa3bbd9bedb658b39d3a07074274142 7SHA1 (patch-Makefile.PL) = d01414b74fa3bbd9bedb658b39d3a07074274142
 8SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm) = 7548564a13a16c0f9da9f8d0df5a6fe5e63079f1
 9SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm) = ba0bd79e697ac5c9a39ffe70ce26575cc88846a2
 10SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm) = c5449c5181f92984cfe129dbca5e11d69094c424
 11SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm) = 48fcf497b55efcd17dd34d8807fa6dc091303169
 12SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm) = a2ffacd0b9ee84accc001b2013aa52a0c0dc419f
 13SHA1 (patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm) = 94f5afb7b4277a1729c322c7111c94481e1cbe34
 14SHA1 (patch-lib_FusionInventory_Agent_Tools_BSD.pm) = d312bc244889beb7c747a4c8b021590102a8294c
 15SHA1 (patch-lib_FusionInventory_Agent_Tools_Generic.pm) = 1e8cc8d8ff4c03ba563c3c63ed348e22bd665e9d

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Adjust for NetBSD's sysctl kern.boottime output

--- lib/FusionInventory/Agent/Task/Inventory/BSD.pm.orig	2021-05-05 00:17:48.974000555 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD.pm	2021-05-05 00:20:26.256041770 +0200
@@ -28,6 +28,12 @@
         command => "sysctl -n kern.boottime",
         pattern => qr/sec = (\d+)/
     );
+    if (! defined($boottime)) {
+        $boottime = getFirstMatch(
+            command => "sysctl -n kern.boottime",
+            pattern => qr/(\d+)/
+        );
+    }
 
     my $name = canRun('lsb_release') ?
         getFirstMatch(

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Use /var/run/dmesg.boot if present

--- lib/FusionInventory/Agent/Task/Inventory/BSD/Alpha.pm.orig	2021-05-04 23:00:51.263555904 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/Alpha.pm	2021-05-04 22:57:35.095417352 +0200
@@ -42,9 +42,16 @@
     # CPU: EV45 (21064A) major=6 minor=2
 
     my $cpu;
-    foreach my $line (getAllLines(command => 'dmesg')) {
-        if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
-        if ($line =~ /^cpu[^:]*:\s*(.*)$/i)            { $cpu->{NAME} = $1;  }
+    if ( -r "/var/run/dmesg.boot") {
+	foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+            if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
+            if ($line =~ /^cpu[^:]*:\s*(.*)$/i)            { $cpu->{NAME} = $1;  }
+	}
+    } else {
+        foreach my $line (getAllLines(command => 'dmesg')) {
+            if ($line =~ /$bios->{SMODEL},\s*(\S+)\s*MHz/) { $cpu->{SPEED} = $1; }
+            if ($line =~ /^cpu[^:]*:\s*(.*)$/i)            { $cpu->{NAME} = $1;  }
+        }
     }
 
     $inventory->setBios($bios);

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Use /var/run/dmesg.boot if present

--- lib/FusionInventory/Agent/Task/Inventory/BSD/MIPS.pm.orig	2021-05-04 23:07:03.767869134 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/MIPS.pm	2021-05-04 23:08:31.241450459 +0200
@@ -48,10 +48,18 @@
     # cpu0: cache L1-I 32KB D 32KB 2 way, L2 512KB direct
 
     my $cpu;
-    foreach my $line (getAllLines(command => 'dmesg')) {
-        if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
-        if ($line =~ /cpu0 at mainbus0:\s*(.*)$/)         { $cpu->{NAME} = $1; }
-        if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/)             { $cpu->{SPEED} = $1;  }
+    if ( -r "/var/run/dmesg.boot") {
+	foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+            if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
+            if ($line =~ /cpu0 at mainbus0:\s*(.*)$/)         { $cpu->{NAME} = $1; }
+            if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/)             { $cpu->{SPEED} = $1;  }
+        }
+    } else {
+	foreach my $line (getAllLines(command => 'dmesg')) {
+            if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
+            if ($line =~ /cpu0 at mainbus0:\s*(.*)$/)         { $cpu->{NAME} = $1; }
+            if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/)             { $cpu->{SPEED} = $1;  }
+        }
     }
 
     $inventory->setBios($bios);

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Use /var/run/dmesg.boot if present

--- lib/FusionInventory/Agent/Task/Inventory/BSD/SPARC.pm.orig	2021-05-04 23:09:07.913462371 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/SPARC.pm	2021-05-04 23:09:59.586815307 +0200
@@ -57,9 +57,16 @@
     # cpu0: Sun Microsystems UltraSparc-I Processor (167.00 MHz CPU)
 
     my $cpu;
-    foreach my $line (getAllLines(command => 'dmesg')) {
-        if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
-        if ($line =~ /^cpu[^:]*:\s*(.*)$/i)        { $cpu->{NAME}    = $1; }
+    if ( -r "/var/run/dmesg.boot") {
+	foreach my $line (getAllLines(file => '/var/run/dmesg.boot')) {
+            if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
+            if ($line =~ /^cpu[^:]*:\s*(.*)$/i)        { $cpu->{NAME}    = $1; }
+        }
+    } else {
+        foreach my $line (getAllLines(command => 'dmesg')) {
+            if ($line=~ /^mainbus0 \(root\):\s*(.*)$/) { $bios->{SMODEL} = $1; }
+            if ($line =~ /^cpu[^:]*:\s*(.*)$/i)        { $cpu->{NAME}    = $1; }
+        }
     }
 
     $bios->{SMODEL} =~ s/SUNW,//;

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Use /var/run/dmesg.boot if present
Use sysctl hw.disknames if present
match NetBSD disk names

--- lib/FusionInventory/Agent/Task/Inventory/BSD/Storages.pm.orig	2020-08-04 09:36:42.000000000 +0200
+++ lib/FusionInventory/Agent/Task/Inventory/BSD/Storages.pm	2021-05-06 22:14:19.168779300 +0200
@@ -37,38 +37,68 @@
         command => $command,
         %params
     );
-    $lines =~ s/^kern.geom.confxml://;
-    my $tpp = XML::TreePP->new();
-    my $tree = $tpp->parse($lines);
-
-    my @storages = ();
-    for my $class (@{$tree->{mesh}->{class}}) {
-        my $name = $class->{name} || $class->{'#name'} || '';
-        next unless ($name && $name eq 'DISK');
-        for my $geom (@{$class->{geom}}) {
-            my $device = {};
-            $device->{NAME} = $geom->{name} if $geom->{name};
-            $device->{DESCRIPTION} = $geom->{provider}->{config}->{descr}
-                if ($geom->{provider}
-                    && $geom->{provider}->{config}
-                    && $geom->{provider}->{config}->{descr});
-            $device->{DISKSIZE} = $geom->{provider}->{mediasize}
-                if ($geom->{provider}
-                    && defined $geom->{provider}->{mediasize});
-            $device->{TYPE} = _retrieveDeviceTypeFromName($device->{NAME});
-            push @storages, $device;
+    if ($lines =~ /^kern.geom.confxml:/) {
+        $lines =~ s/^kern.geom.confxml://;
+        my $tpp = XML::TreePP->new();
+        my $tree = $tpp->parse($lines);
+    
+        my @storages = ();
+        for my $class (@{$tree->{mesh}->{class}}) {
+            my $name = $class->{name} || $class->{'#name'} || '';
+            next unless ($name && $name eq 'DISK');
+            for my $geom (@{$class->{geom}}) {
+                my $device = {};
+                $device->{NAME} = $geom->{name} if $geom->{name};
+                $device->{DESCRIPTION} = $geom->{provider}->{config}->{descr}
+                    if ($geom->{provider}
+                        && $geom->{provider}->{config}
+                        && $geom->{provider}->{config}->{descr});
+                $device->{DISKSIZE} = $geom->{provider}->{mediasize}
+                    if ($geom->{provider}
+                        && defined $geom->{provider}->{mediasize});
+                $device->{TYPE} = _retrieveDeviceTypeFromName($device->{NAME});
+                push @storages, $device;
+            }
         }
+    
+        # Unittest support
+        $params{file} = $params{dmesgFile} if ($params{dmesgFile});
+    
+        _extractDataFromDmesg(
+            storages => \@storages,
+            %params
+        );
+    
+        return @storages;
     }
-
-    # Unittest support
-    $params{file} = $params{dmesgFile} if ($params{dmesgFile});
-
-    _extractDataFromDmesg(
-        storages => \@storages,
+    $command = 'sysctl hw.disknames';
+    $lines = getAllLines(
+        command => $command,
         %params
     );
-
-    return @storages;
+    if ($lines =~ /^hw.disknames = /) {
+        $lines =~ s/^hw.disknames = //;
+	chop $lines;
+        my @storages = ();
+	foreach my $drive (split / /, $lines) {
+	    
+	    next if $drive =~ /^vnd/;
+	    next if $drive =~ /^dk/;
+	    next if $drive =~ /^raid/;
+	    next if $drive =~ /^cgd/;
+	    next if $drive =~ /^ccd/;
+	    next if $drive =~ /^dm/;
+            my $device->{NAME} = $drive;
+            push @storages, $device;
+        }
+    
+        _extractDataFromDmesg(
+            storages => \@storages,
+            %params
+        );
+    
+        return @storages;
+    }
 }
 
 sub _retrieveDeviceTypeFromName {
@@ -76,6 +106,10 @@
     my $type = not (defined $name) ? 'unknown' :
             $name =~ /^da/ ? 'disk' :
             $name =~ /^ada/ ? 'disk' :
+            $name =~ /^wd/ ? 'disk' :
+            $name =~ /^sd/ ? 'disk' :
+            $name =~ /^ld/ ? 'disk' :
+            $name =~ /^xbd/ ? 'disk' :
             $name =~ /^cd/ ? 'cdrom' :
                 'unknown';
     return $type;
@@ -85,11 +119,19 @@
     my (%params) = @_;
 
     my $storages = $params{storages};
+    my $dmesgLines;
 
-    my $dmesgLines = getAllLines(
-        command => 'dmesg',
-        %params
-    );
+    if ( -r "/var/run/dmesg.boot") {
+        $dmesgLines = getAllLines(
+            file => '/var/run/dmesg.boot',
+            %params
+        );
+    } else {
+        $dmesgLines = getAllLines(
+            command => 'dmesg',
+            %params
+        );
+    }
     for my $storage (@$storages) {
         next unless $storage->{NAME};
         $storage->{MODEL} = getFirstMatch(
@@ -105,6 +147,14 @@
             string => $dmesgLines,
             pattern => qr/^\Q$storage->{NAME}\E: Serial Number (.*)$/
         ) || '';
+	
+	if (!defined($storage->{DISKSIZE})) {
+            my $size = getFirstMatch(
+                string => $dmesgLines,
+                pattern => qr/^\Q$storage->{NAME}\E: .* (\d+) sectors/
+            );
+	    $storage->{DISKSIZE} = $size / 2048; # in MB
+        }
 
         if ($storage->{MODEL}) {
             if ($storage->{MODEL} =~ s/^(SGI|SONY|WDC|ASUS|LG|TEAC|SAMSUNG|PHILIPS|PIONEER|MAXTOR|PLEXTOR|SEAGATE|IBM|SUN|SGI|DEC|FUJITSU|TOSHIBA|YAMAHA|HITACHI|VERITAS)\s*//i) {

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm
$NetBSD: patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

accept pcictl as alternative to lspci

--- ./lib/FusionInventory/Agent/Task/Inventory/Generic/PCI.pm.orig	2021-05-06 18:34:38.856037719 +0200
+++ ./lib/FusionInventory/Agent/Task/Inventory/Generic/PCI.pm	2021-05-06 18:35:03.442742192 +0200
@@ -8,7 +8,7 @@
 use FusionInventory::Agent::Tools;
 
 sub isEnabled {
-    return canRun('lspci');
+    return canRun('lspci') || canRun('pcictl');
 }
 
 sub doInventory {}

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm
$NetBSD: patch-lib_FusionInventory_Agent_Tools_BSD.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

Support NetBSD's ifconfig output

--- lib/FusionInventory/Agent/Tools/BSD.pm.orig	2020-08-04 09:36:42.000000000 +0200
+++ lib/FusionInventory/Agent/Tools/BSD.pm	2021-05-05 00:51:31.393670504 +0200
@@ -31,7 +31,7 @@
     );
 
     while (my $line = <$handle>) {
-        if ($line =~ /^(\S+): flags=\d+<([^>]+)> (?:metric \d+ )?mtu (\d+)/) {
+        if ($line =~ /^(\S+): flags=(?:0x)?[A-Fa-f\d]+<([^>]+)> (?:metric \d+ )?mtu (\d+)/) {
 
             if (@addresses) {
                 push @interfaces, @addresses;
@@ -75,6 +75,23 @@
                 MACADDR     => $interface->{MACADDR},
                 MTU         => $interface->{MTU}
             };
+        } elsif ($line =~ /inet ($ip_address_pattern)\/(\d+) (?:--> $ip_address_pattern )?/) {
+            my $address = $1;
+            my $netbit=$2;
+            my $mask  = (2 ** $2 - 1) << (32 - $2);
+            my $netmask = unpack("H8", pack( "N", $mask));
+            $mask    = hex2canonical($netmask);
+            my $subnet  = getSubnetAddress($address, $mask);
+
+            push @addresses, {
+                IPADDRESS   => $address,
+                IPMASK      => $mask,
+                IPSUBNET    => $subnet,
+                STATUS      => $interface->{STATUS},
+                DESCRIPTION => $interface->{DESCRIPTION},
+                MACADDR     => $interface->{MACADDR},
+                MTU         => $interface->{MTU}
+            };
         } elsif ($line =~ /inet6 ([\w:]+)\S* prefixlen (\d+)/) {
             my $address = $1;
             my $mask    = getNetworkMaskIPv6($2);

File Added: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm
$NetBSD: patch-lib_FusionInventory_Agent_Tools_Generic.pm,v 1.1 2021/05/06 20:25:15 bouyer Exp $

accept pcictl as alternative to lspci

--- lib/FusionInventory/Agent/Tools/Generic.pm.orig	2020-11-09 14:49:31.000000000 +0100
+++ lib/FusionInventory/Agent/Tools/Generic.pm	2021-05-06 21:25:27.448948334 +0200
@@ -217,52 +217,103 @@
 }
 
 sub getPCIDevices {
-    my (%params) = (
-        command => 'lspci -v -nn',
-        @_
-    );
-    my $handle = getFileHandle(%params);
-
-    my (@controllers, $controller);
-
-    while (my $line = <$handle>) {
-        chomp $line;
-
-        if ($line =~ /^
-            (\S+) \s                     # slot
-            ([^[]+) \s                   # name
-            \[([a-f\d]+)\]: \s           # class
-            (\S.+) \s                   # manufacturer
-            \[([a-f\d]+:[a-f\d]+)\]      # id
-            (?:\s \(rev \s (\d+)\))?     # optional version
-            /x) {
-
-            $controller = {
-                PCISLOT      => $1,
-                NAME         => $2,
-                PCICLASS     => $3,
-                MANUFACTURER => $4,
-                PCIID        => $5,
-                REV          => $6
-            };
-            next;
-        }
-
-        next unless defined $controller;
-
-        if ($line =~ /^$/) {
-            push(@controllers, $controller);
-            undef $controller;
-        } elsif ($line =~ /^\tKernel driver in use: (\w+)/) {
-            $controller->{DRIVER} = $1;
-        } elsif ($line =~ /^\tSubsystem: ?.* \[?([a-f\d]{4}:[a-f\d]{4})\]?/) {
-            $controller->{PCISUBSYSTEMID} = $1;
+    if (canRun('lspci')) {
+        my (%params) = (
+            command => 'lspci -v -nn',
+            @_
+        );
+        my $handle = getFileHandle(%params);
+    
+        my (@controllers, $controller);
+    
+        while (my $line = <$handle>) {
+            chomp $line;
+    
+            if ($line =~ /^
+                (\S+) \s                     # slot
+                ([^[]+) \s                   # name
+                \[([a-f\d]+)\]: \s           # class
+                (\S.+) \s                   # manufacturer
+                \[([a-f\d]+:[a-f\d]+)\]      # id
+                (?:\s \(rev \s (\d+)\))?     # optional version
+                /x) {
+    
+                $controller = {
+                    PCISLOT      => $1,
+                    NAME         => $2,
+                    PCICLASS     => $3,
+                    MANUFACTURER => $4,
+                    PCIID        => $5,
+                    REV          => $6
+                };
+                next;
+            }
+    
+            next unless defined $controller;
+    
+            if ($line =~ /^$/) {
+                push(@controllers, $controller);
+                undef $controller;
+            } elsif ($line =~ /^\tKernel driver in use: (\w+)/) {
+                $controller->{DRIVER} = $1;
+            } elsif ($line =~ /^\tSubsystem: ?.* \[?([a-f\d]{4}:[a-f\d]{4})\]?/) {
+                $controller->{PCISUBSYSTEMID} = $1;
+            }
         }
+    
+        close $handle;
+    
+        return @controllers;
     }
 
-    close $handle;
-
-    return @controllers;
+    if (canRun('pcictl')) {
+        my (%params) = (
+            command => 'pcictl pci0 list -N',
+            @_
+        );
+        my $handle = getFileHandle(%params);
+    
+        my (@controllers, $controller);
+    
+        while (my $line = <$handle>) {
+            chomp $line;
+
+	    if ($line =~ /^(\S+): ([^\(]+) \((.+), revision ([^\)]+)\)(?: \[(\S+)\])?/) {
+                $controller = {
+                    PCISLOT      => $1,
+                    NAME         => $3,
+                    MANUFACTURER => $2,
+                    REV          => $4,
+                    DRIVER       => $5
+                };
+                push(@controllers, $controller);
+                undef $controller;
+	    }
+	}
+        close $handle;
+        (%params) = (
+            command => 'pcictl pci0 list -n',
+            @_
+        );
+        $handle = getFileHandle(%params);
+    
+        while (my $line = <$handle>) {
+            chomp $line;
+	    if ($line =~ /^(\S+): 0x([0-9a-z]{4})([0-9a-z]{4}) \(0x([0-9a-z]{4})([0-9a-z]{4})\)/) {
+		my $slot = $1;
+		my $pciid = $3 . ":" . $2;
+		my $pciclass = $4;
+		foreach $controller (@controllers) {
+		    next if ($controller->{PCISLOT} ne $slot);
+		    $controller->{PCIID} = $pciid;
+		    $controller->{PCICLASS} = $pciclass;
+		}
+	    }
+	}
+        close $handle;
+    
+        return @controllers;
+    }
 }
 
 sub getPCIDeviceVendor {