Skip to content

Commit

Permalink
Merge pull request #152 from flavorjones/flavorjones-check-xzcat-pres…
Browse files Browse the repository at this point in the history
…ence

Check for the existence of xzcat
  • Loading branch information
flavorjones authored Nov 14, 2024
2 parents 3b06384 + a51c1d6 commit e049576
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ def tar_exe
end
end

def xzcat_exe
@@xzcat_exe ||= which("xzcat") ? "xzcat" : raise("xzcat not found")
end

def tar_command(file, target)
case File.extname(file)
when '.gz', '.tgz'
Expand All @@ -561,7 +565,7 @@ def tar_command(file, target)
[tar_exe, 'xjf', file, '-C', target]
when '.xz'
# NOTE: OpenBSD's tar command does not support the -J option
"xzcat #{file.shellescape} | #{tar_exe.shellescape} xf - -C #{target.shellescape}"
"#{xzcat_exe.shellescape} #{file.shellescape} | #{tar_exe.shellescape} xf - -C #{target.shellescape}"
else
[tar_exe, 'xf', file, '-C', target]
end
Expand Down

0 comments on commit e049576

Please sign in to comment.