[Reproducible-commits] [dpkg] 06/32: scripts: Switch all find(1) command calls to File::Find
Jérémy Bobbio
lunar at moszumanska.debian.org
Fri Nov 6 14:02:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 3f8099b21bbb934d03c340fef1925824465e0571
Author: Guillem Jover <guillem at debian.org>
Date: Fri Oct 2 13:57:57 2015 +0200
scripts: Switch all find(1) command calls to File::Find
The find(1) command has subtle behavior differences depending on the
implementation (for example BSD vs GNU), the perl module is more portable
and has a more consistent behavior, such as always canonicalizing the
pathnames.
Closes: #800649
---
debian/changelog | 3 +++
scripts/dpkg-scanpackages.pl | 28 ++++++++++++++--------------
scripts/dpkg-scansources.pl | 15 ++++++++-------
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index f453856..ed5d6d8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
dpkg (1.18.4) UNRELEASED; urgency=low
[ Guillem Jover ]
+ * Switch dpkg-scansources and dpkg-scanpackages to use File::Find instead
+ of find(1), as the former is more portable with more consistent behavior,
+ and always canonicalizes the pathnames. Closes: #800649
* Documentation:
- Move description for “target architecture” from the dpkg-architecture(1)
‘-A’ option to the TERMS section. Closes: #799046
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index faf8ea2..7d7a121 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -21,6 +21,7 @@ use warnings;
use strict;
use Getopt::Long qw(:config posix_default bundling no_ignorecase);
+use File::Find;
use Dpkg ();
use Dpkg::Gettext;
@@ -230,15 +231,6 @@ foreach my $alg (keys %hash) {
}
}
-my @find_args;
-if ($options{arch}) {
- @find_args = ('(', '-name', "*_all.$type", '-o',
- '-name', "*_${arch}.$type", ')');
-}
-else {
- @find_args = ('-name', "*.$type");
-}
-
my ($binarydir, $override, $pathprefix) = @ARGV;
if (not -d $binarydir) {
@@ -250,13 +242,21 @@ if (defined $override and not -e $override) {
$pathprefix //= '';
-open my $find_h, '-|', 'find', '-L', "$binarydir/", @find_args, '-print'
- or syserr(g_("couldn't open %s for reading"), $binarydir);
-while (my $fn = <$find_h>) {
- chomp $fn;
+my $find_filter;
+if ($options{arch}) {
+ $find_filter = qr/_(?:all|${arch})\.$type$/;
+} else {
+ $find_filter = qr/\.$type$/;
+}
+my @archives;
+my $scan_archives = sub {
+ push @archives, $File::Find::name if m/$find_filter/;
+};
+
+find({ follow => 1, wanted => $scan_archives}, $binarydir);
+foreach my $fn (@archives) {
process_deb($pathprefix, $fn);
}
-close($find_h);
load_override($override) if defined $override;
load_override_extra($options{'extra-override'}) if defined $options{'extra-override'};
diff --git a/scripts/dpkg-scansources.pl b/scripts/dpkg-scansources.pl
index a823ab4..acd9e64 100755
--- a/scripts/dpkg-scansources.pl
+++ b/scripts/dpkg-scansources.pl
@@ -21,6 +21,7 @@ use strict;
use warnings;
use Getopt::Long qw(:config posix_default bundling no_ignorecase);
+use File::Find;
use Dpkg ();
use Dpkg::Gettext;
@@ -303,22 +304,22 @@ load_override $override if defined $override;
load_src_override $src_override, $override;
load_override_extra $extra_override_file if defined $extra_override_file;
-open my $find_fh, '-|', 'find', '-L', $dir, '-name', '*.dsc', '-print'
- or syserr(g_('cannot fork for %s'), 'find');
-while (<$find_fh>) {
- chomp;
- s{^\./+}{};
+my @dsc;
+my $scan_dsc = sub {
+ push @dsc, $File::Find::name if m/\.dsc$/;
+};
+find({ follow => 1, wanted => $scan_dsc }, $dir);
+foreach my $fn (@dsc) {
# FIXME: Fix it instead to not die on syntax and general errors?
eval {
- process_dsc($prefix, $_);
+ process_dsc($prefix, $fn);
};
if ($@) {
warn $@;
next;
}
}
-close $find_fh or syserr(g_('error closing %s (%s)'), 'find', $!);
if (not $no_sort) {
@sources = sort {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list