Skip to content

Commit f11f39b

Browse files
authored
Merge pull request #5540 from xmake-io/tar
use tar to extract .tar.gz
2 parents 7336c8a + 12caa22 commit f11f39b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xmake/modules/utils/archive/extract.lua

+8-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ end
3939
-- extract archivefile using tar
4040
function _extract_using_tar(archivefile, outputdir, extension, opt)
4141

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

@@ -69,7 +70,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt)
6970
end
7071
end
7172
table.insert(argv, "-xf")
72-
table.insert(argv, archivefile)
73+
table.insert(argv, path.absolute(archivefile))
7374

7475
-- ensure output directory
7576
if not os.isdir(outputdir) then
@@ -96,6 +97,7 @@ function _extract_using_tar(archivefile, outputdir, extension, opt)
9697
else
9798
os.vrunv(program, argv)
9899
end
100+
99101
return true
100102
end
101103

@@ -425,7 +427,8 @@ function main(archivefile, outputdir, opt)
425427
, [".tgz"] = {_extract_using_7z, _extract_using_tar}
426428
, [".bz2"] = {_extract_using_7z, _extract_using_bzip2}
427429
, [".tar"] = {_extract_using_7z, _extract_using_tar}
428-
, [".tar.gz"] = {_extract_using_7z, _extract_using_gzip}
430+
-- @see https://github.com/xmake-io/xmake/issues/5538
431+
, [".tar.gz"] = {_extract_using_tar, _extract_using_7z, _extract_using_gzip}
429432
, [".tar.xz"] = {_extract_using_7z, _extract_using_xz}
430433
, [".tar.bz2"] = {_extract_using_7z, _extract_using_bzip2}
431434
, [".tar.lz"] = {_extract_using_7z}
@@ -458,3 +461,4 @@ function main(archivefile, outputdir, opt)
458461
-- extract it
459462
return _extract(archivefile, outputdir, extension, extractors[extension], opt)
460463
end
464+

0 commit comments

Comments
 (0)