From 2be67f301013b092c299f4d3c0fe61bd6d690f92 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 30 Aug 2024 00:44:06 +0800 Subject: [PATCH 1/3] use tar to extract .tar.gz --- xmake/modules/utils/archive/extract.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index 3bb69ee1a35..6736b6f9ea1 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" or extension == ".tar.gz") then return false end @@ -425,7 +426,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} From ed50eae6d3d30d0071e612aec6d9c446b578b0d3 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 30 Aug 2024 00:55:04 +0800 Subject: [PATCH 2/3] improve tar --- xmake/modules/utils/archive/extract.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index 6736b6f9ea1..c77ffc1ac8f 100644 --- a/xmake/modules/utils/archive/extract.lua +++ b/xmake/modules/utils/archive/extract.lua @@ -41,7 +41,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) -- 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" or extension == ".tar.gz") then + if os.host() == "windows" and (extension ~= ".tar" and extension ~= ".tar.gz") then return false end @@ -69,8 +69,12 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) table.insert(argv, "--force-local") end end - table.insert(argv, "-xf") - table.insert(argv, archivefile) + if option.get("verbose") then + table.insert(argv, "-xvf") + else + table.insert(argv, "-xf") + end + table.insert(argv, path.absolute(archivefile)) -- ensure output directory if not os.isdir(outputdir) then @@ -97,6 +101,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) else os.vrunv(program, argv) end + return true end @@ -460,3 +465,4 @@ function main(archivefile, outputdir, opt) -- extract it return _extract(archivefile, outputdir, extension, extractors[extension], opt) end + From 12caa227186041198540a8f738168eba97d906b3 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 30 Aug 2024 00:59:04 +0800 Subject: [PATCH 3/3] remove verbose for tar --- xmake/modules/utils/archive/extract.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index c77ffc1ac8f..ff6d20e1696 100644 --- a/xmake/modules/utils/archive/extract.lua +++ b/xmake/modules/utils/archive/extract.lua @@ -69,11 +69,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) table.insert(argv, "--force-local") end end - if option.get("verbose") then - table.insert(argv, "-xvf") - else - table.insert(argv, "-xf") - end + table.insert(argv, "-xf") table.insert(argv, path.absolute(archivefile)) -- ensure output directory