summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/package/package.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 2cf65f2a4..2021452d7 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -2958,6 +2958,10 @@ function package.cachedir(opt)
local cachedir = package._CACHEDIR
if not cachedir then
cachedir = os.getenv("XMAKE_PKG_CACHEDIR") or global.get("pkg_cachedir") or path.join(global.cachedir(), "packages")
+ -- normalize it to ensure all derived paths are consistent, e.g. the user
+ -- may pass a path with `..` or relative segments via XMAKE_PKG_CACHEDIR.
+ -- @see https://github.com/xmake-io/xmake/issues/7576
+ cachedir = path.normalize(path.absolute(cachedir))
package._CACHEDIR = cachedir
end
if opt.rootonly then
@@ -2981,6 +2985,11 @@ function package.installdir(opt)
local installdir = package._INSTALLDIR
if not installdir then
installdir = os.getenv("XMAKE_PKG_INSTALLDIR") or global.get("pkg_installdir") or path.join(global.directory(), "packages")
+ -- normalize it to ensure all derived paths are consistent, e.g. the user
+ -- may pass a path with `..` or relative segments via XMAKE_PKG_INSTALLDIR.
+ -- otherwise the relocated pkgconfig *.pc files would contain a broken
+ -- relative prefix. @see https://github.com/xmake-io/xmake/issues/7576
+ installdir = path.normalize(path.absolute(installdir))
package._INSTALLDIR = installdir
end
return installdir