Pārlūkot izejas kodu

dpkg-source: improve the logic to identify ignored files

The list of ignored files was only generated by expanding the patterns
relative to the current directory (which usually is the directory above
the source package). Instead what we want is to expand them at the
top-level directory of the source package and at the directory being
inspected.

Reported-by: Joachim Breitner <nomeata@debian.org>
Raphaël Hertzog 15 gadi atpakaļ
vecāks
revīzija
a9345899bd
2 mainītis faili ar 10 papildinājumiem un 3 dzēšanām
  1. 1 0
      debian/changelog
  2. 9 3
      scripts/Dpkg/Source/Package/V2.pm

+ 1 - 0
debian/changelog

@@ -56,6 +56,7 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     variables are meant for users and should not be used by packages.
     variables are meant for users and should not be used by packages.
   * update-alternatives: do not allow to reuse a slave link in another
   * update-alternatives: do not allow to reuse a slave link in another
     slave alternative. Closes: #631547
     slave alternative. Closes: #631547
+  * Improve dpkg-source's logic to identify ignored files. Closes: #632168
 
 
   [ 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

+ 9 - 3
scripts/Dpkg/Source/Package/V2.pm

@@ -417,9 +417,15 @@ sub do_build {
         # tarball due to ignores.
         # tarball due to ignores.
         my %exclude;
         my %exclude;
         my $reldir = File::Spec->abs2rel($File::Find::dir, $dir);
         my $reldir = File::Spec->abs2rel($File::Find::dir, $dir);
-        foreach my $fn (glob($tar_ignore_glob)) {
-            $exclude{$fn} = 1;
-        }
+        my $cwd = getcwd();
+        # Apply the pattern both from the top dir and from the inspected dir
+        chdir($dir) || syserr(_g("unable to chdir to `%s'"), $dir);
+        $exclude{$_} = 1 foreach glob($tar_ignore_glob);
+        chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
+        chdir($File::Find::dir) ||
+            syserr(_g("unable to chdir to `%s'"), $File::Find::dir);
+        $exclude{$_} = 1 foreach glob($tar_ignore_glob);
+        chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
         my @result;
         my @result;
         foreach my $fn (@_) {
         foreach my $fn (@_) {
             unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) {
             unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) {