Skip to content

Commit

Permalink
Check for the existence of xzcat
Browse files Browse the repository at this point in the history
and emit a readable error if it doesn't exist
  • Loading branch information
flavorjones committed Nov 14, 2024
1 parent 3b06384 commit a51c1d6
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 a51c1d6

Please sign in to comment.