Просмотр исходного кода

dpkg-scanpackages: avoid IO::String usage

Instead we use Dpkg::IPC to get a pipe file descriptor where we can
read the output of dpkg-deb -I.
Raphaël Hertzog лет назад: 16
Родитель
Сommit
0991804eb3
2 измененных файлов с 15 добавлено и 12 удалено
  1. 7 0
      debian/changelog
  2. 8 12
      scripts/dpkg-scanpackages.pl

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+dpkg (1.15.5.3) UNRELEASED; urgency=low
+
+  * Avoid usage of IO::String in dpkg-scanpackages, rely on Dpkg::IPC
+    instead to directly get a pipe file descriptor. Closes: #557013
+
+ -- Raphael Hertzog <hertzog@debian.org>  Sat, 21 Nov 2009 14:57:50 +0100
+
 dpkg (1.15.5.2) unstable; urgency=low
 
   * Change Dpkg::Version API to accept invalid versions by default and add

+ 8 - 12
scripts/dpkg-scanpackages.pl

@@ -20,7 +20,6 @@ use strict;
 
 use IO::Handle;
 use IO::File;
-use IO::String;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
@@ -28,6 +27,7 @@ use Dpkg::Control;
 use Dpkg::Version;
 use Dpkg::Checksums;
 use Dpkg::Source::CompressedFile;
+use Dpkg::IPC;
 
 textdomain("dpkg-dev");
 
@@ -189,23 +189,19 @@ FILE:
     while (<$find_h>) {
 	chomp;
 	my $fn = $_;
-	my $control = `dpkg-deb -I $fn control`;
-	if ($control eq "") {
-	    warning(_g("Couldn't call dpkg-deb on %s: %s, skipping package"),
-	            $fn, $!);
-	    next;
-	}
+	my $output;
+	my $pid = fork_and_exec('exec' => [ "dpkg-deb", "-I", $fn, "control" ],
+				'to_pipe' => \$output);
+	my $fields = Dpkg::Control->new(type => CTRL_INDEX_PKG);
+	$fields->parse_fh($output, $fn)
+	    or error(_g("couldn't parse control information from %s."), $fn);
+	wait_child($pid, no_check => 1);
 	if ($?) {
 	    warning(_g("\`dpkg-deb -I %s control' exited with %d, skipping package"),
 	            $fn, $?);
 	    next;
 	}
 	
-	my $fields = Dpkg::Control->new(type => CTRL_INDEX_PKG);
-	my $io = IO::String->new($control);
-	$fields->parse_fh($io, $fn)
-	    or error(_g("couldn't parse control information from %s."), $fn);
-	
 	defined($fields->{'Package'})
 	    or error(_g("No Package field in control file of %s"), $fn);
 	my $p = $fields->{'Package'};