The following commit has been merged in the lenny branch:
commit 54d097352de066053d253a9e49befb4ff4f76a29
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date:   Sat Jun 7 20:50:41 2008 +0200

    dpkg-source/3.0 (quilt): better registration of the automatic patch
    
    * scripts/Dpkg/Source/Package/V3/quilt.pm (register_autopatch):
    Register the newly created patch with quilt only if quilt has
    already been used to apply the existing patches (or if we don't
    have any patch yet), otherwise register it manually at the end of
    the series.

diff --git a/ChangeLog b/ChangeLog
index 0ced3bf..7226c04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-07  Raphael Hertzog  <[EMAIL PROTECTED]>
+
+       * scripts/Dpkg/Source/Package/V3/quilt.pm (register_autopatch):
+       Register the newly created patch with quilt only if quilt has
+       already been used to apply the existing patches (or if we don't
+       have any patch yet), otherwise register it manually at the end of
+       the series.
+
 2008-06-05  Raphael Hertzog  <[EMAIL PROTECTED]>
 
        * scripts/Dpkg/Source/Patch.pm (add_diff_directory): If option
diff --git a/scripts/Dpkg/Source/Package/V3/quilt.pm 
b/scripts/Dpkg/Source/Package/V3/quilt.pm
index 7cb8b60..7f3fae4 100644
--- a/scripts/Dpkg/Source/Package/V3/quilt.pm
+++ b/scripts/Dpkg/Source/Package/V3/quilt.pm
@@ -208,7 +208,8 @@ sub check_patches_applied {
 sub register_autopatch {
     my ($self, $dir) = @_;
     my $auto_patch = $self->get_autopatch_name();
-    my $has_patch = (grep { $_ eq $auto_patch } $self->get_patches($dir)) ? 1 
: 0;
+    my @patches = $self->get_patches($dir);
+    my $has_patch = (grep { $_ eq $auto_patch } @patches) ? 1 : 0;
     my $series = $self->get_series_file($dir);
     $series ||= File::Spec->catfile($dir, "debian", "patches", "series");
     my $applied = File::Spec->catfile($dir, "debian", "patches", 
".dpkg-source-applied");
@@ -216,11 +217,12 @@ sub register_autopatch {
     if (-e $patch) {
         # Add auto_patch to series file
         if (not $has_patch) {
-            if ($self->{'options'}{'without_quilt'}) {
-                open(SERIES, ">>", $series) || syserr(_g("cannot write %s"), 
$series);
-                print SERIES "$auto_patch\n";
-                close(SERIES);
-            } else {
+            # Use quilt to register only if it's wanted/available AND :
+            # - either we have patches and quilt has been used (.pc dir exists)
+            # - or we don't have patches, hence quilt couldn't be used
+            if ((-d "$dir/.pc" or not scalar(@patches)) and
+                not $self->{'options'}{'without_quilt'})
+            {
                 # Registering the new patch with quilt requires some
                 # trickery: reverse-apply the patch, import it, apply it
                 # again with quilt this time
@@ -229,6 +231,10 @@ sub register_autopatch {
                 $self->run_quilt($dir, ['import', 
"debian/patches/$auto_patch"],
                                  wait_child => 1, to_file => '/dev/null');
                 $self->run_quilt($dir, ['push'], wait_child => 1, to_file => 
'/dev/null');
+            } else {
+                open(SERIES, ">>", $series) || syserr(_g("cannot write %s"), 
$series);
+                print SERIES "$auto_patch\n";
+                close(SERIES);
             }
             open(APPLIED, ">>", $applied) || syserr(_g("cannot write %s"), 
$applied);
             print APPLIED "$auto_patch\n";

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to