瀏覽代碼

dpkg-source: support unpacking old source packages lacking the Format field

.dsc files haven't always had a Format field. It was introduced in dpkg
1.6.13, in May 2000. This means that it's still not entirely
implausible to run across source packages without Format, for example
when importing the history of a source package into revision control.

Thus, dpkg-source should treat a missing Format field as 1.0, for
compatibility with these old packages.
Colin Watson 16 年之前
父節點
當前提交
3d2e2cbed0
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 6 0
      debian/changelog
  2. 3 1
      scripts/Dpkg/Source/Package.pm

+ 6 - 0
debian/changelog

@@ -1,11 +1,17 @@
 dpkg (1.15.6.1) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
   * Fix two memory leaks introduced in 1.15.6.
   * Always use C99 variadic macros, as the build requires them anyway, we
     avoid exposing the configure variable HAVE_C99 on installed headers.
   * Use __attribute__ keyword depending on compiler support, we avoid
     exposing the configure variable HAVE_C_ATTRIBUTE on installed headers.
 
+  [ Raphaël Hertzog ]
+  * Accept source packages without "Format" field for compatibility with very
+    old source packages. Thanks to Colin Watson for the report and the patch.
+    Closes: #574097
+
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).
 

+ 3 - 1
scripts/Dpkg/Source/Package.pm

@@ -144,7 +144,7 @@ sub initialize {
     $fields->load($filename);
     $self->{'fields'} = $fields;
 
-    foreach my $f (qw(Source Format Version Files)) {
+    foreach my $f (qw(Source Version Files)) {
         unless (defined($fields->{$f})) {
             error(_g("missing critical source control field %s"), $f);
         }
@@ -158,6 +158,8 @@ sub initialize {
 sub upgrade_object_type {
     my ($self, $update_format) = @_;
     $update_format = 1 unless defined $update_format;
+    $self->{'fields'}{'Format'} = '1.0'
+        unless exists $self->{'fields'}{'Format'};
     my $format = $self->{'fields'}{'Format'};
 
     if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) {