Mk/Uses/npm.mk: Introduce NPM_PREFETCH_REVISION variable
The prefetch function of USES=npm automatically generates an archive
of node modules needed for a port. The versioning for the archive only
include DISTVERSION and not PORTREVISION to avoid generating duplicate
node modules archive on each port revision bump.
There is a case that a porter wants to update the contents of the node
modules archive (without port version bump) due to some changes to
package.json and/or lockfile. The prefetch function cannot overwrite a
pre-existing node modules archive with one with updated distinfo due
to a limitation of the ports framework.
In such a case, a porter can set NPM_PREFETCH_REVISION to a non-zero
value to produce a new name for node modules archive to work around
the limitation.
NPM_PREFETCH_REVISION should be left undefined unless absolutely
necessary.
PR: 301272
Reported by: Derek Schrock <dereks@lifeofadishwasher.com>
Mk/Uses/npm.mk: Add support for pnpm >= 12
pnpm 12 has been rewritten in Rust and introduced an
architecture-dependent node module, which is required to be installed
separately from the main node module.
By default, the installation occurs upon the first pnpm execution and
breaks poudriere builds. So prefetch and extract the native executable
to the expected location in advance to avoid breakage.
Mk/Uses/npm.mk: Preserve WRKDIR itself after archiving node modules
Removing WRKDIR itself breaks the makesum phase. So only removes the
contents of WRKDIR (node-modules-cache directory and
node-modules-cache.mtree file).
Mk/Uses/npm.mk: Move --frozen-lockfile from NPM_FETCH_FLAGS to NPM_EXTRACT_FLAGS
`pnpm fetch` does not read a package manafest and only relies on a
lockfile. So specifying --frozen-lockfile here is redundant. We need
the flag when we extrace (install) node modules from a pre-fetched
node modules cache.
Mk/Uses/npm.mk: Add new variable NPM_PREFETCH_ARCHS
A node modules archive created by the prefetch function may vary
depending on the architecture, especially if the archive contains
architecture-specific node modules.
This variable can be used to indicate which architectures the node
modules archives are prepared for.
If you prepared the archives for amd64 and aarch64 architecutres,
specify:
NPM_PREFETCH_ARCHS= aarch64 amd64
Mk/Uses/npm.mk: Always use X' for denoting BLOB data type
SQLite's .dump always uses X' (capital X) for BLOB. So it's better we
use X' in the code for securing reproducibility of node modules
tarball created by pnpm.
Also, conversion from x' to X' in output dump file in case x' is
accidentally mixed in.
Reported by: pkg-fallout
Mk/Uses/npm.mk: Quote TMPDIR and WRKDIR in shell comparisons
When TMPDIR is unset, the generated shell command becomes:
if [ != ${WRKDIR} ]; then
and /bin/sh reports:
[: !=: unexpected operator
Quoting both variables fixes the issue.
PR: 297181
Reported by: Shin-ichi Nagamura <core@zsc.jp>
Mk/Uses/npm.mk: Remove temp directory in pnpm store before making archive
Leaving the directory in place may cause the node modules archive to
be unreproducible.
Mk/Uses/npm.mk: Unbreak make index
In the previous commit, NPM_VER_MAJOR and NPM_VER_MINOR are left
undefined when NPM_VER is manually specified. This change corrects the
error.
Reported by: Xavier Humbert <xavier@groumpf.org> (via ports),
antoine (via ports-committers)
Fixes: dad28f35db5a (Mk/Uses/npm.mk: Correct NPM version comparison)
Mk/Uses/npm.mk: Correct NPM version comparison
Assuming NPM version follows the semantic versioning, NPM_VER:R was
used to obtain the major and the minor version of NPM. However, when
the minor version is equal or greater than 10, the comparison
NPM:R >= 11.3 does not make sense. This change corrects version
comparison using major and minor combination.
*/*: Use C.UTF-8 locale
Ports 02f27a83b44d fixed the ports tree to the C locale so it would work
correctly in environments where users use a locale that isn't compatible
with the C locale, e.g. xx_YY.UTF-8 where [A-Z] includes more than just
upper case letters. USE_LOCALE was introduced to let ports use another
locale if they needed it. The C.UTF-8 locale was created later on to be
mostly compatible with the C locale.
Switch the ports tree locale to C.UTF-8 and remove USE_LOCALE. The
world has moved to Unicode so all ports either require it or know how to
build correctly in a Unicode environment.
PR: 295945
Exp-run by: antoine
Mk/Uses/electron.mk: Split fetch- and extract-related codes out to npm.mk
Prefetch and extract functions are not necessarily limited to electron
ports. Those functions can be utilized by any ports which needs an
offline node modules installation.
Previously, non-electron ports wanting to use prefetch and/or extract
functions needs to use USES=electron:env, which is now removed in
favor of USES=npm:<package manager name>.
The following description:
USES= electron:env
USE_ELECTRON= npm:npm-name prefetch extract
is simplified to:
USES= npm:npm-name