From 61d541aceb85df01eeab1e55d1d6613c195e3e83 Mon Sep 17 00:00:00 2001
From: Joachim Breitner <nomeata@debian.org>
Date: Wed, 29 Jul 2009 19:58:07 +0200
Subject: [PATCH] Create a fake Sources file

Because passing the whole Sources file to edos-debbuildcheck
(add_source.py to be exact) is too slow, we create a fake one here.
---
 bin/wanna-build | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/bin/wanna-build b/bin/wanna-build
index 693528e..5fb90f0 100755
--- a/bin/wanna-build
+++ b/bin/wanna-build
@@ -2581,7 +2581,27 @@ sub call_edos_depcheck {
     #print "I would look at these sources with edos-depcheck:\n";
     #print join " ", keys %interesting_packages,"\n";
 
-    if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $sourcesfile)) {
+    my $tmpfile_pattern = "/tmp/wanna-build-interesting-sources-$distribution.$$-";
+    my ($tmpfile, $i);
+    for( $i = 0;; ++$i ) {
+	    $tmpfile = $tmpfile_pattern . $i;
+	    last if ! -e $tmpfile;
+    }
+
+    open SOURCES, '>', $tmpfile or die "Could not open temporary file $tmpfile\n";
+    for my $key (keys %interesting_packages) {
+	my $pkg = $db{$key};
+	print SOURCES "Package: $key\n";
+	print SOURCES "Version: $pkg->{'Version'}\n";
+	print SOURCES "Build-Depends: $pkg->{'Build-Depends'}\n" if $pkg->{'Build-Depends'};
+	print SOURCES "Build-Conflicts: $pkg->{'Build-Conflicts'}\n" if $pkg->{'Build-Conflicts'};
+	print SOURCES "Architecture: all\n";
+	print SOURCES "\n";
+    }
+    close SOURCES;
+
+    if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $tmpfile))
+    {
 	local($/) = ""; # read in paragraph mode
 	while( <EDOS> ) {
 		my( $key, $reason ) ;
@@ -2602,6 +2622,8 @@ sub call_edos_depcheck {
 	print "ERROR: Could not run wb-edos-builddebcheck. I am continuing, assuming\n" .
 	      "all packages have installable build-dependencies."
     }
+    
+    unlink( $tmpfile );
 
     for my $key (keys %interesting_packages) {
 	my $pkg = $db{$key};
-- 
2.39.5