- Add merge-pciids.pl to fully duplicate behavior of pciutils-ids
* Helps resolve SLE issue bsc#1180422 OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory/hwdata?expand=0&rev=88
This commit is contained in:
parent
7b28ef64c2
commit
5d140aa34b
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jan 7 14:28:17 UTC 2021 - Martin Pluskal <mpluskal@suse.com>
|
||||||
|
|
||||||
|
- Add merge-pciids.pl to fully duplicate behavior of pciutils-ids
|
||||||
|
* Helps resolve SLE issue bsc#1180422
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Jan 6 08:13:18 UTC 2021 - Martin Pluskal <mpluskal@suse.com>
|
Wed Jan 6 08:13:18 UTC 2021 - Martin Pluskal <mpluskal@suse.com>
|
||||||
|
|
||||||
|
26
hwdata.spec
26
hwdata.spec
@ -22,7 +22,11 @@ Release: 0
|
|||||||
Summary: Hardware identification and configuration data
|
Summary: Hardware identification and configuration data
|
||||||
License: GPL-2.0-or-later
|
License: GPL-2.0-or-later
|
||||||
URL: https://github.com/vcrhonek/hwdata
|
URL: https://github.com/vcrhonek/hwdata
|
||||||
Source: https://github.com/vcrhonek/hwdata/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
Source0: https://github.com/vcrhonek/hwdata/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||||
|
Source1: merge-pciids.pl
|
||||||
|
Requires(post): coreutils
|
||||||
|
Requires(post): perl
|
||||||
|
Conflicts: pciutils-ids
|
||||||
Provides: pciutils-ids = 20200529
|
Provides: pciutils-ids = 20200529
|
||||||
Obsoletes: pciutils-ids < 20200529
|
Obsoletes: pciutils-ids < 20200529
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -42,20 +46,38 @@ such as the pci.ids and usb.ids databases.
|
|||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
# create symlink for smooth transition from pciutils-ids package
|
# create symlink for smooth transition from pciutils-ids package
|
||||||
|
mkdir %{buildroot}%{_datadir}/pci.ids.d
|
||||||
ln -s %{_datadir}/hwdata/pci.ids \
|
ln -s %{_datadir}/hwdata/pci.ids \
|
||||||
|
%{buildroot}%{_datadir}/pci.ids.d/pci.ids.dist
|
||||||
|
|
||||||
|
install -Dpm 0755 %{SOURCE1} \
|
||||||
|
%{buildroot}%{_bindir}/merge-pciids
|
||||||
|
install -Dpm 0644 /dev/null \
|
||||||
%{buildroot}%{_datadir}/pci.ids
|
%{buildroot}%{_datadir}/pci.ids
|
||||||
|
|
||||||
# not needed at all
|
# not needed at all
|
||||||
rm -rf %{buildroot}/%{_libdir}/modprobe.d
|
rm -rf %{buildroot}/%{_libdir}/modprobe.d
|
||||||
|
|
||||||
|
%post
|
||||||
|
if [ -x %{_bindir}/merge-pciids -a -x %{_bindir}/perl ]; then
|
||||||
|
%{_bindir}/merge-pciids
|
||||||
|
else
|
||||||
|
# This should only happen in autobuild
|
||||||
|
echo "WARNING: merge-pciids or perl not found"
|
||||||
|
cp -p %{_datadir}/pci.ids.d/pci.ids.dist %{_datadir}/pci.ids
|
||||||
|
fi
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%license LICENSE COPYING
|
%license LICENSE COPYING
|
||||||
|
%{_bindir}/merge-pciids
|
||||||
%dir %{_datadir}/%{name}
|
%dir %{_datadir}/%{name}
|
||||||
%{_datadir}/hwdata/iab.txt
|
%{_datadir}/hwdata/iab.txt
|
||||||
%{_datadir}/hwdata/oui.txt
|
%{_datadir}/hwdata/oui.txt
|
||||||
%{_datadir}/hwdata/pci.ids
|
%{_datadir}/hwdata/pci.ids
|
||||||
%{_datadir}/hwdata/pnp.ids
|
%{_datadir}/hwdata/pnp.ids
|
||||||
%{_datadir}/hwdata/usb.ids
|
%{_datadir}/hwdata/usb.ids
|
||||||
%{_datadir}/pci.ids
|
%dir %{_datadir}/pci.ids.d
|
||||||
|
%{_datadir}/pci.ids.d/pci.ids.dist
|
||||||
|
%ghost %{_datadir}/pci.ids
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
111
merge-pciids.pl
Normal file
111
merge-pciids.pl
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
# Merge several PCI ID lists to a single one. This script tries to be as agnostic
|
||||||
|
# of the details of the ID list as possible, so it should not break with future
|
||||||
|
# changes of the ID list format as long as they follow the same block structure.
|
||||||
|
#
|
||||||
|
# Options:
|
||||||
|
# -v: Verbose mode. Warn if multiple files provide different definitions for
|
||||||
|
# the same device.
|
||||||
|
#
|
||||||
|
# (c) 2007 Martin Mares <mj@ucw.cz>, GPLv2
|
||||||
|
# (c) 2013, 2015 Jean Delvare <jdelvare@suse.de>
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Getopt::Std;
|
||||||
|
use File::Copy;
|
||||||
|
use vars qw($IDSD_PATH $MASTER_IDS $PCI_IDS @idsd_files $output);
|
||||||
|
|
||||||
|
$IDSD_PATH = "/usr/share/pci.ids.d";
|
||||||
|
$MASTER_IDS = "/usr/share/pci.ids.d/pci.ids.dist";
|
||||||
|
$PCI_IDS = "/usr/share/pci.ids";
|
||||||
|
|
||||||
|
our $opt_v;
|
||||||
|
getopts('v');
|
||||||
|
|
||||||
|
if (! -f $MASTER_IDS) {
|
||||||
|
print STDERR "ERROR: $MASTER_IDS not found, giving up\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub collect_files($)
|
||||||
|
{
|
||||||
|
my ($dir) = @_;
|
||||||
|
my ($file, @files);
|
||||||
|
|
||||||
|
opendir(my $dh, $dir) || die "Could not open directory $dir: $!";
|
||||||
|
# Ignore non-files and hidden files
|
||||||
|
while (defined ($file = readdir($dh))) {
|
||||||
|
push @files, "$dir/$file" if $file !~ m/^\./ && -f "$dir/$file";
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
|
||||||
|
return @files;
|
||||||
|
}
|
||||||
|
|
||||||
|
my %ids = ();
|
||||||
|
my %comments = ();
|
||||||
|
@idsd_files = collect_files($IDSD_PATH);
|
||||||
|
foreach our $file (@idsd_files) {
|
||||||
|
my $fn = ($file =~ /\.gz$/) ? "zcat $file |" : ($file =~ /\.bz2$/) ? "bzcat $file |" : $file;
|
||||||
|
open F, $fn or die "Unable to open $file: $!";
|
||||||
|
my @id = ();
|
||||||
|
my $comm = "";
|
||||||
|
my $class = 0;
|
||||||
|
sub err($) {
|
||||||
|
print STDERR "Error in $file, line $.: @_\n";
|
||||||
|
# If merging fails for whatever reason, fallback to master file copy
|
||||||
|
print STDERR "WARNING: Merge not successful, using master pci.ids file\n";
|
||||||
|
copy($MASTER_IDS, $PCI_IDS) || die "Could not copy $MASTER_IDS to $PCI_IDS: $!";
|
||||||
|
chmod(0644, "$PCI_IDS");
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
while (<F>) {
|
||||||
|
if (/^(#.*|\s*$)/) {
|
||||||
|
$comm .= $_;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
chomp;
|
||||||
|
if (/^(\t|C\s+|)([0-9a-fA-F]+)\s+(.*)$/ ||
|
||||||
|
(!$class && /^(\t\t)([0-9a-fA-F]+\s+[0-9a-fA-F]+)\s+(.*)$/) ||
|
||||||
|
($class && /^(\t\t)([0-9a-fA-F]+)\s+(.*)$/)) {
|
||||||
|
my $indent = $1;
|
||||||
|
my $id = lc($2);
|
||||||
|
my $name = $3;
|
||||||
|
if ($indent =~ /^C\s+$/) {
|
||||||
|
$indent = "";
|
||||||
|
$id = "C $id";
|
||||||
|
}
|
||||||
|
my $depth = length $indent;
|
||||||
|
$depth <= @id or err "Mismatched indentation";
|
||||||
|
@id = (@id[0..$depth-1], $id);
|
||||||
|
$class = ($id =~ /^C\s/) if !$depth; # Remember if we are in a vendor or a class section
|
||||||
|
my $i = join(":", @id);
|
||||||
|
my $j = $class ? "~$i" : $i; # We want to sort special entries last
|
||||||
|
if ($opt_v && exists $ids{$j} && $ids{$j} ne $name) {
|
||||||
|
print STDERR "Warning: ID $i has two different definitions, using the one from $file\n";
|
||||||
|
}
|
||||||
|
$ids{$j} = $name;
|
||||||
|
$comments{$j} = $comm if $comm;
|
||||||
|
} else {
|
||||||
|
err "Parse error";
|
||||||
|
}
|
||||||
|
$comm = "";
|
||||||
|
}
|
||||||
|
close F;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write to a temporary file to avoid a race condition with lspci
|
||||||
|
open($output, ">", "$PCI_IDS.part") || die "Could not write to $PCI_IDS.part: $!";
|
||||||
|
print $output "# This file has been merged automatically from the following files:\n#\t", join("\n#\t", @idsd_files), "\n\n";
|
||||||
|
foreach my $id (sort keys %ids) {
|
||||||
|
my ($i, $j) = ($id, $id);
|
||||||
|
$i =~ s/[^:]//g;
|
||||||
|
$i =~ tr/:/\t/;
|
||||||
|
$j =~ s/.*://g;
|
||||||
|
$j =~ s/^~//;
|
||||||
|
print $output $comments{$id} if $comments{$id};
|
||||||
|
print $output "$i$j $ids{$id}\n";
|
||||||
|
}
|
||||||
|
close($output);
|
||||||
|
rename("$PCI_IDS.part", "$PCI_IDS") || die "Could not rename $PCI_IDS.part to $PCI_IDS: $!";
|
||||||
|
chmod(0644, "$PCI_IDS");
|
Loading…
Reference in New Issue
Block a user