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

dpkg-source: Add a new extraction --ignore-bad-version option

This allows to extract ancient source packages with broken versions,
that used to be accepted at some point in time by dpkg-source.

Closes: #740883
Guillem Jover лет назад: 12
Родитель
Сommit
b916e61f0f

+ 2 - 0
debian/changelog

@@ -30,6 +30,8 @@ dpkg (1.17.7) UNRELEASED; urgency=low
   * Improve dpkg-source warning message when ignoring file removals,
     by adding a hint about the --include-removal option.
     Thanks to Moritz Muehlenhoff <jmm@debian.org>. Closes: #738310
+  * Add a new dpkg-source extraction --ignore-bad-version option.
+    Closes: #740883
 
   [ Updated dpkg translations ]
   * German (Sven Joachim).

+ 5 - 0
man/dpkg-source.1

@@ -250,6 +250,11 @@ signature that can be verified either with the user's
 of the official Debian keyrings
 (\fI/usr/share/keyrings/debian\-keyring.gpg\fP
 and \fI/usr/share/keyrings/debian\-maintainers.gpg\fP).
+.TP
+.B \-\-ignore\-bad\-version
+Turns the bad source package version check into a non-fatal warning.
+This option should only be necessary when extracting ancient source
+packages with broken versions, just for backwards compatibility.
 
 .SH SOURCE PACKAGE FORMATS
 If you don't know what source format to use, you should probably pick

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

@@ -463,7 +463,13 @@ sub extract {
     my $newdirectory = $_[0];
 
     my ($ok, $error) = version_check($self->{fields}{'Version'});
-    error($error) unless $ok;
+    if (not $ok) {
+        if ($self->{options}{ignore_bad_version}) {
+            warning($error);
+        } else {
+            error($error);
+        }
+    }
 
     # Copy orig tarballs
     if ($self->{options}{copy_orig_tarballs}) {

+ 4 - 0
scripts/Dpkg/Source/Package/V1.pm

@@ -53,6 +53,7 @@ sub init_options {
          'debian/source/local-patch-header';
     $self->{options}{sourcestyle} ||= 'X';
     $self->{options}{skip_debianization} ||= 0;
+    $self->{options}{ignore_bad_version} ||= 0;
     $self->{options}{abort_on_upstream_changes} ||= 0;
 
     # V1.0 only supports gzip compression.
@@ -73,6 +74,9 @@ sub parse_cmdline_option {
     } elsif ($opt =~ m/^--skip-debianization$/) {
         $o->{skip_debianization} = 1;
         return 1;
+    } elsif ($opt =~ m/^--ignore-bad-version$/) {
+        $o->{ignore_bad_version} = 1;
+        return 1;
     } elsif ($opt =~ m/^--abort-on-upstream-changes$/) {
         $o->{abort_on_upstream_changes} = 1;
         return 1;

+ 5 - 0
scripts/Dpkg/Source/Package/V2.pm

@@ -67,6 +67,8 @@ sub init_options {
         unless exists $self->{options}{create_empty_orig};
     $self->{options}{auto_commit} = 0
         unless exists $self->{options}{auto_commit};
+    $self->{options}{ignore_bad_version} = 0
+        unless exists $self->{options}{ignore_bad_version};
 }
 
 sub parse_cmdline_option {
@@ -104,6 +106,9 @@ sub parse_cmdline_option {
     } elsif ($opt =~ /^--auto-commit$/) {
         $self->{options}{auto_commit} = 1;
         return 1;
+    } elsif ($opt =~ /^--ignore-bad-version$/) {
+        $self->{options}{ignore_bad_version} = 1;
+        return 1;
     }
     return 0;
 }