From 77cb2189d59154bc475f4bf23d09ff86c4e0519c Mon Sep 17 00:00:00 2001 From: The PCI ID Mail Robot Date: Mon, 4 Mar 2024 18:00:14 +0100 Subject: [PATCH] ids_to_dbdump is still needed by the mailbot --- scripts/ids_to_dbdump | 32 ++++++++++++++++++++++++++++++++ scripts/mailbot | 5 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 scripts/ids_to_dbdump diff --git a/scripts/ids_to_dbdump b/scripts/ids_to_dbdump new file mode 100755 index 0000000..83cd1b6 --- /dev/null +++ b/scripts/ids_to_dbdump @@ -0,0 +1,32 @@ +#!/usr/bin/perl +# Convert pci.ids to format used by the database. + +sub id { + $_ = shift @_; + tr/A-F/a-f/; + return $_; +} + +$last = "????"; $lastd = "????????"; $cmt = ""; +while (<>) { + chomp; + s/ +$//; + s/([^\t])\t+/$1 /g; + if (/^$/) { $cmt=""; next; } + if (/^#/) { s/^#//; $cmt="$cmt $_"; next; } + /^C/ && last; + $cmt =~ s/ +/ /g; + $cmt =~ s/^ +//; + if (/^\t\t([0-9a-fA-F]{4}) ([0-9a-fA-F]{4})\s+([^\t]*)$/) { + print "s\t",id("$lastd$1$2"),"\t$3\t0\t$cmt\n"; + } elsif (/^\t([0-9a-fA-F]{4})\s+([^\t]*)$/) { + $lastd="$last$1"; + print "d\t",id($lastd),"\t$2\t0\t$cmt\n"; + } elsif (/^([0-9a-fA-F]{4})\s+([^\t]*)$/) { + $last=$1; $lastd="$1????"; + print "v\t",id($1),"\t$2\t0\t$cmt\n"; + } else { + die "Syntax error: $_"; + } + $cmt=""; +} diff --git a/scripts/mailbot b/scripts/mailbot index 8119f92..8a862b6 100755 --- a/scripts/mailbot +++ b/scripts/mailbot @@ -99,6 +99,7 @@ if (!$patch) { } $home = "$ENV{HOME}/"; +my $scripts = "$home/ids/perl/scripts"; $tprefix = "${home}tmp/mbot-$$"; # Little hack to stop spam: ignore everything from people not already in database $hasAuth->execute( $author ); @@ -196,11 +197,11 @@ sub process } else { print LOG "Patch succeeded.\n"; print LOG "Parsing patched file.\n"; - print LOG `$home/bin/ids_to_dbdump <$orig 2>&1 >orig.db.unsorted`; + print LOG `$scripts/ids_to_dbdump <$orig 2>&1 >orig.db.unsorted`; $? && error("Error parsing original ID database"); print LOG `sort -k1 orig.db`; $? && error("Error sorting original ID database"); - print LOG `$home/bin/ids_to_dbdump &1 >new.db.unsorted`; + print LOG `$scripts/ids_to_dbdump &1 >new.db.unsorted`; $? && error("Error parsing the patched pci.ids file"); print LOG `sort -k1 new.db`; $? && error("Error sorting the patched pci.ids file"); -- 2.39.2