[package-plan] 02/03: test-packages: Only run apt-cache and grep-dctrl once.

Daniel Silverstone dsilvers at moszumanska.debian.org
Mon Aug 10 13:35:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

dsilvers pushed a commit to branch master
in repository package-plan.

commit 1f56be6d76ab4f6e55187fd0b91a25e17c8b9171
Author: Daniel Silverstone <dsilvers at digital-scurf.org>
Date:   Mon Aug 10 13:19:00 2015 +0000

    test-packages: Only run apt-cache and grep-dctrl once.
    
    Previously we were running apt-cache and grep-dctrl once per
    package we wanted to check.  This was super-slow on low-end devices.
---
 test-packages.pl | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/test-packages.pl b/test-packages.pl
index 9d79f87..a95ac1f 100755
--- a/test-packages.pl
+++ b/test-packages.pl
@@ -119,21 +119,41 @@ while (<AVAILABLE>) {
 close AVAILABLE;
 
 print "Reading available binary versions...\n";
-while ( my ($pkg, $bin) = each %binary ) {
-	open VERS, "-|", "apt-cache dumpavail | grep-dctrl -F Package -s Version -n -X $bin" or die $!;
+my %binavail;
+{
+	my $pkg;
+	open VERS, "-|", "apt-cache dumpavail | grep-dctrl -s Package,Version -n ." or die $!;
 	while (<VERS>) {
 		chomp;
+		if ($_ eq '') {
+			undef $pkg;
+			next;
+		}
+		unless (defined $pkg) {
+			$pkg = $_;
+			$binavail{$pkg} = [] unless (exists $binavail{$pkg});
+			next;
+		}
 		unless (m/^(?:.*:)?(.*?)(?:-(?:.*))?$/) {
 			print "Ignoring unparseable version for $pkg: $_\n";
 			$error_count++;
 		}
 		my $version = $1;
+		push @{$binavail{$pkg}}, $version;
+	}
+	close VERS;
+}
+
+print "Calculating availability...\n";
+
+while ( my ($pkg, $bin) = each %binary ) {
+	foreach my $version (@{$binavail{$bin} or []}) {
 		unless (exists ($available{$pkg}) and version_compare($version, $available{$pkg}) == -1) {
 			$available{$pkg} = $version;
 			$packages{$pkg}++;
 		}
 	}
-	close VERS;
+
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/package-plan.git



More information about the Pkg-haskell-commits mailing list