Commit Graph

271 Commits

Author SHA1 Message Date
AJ ONeal
46508b2ec2 ref: drop unreachable upstream-fetcher references and fix classify-one cache path
The Node server's read path now goes through ~/.cache/webi/legacy/ only
(see #1075). A handful of supporting tools and tests still carried
references to the obsolete upstream-fetcher modules and the old
year-month cache layout. Update them in place; the actual deletion of
the orphaned modules follows in #1076.

- _webi/classify-one.js — read from ~/.cache/webi/legacy/<pkg>.json
  instead of ../_cache/<yearMonth>/<pkg>.json.
- _webi/builds-cacher-test.js — drop the bc.freshenRandomPackage(...)
  call; the freshener was removed when fetching went away.
- _webi/builds.js — drop the //Releases: Releases stub comment.
- _webi/lint-builds.js — drop two now-unused require()s.
- _webi/test.js — adjust a single reference to the post-cleanup shape.
2026-05-08 16:31:18 -06:00
AJ ONeal
70067a620e fix(api): only apply libc filter when caller pinned a meaningful libc
filterReleases unconditionally rejected libc=musl entries unless the
host was libc=musl, even when the caller never specified a libc in
the request. serve-releases.js defaults the libc parameter to 'libc'
(the catch-all glibc-host bucket the installer-side resolver uses),
so the website's release table and the WEBI_RELEASES probe were both
stripped of every musl entry that the cache actually contained — even
though the installer would happily consider those builds on a glibc
host (its waterfall is [none, gnu, musl, libc]).

Treat libc='libc' (and missing) as 'no preference' so the filter only
runs when the caller pinned a real libc (musl, gnu, msvc, etc.).
Specific-libc queries (?libc=musl, ?libc=gnu) still filter exactly as
before.
2026-05-08 11:48:24 -06:00
AJ ONeal
e221dafd69 chore(build-classifier): bump to v1.0.3 for parsePrefix fix
Lexver.parsePrefix now produces a true string-prefix of parseVersion
when the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'). Unblocks pinned-version queries with a
non-trivial release suffix, including the 'webi zig.vim' alias chain
which redirects through 'vim-zig@2025.11.15-15.42.45' at install time.

See webinstall/webi-build-classifier#22.
2026-05-08 11:48:24 -06:00
AJ ONeal
07ad89ce46 ref(builds-cacher): cache-only Node server, no fetches or writes
Make _webi/builds-cacher.js and _webi/transform-releases.js read
exclusively from ~/.cache/webi/legacy/<name>.json and remove every code
path that fetched from upstream or wrote to disk. The Go cache daemon
(webicached) is now the sole writer; the Node server is a thin reader.

builds-cacher.js:
- Resolve cache files via Os.homedir() + '/.cache/webi/legacy/' instead
  of the cacheDir argument. Drop the 'caches' constructor parameter.
- Remove getLatestBuilds / getLatestBuildsInner — they require()d
  per-package releases.js modules, fetched upstream, and wrote
  <yyyy-mm>/<name>.json + .updated.txt to disk.
- Remove the process.nextTick stale-refresh hook in _doGetPackages.
  Cold reads return what's on disk; if the file is missing, return
  empty meta instead of fetching.
- Remove freshenRandomPackage and its supporting state
  (bc._staleNames, bc._freshenTimeout, bc._staleAge). The hourly
  background freshener competed with webicached for the same files.
- In getProjectTypeByEntry, decide selfhosted vs valid by probing for
  the cache file rather than require()-ing releases.js. Drop the
  not_found / 'PROBLEM/SOLUTION/npm clean-install' diagnostic in
  getProjectsByType — the cache-file probe replaces the module-load
  failure mode.

transform-releases.js:
- Remove Releases.get and the _normalize import. Replace
  getCachedReleases's fetch+race+stale-age machinery with a single
  Fs.readFile of ~/.cache/webi/legacy/<pkg>.json.
- Drop the in-process version re-sort in createFormatsSorter; the
  cache file is already version-sorted by webicached, so the sorter
  only re-orders within the same version.

No callers' public signatures change. Every other file is untouched —
the per-package releases.js modules, _common/*.js fetchers, and
_webi/normalize.js still exist on disk but are no longer reachable
from the request path.
2026-05-08 11:48:24 -06:00
AJ ONeal
da10371c71 chore(build-classifier): bump to v1.0.2 + maybeInstallable filename fix
Pulls in webinstall/webi-build-classifier#21 (merged 2026-05-07,
SHA 574eff5) and the host-target x64/win32 fix from #20 (SHA 71c0768)
that landed alongside it.

#21 fixes `maybeInstallable` rejecting any package version ending in
`.1` whose download URL is a GitHub source-archive endpoint
(`/tarball/vX.Y.1` or `/zipball/vX.Y.1`). Without it, this PR's
`_enumerateTriplets` priority fix is undermined: even after picking
the correct posix_2017 triplet, the newest version (e.g. serviceman
v1.0.1) is silently dropped by the classifier and the resolver falls
back to v1.0.0.

Confirmed on next.webi.sh after deploying this branch with the bumped
submodule: `serviceman@stable.sh` now resolves to v1.0.1/zip on macOS
arm64 (was v1.0.0/zip with the pre-rebase pre-fix submodule).
2026-05-07 00:22:02 -06:00
AJ ONeal
d0b0d54d18 fix(builds-cacher): enumerate specific OS/arch before ANYOS/ANYARCH
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.
2026-05-07 00:22:02 -06:00
AJ ONeal
28cd129a23 ref(builds-cacher): gate .git on client-provided unpacker
`.git` was pushed unconditionally into getSortedFormats's candidate
ext list, while sibling unpacker formats (.tar.xz, .tar.zst, .zip,
.7z) are gated on whether the caller's `formats` argument signals
the client has the corresponding tool.

Make `.git` consistent: only add it to the candidate list when
formats includes 'git'. The default WEBI_FORMATS ('tar,exe,zip,xz,
dmg') doesn't include git, so the change is a no-op for the
current default. Clients that want git-source packages installed
can pass `?formats=tar,exe,zip,xz,dmg,git` (or set the equivalent
in a future client-side probe).

For packages that have only a git-source asset (e.g. some vim
plugins), the existing fallback to `packages[0]` still returns the
git entry — behavior unchanged. The only observable change is for
packages where both a binary and a git fallback exist for the same
triplet: previously the git entry could win over the binary; now
it wins only when the client opts in.
2026-05-06 23:05:11 -06:00
AJ ONeal
a5c8fc28a4 fix(builds-cacher): coalesce concurrent getPackages for same name
When two HTTP requests arrived simultaneously for the same package on
a cold in-memory cache (bc._caches[name] === undefined), they would
both:
  1. Enter getPackages, see no warm cache,
  2. Read and parse the same _cache/{pkg}.json independently,
  3. Both call transformAndUpdate, which re-runs _classify on every
     build.

The first call populates bc._targetsByBuildIdCache as it classifies.
The second call then hits the cache shortcut at the top of _classify
and skips the projInfo.oses/arches/libcs/formats/triplets
accumulation block entirely. Its projInfo ends up with empty tracking
arrays (because the prior Object.assign(projInfo, meta) reset them),
and that poisoned projInfo gets written to bc._caches[name],
overwriting the first call's good cache.

After this, every subsequent installer request returns errPackage
because serve-installer.js checks projInfo.oses.includes(hostTarget.os)
— and projInfo.oses is now [].

Fix: a per-name in-flight promise. Concurrent callers for a cold
package share a single load. Calls for warm packages take the fast
path with no synchronization.

Reproduced reliably with Promise.all of 6 cold-cache calls for the
same package: 1/6 succeeded before the fix, 6/6 after. On staging at
HTTP concurrency=12, installer cand-only-errors went from 24-229
(cause-dependent) to 0.
2026-05-06 11:45:26 -06:00
AJ ONeal
8f9b9da4a3 chore: npm run fmt 2026-03-08 19:38:49 -06:00
Michael Dubner
75e39c54a2 fix: add '386' and 'i386' to tab regexp (fixes GH-941) 2025-01-29 22:59:56 +00:00
AJ ONeal
83a6d02d50 fix(api): project 'alias'es (symlinks) should be resolved before checking for 'selfhosted' 2024-12-16 01:02:37 +00:00
AJ ONeal
14cebeeb61 ref(webi): complete transition from 'request' for 'fetch' 2024-12-16 00:01:13 +00:00
AJ ONeal
c94b4cf5c7 fix(windows): use Get-CimInstance instead of deprecated Get-WmiObject 2024-11-10 07:51:52 +00:00
Caleb
d7a4aaf6b7 fix(windows): use Get-WmiObject instead of deprecated wmic
Signed-off-by: Caleb <53413881+CK6853@users.noreply.github.com>
2024-11-10 07:51:23 +00:00
AJ ONeal
005ca9f7da fix(ollama): classify 'rocm' as its own cpu + update classifier 2024-09-16 23:18:07 +00:00
AJ ONeal
efe3df6453 fix(webi): define PKG_STABLE for template when no suitable version is found 2024-09-15 23:39:51 +00:00
AJ ONeal
90eb1587ba doc+fix: enumerateLatestVersions only takes 1 argument 2024-09-13 22:27:08 +00:00
AJ ONeal
e6dcbfb83a feat(installer): show stable, and latest if different from stable 2024-09-13 22:27:07 +00:00
AJ ONeal
8f39617bcd fix: allow 'posix_2017' and 'posix_2024' for non-windows OSes 2024-09-13 08:33:48 +00:00
AJ ONeal
5bb2832ad9 feat(webi): detect 'prev', 'dev', & 'developer' as beta 2024-09-13 08:33:47 +00:00
AJ ONeal
3364dcb075 fix(rpi-zero): add armv6 alias 2024-09-13 08:33:33 +00:00
AJ ONeal
15098ba1d2 ref: use Releases.latest() and Releases.sample() 2024-09-13 08:33:32 +00:00
AJ ONeal
556697ad67 ref: make ./builds-cacher.js one-off testable; add ./classify-one.js 2024-09-11 23:29:22 +00:00
AJ ONeal
595a0b8ef9 fix(linux-gnu): update build-classifier@v1.0.0: respect explicit 'gnu' 2024-09-11 17:18:17 -06:00
AJ ONeal
566b5c047f fix(classifier): log rather than throw on failed classification 2024-08-20 15:51:02 -06:00
AJ ONeal
c71126fcd8 fix: init ~/.config/envman/ during init phase (before pre-install) 2024-07-24 12:23:34 -06:00
AJ ONeal
5c12cb1fa7 fix(busybox): use -k instead of --keep 2024-06-05 17:40:01 +00:00
AJ ONeal
67f361d35c fix(bsd): detect and use OpenBSD 'shasum' 2024-01-15 22:00:01 -07:00
AJ ONeal
05f33b1ff3 fix(bsd): use explicit untar 2024-01-15 22:00:00 -07:00
AJ ONeal
16d108e3d5 fix(fish): treat .app.zip as .zip for extraction 2024-01-15 16:23:14 -07:00
AJ ONeal
904ce1f2d6 fix(cache): set 'updated' to old date, correct typo 2024-01-07 21:04:01 -07:00
AJ ONeal
ca03de16c6 fix(builds-cacher): fallback to setting build.name from build.download 2024-01-02 16:01:43 -07:00
AJ ONeal
8e62e12334 feat(webi): show latest project release version on error 2024-01-02 15:29:19 -07:00
AJ ONeal
f13d582749 ref(webi): show supported OSes, etc with space rather than comma 2024-01-02 15:29:19 -07:00
AJ ONeal
c6bb79648a fix(installer): accept 'ANYOS' if no explicit OS matches 2024-01-02 15:29:19 -07:00
AJ ONeal
22ba86dbed feat(installer): replace getReleases with new builds classifier 2024-01-02 15:29:18 -07:00
AJ ONeal
eec6452769 ref(classify): parallelize release downloads to fetch *much* faster 2024-01-02 15:27:09 -07:00
AJ ONeal
541fdc565e feat: add builds classifier, and lint all builds 2024-01-02 15:27:09 -07:00
AJ ONeal
51b16ba53d feat: add build-classifier submodule 2024-01-02 15:27:09 -07:00
AJ ONeal
546aee8fbb ref: releases.js => installers.js 2023-12-12 02:57:03 -07:00
AJ ONeal
7c61a19e20 ref(internal): packages.js => projects.js 2023-12-12 02:57:02 -07:00
AJ ONeal
281c004445 ref(webi): show supported OSes, Arches, Libcs & Packages more clearly on error 2023-12-12 02:56:01 -07:00
AJ ONeal
e2300c6999 fix: fn_get_os for bootstrap & install 2023-12-12 01:58:58 -07:00
AJ ONeal
c116cb417f fix: remove extra / in doc url 2023-12-12 01:58:58 -07:00
AJ ONeal
3966d3adf8 fix(releases): bump timeout to 15s for uncached github requests 2023-12-12 01:44:11 -07:00
AJ ONeal
4510a61cf0 fix(envman): split non-portable function.env => function.sh, function.fish 2023-11-22 10:05:12 -07:00
AJ ONeal
7eec48ea20 fix(posix): detect current/login shell even when rc file is absent 2023-11-21 11:28:17 -07:00
AJ ONeal
74676206f1 feat+ref!(posix): rewrite to load ENVs only once for all shells 2023-11-21 11:28:17 -07:00
Lockszmith
b6a02eaf21 ref: use cat << EOF > load.sh rather than echo 2023-11-21 11:28:17 -07:00
Lockszmith
ea99790768 fix(posix): run load.sh only once when .bashrc sources .profile 2023-11-21 11:28:17 -07:00