diff options
| author | chooyy <[email protected]> | 2025-12-01 15:43:03 +0800 |
|---|---|---|
| committer | chooyy <[email protected]> | 2025-12-01 15:43:03 +0800 |
| commit | 20cdfc49126d86c28a9c298ab92ac64e19f2aefc (patch) | |
| tree | 89dfc6dd2247b5c11cdedd2c7afe4d9e22f181b7 | |
| parent | d51dfaebebec3f3f3886cf12f1f683021991cac9 (diff) | |
use semver.match
| -rw-r--r-- | xmake/modules/package/manager/pacman/find_package.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua index af7fd837f..3b200db26 100644 --- a/xmake/modules/package/manager/pacman/find_package.lua +++ b/xmake/modules/package/manager/pacman/find_package.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.semver") import("core.project.target") import("lib.detect.find_tool") import("private.core.base.is_cross") @@ -238,9 +239,13 @@ function main(name, opt) end -- We should get version from pacman, because if a pacman package contains multiples .pc we may get a wrong version - local version = try { function() return os.iorunv(pacman.program, {"-Q", name}) end } - version = version:trim():split('%s+')[2] - result.version = version:split('-')[1] + local verstr = try { function() return os.iorunv(pacman.program, {"-Q", name}) end } + if verstr then + local version = semver.match(verstr) + if version then + result.version = version:rawstr():split('-')[1] + end + end else -- if there is no .pc, we parse the package content to obtain the data we want result = _find_package_from_list(list, name, pacman, opt) |
