diff options
| author | ruki <[email protected]> | 2022-08-10 22:34:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-10 22:34:19 +0800 |
| commit | e30ea04edcd294dab6a17f002780239c3bad4ce9 (patch) | |
| tree | fbf5970038fdb504499dcae35e0ed56c6209c3d0 | |
| parent | 08d942bbf1e00d9c40d7e39af80ef0ba461d71c1 (diff) | |
improve install and uninstall
| -rw-r--r-- | xmake/modules/target/action/install/unix.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/unix.lua | 14 |
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 |
