From 3b8b42862a27c8455c717e525d12e81cd41e4402 Mon Sep 17 00:00:00 2001 From: tigro Date: Wed, 27 Sep 2023 07:40:08 +0300 Subject: [PATCH] import nodejs-packaging-2021.06-3.el9 --- .nodejs-packaging.metadata | 2 +- SOURCES/README.md | 218 ++++++++++++++++++++++++++++++++++++ SOURCES/nodejs.prov | 6 +- SPECS/nodejs-packaging.spec | 7 +- 4 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 SOURCES/README.md diff --git a/.nodejs-packaging.metadata b/.nodejs-packaging.metadata index 11b5202..1b02510 100644 --- a/.nodejs-packaging.metadata +++ b/.nodejs-packaging.metadata @@ -1 +1 @@ -dfaa3308397a75e566baec53cc32e6a635eca1e9 SOURCES/test.tar.gz +dfaa3308397a75e566baec53cc32e6a635eca1e9 SOURCES/test.tar.gz diff --git a/SOURCES/README.md b/SOURCES/README.md new file mode 100644 index 0000000..cbad903 --- /dev/null +++ b/SOURCES/README.md @@ -0,0 +1,218 @@ +# 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 + +The upstream Node.js stance on +[global library packages](https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/) +is that they are ".. best avoided if not needed." In Fedora, we take the same +stance with our nodejs packages. You can provide a package that uses nodejs, +but you should bundle all the nodejs libraries that are needed. + +We are providing a sample spec file and bundling script here. +For more detailed packaging information go to the +[Fedora Node.js Packaging Guildelines](https://docs.fedoraproject.org/en-US/packaging-guidelines/Node.js/) + +## Bundling Script + +``` +nodejs-packaging-bundler [version] +``` + +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. +It produces four files and puts them in ${HOME}/rpmbuild/SOURCES + + * -.tgz - This is the tarball from npm.org + * --nm-prod.tgz - This is the tarball that contains all the bundled nodejs modules needs to run + * --nm-dev.tgz - This is the tarball that contains all the bundled nodejs modules needs to test + * --bundled-licenses.txt - This lists the bundled licenses in --nm-prod.tgz + +## Sample Spec File + +``` +%global npm_name my_nodejs_application +... +License: and and +... +Source0: http://registry.npmjs.org/%{npm_name}/-/%{npm_name}-%{version}.tgz +Source1: %{npm_name}-%{version}-nm-prod.tgz +Source2: %{npm_name}-%{version}-nm-dev.tgz +Source3: %{npm_name}-%{version}-bundled-licenses.txt +... +BuildRequires: nodejs-devel +... +%prep +%setup -q -n package +cp %{SOURCE3} . +... +%build +# Setup bundled node modules +tar xfz %{SOURCE1} +mkdir -p node_modules +pushd node_modules +ln -s ../node_modules_prod/* . +ln -s ../node_modules_prod/.bin . +popd +... +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{npm_name} +cp -pr index.js lib package.json %{buildroot}%{nodejs_sitelib}/%{npm_name} +# Copy over bundled nodejs modules +cp -pr node_modules node_modules_prod %{buildroot}%{nodejs_sitelib}/%{npm_name} +... +%check +%nodejs_symlink_deps --check +# Setup bundled dev node_modules for testing +tar xfz %{SOURCE2} +pushd node_modules +ln -s ../node_modules_dev/* . +popd +pushd node_modules/.bin +ln -s ../../node_modules_dev/.bin/* . +popd +# Example test run using the binary in ./node_modules/.bin/ +./node_modules/.bin/vows --spec --isolate +... +%files +%doc HISTORY.md +%license LICENSE.md %{npm_name}-%{version}-bundled-licenses.txt +%{nodejs_sitelib}/%{npm_name} +``` + diff --git a/SOURCES/nodejs.prov b/SOURCES/nodejs.prov index 56a9bf1..663d3d9 100755 --- a/SOURCES/nodejs.prov +++ b/SOURCES/nodejs.prov @@ -93,9 +93,9 @@ def generate_dependencies(module_path, module_dir_set=NODE_MODULES): else: # Invalid metadata path raise ValueError("Invalid module path '%s'" % module_path) - for dir_path, subdir_list, file_list in os.walk(root_dir): - # We are only interested in directories that contain package.json - if "package.json" not in file_list: + for dir_path, subdir_list, __ in os.walk(root_dir): + # Currently in node_modules (or similar), continue to subdirs + if os.path.basename(dir_path) in module_dir_set: continue # Read and format metadata diff --git a/SPECS/nodejs-packaging.spec b/SPECS/nodejs-packaging.spec index dacd509..54623fd 100644 --- a/SPECS/nodejs-packaging.spec +++ b/SPECS/nodejs-packaging.spec @@ -2,7 +2,7 @@ Name: nodejs-packaging Version: 2021.06 -Release: 4%{?dist} +Release: 3%{?dist} Summary: RPM Macros and Utilities for Node.js Packaging BuildArch: noarch License: MIT @@ -10,6 +10,7 @@ URL: https://fedoraproject.org/wiki/Node.js/Packagers ExclusiveArch: %{nodejs_arches} noarch Source0001: LICENSE +Source0002: README.md Source0003: macros.nodejs Source0004: multiver_modules Source0005: nodejs-fixdep @@ -83,8 +84,8 @@ install -Dpm0755 nodejs-packaging-bundler %{buildroot}%{_bindir}/nodejs-packagin %changelog -* Thu Jan 20 2022 Stephen Gallagher - 2021.06-4 -- NPM bundler: also find namespaced bundled dependencies +* Wed Sep 27 2023 Arkady L. Shane - 2021.06-3 +- Rebuilt for MSVSphere 9.2 * Thu Jul 22 2021 Fedora Release Engineering - 2021.06-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild