Subject: [PATCH] Use Lintian::Collect::Source to read the data from the source debian/control file to take advantage of our caching.

From: Raphael Geissert <[email-masked]>
Date: Wed, 28 Jan 2009 01:18:56 -0600

Signed-off-by: Raphael Geissert <[email-masked]>
---
 checks/version-substvars |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/checks/version-substvars b/checks/version-substvars
index cb3d47d..d1d0c69 100644
--- a/checks/version-substvars
+++ b/checks/version-substvars
@@ -42,27 +42,27 @@ sub run {
 
 my $pkg = shift;
 my $type = shift;
+my $info = shift;
 
-my @control_data = read_dpkg_control("debfiles/control");
-my @dep_fields = qw(depends pre-depends recommends suggests conflicts replaces);
+my $binpkgs = $info->binaries;
 
-shift @control_data; # skip source info entry
+my @dep_fields = qw(depends pre-depends recommends suggests conflicts replaces);
 
-foreach (@control_data) {
+foreach (keys %$binpkgs) {
 	my ($pkg1, $pkg1_is_any, $pkg2, $pkg2_is_any, $substvar_strips_binNMU);
 
-	$pkg1 = $_->{'package'};
-	$pkg1_is_any = ($_->{'architecture'} ne 'all');
+	$pkg1 = $_;
+	$pkg1_is_any = ($info->binary_field($pkg1, 'architecture') ne 'all');
 
 	foreach my $field (@dep_fields) {
-		next unless $_->{$field};
-		if ($_->{$field} =~ m/\${Source-Version}/) {
+		next unless $info->binary_field($pkg1, $field);
+		if ($info->binary_field($pkg1, $field) =~ m/\${Source-Version}/) {
 			tag "substvar-source-version-is-deprecated", $pkg1;
 		}
 	}
 
-	foreach (split(m/,/, ($_->{'pre-depends'} || "").", ".
-		       ($_->{'depends'} || ""))) {
+	foreach (split(m/,/, $info->binary_field($pkg1, 'pre-depends').", ".
+		       $info->binary_field($pkg1, 'depends'))) {
 		next unless m/(\S+)\s*\(\s*=\s*\${((?:Source-|source:|binary:)Version)}/x;
 
 		$pkg2 = $1;
@@ -71,12 +71,12 @@ foreach (@control_data) {
 		# We can't test dependencies on packages whose names are
 		# formed via substvars expanded during the build.  Assume
 		# those maintainers know what they're doing.
-		if (not -f "control/$pkg2/architecture") {
+		if (not $info->binary_field($pkg2, 'architecture')) {
 			tag "version-substvar-for-external-package", "$pkg1 -> $pkg2"
 				unless ($pkg2 =~ /\$\{\S+\}/);
 			next;
 		}
-		$pkg2_is_any = (slurp_entire_file("control/$pkg2/architecture") !~ m/^all$/);
+		$pkg2_is_any = ($info->binary_field($pkg2, 'architecture') !~ m/^all$/);
 
 		if ($pkg1_is_any) {
 			if ($pkg2_is_any and $substvar_strips_binNMU) {