summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShifftC <[email protected]>2025-01-27 15:34:23 +0100
committerShifftC <[email protected]>2025-01-27 16:10:45 +0100
commitc775dcb940f93f5254d487d825ae0c33085a1d91 (patch)
treedd030d7b13c4625d31663539ff96ecb3b47f0ead
parent56162130cb62ff02fe27a9978efc687934673a5f (diff)
Forward 'archive.extract' errors
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua19
-rw-r--r--xmake/modules/private/action/require/impl/actions/download_resources.lua17
-rw-r--r--xmake/modules/private/action/require/impl/actions/patch_sources.lua17
3 files changed, 45 insertions, 8 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 47a8bf124..13a81698e 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -220,7 +220,20 @@ function _download(package, url, sourcedir, opt)
local sourcedir_tmp = sourcedir .. ".tmp"
os.rm(sourcedir_tmp)
local extension = archive.extension(packagefile)
- local ok = try {function() archive.extract(packagefile, sourcedir_tmp, {excludes = opt.url_excludes}); return true end}
+ local errors
+ local ok = try {
+ function()
+ archive.extract(packagefile, sourcedir_tmp, {excludes = opt.url_excludes})
+ return true
+ end,
+ catch {
+ function (errs)
+ if errs then
+ errors = tostring(errs)
+ end
+ end
+ }
+ }
if ok then
-- move to source directory and we skip it to avoid long path issues on windows if only one root directory
os.rm(sourcedir)
@@ -241,7 +254,7 @@ function _download(package, url, sourcedir, opt)
-- create an empty source directory if do not extract package file
os.tryrm(sourcedir)
os.mkdir(sourcedir)
- raise("cannot extract %s, maybe extractors(like unzip, ...) are not found!", packagefile)
+ raise(errors or string.format("cannot extract %s, maybe missing extractor or invalid package file!", packagefile))
else
-- if it is not archive file, we only need to create empty source directory and use package:originfile()
os.tryrm(sourcedir)
@@ -439,5 +452,3 @@ function main(package, opt)
os.cd(oldir)
return ok
end
-
-
diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua
index e21b0e091..7edd577f7 100644
--- a/xmake/modules/private/action/require/impl/actions/download_resources.lua
+++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua
@@ -135,14 +135,27 @@ function _download(package, resource_name, resource_url, resource_hash)
local resourcedir_tmp = resourcedir .. ".tmp"
os.tryrm(resourcedir_tmp)
local extension = archive.extension(resource_file)
- local ok = try {function() archive.extract(resource_file, resourcedir_tmp); return true end}
+ local errors
+ local ok = try {
+ function()
+ archive.extract(resource_file, resourcedir_tmp)
+ return true
+ end,
+ catch {
+ function (errs)
+ if errs then
+ errors = tostring(errs)
+ end
+ end
+ }
+ }
if ok then
os.tryrm(resourcedir)
os.mv(resourcedir_tmp, resourcedir)
elseif extension and extension ~= "" then
os.tryrm(resourcedir_tmp)
os.tryrm(resourcedir)
- raise("cannot extract %s", resource_file)
+ raise(errors or string.format("cannot extract %s", resource_file))
else
-- if it is not archive file, we only need to create empty resource directory and use package:resourcefile(resource_name)
os.tryrm(resourcedir)
diff --git a/xmake/modules/private/action/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua
index bd5d698bd..b6eba7fc1 100644
--- a/xmake/modules/private/action/require/impl/actions/patch_sources.lua
+++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua
@@ -107,14 +107,27 @@ function _patch(package, patchinfo)
local patchdir = patch_file .. ".dir"
local patchdir_tmp = patchdir .. ".tmp"
os.tryrm(patchdir_tmp)
- local ok = try {function() archive.extract(patch_file, patchdir_tmp); return true end}
+ local errors
+ local ok = try {
+ function()
+ archive.extract(patch_file, patchdir_tmp)
+ return true
+ end,
+ catch {
+ function (errs)
+ if errs then
+ errors = tostring(errs)
+ end
+ end
+ }
+ }
if ok then
os.tryrm(patchdir)
os.mv(patchdir_tmp, patchdir)
else
os.tryrm(patchdir_tmp)
os.tryrm(patchdir)
- raise("cannot extract %s", patch_file)
+ raise(errors or string.format("cannot extract %s", patch_file))
end
-- apply patch files