summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-30 06:54:44 +0800
committerGitHub <[email protected]>2024-08-30 06:54:44 +0800
commitf11f39bb069741340938f1e4fa9a977fcea27348 (patch)
tree8a7d8ffe0150dda5399a9db917eebf347d610c59
parent7336c8a5459d105febde0a2f43c02502bce30fc7 (diff)
parent12caa227186041198540a8f738168eba97d906b3 (diff)
Merge pull request #5540 from xmake-io/tar
use tar to extract .tar.gz
-rw-r--r--xmake/modules/utils/archive/extract.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua
index 3bb69ee1a..ff6d20e16 100644
--- a/xmake/modules/utils/archive/extract.lua
+++ b/xmake/modules/utils/archive/extract.lua
@@ -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
@@ -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
@@ -96,6 +97,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt)
else
os.vrunv(program, argv)
end
+
return true
end
@@ -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}
@@ -458,3 +461,4 @@ function main(archivefile, outputdir, opt)
-- extract it
return _extract(archivefile, outputdir, extension, extractors[extension], opt)
end
+