1
0
mirror of https://github.com/j178/prek.git synced 2026-06-19 17:17:53 +02:00

Use dedicated Android npm package (#1982)

Revert the shared Linux/Android musl package handling from
7f44e09982.

Add a dedicated `@j178/prek-android-arm64` platform spec that reuses the
`aarch64-unknown-linux-musl` artifact without package-level libc
metadata, so npm can install it on Android/Termux.

Follow-up to #1977
This commit is contained in:
Jo
2026-04-22 01:37:14 +08:00
committed by GitHub
parent 7f44e09982
commit 9693035098
2 changed files with 15 additions and 23 deletions
+1 -13
View File
@@ -99,18 +99,6 @@ function currentLibc() {
return isMusl() ? "musl" : "glibc";
}
function matchesLibc(spec, libc) {
if (!spec.libc) {
return true;
}
if (process.platform === "android") {
// Android uses Bionic, so currentLibc() returns null. The static musl
// binary is the compatible package for Termux.
return spec.libc === "musl";
}
return spec.libc === libc;
}
function pickPlatformPackage() {
const libc = currentLibc();
debug(
@@ -125,7 +113,7 @@ function pickPlatformPackage() {
if (!spec.cpu.includes(process.arch)) {
return false;
}
if (!matchesLibc(spec, libc)) {
if (spec.libc && spec.libc !== libc) {
return false;
}
if (!matchesArmVersion(spec)) {
+14 -10
View File
@@ -70,13 +70,7 @@ class PlatformSpec:
"cpu": self.cpu,
"files": [self.binary_name, "README.md", "LICENSE"],
}
# Only emit package-level libc for Linux-only specs. npm checks this
# field before installing optional dependencies and only detects libc
# when os == "linux"; Android's libc value is undefined. If the shared
# Linux/Android arm64 musl package declared "libc": ["musl"], npm would
# reject it on Termux before bin/prek.js can select the static musl
# binary. Keep libc in platforms.json for the launcher's matching.
if self.libc is not None and self.os == ["linux"]:
if self.libc is not None:
package_json["libc"] = [self.libc]
return package_json
@@ -114,16 +108,26 @@ PLATFORMS = (
libc="glibc",
),
PlatformSpec(
# Android/Termux reports process.platform as "android", but the
# statically linked aarch64 Linux musl binary runs there.
rust_target="aarch64-unknown-linux-musl",
package_name="@j178/prek-linux-arm64-musl",
archive_file="prek-aarch64-unknown-linux-musl.tar.gz",
binary_name="prek",
os=["linux", "android"],
os=["linux"],
cpu=["arm64"],
libc="musl",
),
PlatformSpec(
# Android/Termux reports process.platform as "android" and uses
# Bionic, not glibc or musl. Reuse the static Linux musl artifact via a
# dedicated package with no package-level libc restriction so npm can
# install it on Android.
rust_target="aarch64-unknown-linux-musl",
package_name="@j178/prek-android-arm64",
archive_file="prek-aarch64-unknown-linux-musl.tar.gz",
binary_name="prek",
os=["android"],
cpu=["arm64"],
),
PlatformSpec(
rust_target="armv7-unknown-linux-gnueabihf",
package_name="@j178/prek-linux-arm-gnueabihf",