Skip to content

The agent that grows with you

fix(pm): select native musl artifacts on Linux

JoaoMarcos448371dd17f6f3
diff --git a/pm/cli.py b/pm/cli.py
index 446189848ce..58df307a5a4 100644
--- a/pm/cli.py
+++ b/pm/cli.py
@@ -117,10 +117,14 @@ def _pin_tool(args) -> int:
lockfile = _lockfile()
package = get_package(args.name)
artifacts: dict[str, object] = {}
+ hashes: dict[str, str] = {}
def pin(url: str) -> dict:
print(f" {url}")
- digest = package.known_sha256(args.version, url) or hash_url(url)
+ digest = hashes.get(url)
+ if digest is None:
+ digest = package.known_sha256(args.version, url) or hash_url(url)
+ hashes[url] = digest
print(f" sha256 {digest}")
return {"url": url, "sha256": digest}
diff --git a/pm/lock.json b/pm/lock.json
index 2efbedb8d61..81e34ed1c64 100644
--- a/pm/lock.json
+++ b/pm/lock.json
@@ -23,10 +23,18 @@
"sha256": "de61bfbacbcf6e3648ddc8dbd6ca8bb2245438ccf5f94d54129997528f5a752d",
"url": "https://github.com/bitwarden/sdk-sm/releases/download/bws-v2.0.0/bws-aarch64-unknown-linux-musl-2.0.0.zip"
},
+ "linux-arm64-musl": {
+ "sha256": "de61bfbacbcf6e3648ddc8dbd6ca8bb2245438ccf5f94d54129997528f5a752d",
+ "url": "https://github.com/bitwarden/sdk-sm/releases/download/bws-v2.0.0/bws-aarch64-unknown-linux-musl-2.0.0.zip"
+ },
"linux-x64": {
"sha256": "ea6eb18f1270388f12d15a35f919ccb3488d32a777433baefe883d561f46fc73",
"url": "https://github.com/bitwarden/sdk-sm/releases/download/bws-v2.0.0/bws-x86_64-unknown-linux-musl-2.0.0.zip"
},
+ "linux-x64-musl": {
+ "sha256": "ea6eb18f1270388f12d15a35f919ccb3488d32a777433baefe883d561f46fc73",
+ "url": "https://github.com/bitwarden/sdk-sm/releases/download/bws-v2.0.0/bws-x86_64-unknown-linux-musl-2.0.0.zip"
+ },
"win32-arm64": {
"sha256": "1a02fca3a855ba32d8f0c40813af8da705cf1e7cf9b932164959531e57eccbe0",
"url": "https://github.com/bitwarden/sdk-sm/releases/download/bws-v2.0.0/bws-aarch64-pc-windows-msvc-2.0.0.zip"
@@ -127,10 +135,18 @@
"sha256": "1ec37f4f092521cb785e0ccfa2d82cc4a79ec8d2a4864f5eefc50a314f2d5dec",
"url": "https://packages.termux.dev/apt/termux-main/pool/main/f/ffmpeg/ffmpeg_8.1.2-5_aarch64.deb"
},
+ "linux-arm64-musl": {
+ "sha256": "2de63f615df3a46ac26921ac0314f501c3536aaf9fd5197ffe03dd17cd01a404",
+ "url": "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-09-10-15-31/ffmpeg-n9.0.1-27-g9b0578816c-linuxarm64-gpl-9.0.tar.xz"
+ },
"linux-x64": {
"sha256": "70b162b63517038ff18c8a50f4ea11f919a071f945c5881e87b0b2cd7173f8c7",
"url": "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-09-10-15-31/ffmpeg-n9.0.1-27-g9b0578816c-linux64-gpl-9.0.tar.xz"
},
+ "linux-x64-musl": {
+ "sha256": "70b162b63517038ff18c8a50f4ea11f919a071f945c5881e87b0b2cd7173f8c7",
+ "url": "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-09-10-15-31/ffmpeg-n9.0.1-27-g9b0578816c-linux64-gpl-9.0.tar.xz"
+ },
"win32-arm64": {
"sha256": "0f241c74c576f68dbd375f7557c2d08740783d7b8c6f892031c3830df18f672f",
"url": "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-09-10-15-31/ffmpeg-n9.0.1-27-g9b0578816c-winarm64-gpl-9.0.zip"
@@ -156,10 +172,18 @@
"sha256": "73ea440ecad9c9e284429997ee6f93577bc6f7bc6fba357ef62c53ad8fb641a5",
"url": "https://github.com/cli/cli/releases/download/v2.97.0/gh_2.97.0_linux_arm64.tar.gz"
},
+ "linux-arm64-musl": {
+ "sha256": "73ea440ecad9c9e284429997ee6f93577bc6f7bc6fba357ef62c53ad8fb641a5",
+ "url": "https://github.com/cli/cli/releases/download/v2.97.0/gh_2.97.0_linux_arm64.tar.gz"
+ },
"linux-x64": {
"sha256": "a2c9b8497e1f85b1ad0dfcb78b5a622e098801b8e461e459e88e1ee12f018112",
"url": "https://github.com/cli/cli/releases/download/v2.97.0/gh_2.97.0_linux_amd64.tar.gz"
},
+ "linux-x64-musl": {
+ "sha256": "a2c9b8497e1f85b1ad0dfcb78b5a622e098801b8e461e459e88e1ee12f018112",
+ "url": "https://github.com/cli/cli/releases/download/v2.97.0/gh_2.97.0_linux_amd64.tar.gz"
+ },
"win32-arm64": {
"sha256": "3e2d4a166da4ee5020c592737b65eec0e724946d5d5b962f5fe59d99116dc4bf",
"url": "https://github.com/cli/cli/releases/download/v2.97.0/gh_2.97.0_windows_arm64.zip"
@@ -240,6 +264,24 @@
"url": "https://raw.githubusercontent.com/paradigmxyz/iron-proxy/be5f255d0d9d10d8573bd65f480dd48a07772bf1/public-key.asc"
}
],
+ "linux-arm64-musl": [
+ {
+ "sha256": "1316cb4f20fcfba5042b06d07cd523ffa617de9de2999cd5f1f44474777c48ad",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/iron-proxy_0.39.0_linux_arm64.tar.gz"
+ },
+ {
+ "sha256": "8fb3193b53ca296e2f93ff0fd69d289340cffe9a36c0de22e47ea5cfea899b37",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/checksums.txt"
+ },
+ {
+ "sha256": "1ff70f0bd8699b2f1c2c3545e6aa9034d24267fc01d1b9aaa93d73e893cb610b",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/checksums.txt.asc"
+ },
+ {
+ "sha256": "ce685e36e7e7d184ffa82b35bd5cbe83db010ac38bc504a0e225333453992c56",
+ "url": "https://raw.githubusercontent.com/paradigmxyz/iron-proxy/be5f255d0d9d10d8573bd65f480dd48a07772bf1/public-key.asc"
+ }
+ ],
"linux-x64": [
{
"sha256": "0ab2e031074a01410caecaa2769c0b38f69cbdf4b6333bce498fe73919f6f9f6",
@@ -257,6 +299,24 @@
"sha256": "ce685e36e7e7d184ffa82b35bd5cbe83db010ac38bc504a0e225333453992c56",
"url": "https://raw.githubusercontent.com/paradigmxyz/iron-proxy/be5f255d0d9d10d8573bd65f480dd48a07772bf1/public-key.asc"
}
+ ],
+ "linux-x64-musl": [
+ {
+ "sha256": "0ab2e031074a01410caecaa2769c0b38f69cbdf4b6333bce498fe73919f6f9f6",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/iron-proxy_0.39.0_linux_amd64.tar.gz"
+ },
+ {
+ "sha256": "8fb3193b53ca296e2f93ff0fd69d289340cffe9a36c0de22e47ea5cfea899b37",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/checksums.txt"
+ },
+ {
+ "sha256": "1ff70f0bd8699b2f1c2c3545e6aa9034d24267fc01d1b9aaa93d73e893cb610b",
+ "url": "https://github.com/paradigmxyz/iron-proxy/releases/download/v0.39.0/checksums.txt.asc"
+ },
+ {
+ "sha256": "ce685e36e7e7d184ffa82b35bd5cbe83db010ac38bc504a0e225333453992c56",
+ "url": "https://raw.githubusercontent.com/paradigmxyz/iron-proxy/be5f255d0d9d10d8573bd65f480dd48a07772bf1/public-key.asc"
+ }
]
},
"version": "0.39.0"
@@ -376,10 +436,18 @@
"sha256": "eaf3ed8a6e4b72ebaa8c2cb3bad778c577cdf9ea87ca91761213d8a3940fc090",
"url": "https://packages.termux.dev/apt/termux-main/pool/main/n/nodejs/nodejs_26.4.0-1_aarch64.deb"
},
+ "linux-arm64-musl": {
+ "sha256": "9cc46e7b106abf606dd9b824abfd8f32043f53ca46a41d4ed2e61ebe7c58ef7e",
+ "url": "https://unofficial-builds.nodejs.org/download/release/v26.7.0/node-v26.7.0-linux-arm64-musl.tar.xz"
+ },
"linux-x64": {
"sha256": "982aa24dd8be4c889c6a8ab337ddff3b0896645b20f4239356e80552c16277ee",
"url": "https://nodejs.org/dist/v26.7.0/node-v26.7.0-linux-x64.tar.xz"
},
+ "linux-x64-musl": {
+ "sha256": "b6acfd9133393956ef4dd977678a4a0863314d7cf2f925457069f9541dce8d40",
+ "url": "https://unofficial-builds.nodejs.org/download/release/v26.7.0/node-v26.7.0-linux-x64-musl.tar.xz"
+ },
"win32-arm64": {
"sha256": "be8775204cfceca5a73c30f91bf0de5e85274c01b776dc13f16b91aa251ebb01",
"url": "https://nodejs.org/dist/v26.7.0/node-v26.7.0-win-arm64.zip"
@@ -418,10 +486,18 @@
"sha256": "3166e56c2b6c03fff41191fbb9d736302978e7c484702814d9f6dc99dd6006bd",
"url": "https://packages.termux.dev/apt/termux-main/pool/main/p/python/python_3.14.6-1_aarch64.deb"
},
+ "linux-arm64-musl": {
+ "sha256": "6fcb8708ec4cf604bd970068ce45e4b3228bb207fbce043ccb78e750243bb274",
+ "url": "https://github.com/astral-sh/python-build-standalone/releases/download/20260901/cpython-3.14.7+20260901-aarch64-unknown-linux-musl-install_only.tar.gz"
+ },
"linux-x64": {
"sha256": "0ab3305457051cd3e7c031857e005f1bda17c218a1990567dacaaac6dd1d14f0",
"url": "https://github.com/astral-sh/python-build-standalone/releases/download/20260901/cpython-3.14.7+20260901-x86_64-unknown-linux-gnu-install_only.tar.gz"
},
+ "linux-x64-musl": {
+ "sha256": "75fe4a23502144a343c5c1f27df592ebca085b669fe665394e1812e37bcae258",
+ "url": "https://github.com/astral-sh/python-build-standalone/releases/download/20260901/cpython-3.14.7+20260901-x86_64-unknown-linux-musl-install_only.tar.gz"
+ },
"win32-arm64": {
"sha256": "5efa2548bf1248ca07ed6f8afb0cb52b83d4869d533ea5be919a989c8ee1b17c",
"url": "https://github.com/astral-sh/python-build-standalone/releases/download/20260901/cpython-3.14.7+20260901-aarch64-pc-windows-msvc-install_only.tar.gz"
@@ -451,10 +527,18 @@
"sha256": "800b1e7206afe799dfb5a6901f23147cfaabe0e52210538100f61e86e1740915",
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.2.0/ripgrep-15.2.0-aarch64-unknown-linux-musl.tar.gz"
},
+ "linux-arm64-musl": {
+ "sha256": "800b1e7206afe799dfb5a6901f23147cfaabe0e52210538100f61e86e1740915",
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.2.0/ripgrep-15.2.0-aarch64-unknown-linux-musl.tar.gz"
+ },
"linux-x64": {
"sha256": "33e15bcf1624b25cdd2a55813a47a2f95dbe126268203e76aa6a585d1e7b149c",
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.2.0/ripgrep-15.2.0-x86_64-unknown-linux-musl.tar.gz"
},
+ "linux-x64-musl": {
+ "sha256": "33e15bcf1624b25cdd2a55813a47a2f95dbe126268203e76aa6a585d1e7b149c",
+ "url": "https://github.com/BurntSushi/ripgrep/releases/download/15.2.0/ripgrep-15.2.0-x86_64-unknown-linux-musl.tar.gz"
+ },
"win32-arm64": {
"sha256": "e4abca10c3a64ebea742667dd7009449d49403db5460dd6873e389fa2945360f",
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.2.0/ripgrep-15.2.0-aarch64-pc-windows-msvc.zip"
@@ -530,6 +614,24 @@
"url": "https://github.com/sheeki03/tirith/releases/download/v0.4.2/checksums.txt.pem"
}
],
+ "linux-arm64-musl": [
+ {
+ "sha256": "9c86e81537dc7b7fe6655ea472728b5f7a0dbe93ebb68b95ca7601fb1aba0508",
+ "url": "https://github.com/sheeki03/tirith/releases/download/v0.4.2/tirith-aarch64-unknown-linux-musl.tar.gz"
+ },
+ {
+ "sha256": "bcbb3eeda0f9971db5d60d2eb512970c14601432092f596d7059e0141e272585",
+ "url": "https://github.com/sheeki03/tirith/releases/download/v0.4.2/checksums.txt"
+ },
+ {
+ "sha256": "8d069fa95606f59919a897ff0914b06600f3cede4a8e83a0c4b339d9188c42b0",
+ "url": "https://github.com/sheeki03/tirith/releases/download/v0.4.2/checksums.txt.sig"
+ },
+ {
+ "sha256": "1f39241c7a334e465f78794533675e94e424ed38e9aa1534b5d7c893bd4fb71c",
+ "url": "https://github.com/sheeki03/tirith/releases/download/v0.4.2/checksums.txt.pem"
+ }
+ ],
"linux-x64": [
{
"sha256": "efa6bf414a83dba385d4f13137e8677f850ced9102fe74ebb14c72f31df0dc77",
@@ -569,10 +671,18 @@
"sha256": "6bacc745de035ac87cb6948f495f8d82a0fe0c6e6ff2ca65e6ecf487973b09cd",
"url": "https://packages.termux.dev/apt/termux-main/pool/main/u/uv/uv_0.12.15_aarch64.deb"
},
+ "linux-arm64-musl": {
+ "sha256": "fa513fca1eb2913334c944fe9adbdd410274a1cbe8dd05d03699a9eb85311d4e",
+ "url": "https://github.com/astral-sh/uv/releases/download/0.12.3/uv-aarch64-unknown-linux-musl.tar.gz"
+ },
"linux-x64": {
"sha256": "600cf9a742aca00d292673b16b5acffaa7b8c269a364ad0c2e79498dcb1fe101",
"url": "https://github.com/astral-sh/uv/releases/download/0.12.3/uv-x86_64-unknown-linux-gnu.tar.gz"
},
+ "linux-x64-musl": {
+ "sha256": "0643b9fb8c9fb27458e709ce6ff939695013c41975ff7b02d3f3b138d8d4bdb3",
+ "url": "https://github.com/astral-sh/uv/releases/download/0.12.3/uv-x86_64-unknown-linux-musl.tar.gz"
+ },
"win32-arm64": {
"sha256": "4343217d668727b8a8eb5cad92389a1d2eeead93c89940d1b955ba1bb15462eb",
"url": "https://github.com/astral-sh/uv/releases/download/0.12.3/uv-aarch64-pc-windows-msvc.zip"
diff --git a/pm/packages.py b/pm/packages.py
index 94ab9a4f402..b8c9bd92284 100644
--- a/pm/packages.py
+++ b/pm/packages.py
@@ -42,15 +42,21 @@ _RUST_TRIPLE = {
"win32-arm64": "aarch64-pc-windows-msvc",
"linux-x64": "x86_64-unknown-linux-gnu",
"linux-arm64": "aarch64-unknown-linux-gnu",
+ "linux-x64-musl": "x86_64-unknown-linux-musl",
+ "linux-arm64-musl": "aarch64-unknown-linux-musl",
"darwin-x64": "x86_64-apple-darwin",
"darwin-arm64": "aarch64-apple-darwin",
}
+_MUSL_TARGETS = frozenset({"linux-x64-musl", "linux-arm64-musl"})
+
_NODE_PLAT = {
"win32-x64": "win-x64",
"win32-arm64": "win-arm64",
"linux-x64": "linux-x64",
"linux-arm64": "linux-arm64",
+ "linux-x64-musl": "linux-x64-musl",
+ "linux-arm64-musl": "linux-arm64-musl",
"darwin-x64": "darwin-x64",
"darwin-arm64": "darwin-arm64",
}
@@ -184,7 +190,7 @@ class _BionicDebArm:
@register
class Uv(_BionicDebArm, BinaryPackage, DebPackage):
- """astral's prebuilt tarballs for glibc/mac/win; the Termux main-repo
+ """astral's prebuilt tarballs for glibc/musl/mac/win; the Termux main-repo
uv .deb for bionic (termux builds uv from source -- no astral bionic
artifact exists). The bionic arm is a runtime tool on the phone (lazy
plugin installs) and the wheelhouse's resolver in the build container."""
@@ -446,8 +452,8 @@ class Venv(StatePackage):
@register
class Nodejs(_BionicDebArm, BinaryPackage, DebPackage):
- """nodejs.org tarballs for glibc/mac/win; the Termux main-repo nodejs
- .deb for bionic (same major line, termux-built)."""
+ """nodejs.org tarballs for glibc/mac/win, unofficial-builds for musl;
+ the Termux main-repo nodejs .deb for bionic (same major line, termux-built)."""
name = "node"
binary_rel = {"win32": "node.exe", "posix": "bin/node"}
@@ -465,9 +471,17 @@ class Nodejs(_BionicDebArm, BinaryPackage, DebPackage):
return f"https://packages.termux.dev/apt/termux-main/pool/main/n/nodejs/nodejs_{version}-1_aarch64.deb"
plat = _NODE_PLAT[target]
ext = "zip" if target.startswith("win32") else "tar.xz"
- return f"https://nodejs.org/dist/v{version}/node-v{version}-{plat}.{ext}"
+ base = (
+ "https://unofficial-builds.nodejs.org/download/release"
+ if target in _MUSL_TARGETS
+ else "https://nodejs.org/dist"
+ )
+ return f"{base}/v{version}/node-v{version}-{plat}.{ext}"
def latest_versions(self, target: str, locked=None) -> list[str]:
+ # Keep one Node version across targets. If unofficial musl publication
+ # lags nodejs.org, the later artifact pin/download fails before the
+ # lockfile is written rather than selecting glibc bytes on musl.
return node_latest_versions()
@@ -615,6 +629,8 @@ class Git(BinaryPackage):
gaps = {
"linux-x64": "POSIX uses system git by choice",
"linux-arm64": "POSIX uses system git by choice",
+ "linux-x64-musl": "POSIX uses system git by choice",
+ "linux-arm64-musl": "POSIX uses system git by choice",
"darwin-x64": "POSIX uses system git by choice",
"darwin-arm64": "POSIX uses system git by choice",
}
@@ -652,7 +668,10 @@ class Gh(BinaryPackage):
binary_rel = {"win32": "bin/gh.exe", "posix": "bin/gh"}
def fetch_url(self, version: str, target: str) -> str:
- osname, arch = target.split("-")
+ # GitHub CLI's Linux release matrix is built with CGO_ENABLED=0,
+ # so the generic Linux archive is libc-independent.
+ lookup_target = target.removesuffix("-musl") if target in _MUSL_TARGETS else target
+ osname, arch = lookup_target.split("-")
plat = {"win32": "windows", "linux": "linux", "darwin": "macOS"}[osname]
arch = {"x64": "amd64", "arm64": "arm64"}[arch]
ext = "zip" if osname in ("win32", "darwin") else "tar.gz"
@@ -699,6 +718,8 @@ class Ffmpeg(_BionicDebArm, BinaryPackage, DebPackage):
"win32": "bin/ffmpeg.exe",
"linux-x64": "bin/ffmpeg",
"linux-arm64": "bin/ffmpeg",
+ "linux-x64-musl": "bin/ffmpeg",
+ "linux-arm64-musl": "bin/ffmpeg",
"posix": "ffmpeg",
}
flatten = True
@@ -710,9 +731,10 @@ class Ffmpeg(_BionicDebArm, BinaryPackage, DebPackage):
def fetch_url(self, version: str, target: str) -> str:
if target == "linux-arm64-bionic":
return f"https://packages.termux.dev/apt/termux-main/pool/main/f/ffmpeg/ffmpeg_{version}_aarch64.deb"
- osname, arch = target.split("-")
+ lookup_target = target.removesuffix("-musl") if target in _MUSL_TARGETS else target
+ osname, arch = lookup_target.split("-")
if osname in ("win32", "linux"):
- artifact = btbn_index().get(target, {}).get(version)
+ artifact = btbn_index().get(lookup_target, {}).get(version)
if artifact is not None:
tag, asset = artifact
return f"https://github.com/BtbN/FFmpeg-Builds/releases/download/{tag}/{asset}"
@@ -727,9 +749,10 @@ class Ffmpeg(_BionicDebArm, BinaryPackage, DebPackage):
"retry when the upstream index is available, or keep the existing pin")
def latest_versions(self, target: str, locked=None) -> list[str]:
- if target in ("win32-x64", "win32-arm64", "linux-x64", "linux-arm64"):
- return btbn_versions(target)
- return martin_riedl_versions(target)
+ lookup_target = target.removesuffix("-musl") if target in _MUSL_TARGETS else target
+ if lookup_target in ("win32-x64", "win32-arm64", "linux-x64", "linux-arm64"):
+ return btbn_versions(lookup_target)
+ return martin_riedl_versions(lookup_target)
@register
@@ -783,6 +806,7 @@ class Ripgrep(BinaryPackage):
class CuaDriver(BinaryPackage):
name = "cua-driver"
optional = True
+ gaps = {target: "cua-driver does not publish a musl build" for target in _MUSL_TARGETS}
binary_rel = {
"darwin-arm64": "CuaDriver.app/Contents/MacOS/cua-driver",
"darwin-x64": "CuaDriver.app/Contents/MacOS/cua-driver",
@@ -840,7 +864,10 @@ class AgentBrowser(BinaryPackage):
deps = ("chromium",)
# Termux owns its browser stack (`npm install -g agent-browser`; see
# tools/browser_tool_install.py), and PM has no bionic Chromium to drive.
- gaps = {"linux-arm64-bionic": "Termux installs agent-browser through npm"}
+ gaps = {
+ "linux-arm64-bionic": "Termux installs agent-browser through npm",
+ **{target: "agent-browser has no musl Chromium runtime" for target in _MUSL_TARGETS},
+ }
flatten = True
probe_version = False
url = "https://registry.npmjs.org/agent-browser/-/agent-browser-{version}.tgz"
@@ -901,7 +928,10 @@ class Chromium(Package):
optional = True
on_path = False
# Neither Chrome-for-Testing nor Playwright's mirror builds for Android.
- gaps = {"linux-arm64-bionic": "no Chromium build for Android/Termux"}
+ gaps = {
+ "linux-arm64-bionic": "no Chromium build for Android/Termux",
+ **{target: "Playwright/Chrome-for-Testing publishes no musl build" for target in _MUSL_TARGETS},
+ }
emulated_arch_targets = frozenset({"win32-arm64"})
_CDN = "https://cdn.playwright.dev"
diff --git a/pm/security_packages.py b/pm/security_packages.py
index b0f443b1a33..977aedff1cc 100644
--- a/pm/security_packages.py
+++ b/pm/security_packages.py
@@ -85,6 +85,8 @@ class _SignedBinary(BinaryPackage):
@register
class Tirith(_SignedBinary):
name = "tirith"
+ # v0.4.2 publishes aarch64 musl but no x86_64 musl archive.
+ gaps = {**_SignedBinary.gaps, "linux-x64-musl": "upstream publishes no x86_64 musl binary"}
binary_rel = {"posix": "tirith"}
def fetch_url(self, version: str, target: str) -> str:
@@ -116,7 +118,10 @@ class IronProxy(_SignedBinary):
return allowlisted_env()
def fetch_url(self, version: str, target: str) -> str:
- platform, arch = target.split("-")
+ # Linux releases are built with CGO_ENABLED=0, so the same signed
+ # archive is portable across glibc and musl userlands.
+ lookup_target = target.removesuffix("-musl") if target in _MUSL_TARGETS else target
+ platform, arch = lookup_target.split("-")
arch = "amd64" if arch == "x64" else arch
return f"https://github.com/paradigmxyz/iron-proxy/releases/download/v{version}/iron-proxy_{version}_{platform}_{arch}.tar.gz"
diff --git a/pm/store.py b/pm/store.py
index da9baba18ea..75a63122043 100644
--- a/pm/store.py
+++ b/pm/store.py
@@ -23,6 +23,8 @@ ALL_TARGETS = (
"win32-arm64",
"linux-x64",
"linux-arm64",
+ "linux-x64-musl",
+ "linux-arm64-musl",
"linux-arm64-bionic",
"darwin-x64",
"darwin-arm64",
@@ -96,6 +98,52 @@ def _is_bionic_libc() -> bool:
return bool(sysconfig.get_config_var("ANDROID_API_LEVEL"))
+def _elf_loader_is_musl(binary: Path) -> bool | None:
+ """Read an ELF's interpreter string without executing foreign bytes."""
+ try:
+ with binary.resolve().open("rb") as handle:
+ head = handle.read(8192)
+ except OSError:
+ return None
+ if not head.startswith(b"\x7fELF"):
+ return None
+ if b"ld-musl-" in head:
+ return True
+ if b"ld-linux" in head:
+ return False
+ return None
+
+
+def _native_linux_uses_musl() -> bool | None:
+ """libc of the native userland, independent of the Python bootstrap."""
+ for candidate in (Path("/bin/sh"), Path("/bin/ls")):
+ verdict = _elf_loader_is_musl(candidate)
+ if verdict is not None:
+ return verdict
+ return None
+
+
+def _is_musl_libc() -> bool:
+ """True on native Linux musl userlands (Alpine, Void-musl, etc.).
+
+ libc is part of PM's artifact identity. Prefer Python's build metadata,
+ then inspect a native userland ELF: a bootstrap interpreter may itself be
+ a glibc build running through a compatibility shim and misreport the host
+ libc. A bare musl-loader existence check is only the last resort because
+ glibc hosts may install musl as a secondary toolchain.
+ """
+ import sysconfig
+
+ for key in ("HOST_GNU_TYPE", "MULTIARCH"):
+ value = str(sysconfig.get_config_var(key) or "").lower()
+ if "musl" in value:
+ return True
+ native = _native_linux_uses_musl()
+ if native is not None:
+ return native
+ return any(Path("/lib").glob("ld-musl-*.so.1"))
+
+
def current_target() -> str:
machine = _native_machine()
if machine in ("arm64", "aarch64"):
@@ -110,6 +158,8 @@ def current_target() -> str:
return f"darwin-{arch}"
if _is_bionic_libc():
return f"linux-{arch}-bionic"
+ if _is_musl_libc():
+ return f"linux-{arch}-musl"
return f"linux-{arch}"
diff --git a/tests/pm/test_pm_musl.py b/tests/pm/test_pm_musl.py
new file mode 100644
index 00000000000..0d33ec42981
--- /dev/null
+++ b/tests/pm/test_pm_musl.py
@@ -0,0 +1,203 @@
+"""Regression contracts for native musl Linux PM targets (#123682)."""
+
+from __future__ import annotations
+
+import sysconfig
+from argparse import Namespace
+from pathlib import Path
+
+import pytest
+
+from pm.lock import Lockfile
+from pm.registry import get_package
+from pm.store import ALL_TARGETS
+
+pytestmark = pytest.mark.platforms("linux")
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+_MUSL_TARGETS = ("linux-x64-musl", "linux-arm64-musl")
+
+
+def test_all_targets_include_native_musl_lanes():
+ for target in _MUSL_TARGETS:
+ assert target in ALL_TARGETS
+ assert ALL_TARGETS.count(target) == 1
+
+
+def test_current_target_detects_musl_from_python_build_metadata(monkeypatch):
+ from pm import store
+
+ monkeypatch.setattr(store, "_native_machine", lambda: "x86_64")
+ monkeypatch.setattr(store, "_is_bionic_libc", lambda: False)
+ monkeypatch.setattr(
+ sysconfig,
+ "get_config_var",
+ lambda key: "x86_64-alpine-linux-musl" if key == "HOST_GNU_TYPE" else None,
+ )
+
+ assert store.current_target() == "linux-x64-musl"
+
+
+def test_elf_loader_distinguishes_native_musl_from_glibc(tmp_path):
+ from pm import store
+
+ musl = tmp_path / "musl-bin"
+ musl.write_bytes(b"\x7fELF" + b"\0" * 64 + b"/lib/ld-musl-x86_64.so.1\0")
+ glibc = tmp_path / "glibc-bin"
+ glibc.write_bytes(b"\x7fELF" + b"\0" * 64 + b"/lib64/ld-linux-x86-64.so.2\0")
+
+ assert store._elf_loader_is_musl(musl) is True
+ assert store._elf_loader_is_musl(glibc) is False
+
+
+def test_musl_detection_falls_back_to_native_userland(monkeypatch):
+ from pm import store
+
+ monkeypatch.setattr(sysconfig, "get_config_var", lambda _key: "x86_64-unknown-linux-gnu")
+ monkeypatch.setattr(store, "_native_linux_uses_musl", lambda: True)
+
+ assert store._is_musl_libc() is True
+
+
+def test_bionic_remains_more_specific_than_musl(monkeypatch):
+ from pm import store
+
+ monkeypatch.setattr(store, "_native_machine", lambda: "aarch64")
+ monkeypatch.setattr(store, "_is_bionic_libc", lambda: True)
+ monkeypatch.setattr(store, "_is_musl_libc", lambda: True)
+
+ assert store.current_target() == "linux-arm64-bionic"
+
+
[email protected]("target", _MUSL_TARGETS)
+def test_required_runtime_has_native_musl_pins(target):
+ """Every runtime tool PM selects by default has an artifact for musl."""
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for name in ("python", "uv", "node", "npm", "ffmpeg", "ripgrep"):
+ assert get_package(name).missing_reason(target) is None, name
+ assert lock.artifacts(name, target), f"{name} has no {target} artifact"
+
+
[email protected]("target", _MUSL_TARGETS)
+def test_interpreter_and_js_runtime_never_reuse_glibc_rows(target):
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for name in ("python", "uv", "node"):
+ row = lock.artifacts(name, target)[0]
+ assert "musl" in row["url"], f"{name} {target} fell back to {row['url']}"
+ assert get_package(name).fetch_url(lock.version(name), target) == row["url"]
+
+
+ "target,base",
+ [("linux-x64-musl", "linux-x64"), ("linux-arm64-musl", "linux-arm64")],
+)
+def test_static_linux_tools_reuse_the_reviewed_bytes(target, base):
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for name in ("ffmpeg", "ripgrep", "gh", "bws", "iron-proxy"):
+ assert lock.artifacts(name, target) == lock.artifacts(name, base)
+
+
+def test_ffmpeg_musl_resolution_uses_static_linux_index(monkeypatch):
+ from pm import packages
+
+ package = packages.Ffmpeg()
+ advertised = {
+ "linux-x64": {
+ "9.0.1": ("autobuild-test", "ffmpeg-test-linux64-static.tar.xz")
+ }
+ }
+ monkeypatch.setattr(packages, "btbn_index", lambda: advertised)
+
+ url = package.fetch_url("9.0.1", "linux-x64-musl")
+
+ assert url.endswith("/autobuild-test/ffmpeg-test-linux64-static.tar.xz")
+
+
[email protected]("target", _MUSL_TARGETS)
+def test_optional_incompatible_tools_are_explicit_gaps(target):
+ for name in ("git", "cua-driver", "agent-browser", "chromium"):
+ assert get_package(name).missing_reason(target), name
+
+
+def test_portable_go_tools_resolve_the_generic_linux_archives():
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for name in ("gh", "iron-proxy"):
+ package = get_package(name)
+ for target, base in (("linux-x64-musl", "linux-x64"), ("linux-arm64-musl", "linux-arm64")):
+ assert package.missing_reason(target) is None
+ assert package.fetch_url(lock.version(name), target) == lock.artifacts(name, base)[0]["url"]
+
+
+def test_security_tools_only_claim_musl_where_upstream_has_an_asset():
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for target, base in (("linux-x64-musl", "linux-x64"), ("linux-arm64-musl", "linux-arm64")):
+ assert lock.artifacts("bws", target) == lock.artifacts("bws", base)
+
+ tirith = get_package("tirith")
+ assert tirith.missing_reason("linux-x64-musl")
+ assert tirith.missing_reason("linux-arm64-musl") is None
+ arm = lock.artifacts("tirith", "linux-arm64-musl")
+ assert arm and "aarch64-unknown-linux-musl" in arm[0]["url"]
+
+
+def test_node_musl_rows_use_the_dedicated_build_channel():
+ lock = Lockfile(REPO_ROOT / "pm" / "lock.json")
+
+ for target in _MUSL_TARGETS:
+ assert lock.artifacts("node", target)[0]["url"].startswith(
+ "https://unofficial-builds.nodejs.org/download/release/"
+ )
+
+
+def test_lock_hashes_a_shared_target_url_once(monkeypatch):
+ from pm import cli
+
+ shared = "https://example.invalid/static-linux.tar.gz"
+ other = "https://example.invalid/darwin.tar.gz"
+
+ class Package:
+ name = "portable"
+
+ def missing_reason(self, _target):
+ return None
+
+ def fetch_urls(self, _version, target):
+ return [other if target == "darwin-arm64" else shared]
+
+ def known_sha256(self, _version, _url):
+ return None
+
+ class FakeLock:
+ def __init__(self):
+ self.pin = None
+ self.saved = False
+
+ def set_pin(self, name, version, artifacts):
+ self.pin = (name, version, artifacts)
+
+ def save(self):
+ self.saved = True
+
+ lock = FakeLock()
+ hashed = []
+ monkeypatch.setattr(
+ cli, "ALL_TARGETS",
+ ("linux-x64", "linux-x64-musl", "darwin-arm64"),
+ )
+ monkeypatch.setattr(cli, "get_package", lambda _name: Package())
+ monkeypatch.setattr(cli, "_lockfile", lambda: lock)
+ monkeypatch.setattr(
+ cli, "hash_url",
+ lambda url: hashed.append(url) or ("a" * 64 if url == shared else "b" * 64),
+ )
+
+ assert cli._pin_tool(Namespace(name="portable", version="1.0")) == 0
+ assert hashed.count(shared) == 1
+ assert hashed.count(other) == 1
+ assert lock.saved is True
+ assert lock.pin[2]["linux-x64"] == lock.pin[2]["linux-x64-musl"]