summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/modules/target/action/install/unix.lua11
-rw-r--r--xmake/modules/target/action/uninstall/unix.lua14
2 files changed, 24 insertions, 1 deletions
diff --git a/xmake/modules/target/action/install/unix.lua b/xmake/modules/target/action/install/unix.lua
index 126191c0e..65fce1e3c 100644
--- a/xmake/modules/target/action/install/unix.lua
+++ b/xmake/modules/target/action/install/unix.lua
@@ -52,6 +52,17 @@ function _install_shared_for_package(target, pkg, outputdir)
-- we need reserve symlink
-- @see https://github.com/xmake-io/xmake/issues/1582
os.vcp(sopath, outputdir, {symlink = true})
+ -- https://github.com/xmake-io/xmake/issues/2665#issuecomment-1209619081
+ if os.islink(sopath) then
+ -- relative link? e.g. libxx.so -> libxx.4.so
+ local realitem = os.readlink(sopath)
+ if realitem and not path.is_absolute(realitem) then
+ local realpath = path.join(path.directory(sopath), realitem)
+ if os.isfile(realpath) then
+ os.vcp(realpath, outputdir)
+ end
+ end
+ end
_g.installed_libfiles[sopath] = true
end
end
diff --git a/xmake/modules/target/action/uninstall/unix.lua b/xmake/modules/target/action/uninstall/unix.lua
index 128d24977..904a28a77 100644
--- a/xmake/modules/target/action/uninstall/unix.lua
+++ b/xmake/modules/target/action/uninstall/unix.lua
@@ -32,7 +32,19 @@ function _uninstall_shared_for_package(target, pkg, outputdir)
for _, sopath in ipairs(table.wrap(pkg:get("libfiles"))) do
if sopath:endswith(".so") or sopath:endswith(".dylib") then
local soname = path.filename(sopath)
- os.vrm(path.join(outputdir, soname))
+ local filepath = path.join(outputdir, soname)
+ -- https://github.com/xmake-io/xmake/issues/2665#issuecomment-1209619081
+ if os.islink(filepath) then
+ -- relative link? e.g. libxx.so -> libxx.4.so
+ local realitem = os.readlink(filepath)
+ if realitem and not path.is_absolute(realitem) then
+ local realpath = path.join(outputdir, realitem)
+ if os.isfile(realpath) then
+ os.vrm(realpath)
+ end
+ end
+ end
+ os.vrm(filepath)
end
end
end