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

dpkg-scanpackages/dpkg-scansources: support compressed override files

This feature is supported in the dpkg-scanpackages implementation provided
by dpkg-multicd.
Raphaël Hertzog лет назад: 17
Родитель
Сommit
171610876f
5 измененных файлов с 43 добавлено и 25 удалено
  1. 1 0
      debian/changelog
  2. 3 2
      man/dpkg-scanpackages.1
  3. 7 5
      man/dpkg-scansources.1
  4. 7 4
      scripts/dpkg-scanpackages.pl
  5. 25 14
      scripts/dpkg-scansources.pl

+ 1 - 0
debian/changelog

@@ -45,6 +45,7 @@ dpkg (1.15.5) UNRELEASED; urgency=low
   * Create Launchpad-Bugs-Fixed directly in the changelog parsing code thanks
   * Create Launchpad-Bugs-Fixed directly in the changelog parsing code thanks
     to a new vendor hook post-process-changelog-entry. Closes: #536066
     to a new vendor hook post-process-changelog-entry. Closes: #536066
   * Integrate dpkg-ftp into dselect. Add the required Replaces and Conflicts.
   * Integrate dpkg-ftp into dselect. Add the required Replaces and Conflicts.
+  * dpkg-scanpackages/dpkg-scansources now supports compressed override files.
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * German (Sven Joachim).
   * German (Sven Joachim).

+ 3 - 2
man/dpkg-scanpackages.1

@@ -60,7 +60,7 @@ this string.
 .PP
 .PP
 .I overridefile
 .I overridefile
 is the name of a file to read which contains information about how the
 is the name of a file to read which contains information about how the
-package fits into the distribution; see
+package fits into the distribution (it can be a compressed file); see
 .BR deb\-override (5).
 .BR deb\-override (5).
 .PP
 .PP
 .I pathprefix
 .I pathprefix
@@ -79,7 +79,8 @@ Scan for *.\fItype\fP packages, instead of *.deb.
 \fBObsolete\fP alias for \fB-tudeb\fP.
 \fBObsolete\fP alias for \fB-tudeb\fP.
 .TP
 .TP
 .BR \-e ", " \-\-extra\-override " \fIfile\fP"
 .BR \-e ", " \-\-extra\-override " \fIfile\fP"
-Scan \fIfile\fP to find supplementary overrides. See
+Scan \fIfile\fP to find supplementary overrides (the file can be
+compressed). See
 .BR deb\-extra\-override (5)
 .BR deb\-extra\-override (5)
 for more information on its format.
 for more information on its format.
 .TP
 .TP

+ 7 - 5
man/dpkg-scansources.1

@@ -18,8 +18,8 @@ stdout.
 .PP
 .PP
 The \fIoverride-file\fR, if given, is used to set priorities in the resulting
 The \fIoverride-file\fR, if given, is used to set priorities in the resulting
 index records and to override the maintainer field given in the \fI.dsc\fR
 index records and to override the maintainer field given in the \fI.dsc\fR
-files. See
-.BR dpkg-scanpackages (1)
+files. The file can be compressed. See
+.BR deb-override (5)
 for the format of this file. \s-1NB:\s0  Since
 for the format of this file. \s-1NB:\s0  Since
 the override file is indexed by binary, not source, packages, there's a bit
 the override file is indexed by binary, not source, packages, there's a bit
 of a problem here. The current implementation uses the highest priority of
 of a problem here. The current implementation uses the highest priority of
@@ -48,12 +48,14 @@ Don't sort the index records. Normally they are sorted by source package
 name.
 name.
 .TP
 .TP
 .IP "\fB\-e\fR, \fB\-\-extra\-override\fR \fIfile\fP" 4
 .IP "\fB\-e\fR, \fB\-\-extra\-override\fR \fIfile\fP" 4
-Scan \fIfile\fP to find supplementary overrides. See
+Scan \fIfile\fP to find supplementary overrides (the file can be
+compressed). See
 .BR deb\-extra\-override (5)
 .BR deb\-extra\-override (5)
 for more information on its format.
 for more information on its format.
 .IP "\fB\-s\fR, \fB\-\-source\-override\fR \fIfile\fR" 4
 .IP "\fB\-s\fR, \fB\-\-source\-override\fR \fIfile\fR" 4
-Use \fIfile\fR as the source override file. The default is the name of the
-override file you specified with \fI.src\fR appended.
+Use \fIfile\fR as the source override file (the file can be compressed).
+The default is the name of the override file you specified with \fI.src\fR
+appended.
 .sp
 .sp
 The source override file is in a different format from the binary override
 The source override file is in a different format from the binary override
 file. It contains only two whitespace separated fields, the first is the
 file. It contains only two whitespace separated fields, the first is the

+ 7 - 4
scripts/dpkg-scanpackages.pl

@@ -11,6 +11,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
 use Dpkg::Version qw(compare_versions);
 use Dpkg::Version qw(compare_versions);
 use Dpkg::Checksums;
 use Dpkg::Checksums;
+use Dpkg::Source::CompressedFile;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
 
 
@@ -67,8 +68,8 @@ sub set_type_udeb()
 sub load_override
 sub load_override
 {
 {
     my $override = shift;
     my $override = shift;
-    my $override_fh = new IO::File $override, 'r' or
-        syserr(_g("Couldn't open override file %s"), $override);
+    my $comp_file = Dpkg::Source::CompressedFile->new(filename => $override);
+    my $override_fh = $comp_file->open_for_read();
 
 
     while (<$override_fh>) {
     while (<$override_fh>) {
 	s/\#.*//;
 	s/\#.*//;
@@ -109,13 +110,14 @@ sub load_override
     }
     }
 
 
     close($override_fh);
     close($override_fh);
+    $comp_file->cleanup_after_open();
 }
 }
 
 
 sub load_override_extra
 sub load_override_extra
 {
 {
     my $extra_override = shift;
     my $extra_override = shift;
-    my $override_fh = new IO::File $extra_override, 'r' or
-        syserr(_g("Couldn't open override file %s"), $extra_override);
+    my $comp_file = Dpkg::Source::CompressedFile->new(filename => $extra_override);
+    my $override_fh = $comp_file->open_for_read();
 
 
     while (<$override_fh>) {
     while (<$override_fh>) {
 	s/\#.*//;
 	s/\#.*//;
@@ -132,6 +134,7 @@ sub load_override_extra
     }
     }
 
 
     close($override_fh);
     close($override_fh);
+    $comp_file->cleanup_after_open();
 }
 }
 
 
 usage() and exit 1 if not $result;
 usage() and exit 1 if not $result;

+ 25 - 14
scripts/dpkg-scansources.pl

@@ -33,6 +33,8 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
 use Dpkg::Checksums;
 use Dpkg::Checksums;
+use Dpkg::Source::CompressedFile;
+use Dpkg::Compression;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
 
 
@@ -140,8 +142,9 @@ sub load_override {
     my $file = shift;
     my $file = shift;
     local $_;
     local $_;
 
 
-    open OVERRIDE, $file or syserr(_g("can't read override file %s"), $file);
-    while (<OVERRIDE>) {
+    my $comp_file = Dpkg::Source::CompressedFile->new(filename => $file);
+    my $override_fh = $comp_file->open_for_read();
+    while (<$override_fh>) {
     	s/#.*//;
     	s/#.*//;
 	next if /^\s*$/;
 	next if /^\s*$/;
 	s/\s+$//;
 	s/\s+$//;
@@ -178,7 +181,8 @@ sub load_override {
 	    $Override{$package}[O_MAINT_TO] = $maintainer;
 	    $Override{$package}[O_MAINT_TO] = $maintainer;
 	}
 	}
     }
     }
-    close OVERRIDE or syserr(_g("error closing override file"));
+    close($override_fh);
+    $comp_file->cleanup_after_open();
 }
 }
 
 
 sub load_src_override {
 sub load_src_override {
@@ -190,18 +194,23 @@ sub load_src_override {
 	$file = $user_file;
 	$file = $user_file;
     }
     }
     elsif (defined $regular_file) {
     elsif (defined $regular_file) {
-	$file = "$regular_file.src";
+        my $comp = get_compression_from_filename($regular_file);
+        if (defined($comp)) {
+	    $file = $regular_file;
+            $file =~ s/\.$comp_ext{$comp}$/.src.$comp_ext{$comp}/;
+        } else {
+	    $file = "$regular_file.src";
+        }
+        return unless -e $file;
     }
     }
     else {
     else {
 	return;
 	return;
     }
     }
 
 
     debug "source override file $file";
     debug "source override file $file";
-    unless (open SRC_OVERRIDE, $file) {
-	return if !defined $user_file;
-	syserr(_g("can't read source override file %s"), $file);
-    }
-    while (<SRC_OVERRIDE>) {
+    my $comp_file = Dpkg::Source::CompressedFile->new(filename => $file);
+    my $override_fh = $comp_file->open_for_read();
+    while (<$override_fh>) {
     	s/#.*//;
     	s/#.*//;
 	next if /^\s*$/;
 	next if /^\s*$/;
 	s/\s+$//;
 	s/\s+$//;
@@ -223,16 +232,17 @@ sub load_src_override {
 	$Override{$key} = [];
 	$Override{$key} = [];
 	$Override{$key}[O_SECTION] = $section;
 	$Override{$key}[O_SECTION] = $section;
     }
     }
-    close SRC_OVERRIDE or syserr(_g("error closing source override file"));
+    close($override_fh);
+    $comp_file->cleanup_after_open();
 }
 }
 
 
 sub load_override_extra
 sub load_override_extra
 {
 {
     my $extra_override = shift;
     my $extra_override = shift;
-    open(OVERRIDE, "<", $extra_override) or
-        syserr(_g("Couldn't open override file %s"), $extra_override);
+    my $comp_file = Dpkg::Source::CompressedFile->new(filename => $extra_override);
+    my $override_fh = $comp_file->open_for_read();
 
 
-    while (<OVERRIDE>) {
+    while (<$override_fh>) {
 	s/\#.*//;
 	s/\#.*//;
 	s/\s+$//;
 	s/\s+$//;
 	next unless $_;
 	next unless $_;
@@ -240,7 +250,8 @@ sub load_override_extra
 	my ($p, $field, $value) = split(/\s+/, $_, 3);
 	my ($p, $field, $value) = split(/\s+/, $_, 3);
         $Extra_Override{$p}{$field} = $value;
         $Extra_Override{$p}{$field} = $value;
     }
     }
-    close(OVERRIDE);
+    close($override_fh);
+    $comp_file->cleanup_after_open();
 }
 }
 
 
 # Given PREFIX and DSC-FILE, process the file and returns the fields.
 # Given PREFIX and DSC-FILE, process the file and returns the fields.