]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Made output better
authorLars Kurth <lars.kurth@citrix.com>
Sun, 30 Jul 2017 10:52:09 +0000 (11:52 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Sun, 30 Jul 2017 10:52:09 +0000 (11:52 +0100)
match-xsa

index cdd48a8df80630b94b65c3faa48c13eefafd7c9d..fbf7efbb5781d15440c7647a818a278d2e6ae1cf 100755 (executable)
--- a/match-xsa
+++ b/match-xsa
@@ -6,6 +6,12 @@
 #   [--xsadir xsadir] --xsa xsafile
 
 use strict;
+# Disabled warnings as
+# - if ( @{ $XSA_TO_INDEX_MATCH{$e} } ) throws an error, while
+#   if ( defined @{ $XSA_TO_INDEX_MATCH{$e} } ) works but warns
+no warnings 'deprecated';
+no warnings 'experimental';
+
 use warnings;
 use 5.010;
 use Getopt::Long qw(GetOptions);
@@ -184,6 +190,8 @@ for ($i=0; $i <= $XSAs; $i++) {
 # PRINT REPORT
 my @XSA_LIST;
 my %XSA_TO_INDEX;
+my %XSA_TO_INDEX_AUX;    # Contains *.patch files deemed not important
+my %XSA_TO_INDEX_MATCH;  # Contains *.patch files matching a version
 
 preparedatabyxsa();
 printreport();
@@ -199,6 +207,17 @@ sub preparedatabyxsa {
     
     for ($i=0; $i <= $#XSA; $i++) {
         push @{ $XSA_TO_INDEX{$XSA[$i]} }, $i;
+        
+        # Check $XSA_PATCH[$i] against @XSA_REGEXFORVERSION
+        # If there is a match put in %XSA_TO_INDEX_MATCH
+        # Otherwise in               %XSA_TO_INDEX_AUX
+        my $rx = join "|", @XSA_REGEXFORVERSION;
+        
+        if ($XSA_PATCH[$i] =~ /$rx/) {
+            push @{ $XSA_TO_INDEX_MATCH{$XSA[$i]} }, $i;
+        } else {
+            push @{ $XSA_TO_INDEX_AUX{$XSA[$i]} }, $i;
+        }
     }
 }
 
@@ -211,11 +230,25 @@ sub printreport {
     foreach $e (@XSA_LIST)
     {
         printheadline($e);
-        printlistheader();
-        foreach $i ( @{ $XSA_TO_INDEX{$e} } ) {
-             printxsadetail_byindex($i, $debug);
+        if ( defined @{ $XSA_TO_INDEX_MATCH{$e} } ) {
+            printlistheader("Comparisons specific to $VERSION.$MAJOR:",
+                            "BLACK");
+            foreach $i ( @{ $XSA_TO_INDEX_MATCH{$e} } ) {
+                 printxsadetail_byindex($i, "RED", $debug);
+            }
+            printlistend();
+
+            printseparator();
+        }
+        
+        if ( defined @{ $XSA_TO_INDEX_AUX{$e} } ) {
+            printlistheader("Other comparisons (can probably be ignored):",
+                            "GRAY");
+            foreach $i ( @{ $XSA_TO_INDEX_AUX{$e} } ) {
+                 printxsadetail_byindex($i, "GRAY", $debug);
+            }
+            printlistend();
         }
-        printlistend();
     }
 }
 
@@ -240,12 +273,17 @@ sub printheadline {
 sub printxsadetail_byindex {
 
     my $i = shift;
+    my $nomatchcolor = shift;
     my $debug = shift;
     
     my $i_correct = $i+1;
     
     if ($HTML) {
-        printf('  <li>');
+        if ( $XSA_IN[$i] eq "in NONE" ) {
+            printf('  <li style="color:%s;">', $nomatchcolor);
+        } else {
+            printf('  <li>');
+        }
         printf('<a href="http://xenbits.xenproject.org/xsa/%s">%s</a> ',
         $XSA_PATCH[$i], $XSA_PATCH[$i]);
         printf(' <b>%s</b> ', $XSA_IN[$i]);
@@ -271,16 +309,19 @@ sub printxsadetail_byindex {
 
 sub printseparator {
     
-    if ($HTML) {
-        printf('<hr>');
-    }
     printf("\n");
 }
 
 sub printlistheader {
+    my $text = shift;
+    my $color = shift;
     
     if ($HTML) {
-        printf('<ul> ');
+        printf('<p style="color:%s;">%s</p>', $color, $text);
+        printf('<ul style="color:%s;"> ', $color);
+        printf("\n");
+    } else {
+        printf("== %s ==\n", $text);
         printf("\n");
     }
 }