Skip to content

Commit e737a19

Browse files
pyckleAndrew Pikler
and
Andrew Pikler
authored
Musl check improvements
* Fix older linux compatibility with MUSL check * Add check for alpine linux for older Linux Kernel or no ptrace permissions Closes: #706 Co-authored-by: Andrew Pikler <[email protected]>
1 parent 14d5903 commit e737a19

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/org/sqlite/util/OSInfo.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,17 @@ public static boolean isMusl() {
125125
}
126126
})
127127
.anyMatch(s -> s.toLowerCase().contains("musl"));
128-
} catch (IOException ignored) {
128+
} catch (Exception ignored) {
129+
// fall back to checking for alpine linux in the event we're using an older kernel which
130+
// may not fail the above check
131+
return isAlpineLinux();
132+
}
133+
}
134+
135+
private static boolean isAlpineLinux() {
136+
try (Stream<String> osLines = Files.lines(Paths.get("/etc/os-release"))) {
137+
return osLines.anyMatch(l -> l.startsWith("ID") && l.contains("alpine"));
138+
} catch (Exception ignored2) {
129139
}
130140
return false;
131141
}
@@ -223,14 +233,14 @@ static String translateOSNameToFolderName(String osName) {
223233
return "Windows";
224234
} else if (osName.contains("Mac") || osName.contains("Darwin")) {
225235
return "Mac";
236+
} else if (osName.contains("AIX")) {
237+
return "AIX";
226238
} else if (isMusl()) {
227239
return "Linux-Musl";
228240
} else if (isAndroid()) {
229241
return "Linux-Android";
230242
} else if (osName.contains("Linux")) {
231243
return "Linux";
232-
} else if (osName.contains("AIX")) {
233-
return "AIX";
234244
} else {
235245
return osName.replaceAll("\\W", "");
236246
}

0 commit comments

Comments
 (0)