feat(aur): publish a Node.js flavored clever-tools package - #1125
feat(aur): publish a Node.js flavored clever-tools package#1125hsablonniere wants to merge 4 commits into
Conversation
Add getSha512 next to getSha256, both factored on a private getFileHash. Add getNpmTarballSha512, which derives a published tarball checksum from the dist.integrity field of the npm registry, without downloading the tarball. The registry is written to by npm publish but read through a CDN, so the read is retried a few times.
We just recovered the ownership of the clever-tools AUR package, which used to rebuild the very same binary as clever-tools-bin. It now ships the Node.js flavor of the CLI, running on the system nodejs package. PKGBUILD templates are split per flavor, and publish-aur.js takes the flavor as an argument, so a single script publishes both AUR repositories. The Node.js package is built from the npm registry tarball, as prescribed by the Arch Node.js package guidelines, plus the package-lock.json of the matching git tag as a second source. The lockfile is what makes the install reproducible: without it, npm resolves the transitive dependency tree to whatever is latest at build time (52 transitive packages differed when measured on 4.11.0), so users would not install what we test and release.
Present clever-tools and clever-tools-bin side by side in the setup guide, and document how to validate a PKGBUILD template locally before it reaches AUR.
namcap reports 3 errors on clever-tools-bin: the binary is dynamically linked against the C and C++ runtimes, but the PKGBUILD declares no dependency at all. Add glibc and gcc-libs, and !debug to stop shipping an empty /usr/src/debug. On the Node.js package, drop the man pages vendored by dependencies, which namcap flags as non FHS. Both packages now build with zero namcap error.
|
🔎 A preview has been automatically published! If you created the alias to the preview script, you can run this command to download and install this preview: clever-preview update feat-aur-nodejs-packageYou can also run it from your local repository: ./scripts/preview.js update feat-aur-nodejs-package
This preview will be deleted once this PR is closed. |
Follow-up: how do we disable the update notifier properly?This PR ships a How it works today, for the record: nothing at the packaging level disables the notifier. if (id.endsWith('/bin/clever.js')) {
return code.replace("import '../src/initial-update-notifier.js';", '');
}The module and the Which means the disabling is a side effect of the binary build, not a decision. Two things worth fixing beyond this PR:
Options for the "how do we know" part, roughly by decreasing cleanliness:
No decision needed to merge this PR, the wrapper is not a blocker. Opening the discussion so we do not end up with one ad hoc mechanism per packaging channel. |
Closes #1124
Context
We now own the
clever-toolsAUR package. It used to be maintained by a third party, and its inherited PKGBUILD rebuilt, from the GitHub sources, the very same@yao-pkg/pkgbinary that we already publish asclever-tools-bin: two AUR packages, one artifact, and a bump lag of days to weeks after each release.It now ships the Node.js flavor of the CLI, running on the system
nodejspackage, and both packages are published by the release pipeline.What Arch users get:
clever-tools-bin: self-contained binary, no runtime dependency, frozen Node.js runtimeclever-tools: Node.js flavor,arch=any, follows the systemnodejs, so runtime security fixes are applied by pacmanProposal
scripts/publish-aur.jsnow takes a flavor argument (binornodejs) and templates live inscripts/templates/aur/<flavor>/. One script, two AUR repositories, two release jobs:publish-aur-bin(unchanged,needs: publish-cellar-archives) andpublish-aur-nodejs(needs: publish-npm).Design decisions
The npm registry tarball as source. This is the URL template prescribed by the Arch Node.js package guidelines: immutable, versioned, and already attested by our
npm publish --provenance. It is also what most Node.js CLIs packaged on the AUR use (gemini-cli,netlify,firebase-tools,devcontainer-cli,repomix).npm ciagainst the lockfile, not the wiki'snpm install -g --prefix. This is the one place where we knowingly deviate from the guidelines, and the reason is worth stating.npm always strips
package-lock.jsonfrom published tarballs, even when the file is explicitly listed in thefilesfield, so the minimal recipe resolves the transitive dependency tree to whatever is latest at build time. Measured on 4.11.0: 52 transitive dependencies resolve to versions this release was never tested against, including major bumps (@pnpm/npm-conf2.3.1 → 3.0.3,ansi-regex5.0.1 → 6.3.0,@inquirer/core10.2.0 → 10.3.2). Our direct dependencies are pinned to exact versions, their own dependencies are not.Three consequences we are not willing to ship:
clever-toolsmovingpkgver-pkgreltwo weeks apart get different packagesSo the PKGBUILD fetches
package-lock.jsonfrom the matching git tag as a second source, and runsnpm ci --omit=dev --ignore-scripts. The rationale is also inlined in the PKGBUILD, since that file is read by AUR users and by whoever edits it next.--ignore-scripts: no production dependency needs a lifecycle script, so none runs while packaging.arch=any: verified, no native addon in the production tree.A thin
shwrapper for/usr/bin/clever, exportingNO_UPDATE_NOTIFIER=1: a pacman-managed CLI must not advertise out-of-band updates. Same approach ascommand-code,claude-codeandsillytavernon the AUR.No
jqcleanup of the_whereandmankeys: the recipe in the wiki dates back to npm 6, npm 11 no longer writes those references (verified on the built package)..SRCINFOstays templated, and no containerized validation job was added.makepkg --printsrcinfooutput is byte-identical to the templated file for both flavors, and what a build in CI would catch (a broken PKGBUILD) only happens when the template is edited, not on every tag. The local validation procedure is documented inCONTRIBUTING.mdinstead.Drive-by fix
namcapreports 3 errors on the currentclever-tools-bin: the PKGBUILD declares no dependency at all, while the binary is dynamically linked against glibc, libstdc++ and libgcc. Fixed withdepends=('glibc' 'gcc-libs'), plus!debugto stop shipping an empty/usr/src/debug. Both packages now build with zero namcap error.How to review
scripts/templates/aur/nodejs/PKGBUILDfirst, it carries the whole reasoningscripts/publish-aur.jsfor the flavor dispatch, andscripts/lib/npm-registry.jswhich derives the tarball sha512 fromdist.integritywithout downloading anything.github/workflows/release.ymllast, the new job is a twin of the existing oneHow to test
Requires an Arch machine,
makepkgandnamcap. Against a local bare repository, nothing reaches AUR:Results on 4.11.0: package builds as
any, 5.4 MB compressed / 31 MB installed, zero namcap error,clever versionandclever helpwork, bash and zsh completions installed, and installing it correctly prompts to removeclever-tools-binthanks to the newconflicts.Same sequence with the
binflavor to check the existing channel still builds.Out of scope
scripts/templates/aur/**, not every tagBefore merging
The
AUR_NODEJS_GIT_URLrepository variable is already created (ssh://aur@aur.archlinux.org/clever-tools.git). Remaining check: confirm the CI SSH key has push rights on the transferred package, withssh aur@aur.archlinux.org list-repos.