Skip to content

Commit f1ca317

Browse files
committed
patch without a shell, fix ci
1 parent d1e7e39 commit f1ca317

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

lib/Perl/Dist/APPerl.pm

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,22 +973,28 @@ sub Set {
973973
} else {
974974
my $tarball_name = basename($itemconfig->{perl_url});
975975
my $download_dir = $UserProjectConfig->{apperl_output};
976+
print "mkdir -p $download_dir\n";
977+
make_path($download_dir);
976978
chdir($download_dir) or die "Failed to enter download dir";
977979
if (! -f $tarball_name) {
978980
_command_or_die('wget', $itemconfig->{perl_url});
979981
}
980982
_command_or_die('tar', '-xf', $tarball_name);
981-
_command_or_die("rm", '-rf', $perl_build_dir);
983+
print "rm -rf $perl_build_dir\n";
984+
remove_tree($perl_build_dir);
982985
my ($version) = $tarball_name =~ /^v(\d+\.\d+\.\d+)\.tar/;
986+
my $perl_build_dir_dir = dirname($perl_build_dir);
987+
print "mkdir -p $perl_build_dir_dir\n";
988+
make_path($perl_build_dir_dir);
983989
my $tomove = "perl5-$version";
984-
_command_or_die('mv', $tomove, $perl_build_dir);
985-
chdir($perl_build_dir) or die "Failed to enter perl repo";
990+
print "mv $tomove $perl_build_dir\n";
991+
move($tomove, $perl_build_dir) or die "Failed to move perl src";
992+
chdir($perl_build_dir) or die "Failed to enter perl build_dir";
986993
}
987994
foreach my $patch (@{$itemconfig->{patches}}) {
988995
my $realpatch = _fix_bases($patch, {__sharedir__ => SHARE_DIR});
989-
my $cmd = "patch -p1 < $realpatch"; # can't git apply to ignored files within a git repository :(
990-
print "$cmd\n";
991-
system($cmd) == 0 or die "failed to apply patch $realpatch";
996+
# can't `git apply` to ignored files within a git repository :(
997+
_cmdinputfile_or_die('patch', '-p1', $realpatch);
992998
}
993999
print "cd ".START_WD."\n";
9941000
chdir(START_WD) or die "Failed to restore cwd";
@@ -1478,7 +1484,7 @@ END_USAGE
14781484

14791485
sub _command_or_die {
14801486
print join(' ', @_), "\n";
1481-
system(@_) == 0 or die;
1487+
(system { $_[0] } @_) == 0 or die;
14821488
}
14831489

14841490
sub _cmdoutput_or_die {
@@ -1490,6 +1496,19 @@ sub _cmdoutput_or_die {
14901496
return $output;
14911497
}
14921498

1499+
sub _cmdinputfile_or_die {
1500+
my $input_file = pop @_;
1501+
print join(' ', @_), " < $input_file\n";
1502+
my $kid = fork() // die "forking failed";
1503+
if ($kid == 0) {
1504+
open(STDIN, '<', $input_file) or die "Can't dup to STDIN";
1505+
exec { $_[0] } @_;
1506+
die "exec failed"
1507+
}
1508+
waitpid($kid, 0);
1509+
(($? >> 8) == 0) or die("child failed");
1510+
}
1511+
14931512
sub _setup_repo {
14941513
my ($repopath, $remotes) = @_;
14951514
print "mkdir -p $repopath\n";

0 commit comments

Comments
 (0)