The following commit has been merged in the sourcev3 branch:
commit 52361409ba4dc0a3eb9700bc8ef7151292d5f450
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date:   Fri Mar 14 19:32:04 2008 +0100

    Dpkg::Source::Package::V3_0::quilt: Add fallback when quilt is not available
    
    * scripts/Dpkg/Source/Package/V3_0/quilt.pm: Check for quilt availability
    before using it to apply patches. Otherwise resort to using
    Dpkg::Source::Patch to apply patches.

diff --git a/scripts/Dpkg/Source/Package/V3_0/quilt.pm 
b/scripts/Dpkg/Source/Package/V3_0/quilt.pm
index 1264767..c9db072 100644
--- a/scripts/Dpkg/Source/Package/V3_0/quilt.pm
+++ b/scripts/Dpkg/Source/Package/V3_0/quilt.pm
@@ -70,6 +70,9 @@ sub get_patches {
 sub apply_patches {
     my ($self, $dir, $skip_auto) = @_;
 
+    # Check if quilt is available
+    my $have_quilt = (-x "/usr/bin/quilt") ? 1 : 0;
+
     # 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
@@ -87,25 +90,31 @@ sub apply_patches {
     my $now = time();
     foreach my $patch ($self->get_patches($dir, $skip_auto)) {
         my $path = File::Spec->catfile($dir, "debian", "patches", $patch);
-        info(_g("applying %s"), $patch) unless $skip_auto;
         my $patch_obj = Dpkg::Source::Patch->new(filename => $path);
-        my $analysis = $patch_obj->analyze($dir);
-        foreach my $dir (keys %{$analysis->{'dirtocreate'}}) {
-            eval { mkpath($dir); };
-            syserr(_g("cannot create directory %s"), $dir) if $@;
-        }
-        my %opts = (
-            env => { QUILT_PATCHES => 'debian/patches' },
-            delete_env => [ 'QUILT_PATCH_OPTS' ],
-            'chdir' => $dir,
-            'exec' => [ 'quilt', '--quiltrc', '/dev/null', 'push', $patch ],
-            wait_child => 1,
-            to_file => '/dev/null',
-        );
-        fork_and_exec(%opts);
-        foreach my $fn (keys %{$analysis->{'filepatched'}}) {
-            utime($now, $now, $fn) ||
-                syserr(_g("cannot change timestamp for %s"), $fn);
+        if ($have_quilt) {
+            info(_g("applying %s with quilt"), $patch) unless $skip_auto;
+            my $analysis = $patch_obj->analyze($dir);
+            foreach my $dir (keys %{$analysis->{'dirtocreate'}}) {
+                eval { mkpath($dir); };
+                syserr(_g("cannot create directory %s"), $dir) if $@;
+            }
+            my %opts = (
+                env => { QUILT_PATCHES => 'debian/patches' },
+                delete_env => [ 'QUILT_PATCH_OPTS' ],
+                'chdir' => $dir,
+                'exec' => [ 'quilt', '--quiltrc', '/dev/null', 'push', $patch 
],
+                wait_child => 1,
+                to_file => '/dev/null',
+            );
+            fork_and_exec(%opts);
+            foreach my $fn (keys %{$analysis->{'filepatched'}}) {
+                utime($now, $now, $fn) ||
+                    syserr(_g("cannot change timestamp for %s"), $fn);
+            }
+        } else {
+            info(_g("applying %s"), $patch) unless $skip_auto;
+            $patch_obj->apply($dir, timestamp => $now,
+                    force_timestamp => 1, create_dirs => 1);
         }
     }
 }
@@ -128,7 +137,7 @@ sub prepare_build {
 sub register_autopatch {
     my ($self, $dir) = @_;
     my $auto_patch = $self->get_autopatch_name();
-    my $has_patch = grep(/\/\Q$auto_patch\E$/, $self->get_patches($dir)) ? 1 : 
0;
+    my $has_patch = (grep { $_ eq $auto_patch } $self->get_patches($dir)) ? 1 
: 0;
     my $series = $self->get_series_file($dir);
     $series ||= File::Spec->catfile($dir, "debian", "patches", "series");
     if (-e "$dir/debian/patches/$auto_patch") {

-- 
dpkg's main repository


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

Reply via email to