summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-02 22:38:56 +0800
committerruki <[email protected]>2021-11-02 22:38:56 +0800
commit57ac15ded63c921ca913dd51adf039af842b8a1b (patch)
tree6d80026120d258eea1afd1721c04b8d8b100110a /xmake/modules
parent1c667ecedce4a2f90f32787f7f667f967421ec1f (diff)
improve apt::find_package
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/package/manager/apt/find_package.lua63
1 files changed, 43 insertions, 20 deletions
diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua
index 27a0ebbe1..e2617b4ec 100644
--- a/xmake/modules/package/manager/apt/find_package.lua
+++ b/xmake/modules/package/manager/apt/find_package.lua
@@ -24,26 +24,8 @@ import("core.project.config")
import("core.project.target")
import("lib.detect.find_tool")
--- find package using the dpkg package manager
---
--- @param name the package name
--- @param opt the options, e.g. {verbose = true, version = "1.12.0")
---
-function main(name, opt)
-
- -- check
- opt = opt or {}
- if not is_host(opt.plat) or os.arch() ~= opt.arch then
- return
- end
-
- -- find dpkg
- local dpkg = find_tool("dpkg")
- if not dpkg then
- return
- end
-
- -- find package
+-- find package
+function _find_package(dpkg, name, opt)
local result = nil
local listinfo = try {function () return os.iorunv(dpkg.program, {"--listfiles", name}) end}
if listinfo then
@@ -70,6 +52,24 @@ function main(name, opt)
end
end
+ -- meta/alias package? e.g. libboost-dev -> libboost1.74-dev
+ -- @see https://github.com/xmake-io/xmake/issues/1786
+ if not result then
+ local statusinfo = try {function () return os.iorunv(dpkg.program, {"--status", name}) end}
+ if statusinfo then
+ for _, line in ipairs(statusinfo:split("\n", {plain = true})) do
+ -- parse depends, e.g. Depends: libboost1.74-dev
+ if line:startswith("Depends:") then
+ local depends = line:sub(9):split("%s+")
+ if #depends == 1 then
+ return _find_package(dpkg, depends[1], opt)
+ end
+ break
+ end
+ end
+ end
+ end
+
-- remove repeat
if result then
if result.links then
@@ -84,3 +84,26 @@ function main(name, opt)
end
return result
end
+
+-- find package using the dpkg package manager
+--
+-- @param name the package name
+-- @param opt the options, e.g. {verbose = true, version = "1.12.0")
+--
+function main(name, opt)
+
+ -- check
+ opt = opt or {}
+ if not is_host(opt.plat) or os.arch() ~= opt.arch then
+ return
+ end
+
+ -- find dpkg
+ local dpkg = find_tool("dpkg")
+ if not dpkg then
+ return
+ end
+
+ -- find package
+ return _find_package(dpkg, name, opt)
+end