pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/sysutils/decode-dimms Re-add the decode-dimms package ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a0b4dd725249
branches:  trunk
changeset: 310823:a0b4dd725249
user:      pgoyette <pgoyette%pkgsrc.org@localhost>
date:      Wed Jul 25 02:05:26 2018 +0000

description:
Re-add the decode-dimms package after resolving the various issues
related to packaging.  Many thanks to maya@ for her extensive help
in getting this to work!

diffstat:

 sysutils/decode-dimms/DESCR                        |    7 +
 sysutils/decode-dimms/Makefile                     |   36 +++++
 sysutils/decode-dimms/PLIST                        |    3 +
 sysutils/decode-dimms/distinfo                     |    8 +
 sysutils/decode-dimms/patches/patch-decode-dimms   |  141 +++++++++++++++++++++
 sysutils/decode-dimms/patches/patch-decode-dimms.1 |   39 +++++
 6 files changed, 234 insertions(+), 0 deletions(-)

diffs (258 lines):

diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/DESCR       Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,7 @@
+decode-dimms is a small utility that displays the contents of DIMM memory
+SPD ROMs in human-readable form.  (It is part of a larger collection of
+https://git.kernel.org/pub/scm/utils/i2c-tools - most of which is very
+Linux-specific.)
+
+This version of decode-dimms can even directly read the SPD ROM data from
+the sysctl variables created by NetBSD's spdmem(4) device driver.
diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/Makefile    Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile,v 1.3 2018/07/25 02:05:26 pgoyette Exp $
+
+# no Release yet
+GIT_COMMIT=    84da8192c7c409f37c1906b60ef166c58aafc847
+DISTNAME=      i2c-tools-${GIT_COMMIT}
+PKGNAME=       decode-dimms-0.0.20181205
+CATEGORIES=    sysutils
+
+MASTER_SITES=  https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/snapshot/
+
+EXTRACT_SUFX=  .tar.gz
+
+MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=      https://git.kernel.org/pub/scm/utils/i2c-tools/
+COMMENT=       Decode memory DIMM SPD ROM info
+LICENSE=       gnu-gpl-v2
+
+REPLACE_PERL+= eeprom/decode-dimms
+
+NO_BUILD=      yes
+
+USE_LANGUAGES= # empty
+
+ONLY_FOR_PLATFORM= NetBSD-*-*
+
+INSTALLATION_DIRS=     bin ${PKGMANDIR}/man1
+do-install:
+       ${INSTALL_SCRIPT} ${WRKSRC}/eeprom/decode-dimms \
+               ${DESTDIR}${PREFIX}/bin/decode-dimms
+       ${INSTALL_MAN} ${WRKSRC}/eeprom/decode-dimms.1 \
+               ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/decode-dimms.1
+
+.include "../../lang/perl5/module.mk"
+.include "../../mk/bsd.pkg.mk"
+
+
diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/PLIST       Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.3 2018/07/25 02:05:26 pgoyette Exp $
+bin/decode-dimms
+man/man1/decode-dimms.1
diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/distinfo
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/distinfo    Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,8 @@
+$NetBSD: distinfo,v 1.5 2018/07/25 02:05:26 pgoyette Exp $
+
+SHA1 (i2c-tools-84da8192c7c409f37c1906b60ef166c58aafc847.tar.gz) = 0765225f1f7ee63d0ebb3a3881ad819fa9d48d9e
+RMD160 (i2c-tools-84da8192c7c409f37c1906b60ef166c58aafc847.tar.gz) = 0e1f9c86e5005bf8534789e4dea532bc8dda522a
+SHA512 (i2c-tools-84da8192c7c409f37c1906b60ef166c58aafc847.tar.gz) = 4cd57f6cc4424888fe4e7bede28b7a5e15e7f658b57fa4df528cc3636cd5124036a69492de9636d81478e58b660275df2dee239999bd5ea0bec13313b240b352
+Size (i2c-tools-84da8192c7c409f37c1906b60ef166c58aafc847.tar.gz) = 95860 bytes
+SHA1 (patch-decode-dimms) = a64426b096120f225a55793afde9ef720fd8b15b
+SHA1 (patch-decode-dimms.1) = c1c1444a73fa848eda0223e2c176819d4ded6641
diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/patches/patch-decode-dimms
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/patches/patch-decode-dimms  Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,141 @@
+$NetBSD: patch-decode-dimms,v 1.4 2018/07/25 02:05:26 pgoyette Exp $
+
+Add NetBSD-specific ability to use spdmem(4)'s sysctl values as
+input.
+
+--- eeprom/decode-dimms.orig   2018-05-31 13:53:29.771907986 +0800
++++ eeprom/decode-dimms        2018-03-03 13:20:15.572272632 +0800
+@@ -1,4 +1,4 @@
+-#!/usr/bin/perl -w
++#!/usr/pkg/bin/perl -w
+ #
+ # EEPROM data decoder for SDRAM DIMM modules
+ #
+@@ -42,15 +42,14 @@
+ use Fcntl qw(:DEFAULT :seek);
+ use File::Basename;
+ use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge
+-          $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width
+-          @vendors %decode_callback $revision @dimm $current %hexdump_cache);
++          $opt_igncheck $use_sysfs $use_hexdump $use_sysctl $sbs_col_width
++          @vendors %decode_callback $revision @dimm $current %hexdump_cache
++          %sysctl_cache);
+ 
+ use constant LITTLEENDIAN     => "little-endian";
+ use constant BIGENDIAN                => "big-endian";
+ 
+-$revision = '$Revision: 1.4 $ ($Date: 2018/07/25 02:05:26 $)';
+-$revision =~ s/\$\w+: (.*?) \$/$1/g;
+-$revision =~ s/ \([^()]*\)//;
++$revision = '20171205';
+ 
+ @vendors = (
+ ["AMD", "AMI", "Fairchild", "Fujitsu",
+@@ -341,6 +340,7 @@
+ );
+ 
+ $use_sysfs = -d '/sys/bus';
++$use_sysctl = 0;
+ 
+ # We consider that no data was written to this area of the SPD EEPROM if
+ # all bytes read 0x00 or all bytes read 0xff
+@@ -2252,6 +2252,26 @@
+       }
+ }
+ 
++# read data from a NetBSD (or equivalent) sysctl variable
++
++sub read_sysctl($)
++{
++
++      # Look in the cache first
++      return @{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]};
++
++      my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]);
++      open(PIPE, "-|", "sysctl -r $sysctl_var")
++              or die "Cannot read sysctl variable $sysctl_var";
++      sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX
++      close PIPE or die "sysctl returned $?";
++      my @bytes = unpack("C*", $eeprom);
++
++      # Cache the data for later use
++      $hexdump_cache{$_[0]} = \@bytes;
++      return @bytes;
++}
++
+ # Read bytes from SPD-EEPROM
+ # Note: offset must be a multiple of 16!
+ sub readspd($$$)
+@@ -2261,6 +2281,9 @@
+       if ($use_hexdump) {
+               @bytes = read_hexdump($dimm_i);
+               return @bytes[$offset..($offset + $size - 1)];
++      } elsif ($use_sysctl) {
++              @bytes = read_sysctl($dimm_i);
++              return @bytes[$offset..($offset + $size - 1)];
+       } elsif ($use_sysfs) {
+               # Kernel 2.6 with sysfs
+               sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY)
+@@ -2337,7 +2360,7 @@
+ # Parse command-line
+ foreach (@ARGV) {
+       if ($_ eq '-h' || $_ eq '--help') {
+-              print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n",
++              print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n",
+                       "       $0 -h\n\n",
+                       "  -f, --format            Print nice html output\n",
+                       "  -b, --bodyonly          Don't print html header\n",
+@@ -2351,6 +2374,8 @@
+                       "  -x,                     Read data from hexdump files\n",
+                       "  -X,                     Same as -x except treat multibyte hex\n",
+                       "                          data as little endian\n",
++                      "  -s,                     Use NetBSD-compatible sysctl(8) to obtain\n",
++                      "                          EEPROM data\n",
+                       "  -h, --help              Display this usage summary\n";
+               print <<"EOF";
+ 
+@@ -2395,13 +2420,20 @@
+               $use_hexdump = LITTLEENDIAN;
+               next;
+       }
++      if ($_ eq '-s') {
++              if (-x "/sbin/sysctl") {
++                      $use_sysctl = 1;
++              } else { die "No /sbin/sysctl available for -s"; }
++              next;
++      }
+ 
+       if (m/^-/) {
+               print STDERR "Unrecognized option $_\n";
+               exit;
+       }
+ 
+-      push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump;
++      push @dimm, { eeprom => basename($_), file => $_ }
++              if ($use_sysctl || $use_hexdump);
+ }
+ 
+ # Default values
+@@ -2479,7 +2511,7 @@
+ #  * chk_spd: The checksum or CRC value found in the EEPROM
+ #  * chk_calc: The checksum or CRC computed from the EEPROM data
+ # Keys are added over time.
+-@dimm = get_dimm_list() unless $use_hexdump;
++@dimm = get_dimm_list() unless ($use_sysctl || $use_hexdump);
+ 
+ for my $i (0 .. $#dimm) {
+       my @bytes = readspd(0, 128, $dimm[$i]->{file});
+@@ -2531,7 +2563,7 @@
+               printl("Decoding EEPROM", $dimm[$current]->{eeprom});
+       }
+ 
+-      if (!$use_hexdump) {
++      if (!$use_hexdump && !$use_sysctl) {
+               if ($dimm[$current]->{file} =~ /-([\da-f]+)$/i) {
+                       my $dimm_num = hex($1) - 0x50 + 1;
+                       if ($dimm_num >= 1 && $dimm_num <= 8) {
+@@ -2737,3 +2769,4 @@
+ printl2("\n\nNumber of SDRAM DIMMs detected and decoded", scalar @dimm);
+ 
+ print "</body></html>\n" if ($opt_html && !$opt_bodyonly);
++
diff -r e2fb492416d8 -r a0b4dd725249 sysutils/decode-dimms/patches/patch-decode-dimms.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/decode-dimms/patches/patch-decode-dimms.1        Wed Jul 25 02:05:26 2018 +0000
@@ -0,0 +1,39 @@
+$NetBSD: patch-decode-dimms.1,v 1.1 2018/07/25 02:05:26 pgoyette Exp $
+
+Document the -s option (use spdmem(4)'s sysctl for input)
+
+--- eeprom/decode-dimms.1.orig 2018-07-25 07:26:21.321627123 +0800
++++ eeprom/decode-dimms.1      2018-07-25 07:26:56.967194551 +0800
+@@ -22,7 +22,7 @@
+ decode-dimms \- decode the information found in memory module SPD EEPROMs
+ .SH SYNOPSIS
+ .B decode-dimms
+-[-c] [-f [-b]] [-x|-X file [files..]]
++[-c] [-f [-b]] [-x|-X|-s file [files..]]
+ .br
+ .B decode-dimms
+ -h
+@@ -32,8 +32,7 @@
+ .B decode-dimms
+ tool is to decode the information found in memory module SPD EEPROMs.
+ The SPD data is read either from the running system or dump files.
+-In the former case, the tool requires a kernel module to be loaded:
+-eeprom, at24 or ee1004 (for DDR4 SDRAM.)
++In the former case, the tool requires the spdmem kernel module to be loaded.
+ .SH PARAMETERS
+ .TP
+ .B \-f, --format
+@@ -60,9 +59,11 @@
+ .B \-X
+ Same as -x except treat multibyte hex data as little endian
+ .TP
++.B \-s
++Read the SPD data from the sysctl (9) node hw.<file>.spd_data instead of
++from a file.
++.TP
+ .B \-h, --help
+ Display the usage summary
+-.SH SEE ALSO
+-.BR decode-vaio (1)
+ .SH AUTHORS
+ Philip Edelbrock, Christian Zuckschwerdt, Burkart Lingner, Jean Delvare



Home | Main Index | Thread Index | Old Index