From 9d9673d3eb54aacb2f37c6b1f6425ea9f267c119 Mon Sep 17 00:00:00 2001 From: Shiffted Date: Thu, 11 Jun 2026 00:49:37 +0200 Subject: pass explicit tar compression flags --- xmake/modules/utils/archive/extract.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index a11f4146f..8116617fb 100644 --- a/xmake/modules/utils/archive/extract.lua +++ b/xmake/modules/utils/archive/extract.lua @@ -65,6 +65,25 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) table.insert(argv, "--force-local") end end + + if is_host("bsd") then + -- pass explicit compression flag only to tar without auto-detection, + -- as auto-detection can handle more cases. + local auto_detect = _g.compression_auto_detect + if auto_detect == nil then + auto_detect = try { function () os.runv(program, {"--version"}); return true end } or false + _g.compression_auto_detect = auto_detect + end + if not auto_detect then + if extension == ".tgz" or extension == ".tar.gz" then + table.insert(argv, "-z") + elseif extension == ".tar.bz2" then + table.insert(argv, "-j") + elseif extension == ".tar.Z" then + table.insert(argv, "-Z") + end + end + end table.insert(argv, "-xf") table.insert(argv, path.absolute(archivefile)) -- cgit v1.3.1