pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/net/p5-FusionInventory-Agent



Module Name:    pkgsrc
Committed By:   bouyer
Date:           Thu May  6 20:25:15 UTC 2021

Modified Files:
        pkgsrc/net/p5-FusionInventory-Agent: Makefile distinfo
Added Files:
        pkgsrc/net/p5-FusionInventory-Agent/patches:
            patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm
            patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm
            patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm
            patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm
            patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm
            patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm
            patch-lib_FusionInventory_Agent_Tools_BSD.pm
            patch-lib_FusionInventory_Agent_Tools_Generic.pm

Log Message:
Improves NetBSD suport: use (and parse) /var/run/dmesg.boot if present,
use pcictl if present, use NetBSD sysctls when present.
Bump PKGREVISION


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 pkgsrc/net/p5-FusionInventory-Agent/Makefile
cvs rdiff -u -r1.6 -r1.7 pkgsrc/net/p5-FusionInventory-Agent/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm \
    pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/net/p5-FusionInventory-Agent/Makefile
diff -u pkgsrc/net/p5-FusionInventory-Agent/Makefile:1.19 pkgsrc/net/p5-FusionInventory-Agent/Makefile:1.20
--- pkgsrc/net/p5-FusionInventory-Agent/Makefile:1.19   Mon May  3 17:12:23 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/Makefile        Thu May  6 20:25:15 2021
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.19 2021/05/03 17:12:23 bouyer Exp $
+# $NetBSD: Makefile,v 1.20 2021/05/06 20:25:15 bouyer Exp $
 
 DISTNAME=      FusionInventory-Agent-2.6
 PKGNAME=       p5-${DISTNAME}
+PKGREVISION=   1
 CATEGORIES=    net perl5
 MASTER_SITES=  ${MASTER_SITE_PERL_CPAN:=../../authors/id/G/GB/GBOUGARD/}
 
@@ -32,6 +33,7 @@ DEPENDS+=     p5-HTTP-Server-Simple-[0-9]*:.
 DEPENDS+=      p5-IO-Capture-[0-9]*:../../devel/p5-IO-Capture
 DEPENDS+=      p5-IPC-Run-[0-9]*:../../devel/p5-IPC-Run
 DEPENDS+=      p5-YAML-[0-9]*:../../textproc/p5-YAML
+DEPENDS+=      p5-YAML-Tiny-[0-9]*:../../textproc/p5-YAML-Tiny
 DEPENDS+=      p5-SUPER-[0-9]*:../../devel/p5-SUPER
 DEPENDS+=      p5-Net-SNMP-[0-9]*:../../net/p5-Net-SNMP
 DEPENDS+=      p5-File-Copy-Recursive-[0-9]*:../../sysutils/p5-File-Copy-Recursive

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

Added files:

Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD.pm   Thu May  6 20:25:15 2021
@@ -0,0 +1,19 @@
+$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(
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Alpha.pm     Thu May  6 20:25:15 2021
@@ -0,0 +1,26 @@
+$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);
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_MIPS.pm      Thu May  6 20:25:15 2021
@@ -0,0 +1,29 @@
+$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);
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_SPARC.pm     Thu May  6 20:25:15 2021
@@ -0,0 +1,26 @@
+$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,//;
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_BSD_Storages.pm  Thu May  6 20:25:15 2021
@@ -0,0 +1,155 @@
+$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) {
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Task_Inventory_Generic_PCI.pm   Thu May  6 20:25:15 2021
@@ -0,0 +1,15 @@
+$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 {}
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_BSD.pm    Thu May  6 20:25:15 2021
@@ -0,0 +1,39 @@
+$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);
Index: pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm
diff -u /dev/null pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm:1.1
--- /dev/null   Thu May  6 20:25:15 2021
+++ pkgsrc/net/p5-FusionInventory-Agent/patches/patch-lib_FusionInventory_Agent_Tools_Generic.pm        Thu May  6 20:25:15 2021
@@ -0,0 +1,153 @@
+$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 {



Home | Main Index | Thread Index | Old Index