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:
+1
-13
@@ -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)) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user