Browse Source

dpkg-source: unpacking a 3.0 (quilt) source package configures quilt accordingly

The files .pc/.quilt_patches and .pc/.quilt_series are always created so
that any quilt invocation will know where to look for (or where to store)
patches. This will only work with quilt >= 0.48-5.
Raphaël Hertzog 16 years ago
parent
commit
bf8ff0cd3d
2 changed files with 25 additions and 4 deletions
  1. 3 0
      debian/changelog
  2. 22 4
      scripts/Dpkg/Source/Package/V3/quilt.pm

+ 3 - 0
debian/changelog

@@ -20,6 +20,9 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * Accept filename with spaces and colon in the output of objdump.
     Required so that dpkg-shlibdeps support such files properly.
     Thanks to Raphaël Geissert for the patch. Closes: #565712
+  * When unpacking a "3.0 (quilt)" source package, tell quilt where
+    patches are (to be) stored. Requires quilt >= 0.48-5 to work.
+    Closes: #557619
 
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages

+ 22 - 4
scripts/Dpkg/Source/Package/V3/quilt.pm

@@ -133,12 +133,27 @@ sub create_quilt_db {
     if (not -d $db_dir) {
         mkdir $db_dir or syserr(_g("cannot mkdir %s"), $db_dir);
     }
-    my $version_file = File::Spec->catfile($db_dir, ".version");
-    if (not -e $version_file) {
-        open(VERSION, ">", $version_file);
+    my $file = File::Spec->catfile($db_dir, ".version");
+    if (not -e $file) {
+        open(VERSION, ">", $file) or syserr(_g("cannot write %s"), $file);
         print VERSION "2\n";
         close(VERSION);
     }
+    # The files below are used by quilt to know where patches are stored
+    # and what file contains the patch list (supported by quilt >= 0.48-5
+    # in Debian).
+    $file = File::Spec->catfile($db_dir, ".quilt_patches");
+    if (not -e $file) {
+        open(QPATCH, ">", $file) or syserr(_g("cannot write %s"), $file);
+        print QPATCH "debian/patches\n";
+        close(QPATCH);
+    }
+    $file = File::Spec->catfile($db_dir, ".quilt_series");
+    if (not -e $file) {
+        open(QSERIES, ">", $file) or syserr(_g("cannot write %s"), $file);
+        print QSERIES "series\n";
+        close(QSERIES);
+    }
 }
 
 sub apply_quilt_patch {
@@ -174,6 +189,10 @@ sub apply_patches {
 
     my $patches = $opts{"patches"};
 
+    # Always create the quilt db so that if the maintainer calls quilt to
+    # create a patch, it's stored in the right directory
+    $self->create_quilt_db($dir);
+
     # Update debian/patches/series symlink if needed to allow quilt usage
     my $series = $self->get_series_file($dir);
     return unless $series; # No series, no patches
@@ -193,7 +212,6 @@ sub apply_patches {
     return unless scalar(@$patches);
 
     # Apply patches
-    $self->create_quilt_db($dir);
     my $pc_applied = File::Spec->catfile($dir, ".pc", "applied-patches");
     my @applied = $self->read_patch_list($pc_applied);
     my @patches = $self->read_patch_list($self->get_series_file($dir));