Skip to content

Commit 604db97

Browse files
Copilotbytemain
andauthored
Add libc detection for musl vs glibc on Linux (#50)
* Initial plan * Add libc detection for musl vs glibc on Linux systems Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 6d51d65 commit 604db97

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/foojay.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ local foojay = {}
66
local URL =
77
"https://api.foojay.io/disco/v3.0/packages/jdks?version=%s&distribution=%s&architecture=%s&archive_type=%s&operating_system=%s&lib_c_type=%s&release_status=ga&directly_downloadable=true"
88

9+
--- Detects the libc type on Linux systems (glibc or musl)
10+
--- @return string "glibc" or "musl"
11+
local function detect_lib_c_type()
12+
local handle = io.popen("ldd --version 2>&1")
13+
if handle then
14+
local result = handle:read("*a")
15+
handle:close()
16+
if result and result:lower():find("musl") then
17+
return "musl"
18+
end
19+
end
20+
return "glibc"
21+
end
22+
923
foojay.fetchtJdkList= function (distribution, version)
1024

1125
local os = RUNTIME.osType
@@ -24,7 +38,7 @@ foojay.fetchtJdkList= function (distribution, version)
2438

2539
local lib_c_type = ""
2640
if os == "linux" then
27-
lib_c_type = "glibc"
41+
lib_c_type = detect_lib_c_type()
2842
end
2943

3044
-- Convert arm64 to aarch64 for foojay API compatibility

0 commit comments

Comments
 (0)