Skip to content

Commit

Permalink
Merge pull request #580 from ugexe/avoid-gnu-tar-remote-file
Browse files Browse the repository at this point in the history
Workaround gnu tar remote file feature
  • Loading branch information
ugexe authored Jan 7, 2025
2 parents 7dc3492 + e0b595a commit 48cbce8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Zef/Service/Shell/tar.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Zef::Service::Shell::tar does Extractor {
react {
my $cwd := $archive-file.parent;
my $ENV := %*ENV;
my $proc = Zef::zrun-async('tar', '-zxvf', $archive-file.basename, '-C', $extract-to.relative($cwd));
my $proc = Zef::zrun-async('tar', '-zxvf', self!cli-path($archive-file.basename), '-C', $extract-to.relative($cwd));
$stdout.emit("Command: {$proc.command}");
whenever $proc.stdout(:bin) { }
whenever $proc.stderr(:bin) { }
Expand All @@ -141,7 +141,7 @@ class Zef::Service::Shell::tar does Extractor {
react {
my $cwd := $archive-file.parent;
my $ENV := %*ENV;
my $proc = Zef::zrun-async('tar', '-zt', '-f', $archive-file.basename);
my $proc = Zef::zrun-async('tar', '-zt', '-f', self!cli-path($archive-file.basename));
$stdout.emit("Command: {$proc.command}");
whenever $proc.stdout(:bin) { $output.append($_) }
whenever $proc.stderr(:bin) { }
Expand All @@ -151,4 +151,13 @@ class Zef::Service::Shell::tar does Extractor {
my @extracted-paths = $output.decode.lines;
$passed ?? @extracted-paths.grep(*.defined) !! ();
}

# Workaround for https://github.com/ugexe/zef/issues/444
# We could alternative use --force-local but that requires figuring out which
# flavor of tar we're using.
# Expects $path to already be a relative path string (not an absolute path)
method !cli-path(Str $path --> Str) {
return $path if <./ ../ .\\ ..\\>.grep({ $path.starts-with($_) });
return './' ~ $path;
}
}

0 comments on commit 48cbce8

Please sign in to comment.