Skip to content

Commit 3a3a7c8

Browse files
committed
Fix race condition in realclean by depping clean off realclean_subdirs
1 parent afbb9a1 commit 3a3a7c8

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

lib/ExtUtils/MM_Any.pm

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use File::Basename;
99
BEGIN { our @ISA = qw(File::Spec); }
1010

1111
# We need $Verbose
12-
use ExtUtils::MakeMaker qw($Verbose write_file_via_tmp neatvalue);
12+
use ExtUtils::MakeMaker qw($Verbose write_file_via_tmp neatvalue _sprintf562);
1313

1414
use ExtUtils::MakeMaker::Config;
1515

@@ -1745,7 +1745,7 @@ sub realclean {
17451745

17461746
my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
17471747
# Delete temporary files (via clean) and also delete dist files
1748-
realclean purge :: clean realclean_subdirs
1748+
realclean purge :: realclean_subdirs
17491749
%s
17501750
%s
17511751
MAKE
@@ -1767,28 +1767,20 @@ target to call realclean on any subdirectories which contain Makefiles.
17671767

17681768
sub realclean_subdirs_target {
17691769
my $self = shift;
1770-
1771-
return <<'NOOP_FRAG' unless @{$self->{DIR}};
1772-
realclean_subdirs :
1773-
$(NOECHO) $(NOOP)
1774-
NOOP_FRAG
1775-
1776-
my $rclean = "realclean_subdirs :\n";
1777-
1770+
my @m = <<'EOF';
1771+
# so clean is forced to complete before realclean_subdirs runs
1772+
realclean_subdirs : clean
1773+
EOF
1774+
return join '', @m, "\t\$(NOECHO) \$(NOOP)\n" unless @{$self->{DIR}};
17781775
foreach my $dir (@{$self->{DIR}}) {
17791776
foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
1780-
my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
1781-
chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
1777+
my $subrclean .= $self->oneliner(_sprintf562 <<'CODE', $dir, $makefile);
1778+
chdir '%1$s'; system '$(MAKE) $(USEMAKEFILE) %2$s realclean' if -f '%2$s';
17821779
CODE
1783-
1784-
$rclean .= sprintf <<'RCLEAN', $subrclean;
1785-
- %s
1786-
RCLEAN
1787-
1780+
push @m, "\t- $subrclean\n";
17881781
}
17891782
}
1790-
1791-
return $rclean;
1783+
return join '', @m;
17921784
}
17931785

17941786

0 commit comments

Comments
 (0)