Compare commits

...
Sign in to create a new pull request.

31 commits

Author SHA1 Message Date
Fedora Release Engineering
769c465c78 Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild 2026-07-16 09:39:21 +00:00
Jan Staněk
d5492bc305
Update tests from git 2026-02-04 14:42:48 +01:00
Daniel P. Berrangé
8c93ed1606 Always report the nodejs engine dep
The "has only bundled deps" check was short-circuiting logic too
early, causing the "nodejs(engine) == <ver>" dep to be missed,
which is still relevant even when bundling.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-02-04 13:40:50 +00:00
Daniel P. Berrangé
b786cecdf9 Honour package version when no tarball is given
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-02-03 15:57:41 +00:00
Daniel P. Berrangé
0a0c95bab7 Use --sort=name when creating tarballs
Using --sort=name ensures that files are added to the tarball in a
predictable ordering. This should result in a consistent checksum
for the tarball and thus facilitate reproducibility for auditing
purposes.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-02-03 15:57:41 +00:00
Daniel P. Berrangé
fdd68fbe2d Fix indentation mistakes in nodejs-packaging-bundler
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-02-03 15:57:41 +00:00
Fedora Release Engineering
aac86e3646 Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild 2026-01-16 22:12:26 +00:00
tjuhasz
4e33741bc9 Change %{nodejs_sitelib} to nonversion/shared path (rhbz#2404685) 2025-10-23 12:58:35 +02:00
Evgeni Golov
cd097f083d Properly handle @group/package deps in nodejs-symlink-deps
Node packages can have dependencies of the for "@group/package" instead of just "package".
Calling symlink() (and thus os.symlink()) in such a case fails when there is no "@group" directory yet.

```
+ /usr/lib/rpm/nodejs-symlink-deps /usr/lib/node_modules

ERROR: the path for dependency "@babel/runtime" already exists

This could mean that bundled modules are being installed.  Bundled libraries are
forbidden in Fedora. For more information, see:
    <https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries>
    
It is generally reccomended to remove the entire "node_modules" directory in
%prep when it exists. For more information, see:
    <https://fedoraproject.org/wiki/Packaging:Node.js#Removing_bundled_modules>
    
If you have obtained permission from the Fedora Packaging Committee to bundle
libraries, please use `%nodejs_fixdep -r` in %prep to remove the dependency on
the bundled module. This will prevent an unnecessary dependency on the system
version of the module and eliminate this error.
error: Bad exit status from /var/tmp/rpm-tmp.nn3mkP (%install)
```

The reported error is misleading - the path does not exist yet, but it also can't be created.
os.symlink throws OSError in both cases.

The patch prevents the issue by calling os.makedirs on the group-part of the dependency if there is one.
2025-09-02 11:43:02 +00:00
Ewoud Kohl van Wijngaarden
36224631ac Correctly determine if a package has bundled dependencies
I have a package that's as follows:

    # tree /usr/lib/node_modules/history
    /usr/lib/node_modules/history
    |-- DOMUtils.js
    |-- LocationUtils.js
    |-- PathUtils.js
    |-- createBrowserHistory.js
    |-- createHashHistory.js
    |-- createMemoryHistory.js
    |-- createTransitionManager.js
    |-- es
    |   |-- DOMUtils.js
    |   |-- LocationUtils.js
    |   |-- PathUtils.js
    |   |-- createBrowserHistory.js
    |   |-- createHashHistory.js
    |   |-- createMemoryHistory.js
    |   |-- createTransitionManager.js
    |   `-- index.js
    |-- index.js
    |-- node_modules
    |   |-- invariant -> /usr/lib/node_modules/invariant
    |   |-- loose-envify -> /usr/lib/node_modules/loose-envify
    |   |-- resolve-pathname -> /usr/lib/node_modules/resolve-pathname
    |   |-- value-equal -> /usr/lib/node_modules/value-equal
    |   `-- warning -> /usr/lib/node_modules/warning
    |-- package.json
    `-- umd
        |-- history.js
        `-- history.min.js

The node_modules directory was created by the %nodejs_symlink_deps
macro. Then when using nodejs.req I don't get any dependencies:

    # echo /usr/lib/node_modules/history/package.json | /usr/lib/rpm/nodejs.req

It looks like has_only_bundled_dependencies returns true, while it
shouldn't. Critically, it runs this code:

    bundled_dependency_iter = (
        os.path.realpath(path)
        for path in dependency_path_iter
        if not os.path.islink(path) or path.startswith(module_root_path)
    )

Here dependency_path_iter is:

    [
        '/usr/lib/node_modules/history/node_modules/invariant',
        '/usr/lib/node_modules/history/node_modules/loose-envify',
        '/usr/lib/node_modules/history/node_modules/resolve-pathname',
        '/usr/lib/node_modules/history/node_modules/value-equal',
        '/usr/lib/node_modules/history/node_modules/warning'
    ]

And module_root_path is /usr/lib/node_modules/history.

We can conclude that path.startswith(module_root_path) will always be
true, because we started with iterating over files under
module_root_path. The code suggests it should have looked up the real
path instead. If we make that change, it correctly generates the
dependencies.
2025-09-02 11:40:00 +00:00
Jan Staněk
64a93f15aa
Move nodejs_abi generator to the various streams
The generator assumed there is only one /usr/bin/node available in the distro.
Additionally, there were no generators presents for the alternative streams.

This removes the generator from here; a variant of it is being added
to each of the existing nodejs streams, adjusted to work with that
stream specifically.

Resolves: rhbz#2389160
2025-08-20 13:57:00 +02:00
Fedora Release Engineering
bbd74d8e40 Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-24 22:53:57 +00:00
Jan Staněk
15aac7eeb8
Use %autochangelog macro
Fixup: 5c3231171a
2025-02-25 12:37:58 +01:00
Fedora Release Engineering
792f09d75d Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-17 20:15:35 +00:00
Fedora Release Engineering
d504fbf5e5 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-18 19:38:12 +00:00
Yaakov Selkowitz
4299cf9076 Fix build with rpm 4.20
rpm 4.20 now uses a build-specific %_builddir (previously %_topdir/BUILD),
but this directory change occurs by default even in older versions.

https://github.com/rpm-software-management/rpm/issues/2078
2024-06-21 15:18:06 -04:00
Fedora Release Engineering
72cb54ec6a Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-25 09:10:06 +00:00
Fedora Release Engineering
945b0837ce Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-21 09:48:26 +00:00
Stephen Gallagher
9b4f2a673f Restrict autoprovides and requires to top-level
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-10-26 10:04:04 -04:00
Stephen Gallagher
7e46ce796e Get autoprovides from any package.json
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-10-24 08:35:12 -04:00
Fedora Release Engineering
53bdaf5b75 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-20 16:47:03 +00:00
Stephen Gallagher
aacfe2f12b
Drop instructions for upgrading node pkg
It is out of date as of
https://www.fedoraproject.org/wiki/Changes/NodejsRepackaging and we now
have packaging instructions included in the README.md of the individual
Node.js interpreter packaging repositories.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-04-27 11:44:13 -04:00
Stephen Gallagher
5c3231171a
Update version and switch to rpmautospec
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-03-10 10:57:08 -05:00
Stephen Gallagher
1998d72b1a
Set correct %nodejs_sitelib path
Resolves: rhbz#2177117

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-03-10 10:37:32 -05:00
Stephen Gallagher
0cd3fed400
The Node.js ABI version is now represented by the NODE_MODULE_VERSION
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-03-10 10:09:57 -05:00
Stephen Gallagher
5079b893be
Bundler: Update to modern npm arguments
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2023-03-10 09:44:24 -05:00
Fedora Release Engineering
abc52b1e7b Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-19 21:42:02 +00:00
Stephen Gallagher
2a08691cf3
Move native module building tools here from Node.js
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2022-10-20 10:00:18 -04:00
53057fc311 nodejs-packaging-bundler: recursively bundle modules for all packages found 2022-10-18 19:54:26 -07:00
Fedora Release Engineering
3c8da6aa4e Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-22 00:41:14 +00:00
1e45404676 nodejs-packaging-bundler: optionally use a local tarball instead of npm 2022-07-02 09:08:17 -07:00
11 changed files with 233 additions and 334 deletions

143
README.md
View file

@ -1,142 +1,3 @@
# How to update Node.js in Fedora
## Determine the Node.js version
Monitor the [Node.js Blog](https://nodejs.org/en/blog/) to be notified of
available updates.
For simplicity and copy-and-paste of instructions below, set some variables
here:
```
NODEJS_MAJOR=12
NODEJS_VERSION=12.9.0
```
## Clone the Fedora package repository
These steps assume that you are a comaintainer of Node.js or a provenpackager
in Fedora.
```
fedpkg clone nodejs nodejs-fedora
```
Next, switch to the major version branch you are going to update. We'll use
Node.js 12.9.0 in this document. Adjust the versions appropriately for the
version you are working on.
```
pushd nodejs-fedora
fedpkg switch-branch $NODEJS_MAJOR
popd
```
## Clone the Fedora Module repository
```
fedpkg clone modules/nodejs nodejs-fedora-module
```
## Clone the upstream Node.js repository
```
git clone -o upstream git://github.com/nodejs/node.git nodejs-upstream
```
## Rebase the Fedora patches atop the latest release
```
pushd nodejs-upstream
git checkout -b fedora-v$NODEJS_VERSION v$NODEJS_VERSION
git am -3 ../nodejs-fedora/*.patch
```
If the patches do not apply cleanly, resolve the merges appropriately. Once
they have all been applied, output them again:
```
git format-patch -M --patience --full-index -o ../nodejs-fedora v$NODEJS_VERSION..HEAD
popd
```
## Update the Node.js tarball and specfile
```
pushd nodejs-fedora
./nodejs-tarball.sh $NODEJS_VERSION
```
Note that this command will also output all of the versions for the software
bundled with Node.js. You will need to edit `nodejs.spec` and update the
%global values near the top of that file to include the appropriate values
matching the dependencies. Make sure to also update the Node.js versions too!
Note that if libuv is updated, you need to ensure that the libuv in each
buildroot is of a sufficient version. If not, you may need to update that
package first and submit a buildroot override.
Update the RPM spec %changelog appropriately.
## (Preferred) Perform a scratch-build on at least one architecture
```
fedpkg scratch-build [--arch x86_64] --srpm
```
Verify that it built successfully.
## Push the changes up to Fedora
```
fedpkg commit -cs
fedpkg push
popd
```
## (Optional) Build for Fedora releases
If this major version is the default for one or more Fedora releases, build it
for them. (Note: this step will go away in the future, once module default
streams are available in the non-modular buildroot.)
In the case of Node.js 12.x, this is the default version for Fedora 31 and 32.
```
pushd nodejs-fedora
fedpkg switch-branch [master|31]
git merge $NODEJS_MAJOR
fedpkg push
fedpkg build
popd
```
## Build module stream
```
pushd nodejs-fedora-module
fedpkg switch-branch $NODEJS_MAJOR
```
If the module has changed any package dependencies (such as added a dep on a
new shared library), you may need to modify nodejs.yaml here. If not, you can
simply run:
```
git commit --allow-empty -sm "Update to $NODEJS_VERSION"
fedpkg push
fedpkg module-build
popd
```
## Submit built packages to Bodhi
Follow the usual processes for stable/branched releases to submit builds for
testing.
# How to bundle nodejs libraries in Fedora # How to bundle nodejs libraries in Fedora
The upstream Node.js stance on The upstream Node.js stance on
@ -152,11 +13,11 @@ For more detailed packaging information go to the
## Bundling Script ## Bundling Script
``` ```
nodejs-packaging-bundler <npm_name> [version] nodejs-packaging-bundler <npm_name> [version] [tarball]
``` ```
nodejs-packaging-bundler is it's own package, nodejs-packaging-bundler and must be installed before use. nodejs-packaging-bundler is it's own package, nodejs-packaging-bundler and must be installed before use.
nodejs-packaging-bundler gets the latest npm version available, if no version is given. nodejs-packaging-bundler gets the latest npm version available, if no version is given, or uses the existing tarball if one is given. Using npm is preferred for to ease reproducibility. If a local tarball is required (e.g. because the package is missing from npm or its version is too old), please ensure to document how the tarball was created.
It produces four files and puts them in ${HOME}/rpmbuild/SOURCES It produces four files and puts them in ${HOME}/rpmbuild/SOURCES
* <npm_name>-<version>.tgz - This is the tarball from npm.org * <npm_name>-<version>.tgz - This is the tarball from npm.org

170
changelog Normal file
View file

@ -0,0 +1,170 @@
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2022.10-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Thu Oct 20 2022 Stephen Gallagher <sgallagh@redhat.com> - 2022.10-1
- Move native module building tools here from Node.js
- Add `Requires: /usr/bin/node`
* Tue Oct 18 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 2021.06-7
- NPM bundler: recursively bundle modules for all packages found
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2021.06-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sun May 01 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 2021.06-5
- NPM bundler: optionally use a local tarball instead of npm
* Thu Jan 20 2022 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-4
- NPM bundler: also find namespaced bundled dependencies
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2021.06-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Jun 22 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-2
- Fix hard-coded output directory in the bundler
* Wed Jun 02 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-1
- Update to 2021.06-1
- bundler: Handle archaic license metadata
- bundler: Warn about bundled dependencies with no license metadata
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2021.01-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jan 20 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.01-2
- nodejs-packaging-bundler improvements to handle uncommon characters
* Wed Jan 06 2021 Troy Dawson <tdawson@redhat.com> - 2021.01
- Add nodejs-packaging-bundler and update README.md
* Fri Sep 18 2020 Stephen Gallagher <sgallagh@redhat.com> - 2020.09-1
- Move to dist-git as the upstream
* Wed Sep 02 2020 Stephen Gallagher <sgallagh@redhat.com> - 25-1
- Fix incorrect bundled library detection for Requires
* Tue Sep 01 2020 Stephen Gallagher <sgallagh@redhat.com> - 24-1
- Check node_modules_prod for bundled dependencies
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 23-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jun 03 2020 Stephen Gallagher <sgallagh@redhat.com> - 23-3
- Drop Requires: nodejs(engine)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 23-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Oct 31 2019 Tom Hughes <tom@compton.nu> - 23-1
- Ensure nodejs(engine) is required for packages with no dependencies
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 22-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jul 2 2019 Tom Hughes <tom@compton.nu> - 22-1
- Refactor nodejs.req in more idiomatic Python
- Treat only external dependency links as un-bundled
* Mon Jun 10 2019 Tom Hughes <tom@compton.nu> - 21-1
- Refactor nodejs.prov in more idiomatic Python
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 20-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jan 5 2019 Tom Hughes <tom@compton.nu> - 20-1
- Fix handling of ^ dependencies for multiversion modules
* Thu Jan 3 2019 Tom Hughes <tom@compton.nu> - 18-1
- Handle =, >= and <= dependencies for multiversion modules
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu May 3 2018 Tom Hughes <tom@compton.nu> - 17-1
- Fix version comparators with a space after the operator
* Tue May 1 2018 Tom Hughes <tom@compton.nu> - 16-1
- Rewrite nodejs.req to better match npm versioning rules
- Add tests for nodejs.req and nodejs.prov
* Mon Apr 30 2018 Tom Hughes <tom@compton.nu> - 15-1
- Fix caret dependency ranges
* Thu Apr 12 2018 Tom Hughes <tom@compton.nu> - 14-1
- Only match top level modules for requires and provides generation
* Wed Feb 28 2018 Tom Hughes <tom@compton.nu> - 13-1
- Add %%nodejs_setversion macro
* Fri Feb 23 2018 Tom Hughes <tom@compton.nu> - 12-1
- Port to python 3
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Sat Jan 13 2018 Tom Hughes <tom@compton.nu> - 11-1
- nodesjs.req: use boolean with for range dependencies
* Tue Sep 12 2017 Stephen Gallagher <sgallagh@redhat.com> - 10-1
- Release v10
- Automatically generate Provides for bundled npm dependencies
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Tue Feb 21 2017 Tom Hughes <tom@compton.nu> - 9-3
- switch source URL to pagure
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Feb 2 2016 Tom Hughes <tom@compton.nu> - 9-1
- nodejs-fixdep: stop --move erroring on missing dependency types
* Sun Jan 31 2016 Tom Hughes <tom@compton.nu> - 8-1
- nodejs-fixdep: add --move option
- nodejs-symlink-deps: add --optional option
- req: generate suggests for optional dependencies
* Mon Nov 16 2015 Tom Hughes <tom@compton.nu> - 7-5
- nodejs-symlink-deps: handle caret in versions
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Wed Mar 4 2015 Ville Skyttä <ville.skytta@iki.fi> - 7-3
- Install macros in %%{_rpmconfidir}/macros.d where available (#1074279)
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Sun May 25 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 7-1
- nodejs-symlink-deps: fix regression preventing multiply versioned modules from
being symlinked correctly
* Sat May 24 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 6-1
- nodejs-fixdep: use real option parsing
- nodejs-fixdep: support modifying optionalDependencies and devDependencies
- req: support the caret operator
- nodejs-symlink-deps: add --force option
- nodejs-symlink-deps: add --build alias for --check
- nodejs-fixdep: support converting to caret dependencies
- nodejs-fixdep: support non-dictionary dependency properties
- multiver_modules: add nan
* Mon Jul 29 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 4-1
- handle cases where the symlink target exists gracefully
* Wed Jul 10 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 3-1
- dependencies and engines can be lists or strings too
- handle unversioned dependencies on multiply versioned modules correctly
(RHBZ#982798)
- restrict to compatible arches
* Fri Jun 21 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 2-1
- move multiple version list to /usr/share/node
- bump nodejs Requires to 0.10.12
- add Requires: redhat-rpm-config
* Thu Jun 13 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 1-1
- initial package

View file

@ -8,9 +8,6 @@
#for future-proofing only; we don't do multilib #for future-proofing only; we don't do multilib
%nodejs_sitearch %{nodejs_sitelib} %nodejs_sitearch %{nodejs_sitelib}
# currently installed nodejs version
%nodejs_version %(%{__nodejs} -v | sed s/v//)
# symlink dependencies so `npm link` works # symlink dependencies so `npm link` works
# this should be run in every module's %%install section # this should be run in every module's %%install section
# pass --check to work in the current directory instead of the buildroot # pass --check to work in the current directory instead of the buildroot

View file

@ -2,13 +2,14 @@
OUTPUT_DIR="$(rpm -E '%{_sourcedir}')" OUTPUT_DIR="$(rpm -E '%{_sourcedir}')"
usage() { usage() {
echo "Usage `basename $0` <npm_name> [version] " >&2 echo "Usage `basename $0` <npm_name> [version] [tarball]" >&2
echo >&2 echo >&2
echo " Given a npm module name, and optionally a version," >&2 echo " Given a npm module name, and optionally a version," >&2
echo " download the npm, the prod and dev dependencies," >&2 echo " download the npm, the prod and dev dependencies," >&2
echo " each in their own tarball." >&2 echo " each in their own tarball." >&2
echo " Also finds licenses prod dependencies." >&2 echo " Also finds licenses prod dependencies." >&2
echo " All three tarballs and the license list are copied to ${OUTPUT_DIR}" >&2 echo " All three tarballs and the license list are copied to ${OUTPUT_DIR}" >&2
echo " If a tarball is passed, use that instead of downloading from npm" >&2
echo >&2 echo >&2
exit 1 exit 1
} }
@ -38,6 +39,9 @@ fi
if [ $# -ge 2 ]; then if [ $# -ge 2 ]; then
VERSION="$2" VERSION="$2"
if [ $# -ge 3 ]; then
TARBALL="$(realpath "$3")"
fi
else else
VERSION="$(npm view ${PACKAGE} version)" VERSION="$(npm view ${PACKAGE} version)"
fi fi
@ -47,11 +51,23 @@ TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
mkdir -p ${OUTPUT_DIR} mkdir -p ${OUTPUT_DIR}
mkdir -p ${TMP_DIR} mkdir -p ${TMP_DIR}
pushd ${TMP_DIR} pushd ${TMP_DIR}
npm pack ${PACKAGE} if [ -f "$TARBALL" ]; then
TARBALL_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
pushd ${TARBALL_DIR}
tar xfz ${TARBALL} --strip-components 1
npm pack .
popd > /dev/null
mv ${TARBALL_DIR}/*.tgz .
rm -rf ${TARBALL_DIR}
else
npm pack ${PACKAGE}@${VERSION}
fi
tar xfz *.tgz tar xfz *.tgz
cd package cd package
for packagejson in $(find . -type d -name node_modules\* -prune -o -type f -name package.json -print); do
pushd $(dirname $packagejson)
echo " Downloading prod dependencies" echo " Downloading prod dependencies"
npm install --no-optional --only=prod npm install --omit=dev --omit=optional
if [ $? -ge 1 ] ; then if [ $? -ge 1 ] ; then
echo " ERROR WILL ROBINSON" echo " ERROR WILL ROBINSON"
rm -rf node_modules rm -rf node_modules
@ -59,6 +75,9 @@ else
echo " Successful prod dependencies download" echo " Successful prod dependencies download"
mv node_modules/ node_modules_prod mv node_modules/ node_modules_prod
fi fi
popd
done
echo "LICENSES IN BUNDLE:" echo "LICENSES IN BUNDLE:"
find . -name "package.json" -exec jq '.license | strings' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt find . -name "package.json" -exec jq '.license | strings' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt
find . -name "package.json" -exec jq '.license | objects | .type' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt 2>/dev/null find . -name "package.json" -exec jq '.license | objects | .type' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt 2>/dev/null
@ -75,19 +94,23 @@ if [ -s ${TMP_DIR}/nolicense.txt ]; then
fi fi
for packagejson in $(find . -type d -name node_modules\* -prune -o -type f -name package.json -print); do
pushd $(dirname $packagejson)
echo " Downloading dev dependencies" echo " Downloading dev dependencies"
npm install --no-optional --only=dev npm install --omit=optional
if [ $? -ge 1 ] ; then if [ $? -ge 1 ] ; then
echo " ERROR WILL ROBINSON" echo " ERROR WILL ROBINSON"
else else
echo " Successful dev dependencies download" echo " Successful dev dependencies download"
mv node_modules/ node_modules_dev mv node_modules/ node_modules_dev
fi fi
popd
done
if [ -d node_modules_prod ] ; then if [ -d node_modules_prod ] ; then
tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-prod.tgz node_modules_prod tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-prod.tgz --sort=name $(find . -type d -name node_modules_prod)
fi fi
if [ -d node_modules_dev ] ; then if [ -d node_modules_dev ] ; then
tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-dev.tgz node_modules_dev tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-dev.tgz --sort=name $(find . -type d -name node_modules_dev)
fi fi
cd .. cd ..
cp -v ${PACKAGE_SAFE}-${VERSION}* "${OUTPUT_DIR}" cp -v ${PACKAGE_SAFE}-${VERSION}* "${OUTPUT_DIR}"

View file

@ -1,8 +1,8 @@
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
Name: nodejs-packaging Name: nodejs-packaging
Version: 2021.06 Version: 2023.10
Release: 4%{?dist} Release: %autorelease
Summary: RPM Macros and Utilities for Node.js Packaging Summary: RPM Macros and Utilities for Node.js Packaging
BuildArch: noarch BuildArch: noarch
License: MIT License: MIT
@ -19,7 +19,8 @@ Source0007: nodejs-symlink-deps
Source0008: nodejs.attr Source0008: nodejs.attr
Source0009: nodejs.prov Source0009: nodejs.prov
Source0010: nodejs.req Source0010: nodejs.req
Source0011: nodejs-packaging-bundler
Source0111: nodejs-packaging-bundler
# Created with `tar cfz test.tar.gz test` # Created with `tar cfz test.tar.gz test`
Source0101: test.tar.gz Source0101: test.tar.gz
@ -46,10 +47,8 @@ It generates a bundled license file that gets the licenses in the runtime
dependency tarball dependency tarball
%prep %prep
pushd %{_topdir}/BUILD
cp -da %{_sourcedir}/* . cp -da %{_sourcedir}/* .
tar xvf test.tar.gz tar xvf test.tar.gz
popd
%build %build
@ -84,157 +83,4 @@ install -Dpm0755 nodejs-packaging-bundler %{buildroot}%{_bindir}/nodejs-packagin
%changelog %changelog
* Thu Jan 20 2022 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-4 %autochangelog
- NPM bundler: also find namespaced bundled dependencies
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2021.06-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Jun 22 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-2
- Fix hard-coded output directory in the bundler
* Wed Jun 02 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.06-1
- Update to 2021.06-1
- bundler: Handle archaic license metadata
- bundler: Warn about bundled dependencies with no license metadata
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2021.01-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jan 20 2021 Stephen Gallagher <sgallagh@redhat.com> - 2021.01-2
- nodejs-packaging-bundler improvements to handle uncommon characters
* Wed Jan 06 2021 Troy Dawson <tdawson@redhat.com> - 2021.01
- Add nodejs-packaging-bundler and update README.md
* Fri Sep 18 2020 Stephen Gallagher <sgallagh@redhat.com> - 2020.09-1
- Move to dist-git as the upstream
* Wed Sep 02 2020 Stephen Gallagher <sgallagh@redhat.com> - 25-1
- Fix incorrect bundled library detection for Requires
* Tue Sep 01 2020 Stephen Gallagher <sgallagh@redhat.com> - 24-1
- Check node_modules_prod for bundled dependencies
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 23-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jun 03 2020 Stephen Gallagher <sgallagh@redhat.com> - 23-3
- Drop Requires: nodejs(engine)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 23-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Oct 31 2019 Tom Hughes <tom@compton.nu> - 23-1
- Ensure nodejs(engine) is required for packages with no dependencies
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 22-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jul 2 2019 Tom Hughes <tom@compton.nu> - 22-1
- Refactor nodejs.req in more idiomatic Python
- Treat only external dependency links as un-bundled
* Mon Jun 10 2019 Tom Hughes <tom@compton.nu> - 21-1
- Refactor nodejs.prov in more idiomatic Python
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 20-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jan 5 2019 Tom Hughes <tom@compton.nu> - 20-1
- Fix handling of ^ dependencies for multiversion modules
* Thu Jan 3 2019 Tom Hughes <tom@compton.nu> - 18-1
- Handle =, >= and <= dependencies for multiversion modules
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu May 3 2018 Tom Hughes <tom@compton.nu> - 17-1
- Fix version comparators with a space after the operator
* Tue May 1 2018 Tom Hughes <tom@compton.nu> - 16-1
- Rewrite nodejs.req to better match npm versioning rules
- Add tests for nodejs.req and nodejs.prov
* Mon Apr 30 2018 Tom Hughes <tom@compton.nu> - 15-1
- Fix caret dependency ranges
* Thu Apr 12 2018 Tom Hughes <tom@compton.nu> - 14-1
- Only match top level modules for requires and provides generation
* Wed Feb 28 2018 Tom Hughes <tom@compton.nu> - 13-1
- Add %%nodejs_setversion macro
* Fri Feb 23 2018 Tom Hughes <tom@compton.nu> - 12-1
- Port to python 3
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Sat Jan 13 2018 Tom Hughes <tom@compton.nu> - 11-1
- nodesjs.req: use boolean with for range dependencies
* Tue Sep 12 2017 Stephen Gallagher <sgallagh@redhat.com> - 10-1
- Release v10
- Automatically generate Provides for bundled npm dependencies
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Tue Feb 21 2017 Tom Hughes <tom@compton.nu> - 9-3
- switch source URL to pagure
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Feb 2 2016 Tom Hughes <tom@compton.nu> - 9-1
- nodejs-fixdep: stop --move erroring on missing dependency types
* Sun Jan 31 2016 Tom Hughes <tom@compton.nu> - 8-1
- nodejs-fixdep: add --move option
- nodejs-symlink-deps: add --optional option
- req: generate suggests for optional dependencies
* Mon Nov 16 2015 Tom Hughes <tom@compton.nu> - 7-5
- nodejs-symlink-deps: handle caret in versions
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Wed Mar 4 2015 Ville Skyttä <ville.skytta@iki.fi> - 7-3
- Install macros in %%{_rpmconfidir}/macros.d where available (#1074279)
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Sun May 25 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 7-1
- nodejs-symlink-deps: fix regression preventing multiply versioned modules from
being symlinked correctly
* Sat May 24 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 6-1
- nodejs-fixdep: use real option parsing
- nodejs-fixdep: support modifying optionalDependencies and devDependencies
- req: support the caret operator
- nodejs-symlink-deps: add --force option
- nodejs-symlink-deps: add --build alias for --check
- nodejs-fixdep: support converting to caret dependencies
- nodejs-fixdep: support non-dictionary dependency properties
- multiver_modules: add nan
* Mon Jul 29 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 4-1
- handle cases where the symlink target exists gracefully
* Wed Jul 10 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 3-1
- dependencies and engines can be lists or strings too
- handle unversioned dependencies on multiply versioned modules correctly
(RHBZ#982798)
- restrict to compatible arches
* Fri Jun 21 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 2-1
- move multiple version list to /usr/share/node
- bump nodejs Requires to 0.10.12
- add Requires: redhat-rpm-config
* Thu Jun 13 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 1-1
- initial package

View file

@ -30,6 +30,8 @@ import shutil
import sys import sys
def symlink(source, dest): def symlink(source, dest):
if os.path.sep in dest:
os.makedirs(os.path.dirname(dest), exist_ok=True)
try: try:
os.symlink(source, dest) os.symlink(source, dest)
except OSError: except OSError:

View file

@ -1,4 +1,4 @@
%__nodejs_provides %{_rpmconfigdir}/nodejs.prov %__nodejs_provides %{_rpmconfigdir}/nodejs.prov
%__nodejs_requires %{_rpmconfigdir}/nodejs.req %__nodejs_requires %{_rpmconfigdir}/nodejs.req
%__nodejs_suggests %{_rpmconfigdir}/nodejs.req --optional %__nodejs_suggests %{_rpmconfigdir}/nodejs.req --optional
%__nodejs_path ^/usr/lib(64)?/node_modules/[^/]+/package\\.json$ %__nodejs_path ^/usr/lib/node_modules\(_[[:digit:]]\+\)\{0,1\}/[^/]\+/package\.json$

View file

@ -633,9 +633,9 @@ def has_only_bundled_dependencies(module_dir_path):
for basename in os.listdir(dependency_root_path) for basename in os.listdir(dependency_root_path)
) )
bundled_dependency_iter = ( bundled_dependency_iter = (
os.path.realpath(path) path
for path in dependency_path_iter for path in dependency_path_iter
if not os.path.islink(path) or path.startswith(module_root_path) if not os.path.islink(path) or os.path.realpath(path).startswith(module_root_path)
) )
return any(bundled_dependency_iter) return any(bundled_dependency_iter)
@ -659,9 +659,6 @@ def extract_dependencies(metadata_path, optional=False):
TypeError: Invalid dependency data type. TypeError: Invalid dependency data type.
""" """
if has_only_bundled_dependencies(os.path.dirname(metadata_path)):
return # skip
# Read metadata # Read metadata
try: try:
with open(metadata_path, mode="r") as metadata_file: with open(metadata_path, mode="r") as metadata_file:
@ -676,6 +673,9 @@ def extract_dependencies(metadata_path, optional=False):
except KeyError: # NodeJS engine version unspecified except KeyError: # NodeJS engine version unspecified
yield rpm_format("nodejs(engine)") yield rpm_format("nodejs(engine)")
if has_only_bundled_dependencies(os.path.dirname(metadata_path)):
return # skip
# Report listed dependencies # Report listed dependencies
kind = "optionalDependencies" if optional else "dependencies" kind = "optionalDependencies" if optional else "dependencies"
container = metadata.get(kind, {}) container = metadata.get(kind, {})

View file

@ -1 +1 @@
SHA512 (test.tar.gz) = dfbda67b8741f1ca36bf63b2e842f81ba07381b3d92e75fa7e29f8e456543b4cae55e95785902f31a14ae4d0b7e89161ba04c0c10c2fff617b4ae9607c91e599 SHA512 (test.tar.gz) = 04c1e741caa124c12b1070b6411d1a9fef9b328e15ec274170b7dcd9d26d9a6f9db21d6722ce0b39d0b693f237398065dd127b95a9a6e4947e182db2e3fad6f2

View file

@ -1 +1 @@
(nodejs(engine) >= 6 with nodejs(engine) < 10)

View file

@ -1 +1 @@
(nodejs(engine) >= 6 with nodejs(engine) < 10)