Просмотр исходного кода

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 лет назад: 15
Родитель
Сommit
7c2df89844
2 измененных файлов с 5 добавлено и 0 удалено
  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
     options from the returned build flags.
   * 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 ]
   * 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::ErrorHandling;
 use Dpkg::Compression;
+use Dpkg::Exit;
 use Dpkg::Source::Archive;
 use Dpkg::Source::Functions qw(erasedir);
 
@@ -84,6 +85,7 @@ sub do_build {
 
     my ($ntfh, $newtar) = tempfile("$tarname.new.XXXXXX",
                                    DIR => getcwd(), UNLINK => 0);
+    push @Dpkg::Exit::handlers, sub { unlink($newtar) };
 
     my ($dirname, $dirbase) = fileparse($dir);
     my $tar = Dpkg::Source::Archive->new(filename => $newtar,
@@ -95,6 +97,7 @@ sub do_build {
     rename($newtar, $tarname) ||
         syserr(_g("unable to rename `%s' (newly created) to `%s'"),
                $newtar, $tarname);
+    pop @Dpkg::Exit::handlers;
     chmod(0666 &~ umask(), $tarname) ||
         syserr(_g("unable to change permission of `%s'"), $tarname);