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

use tar to extract .tar.gz #5540

Merged
merged 3 commits into from
Aug 29, 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
12 changes: 8 additions & 4 deletions xmake/modules/utils/archive/extract.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ end
-- extract archivefile using tar
function _extract_using_tar(archivefile, outputdir, extension, opt)

-- the tar of windows can only extract "*.tar"
if os.host() == "windows" and extension ~= ".tar" then
-- the tar on windows can only extract "*.tar", "*.tar.gz"
-- the tar on msys2 can extract more, like "*.tar.bz2", ..
if os.host() == "windows" and (extension ~= ".tar" and extension ~= ".tar.gz") then
return false
end

Expand Down Expand Up @@ -69,7 +70,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt)
end
end
table.insert(argv, "-xf")
table.insert(argv, archivefile)
table.insert(argv, path.absolute(archivefile))

-- ensure output directory
if not os.isdir(outputdir) then
Expand All @@ -96,6 +97,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt)
else
os.vrunv(program, argv)
end

return true
end

Expand Down Expand Up @@ -425,7 +427,8 @@ function main(archivefile, outputdir, opt)
, [".tgz"] = {_extract_using_7z, _extract_using_tar}
, [".bz2"] = {_extract_using_7z, _extract_using_bzip2}
, [".tar"] = {_extract_using_7z, _extract_using_tar}
, [".tar.gz"] = {_extract_using_7z, _extract_using_gzip}
-- @see https://github.com/xmake-io/xmake/issues/5538
, [".tar.gz"] = {_extract_using_tar, _extract_using_7z, _extract_using_gzip}
, [".tar.xz"] = {_extract_using_7z, _extract_using_xz}
, [".tar.bz2"] = {_extract_using_7z, _extract_using_bzip2}
, [".tar.lz"] = {_extract_using_7z}
Expand Down Expand Up @@ -458,3 +461,4 @@ function main(archivefile, outputdir, opt)
-- extract it
return _extract(archivefile, outputdir, extension, extractors[extension], opt)
end

Loading