From 390dca9ae3b5d6c937c41c18a266ffc540ccdccd Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Fri, 23 Oct 2015 14:05:37 +0200 Subject: [PATCH] ids-update.pl: add Generated header with a date Also extend generated file's header for date of source file. Related: rhbz#1266217 Signed-off-by: Michal Minar --- ids-update.pl | 70 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/ids-update.pl b/ids-update.pl index 86d414a..ca58038 100644 --- a/ids-update.pl +++ b/ids-update.pl @@ -2,18 +2,31 @@ use strict; use warnings; +use Date::Format; sub usb_vendor { my $vendor; + my $source_date; open(IN, "<", "usb.ids"); open(OUT, ">", "20-usb-vendor-model.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: http://www.linux-usb.org/usb.ids\n"); while (my $line = ) { $line =~ s/\s+$//; + if (not defined $source_date) { + $line =~ m/^#\s*Date:\s*(.+)$/; + if (defined $1) { + $source_date = $1; + print(OUT "#\n# Source date: $1\n"); + next; + } + } + $line =~ m/^([0-9a-f]{4})\s*(.+)$/; if (defined $1) { $vendor = uc $1; @@ -42,16 +55,28 @@ sub usb_classes { my $class; my $subclass; my $protocol; + my $source_date; open(IN, "<", "usb.ids"); open(OUT, ">", "20-usb-classes.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: http://www.linux-usb.org/usb.ids\n"); while (my $line = ) { $line =~ s/\s+$//; + if (not defined $source_date) { + $line =~ m/^#\s*Date:\s*(.+)$/; + if (defined $1) { + $source_date = $1; + print(OUT "#\n# Source date: $1\n"); + next; + } + } + $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/; if (defined $1) { $class = uc $1; @@ -108,17 +133,29 @@ sub pci_vendor { my $vendor; my $device; my $device_text; + my $source_date; open(IN, "<", "pci.ids"); open(OUT, ">", "20-pci-vendor-model.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n"); while (my $line = ) { $line =~ s/\s+$//; - $line =~ m/^([0-9a-f]{4})\s*(.+)$/; + if (not defined $source_date) { + $line =~ m/^#\s*Date:\s*(.+)$/; + if (defined $1) { + $source_date = $1; + print(OUT "#\n# Source date: $1\n"); + next; + } + } + + $line =~ m/^([0-9a-f]{4})\s*(.+)$/; if (defined $1) { $vendor = uc $1; my $text = $2; @@ -159,16 +196,28 @@ sub pci_classes { my $class; my $subclass; my $interface; + my $source_date; open(IN, "<", "pci.ids"); open(OUT, ">", "20-pci-classes.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n"); while (my $line = ) { $line =~ s/\s+$//; + if (not defined $source_date) { + $line =~ m/^#\s*Date:\s*(.+)$/; + if (defined $1) { + $source_date = $1; + print(OUT "#\n# Source date: $1\n"); + next; + } + } + $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/; if (defined $1) { $class = uc $1; @@ -216,13 +265,15 @@ sub sdio_vendor { open(IN, "<", "sdio.ids"); open(OUT, ">", "20-sdio-vendor-model.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: hwdb/sdio.ids\n"); while (my $line = ) { $line =~ s/\s+$//; - $line =~ m/^([0-9a-f]{4})\s*(.+)$/; + $line =~ m/^([0-9a-f]{4})\s*(.+)$/; if (defined $1) { $vendor = uc $1; my $text = $2; @@ -255,6 +306,8 @@ sub sdio_classes { open(IN, "<", "sdio.ids"); open(OUT, ">", "20-sdio-classes.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from: hwdb/sdio.ids\n"); @@ -279,9 +332,12 @@ sub sdio_classes { sub oui { my $iab_prefix; my %iab_prefixes = (); + my $source_date; open(OUT, ">", "20-OUI.hwdb"); print(OUT "# This file is part of systemd.\n" . + "#\n" . + "# Generated: " . time2str("%Y-%m-%d\n", time) . "#\n" . "# Data imported from:\n" . "# http://standards.ieee.org/develop/regauth/oui/oui.txt\n" . @@ -290,6 +346,16 @@ sub oui { open(IN, "<", "iab.txt"); while (my $line = ) { $line =~ s/^ +//; + + if (not defined $source_date) { + $line =~ m/^\s*Generated:\s+(.+)$/; + if (defined $1) { + $source_date = $1; + print(OUT "#\n# Source date: $1\n"); + next; + } + } + $line =~ s/\s+$//; $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/; if (defined $1) { -- 2.25.1