Skip to content

Commit

Permalink
Merge pull request #5540 from xmake-io/tar
Browse files Browse the repository at this point in the history
use tar to extract .tar.gz
  • Loading branch information
waruqi authored Aug 29, 2024
2 parents 7336c8a + 12caa22 commit f11f39b
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit f11f39b

Please sign in to comment.