Parcourir la source

dpkg-source: verify version of the quilt metadata before build

Since format "3.0 (quilt)" can now modify the content of the .pc
directory, ensure it still uses the supported format (currently version
2). Add an option --allow-version-of-quilt-db=<ver> to be able
to force creation of a source package despite the unexpected version.
Raphaël Hertzog il y a 16 ans
Parent
commit
59931a5c45
2 fichiers modifiés avec 36 ajouts et 0 suppressions
  1. 8 0
      man/dpkg-source.1
  2. 28 0
      scripts/Dpkg/Source/Package/V3/quilt.pm

+ 8 - 0
man/dpkg-source.1

@@ -441,6 +441,14 @@ behaviour.
 .PP
 .B Build options
 .TP
+.BI \-\-allow\-version\-of\-quilt\-db= version
+Allow \fBdpkg\-source\fP to build the source package if the version of
+the quilt metadata is the one specified, even if \fBdpkg\-source\fP
+doesn't know about it. Effectively this says that the given version of the
+quilt metadata is compatible with the version 2 that \fBdpkg\-source\fP
+currently supports. The version of the quilt metadata is stored in
+\fB.pc/.version\fP.
+.TP
 .B \-\-include\-removal
 Do not ignore removed files and include them in the automatically
 generated patch.

+ 28 - 0
scripts/Dpkg/Source/Package/V3/quilt.pm

@@ -42,6 +42,8 @@ sub init_options {
     my ($self) = @_;
     $self->{'options'}{'single-debian-patch'} = 0
         unless exists $self->{'options'}{'single-debian-patch'};
+    $self->{'options'}{'allow-version-of-quilt-db'} = []
+        unless exists $self->{'options'}{'allow-version-of-quilt-db'};
 
     $self->SUPER::init_options();
 }
@@ -52,6 +54,9 @@ sub parse_cmdline_option {
     if ($opt =~ /^--single-debian-patch$/) {
         $self->{'options'}{'single-debian-patch'} = 1;
         return 1;
+    } elsif ($opt =~ /^--allow-version-of-quilt-db=(.*)$/) {
+        push @{$self->{'options'}{'allow-version-of-quilt-db'}}, $1;
+        return 1;
     }
     return 0;
 }
@@ -216,6 +221,29 @@ sub prepare_build {
     $self->{'diff_options'}{'diff_ignore_func'} = $func;
 }
 
+sub do_build {
+    my ($self, $dir) = @_;
+    my $pc_ver = File::Spec->catfile($dir, ".pc", ".version");
+    if (-f $pc_ver) {
+        open(VER, "<", $pc_ver) || syserr(_g("cannot read %s"), $pc_ver);
+        my $version = <VER>;
+        chomp $version;
+        close(VER);
+        if ($version != 2) {
+            if (scalar grep { $version eq $_ }
+                @{$self->{'options'}{'allow-version-of-quilt-db'}})
+            {
+                warning(_g("unsupported version of the quilt metadata: %s"),
+                        $version);
+            } else {
+                error(_g("unsupported version of the quilt metadata: %s"),
+                      $version);
+            }
+        }
+    }
+    $self->SUPER::do_build($dir);
+}
+
 sub check_patches_applied {
     my ($self, $dir) = @_;
     my $pc_applied = File::Spec->catfile($dir, ".pc", "applied-patches");