]> mj.ucw.cz Git - pciids.git/commitdiff
ids_to_dbdump is still needed by the mailbot master
authorThe PCI ID Mail Robot <pci-admins@ucw.cz>
Mon, 4 Mar 2024 17:00:14 +0000 (18:00 +0100)
committerThe PCI ID Mail Robot <pci-admins@ucw.cz>
Mon, 4 Mar 2024 17:00:14 +0000 (18:00 +0100)
scripts/ids_to_dbdump [new file with mode: 0755]
scripts/mailbot

diff --git a/scripts/ids_to_dbdump b/scripts/ids_to_dbdump
new file mode 100755 (executable)
index 0000000..83cd1b6
--- /dev/null
@@ -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="";
+}
index 8119f92bba94de0daa8abda36d64409e3848bfa7..8a862b690a6b4d1d0cc45be7a30f893b35f0a2e0 100755 (executable)
@@ -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.unsorted >orig.db`;
                        $? && error("Error sorting original ID database");
-                       print LOG `$home/bin/ids_to_dbdump <pci.ids 2>&1 >new.db.unsorted`;
+                       print LOG `$scripts/ids_to_dbdump <pci.ids 2>&1 >new.db.unsorted`;
                        $? && error("Error parsing the patched pci.ids file");
                        print LOG `sort -k1 <new.db.unsorted >new.db`;
                        $? && error("Error sorting the patched pci.ids file");