From d0b0d54d180f6b3c48d6c17c7bf67deba4356801 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 6 May 2026 23:39:09 -0600 Subject: [PATCH] fix(builds-cacher): enumerate specific OS/arch before ANYOS/ANYARCH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In _enumerateTriplets, the order of `oses` and `arches` was ANYOS/ANYARCH first, specific second. This caused findMatchingPackages to pick the most-generic triplet (e.g. ANYOS-ANYARCH-none) before trying specific OS triplets — and packages that have a wildcard git fallback alongside per-platform binaries would resolve to the git source instead of the binary, even when the client never asked for git as an unpacker. Reverse the order so specific platforms win: - oses: hostTarget.os, posix_2017, posix_2024, ANYOS - arches: arches.concat(['ANYARCH']) Concrete example: serviceman has both posix_2017/*/tar.gz and */*/git in the cache. Pre-fix, findMatchingPackages picks ANYOS-ANYARCH-none (containing only the .git entry). The .git gate in getSortedFormats then correctly excludes git from format candidates, but the chosen triplet has nothing else, so selectPackage falls through to packages[0] = git entry. Post-fix, findMatchingPackages picks posix_2017-ANYARCH-none first (containing [tar.gz, zip]), and selectPackage returns tar.gz. --- _webi/builds-cacher.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/_webi/builds-cacher.js b/_webi/builds-cacher.js index f7da9b4..9325fb6 100644 --- a/_webi/builds-cacher.js +++ b/_webi/builds-cacher.js @@ -742,19 +742,22 @@ BuildsCacher.create = function ({ ALL_TERMS, installers, caches }) { return triplets; } + // Prefer platform-specific matches over ANYOS/ANYARCH fallbacks. + // This ensures e.g. darwin-aarch64-none matches before + // ANYOS-ANYARCH-none (.git source URLs from old releases). let oses = []; if (hostTarget.os === 'windows') { - oses = ['ANYOS', 'windows']; + oses = ['windows', 'ANYOS']; } else if (hostTarget.os === 'android') { - oses = ['ANYOS', 'posix_2017', 'posix_2024', 'android', 'linux']; + oses = ['android', 'linux', 'posix_2017', 'posix_2024', 'ANYOS']; } else { - oses = ['ANYOS', 'posix_2017', 'posix_2024', hostTarget.os]; + oses = [hostTarget.os, 'posix_2017', 'posix_2024', 'ANYOS']; } let waterfall = HostTargets.WATERFALL[hostTarget.os] || {}; let arches = waterfall[hostTarget.arch] || HostTargets.WATERFALL.ANYOS[hostTarget.arch] || [hostTarget.arch]; - arches = ['ANYARCH'].concat(arches); + arches = arches.concat(['ANYARCH']); let libcs = waterfall[hostTarget.libc] || HostTargets.WATERFALL.ANYOS[hostTarget.libc] || [hostTarget.libc];