File project.diff of Package nodejs22

--- nodejs22.spec.orig
+++ nodejs22.spec
@@ -1,7 +1,7 @@
 #
 # spec file for package nodejs22
 #
-# Copyright (c) 2024 SUSE LLC
+# Copyright (c) 2025 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,17 +15,7 @@
 # Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
-###########################################################
-#
-#   WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
-#
-# This spec file is generated from a template hosted at
-# https://github.com/AdamMajer/nodejs-packaging
-#
-###########################################################
 
-# Fedora doesn't have rpm-config-SUSE which provides
-# ext_man in /usr/lib/rpm/macros.d/macros.obs
 %if 0%{?fedora_version}
 %define ext_man .gz
 %endif
@@ -49,6 +39,15 @@ Release:        0
 %bcond_with libalternatives
 %endif
 
+%bcond_with nodejs_shared
+
+%if %{with nodejs_shared}
+# the testsuite tries to link libraries which are not part of the normal build
+%bcond_with nodejs_run_tests
+%else
+%bcond_without nodejs_run_tests
+%endif
+
 # nodejs20+ is not for SLE12
 %if %{node_version_number} >= 20 && 0%{?suse_version} > 0 && 0%{?suse_version} < 1500
 ExclusiveArch do_not_build
@@ -134,8 +133,8 @@ Source1:        https://nodejs.org/dist/
 Source2:        https://nodejs.org/dist/v%{version}/SHASUMS256.txt.sig
 Source3:        nodejs.keyring
 
-# Only required to run unit tests in NodeJS 10+ 
-Source10:       update_npm_tarball.sh 
+# Only required to run unit tests in NodeJS 10+
+Source10:       update_npm_tarball.sh
 Source11:       node_modules.tar.xz
 Source20:       bash_output_helper.bash
 
@@ -146,8 +145,6 @@ Patch5:         sle12_python3_compat.pat
 Patch7:         manual_configure.patch
 Patch13:        openssl_binary_detection.patch
 
-
-
 ## Patches specific to SUSE and openSUSE
 Patch100:       linker_lto_jobs.patch
 # PATCH-FIX-OPENSUSE -- set correct path for dtrace if it is built
@@ -175,8 +172,10 @@ Patch309:       gcc13.patch
 Patch311:       old_cares.patch
 Patch312:       fab6906c5d1c16b046187485a7cb136b3659d42b.patch
 
-BuildRequires:  pkg-config
+Patch400:       use_libdir_forlib.patch
+
 BuildRequires:  fdupes
+BuildRequires:  pkg-config
 BuildRequires:  procps
 BuildRequires:  xz
 BuildRequires:  zlib-devel
@@ -209,8 +208,8 @@ BuildRequires:  gcc48-c++
 # for SLE-12:Update targets
 %if 0%{?suse_version} == 1315
 %if %node_version_number >= 17
-BuildRequires:  gcc12-c++
 BuildRequires:  gcc12-PIE
+BuildRequires:  gcc12-c++
 %define forced_gcc_version 12
 %else
 %if %node_version_number >= 14
@@ -227,8 +226,8 @@ BuildRequires:  gcc7-c++
 
 %if 0%{?suse_version} == 1500
 %if %node_version_number >= 17
-BuildRequires:  gcc12-c++
 BuildRequires:  gcc12-PIE
+BuildRequires:  gcc12-c++
 %define forced_gcc_version 12
 %endif
 %endif
@@ -239,7 +238,6 @@ BuildRequires:  gcc12-PIE
 BuildRequires:  gcc-c++
 %endif
 
-
 # Python dependencies
 %if %node_version_number >= 14
 
@@ -253,8 +251,8 @@ BuildRequires:  python311
 %define forced_python_version 3.11
 %endif
 %if %{?suse_version} > 1500
-BuildRequires:  python3
-BuildRequires:  python3-setuptools
+BuildRequires:  python311
+BuildRequires:  python311-setuptools
 %endif
 %endif
 
@@ -273,8 +271,8 @@ BuildRequires:  python
 %endif
 
 %if 0%{?suse_version} >= 1500 && %{node_version_number} >= 10
-BuildRequires:  user(nobody)
 BuildRequires:  group(nobody)
+BuildRequires:  user(nobody)
 %endif
 
 # shared openssl
@@ -289,11 +287,10 @@ BuildRequires:  openssl >= %{openssl_req
 BuildRequires:  (libopenssl1_1-hmac if libopenssl-1_1-devel)
 BuildRequires:  (libopenssl3-hmac if libopenssl-3-devel)
 %else
-BuildRequires:  openssl-1_1 >= %{openssl_req_ver}
 BuildRequires:  libopenssl1_1-hmac
+BuildRequires:  openssl-1_1 >= %{openssl_req_ver}
 %endif
 
-
 # /suse_version
 %endif
 
@@ -380,8 +377,8 @@ ExclusiveArch:  not_buildable
 %endif
 %endif
 
-Provides:       bundled(uvwasi) = 0.0.21
 Provides:       bundled(libuv) = 1.49.2
+Provides:       bundled(uvwasi) = 0.0.21
 Provides:       bundled(v8) = 12.4.254.21
 %if %{with intree_brotli}
 Provides:       bundled(brotli) = 1.1.0
@@ -389,12 +386,11 @@ Provides:       bundled(brotli) = 1.1.0
 BuildRequires:  pkgconfig(libbrotlidec)
 %endif
 
-
 Provides:       bundled(llhttp) = 9.2.1
 Provides:       bundled(ngtcp2) = 1.9.1
 
-Provides:       bundled(simdutf) = 5.6.4
 Provides:       bundled(simdjson) = 3.10.1
+Provides:       bundled(simdutf) = 5.6.4
 # bundled url-ada parser, not ada
 Provides:       bundled(ada) = 2.9.2
 
@@ -415,8 +411,8 @@ provided by npm.
 Summary:        Development headers for NodeJS 22.x
 Group:          Development/Languages/NodeJS
 Provides:       nodejs-devel = %{version}
-Requires:       npm22 = %{version}
 Requires:       %{name} = %{version}
+Requires:       npm22 = %{version}
 
 %description devel
 This package provides development headers for Node.js needed for creation
@@ -433,12 +429,12 @@ Requires:       nodejs-common
 Requires:       nodejs22 = %{version}
 Provides:       nodejs-npm = %{version}
 Obsoletes:      nodejs-npm < 4.0.0
-Provides:       npm(npm) = 10.9.2
 Provides:       npm = %{version}
+Provides:       npm(npm) = 10.9.2
 %if 0%{?suse_version} >= 1500
 %if %{node_version_number} >= 10
-Requires:       user(nobody)
 Requires:       group(nobody)
+Requires:       user(nobody)
 %endif
 %endif
 Provides:       bundled(node-abbrev) = 2.0.0
@@ -706,6 +702,10 @@ popd
 %patch -P 311 -p1
 %patch -P 312 -p1
 
+%if %{with nodejs_shared}
+%patch -P 400 -p1
+%endif
+
 %if %{node_version_number} == 12
 # minimist security update - patch50
 rm -r deps/npm/node_modules/mkdirp/node_modules/minimist
@@ -718,8 +718,6 @@ find -name \*~ -print0 -delete
 # abnormalities from patching
 find \( -name \*.js.orig -or -name \*.md.orig -or -name \*.1.orig \) -delete
 
-
-
 %build
 # normalize shebang
 %if %{node_version_number} >= 12
@@ -778,6 +776,10 @@ EOF
 
 ./configure \
     --prefix=%{_prefix} \
+%if %{with nodejs_shared}
+    --shared \
+    --libdir=%{_libdir} \
+%endif
 %if 0%{?with nodejs_lto}
     --enable-lto \
 %endif
@@ -821,6 +823,14 @@ find doc/api -type f -exec chmod 0644 {}
 . ./spec.build.config
 
 decoupled_cmd %make_install %{?_smp_mflags}
+
+%if %{with nodejs_shared}
+# TODO: move to tools/install.py
+pushd %{buildroot}%{_libdir}
+ln -s libnode%{node_version_number}.so.* libnode%{node_version_number}.so
+popd
+%endif
+
 rm %{buildroot}%{_datadir}/doc/node/gdbinit
 rm -f %{buildroot}%{_datadir}/doc/node/lldbinit
 rm -f %{buildroot}%{_datadir}/doc/node/lldb_commands.py
@@ -923,6 +933,7 @@ EOF
 mkdir -p %{buildroot}%{_defaultlicensedir}
 %endif
 
+%if %{with nodejs_run_tests}
 %check
 . ./spec.build.config
 
@@ -932,6 +943,9 @@ export OPENSSL_CONF=''
 
 export CI_JS_SUITES=default
 export NODE_TEST_NO_INTERNET=1
+%if %{with nodejs_shared}
+export LD_LIBRARY_PATH=${PWD}/out/Release/
+%endif
 
 %if %{node_version_number} >= 12
 find test \( -name \*.out -or -name \*.js -or -name \*.snapshot \) -exec sed -i 's,Use `node ,Use `node%{node_version_number} ,' {} \;
@@ -1011,6 +1025,7 @@ rm -v test/sequential/test-perf-*.js tes
 make test-valgrind ||:
 %endif
 make test-ci
+%endif
 
 %files
 %defattr(-, root, root)
@@ -1035,6 +1050,9 @@ make test-ci
 %if 0%{?suse_version} < 1500
 %dir %{_defaultlicensedir}
 %endif
+%if %{with nodejs_shared}
+%{_libdir}/libnode%{node_version_number}.so.*
+%endif
 
 %files -n npm%{node_version_number}
 %defattr(-, root, root)
@@ -1079,6 +1097,9 @@ make test-ci
 
 %files devel
 %defattr(-, root, root)
+%if %{with nodejs_shared}
+%{_libdir}/libnode%{node_version_number}.so
+%endif
 %{_includedir}/node%{node_version_number}
 %if %{node_version_number} < 19
 %dir %{_datadir}/systemtap
@@ -1093,8 +1114,16 @@ make test-ci
 %if %{with libalternatives}
 
 %post
+%if %{with nodejs_shared}
+/sbin/ldconfig
+%endif
 update-alternatives --remove node-default %{_bindir}/node%{node_version_number}
 
+%if %{with nodejs_shared}
+%postun
+/sbin/ldconfig
+%endif
+
 %post -n npm%{node_version_number}
 update-alternatives --remove npm-default %{_bindir}/npm%{node_version_number}
 update-alternatives --remove npx-default %{_bindir}/npx%{node_version_number}
@@ -1105,6 +1134,7 @@ update-alternatives --remove corepack-de
 %endif
 
 %else
+
 %pre
 # remove files that are no longer owned but provided by update-alternatives
 if ! [ -L %{_mandir}/man1/node.1%{ext_man} ]; then
@@ -1112,11 +1142,17 @@ if ! [ -L %{_mandir}/man1/node.1%{ext_ma
 fi
 
 %post
+%if %{with nodejs_shared}
+/sbin/ldconfig
+%endif
 update-alternatives \
         --install %{_bindir}/node-default node-default %{_bindir}/node%{node_version_number} %{node_version_number} \
         --slave %{_mandir}/man1/node.1%{ext_man} node.1%{ext_man} %{_mandir}/man1/node%{node_version_number}.1%{ext_man}
 
 %postun
+%if %{with nodejs_shared}
+/sbin/ldconfig
+%endif
 if [ ! -f %{_bindir}/node%{node_version_number} ] ; then
     update-alternatives --remove node-default %{_bindir}/node%{node_version_number}
 fi
openSUSE Build Service is sponsored by