Add better version tracking
authorSteve McIntyre <steve@einval.com>
Sun, 23 Dec 2018 17:55:36 +0000 (17:55 +0000)
committerSteve McIntyre <steve@einval.com>
Sun, 23 Dec 2018 17:55:36 +0000 (17:55 +0000)
Check on what versions have been built, including non-buildd all
packages.

bin/analyze_results

index 554c76b..a9c2f0b 100755 (executable)
@@ -14,6 +14,7 @@ use POSIX qw(strftime);
 use Data::Dumper;
 use Getopt::Std;
 use HTTP::Tiny;
+use URI::Encode qw(uri_encode uri_decode);
 
 my $name = "analyze_results";
 my $repo = "https://git.einval.com/cgi-bin/gitweb.cgi?p=buildd-scripts.git";
@@ -483,6 +484,7 @@ if (defined $opt_u) {
 
 sub check_buildd_status {
     my $pkg = shift;
+    my $version = shift;
     my $arch = shift;
 
     my $url = "$buildd_base_url$pkg";
@@ -490,9 +492,10 @@ sub check_buildd_status {
 #    print "Looking at URL $url\n";
 
     my $built_on_arches = "";
-    my $built_this_arch = 0;
-    my $ftbfs_this_arch = 0;
-    my $not_this_arch = 0;
+    my $built_my_arch = 0;
+    my $ftbfs_my_arch = 0;
+    my $not_my_arch = 0;
+    my $current_version = "";
 
 #    print "Checking buildd data for package $pkg, arch $arch\n";
 
@@ -509,34 +512,68 @@ sub check_buildd_status {
        # Now look for two things:
        # 1. how many arches have built this package?
        # 2. has *our* arch built it?
+#      print "we tried $version on arch $arch\n";
        foreach my $line (@lines) {
            chomp $line;
-           if ($line =~ /fetch.php/) {
-               if ($line =~ /arch=([^&]*)&amp\;.*Installed/) {
-                   $built_on_arches .= "$1 ";
+           $line = uri_decode($line);
+           if ($line =~ /https:\/\/buildd.debian.org\/stats\/graph/) {
+               my @info = split (/<\/td>/, $line);
+               # Grab the info from our fields
+               my $this_arch = "";
+               if ($info[0] =~ /architecture.php\?a=([^&]*)&amp/) {
+                   $this_arch = $1;
+#                  print "Found entry for arch $this_arch\n";
+               } else {
+                   print "  <li>FAILED TO PARSE $url\n";
                }
-               if ($line =~ /a=$arch.*Installed/) {
-                   $built_this_arch++;
+               $current_version = $info[1];
+               $current_version =~ s/^<td>//;
+#              print "current_version for $this_arch is $current_version, we tried $version\n";
+               my $status = "";
+               if ($info[2] =~ /class="status status-([a-z]*)/) {
+                   $status = $1;
+#                  print "Found status $status\n";
+               } else {
+                   print "  <li>FAILED TO PARSE $url\n";
                }
-               if ($line =~ /a=$arch.*Build-Attempted/) {
-                   $ftbfs_this_arch++;
+#              foreach my $field(@info) {
+#                  print "$field\n";
+#              }
+#              print "  On $this_arch we have version $current_version, status $status\n";
+               if ($arch =~ /^\Q$this_arch\E$/) {
+                   if ($status =~ /installed/) {
+                       $built_my_arch++;
+                   } else {
+                       $ftbfs_my_arch++;
+                   }
+               }
+               if ($status =~ /installed/) {
+                   $built_on_arches .= "$this_arch ";
                }
            }
+
            if ($line =~ /$arch is not present in the architecture list set by the maintainer/) {
-               $not_this_arch++;
+               $not_my_arch++;
            }
            if ($line =~ /No entry in $arch database/) {
-               $not_this_arch++;
+               $not_my_arch++;
            }
        }
-       print "  <li>Built on this arch: $built_this_arch\n";
+       print "  <li>Built on this arch: $built_my_arch\n";
        print "  <li>Built on arches: $built_on_arches\n";
-       if ($not_this_arch) {
+       if ($not_my_arch) {
            print "  <li>Not set to build on $arch\n";
        }
-       if ($ftbfs_this_arch) {
+       if ($ftbfs_my_arch) {
            print "  <li>Already seen to FTBFS on $arch\n";
        }
+       if (length($current_version) < 2) {
+           print "  <li>No current version found - has this been removed\n";
+       } elsif (! ($current_version =~ /\Q$version\E/)) {
+           print "  <li><strong>New version $current_version available - retry?</strong>\n";
+       }
+    } else {
+       print "  <LI>FAILED TO RETRIEVE buildd URL $url\n";
     }
 }
     
@@ -630,7 +667,7 @@ foreach my $input (@ARGV) {
                }
                print "  </ul>\n";
            }
-           check_buildd_status($pkg, $arch);
+           check_buildd_status($pkg, $version, $arch);
        }
     }