Skip to content

Commit

Permalink
fix(java): 将linux 下 musl 架构系统使用的库文件与普通 linux 统一为同一个,用 libc6-compat 来实现兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjelly committed Sep 13, 2024
1 parent 8c5ef7d commit 4e123e3
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,28 @@ public static Architecture getArchitecture() {
if (Processor.UNKNOWN != processor) {
final String name = System.getProperty("os.name").toLowerCase();
if (name.contains("nix") || name.contains("nux")) {
Boolean isMusl = false;
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command("sh", "-c", "case `ldd --version 2>&1` in *musl*) exit 0 ;; *) exit 1 ;; esac");
Process process = builder.start();
isMusl = process.waitFor() == 0;
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Problem with detecting libc", e);
}
if (isMusl) {
if (Processor.INTEL_32 == processor) {
architecture = Architecture.LINUX_MUSL32;
} else if (Processor.INTEL_64 == processor) {
architecture = Architecture.LINUX_MUSL64;
}
} else if (Processor.INTEL_32 == processor) {
// MUSL 架构系统下通过安装 libc6-compat gcompat 实现兼容
// Boolean isMusl = false;
// try {
// ProcessBuilder builder = new ProcessBuilder();
// builder.command("sh", "-c", "case `ldd --version 2>&1` in *musl*) exit 0 ;; *) exit 1 ;; esac");
// Process process = builder.start();
// isMusl = process.waitFor() == 0;
// } catch (Exception e) {
// LOGGER.log(Level.WARNING, "Problem with detecting libc", e);
// }
// if (isMusl) {
// if (Processor.INTEL_32 == processor) {
// architecture = Architecture.LINUX_32;
// } else if (Processor.INTEL_64 == processor) {
// architecture = Architecture.LINUX_64;
// } else if (Processor.ARM == processor) {
// architecture = Architecture.LINUX_ARM;
// } else if (Processor.AARCH_64 == processor) {
// architecture = Architecture.LINUX_ARM64;
// }
// } else if (Processor.INTEL_32 == processor) {
if (Processor.INTEL_32 == processor) {
architecture = Architecture.LINUX_32;
} else if (Processor.INTEL_64 == processor) {
architecture = Architecture.LINUX_64;
Expand Down

0 comments on commit 4e123e3

Please sign in to comment.