Kaynağa Gözat

dpkg-source (2.0/3.0 (quilt)): create stamp file with automatic patch

* scripts/Dpkg/Source/Package/V2.pm,
scripts/Dpkg/Source/Package/V3/quilt.pm: Ensure the
.dpkg-source-applied stamp file is created when an automatic patch
is created so that a second build doesn't try to mistakenly
reapply it.
Raphael Hertzog 18 yıl önce
ebeveyn
işleme
36ac590f5f

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-05-08  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Source/Package/V2.pm,
+	scripts/Dpkg/Source/Package/V3/quilt.pm: Ensure the
+	.dpkg-source-applied stamp file is created when an automatic patch
+	is created so that a second build doesn't try to mistakenly
+	reapply it.
+
 2008-05-08  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/Dpkg/Source/Functions.pm (is_binary): New function

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

@@ -386,6 +386,14 @@ sub do_build {
 
 sub register_autopatch {
     my ($self, $dir) = @_;
+    my $autopatch = File::Spec->catfile($dir, "debian", "patches",
+                                        $self->get_autopatch_name());
+    if (-e $autopatch) {
+        my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
+        open(APPLIED, '>>', $applied) || syserr(_g("cannot write %s"), $applied);
+        print APPLIED ($self->get_autopatch_name() . "\n");
+        close(APPLIED);
+    }
 }
 
 # vim:et:sw=4:ts=8

+ 8 - 2
scripts/Dpkg/Source/Package/V3/quilt.pm

@@ -204,8 +204,10 @@ sub check_patches_applied {
         return;
     }
     unless (-e $applied) {
-        warning(_g("patches have not been applied, applying them now (use --no-preparation to override)"));
-        $self->apply_patches($dir);
+        if (scalar($self->get_patches($dir))) {
+            warning(_g("patches have not been applied, applying them now (use --no-preparation to override)"));
+            $self->apply_patches($dir);
+        }
     }
 }
 
@@ -215,12 +217,16 @@ sub register_autopatch {
     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");
+    my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
     if (-e "$dir/debian/patches/$auto_patch") {
         # Add auto_patch to series file
         if (not $has_patch) {
             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";
+            close(APPLIED);
         }
     } else {
         # Remove auto_patch from series