Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for the existence of xzcat #152

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading