Parcourir la source

dpkg-source: clean up temporary file in case of interruption

Navite packages (both "1.0" and "3.0 (native)") failed to remove
the temporary tarball if the process is interrupted during its
generation.

Reported-by: Cyril Brulebois <kibi@debian.org>
Raphaël Hertzog il y a 15 ans
Parent
commit
7c2df89844
2 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 2 0
      debian/changelog
  2. 3 0
      scripts/Dpkg/Source/Package/V3/native.pm

+ 2 - 0
debian/changelog

@@ -96,6 +96,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     extend the build flags to use. Last but not least, it can now also strip
     extend the build flags to use. Last but not least, it can now also strip
     options from the returned build flags.
     options from the returned build flags.
   * Fix possible segfault of dpkg in findbreakcycle(). LP: #733414
   * Fix possible segfault of dpkg in findbreakcycle(). LP: #733414
+  * dpkg-source now properly cleans up the temporary tarball generated for
+    native formats in case of unexpected interruption. Closes: #631494
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 3 - 0
scripts/Dpkg/Source/Package/V3/native.pm

@@ -26,6 +26,7 @@ use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Compression;
 use Dpkg::Compression;
+use Dpkg::Exit;
 use Dpkg::Source::Archive;
 use Dpkg::Source::Archive;
 use Dpkg::Source::Functions qw(erasedir);
 use Dpkg::Source::Functions qw(erasedir);
 
 
@@ -84,6 +85,7 @@ sub do_build {
 
 
     my ($ntfh, $newtar) = tempfile("$tarname.new.XXXXXX",
     my ($ntfh, $newtar) = tempfile("$tarname.new.XXXXXX",
                                    DIR => getcwd(), UNLINK => 0);
                                    DIR => getcwd(), UNLINK => 0);
+    push @Dpkg::Exit::handlers, sub { unlink($newtar) };
 
 
     my ($dirname, $dirbase) = fileparse($dir);
     my ($dirname, $dirbase) = fileparse($dir);
     my $tar = Dpkg::Source::Archive->new(filename => $newtar,
     my $tar = Dpkg::Source::Archive->new(filename => $newtar,
@@ -95,6 +97,7 @@ sub do_build {
     rename($newtar, $tarname) ||
     rename($newtar, $tarname) ||
         syserr(_g("unable to rename `%s' (newly created) to `%s'"),
         syserr(_g("unable to rename `%s' (newly created) to `%s'"),
                $newtar, $tarname);
                $newtar, $tarname);
+    pop @Dpkg::Exit::handlers;
     chmod(0666 &~ umask(), $tarname) ||
     chmod(0666 &~ umask(), $tarname) ||
         syserr(_g("unable to change permission of `%s'"), $tarname);
         syserr(_g("unable to change permission of `%s'"), $tarname);