summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-21 22:51:44 +0800
committerruki <[email protected]>2022-04-21 22:51:44 +0800
commit08cd8e8c27448cd9af15da9fcc645366456716ba (patch)
tree636a8fa399f4cc31b953319249fbcafc77a03285
parent5d2acc0788c9154b39781e893212ecdc4659c60c (diff)
add anchor
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua2
-rw-r--r--xmake/modules/private/action/require/impl/actions/install.lua3
2 files changed, 4 insertions, 1 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index ccbdd23c0..e1853e3c7 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -168,6 +168,8 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
local filedirs = os.filedirs(path.join(sourcedir_tmp, "*"))
if #filedirs == 1 and os.isdir(filedirs[1]) then
os.mv(filedirs[1], sourcedir)
+ -- we need anchor it to avoid expand it when installing package
+ io.writefile(path.join(sourcedir, "__sourceroot_anchor__.txt"), "")
os.rm(sourcedir_tmp)
else
os.mv(sourcedir_tmp, sourcedir)
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua
index 6e451b891..348986239 100644
--- a/xmake/modules/private/action/require/impl/actions/install.lua
+++ b/xmake/modules/private/action/require/impl/actions/install.lua
@@ -238,8 +238,9 @@ function main(package)
oldir = os.cd(sourcedir)
elseif #package:urls() > 0 then
-- only one root directory? skip it
+ local anchorfile = path.join(workdir, "source", "__sourceroot_anchor__.txt")
local filedirs = os.filedirs(path.join(workdir, "source", "*"))
- if #filedirs == 1 and os.isdir(filedirs[1]) then
+ if not os.isfile(anchorfile) and #filedirs == 1 and os.isdir(filedirs[1]) then
oldir = os.cd(filedirs[1])
else
oldir = os.cd(path.join(workdir, "source"))