Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package nodejs-electron for openSUSE:Factory
checked in at 2024-05-12 22:54:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nodejs-electron (Old)
and /work/SRC/openSUSE:Factory/.nodejs-electron.new.1880 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nodejs-electron"
Sun May 12 22:54:10 2024 rev:117 rq:1173455 version:29.3.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/nodejs-electron/nodejs-electron.changes
2024-05-10 12:06:13.883870258 +0200
+++
/work/SRC/openSUSE:Factory/.nodejs-electron.new.1880/nodejs-electron.changes
2024-05-13 01:19:26.547354337 +0200
@@ -1,0 +2,9 @@
+Sat May 11 22:35:19 UTC 2024 - Bruno Pitrus <[email protected]>
+
+- nodejs-electron-devel:
+ * Introduce /usr/libexec/electron-node wrapper scripts
+ * Introduce `electron_rebuild`, `electron_check_native`
+ and `electron_check_native_unstable` RPM macros to ease packaging Electron
apps
+ * Correct some injected compiler flags (common.gypi-compiler.patch)
+
+-------------------------------------------------------------------
New:
----
common.gypi-compiler.patch
BETA DEBUG BEGIN:
New: and `electron_check_native_unstable` RPM macros to ease packaging
Electron apps
* Correct some injected compiler flags (common.gypi-compiler.patch)
BETA DEBUG END:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ nodejs-electron.spec ++++++
--- /var/tmp/diff_new_pack.4a0Lzk/_old 2024-05-13 01:19:32.003554090 +0200
+++ /var/tmp/diff_new_pack.4a0Lzk/_new 2024-05-13 01:19:32.003554090 +0200
@@ -192,6 +192,12 @@
%endif
+%if 0%{?suse_version}
+%{expand:%%global NODEJS_DEFAULT_VER %(echo %{nodejs_version}|sed 's/\..*//')}
+%else
+%global NODEJS_DEFAULT_VER %nil
+%endif
+
# We always ship the following bundled libraries as part of Electron despite a
system version being available in either openSUSE or Fedora:
# Name | Path in tarball | Reason
#
-------------+-----------------------------------+---------------------------------------
@@ -238,6 +244,7 @@
# PATCHES for openSUSE-specific things (compiler flags, paths, etc.)
Patch0: chromium-102-compiler.patch
Patch1: fpic.patch
+Patch2: common.gypi-compiler.patch
Patch3: gcc-enable-lto.patch
Patch7: chromium-91-java-only-allowed-in-android-builds.patch
# Always disable use_thin_lto which is an lld feature
@@ -438,6 +445,9 @@
%else
BuildRequires: npm
%endif
+%if 0%{?suse_version}
+BuildRequires: nodejs-packaging
+%endif
BuildRequires: pkgconfig
BuildRequires: plasma-wayland-protocols
BuildRequires: python3-json5
@@ -679,6 +689,11 @@
Group: Development/Libraries/C and C++
Requires: nodejs-electron%{_isa} = %{version}
Requires: pkgconfig(zlib)
+%if 0%{?suse_version}
+Requires: npm%{NODEJS_DEFAULT_VER}
+%else
+Requires: nodejs-npm
+%endif
%description devel
@@ -1373,10 +1388,83 @@
cp -lrvT out/Release/gen/node_headers/include/node
%{buildroot}%{_includedir}/electron
+# Electron has a little known feature that make it work like a nodejs binary.
+# We make use of it in the %%electron_rebuild macro which builds all
dependencies in node_modules against Electron's headers.
+# Not all scripts work when run under electron,
+# but importantly npm/yarn and GYP do.
+mkdir -pv %{buildroot}%{_libexecdir}/electron-node
+
+
+cat <<EOF > %{buildroot}%{_libexecdir}/electron-node/node
+#!/bin/sh
+ELECTRON_RUN_AS_NODE=1 exec %{_libdir}/electron/electron "\$@"
+EOF
+
+# HACK: This will refer to /usr/bin/npm17 on openSUSE, /usr/bin/npm on Fedora
which are Node scripts
+cat <<EOF >%{buildroot}%{_libexecdir}/electron-node/npm
+#!/bin/sh
+exec %{_libexecdir}/electron-node/node %{_bindir}/npm%{NODEJS_DEFAULT_VER}
"\$@"
+EOF
+
+cat <<EOF > %{buildroot}%{_libexecdir}/electron-node/npx
+#!/bin/sh
+exec %{_libexecdir}/electron-node/node %{_bindir}/npx%{NODEJS_DEFAULT_VER}
"\$@"
+EOF
+
+# On Fedora, /usr/bin/yarn is a node script which means it needs to be wrapped
too. On openSUSE, it is a shell script.
+%if 0%{?fedora}
+cat <<EOF > %{buildroot}%{_libexecdir}/electron-node/yarn
+#!/bin/sh
+exec %{_libexecdir}/electron-node/node %{_bindir}/yarn "\$@"
+EOF
+%endif
+chmod -v 0755 %{buildroot}%{_libexecdir}/electron-node/*
+
# Install electron.macros
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d
cp /dev/stdin %{buildroot}%{_rpmconfigdir}/macros.d/macros.electron <<"EOF"
+# Ensure rebuilds when electron major changes.
%%electron_req Requires: electron%{_isa}(abi) = %{abi_version}
+
+# Build native modules against Electron. This should be done as the first step
in â°build. You must set CFLAGS/LDFLAGS previously.
+# You can call it multiple times in different directories and pass more
parameters to it (seen in vscode)
+%%electron_rebuild PATH="%{_libexecdir}/electron-node:$PATH" npm rebuild
--verbose --foreground-scripts --nodedir=%{_includedir}/electron
+
+# Sanity check that native modules load. You must include this in â°check if
the package includes native modules (possibly in addition to actual test suites)
+# These do, in order:
+# 1. Detect underlinking (missing dependencies)
+# 2. Detect accidental linking to libuv which must not be used (Electron
exports its own incompatible version)
+# 3. Actually load each module
+
+# This one should be paired with a simple `Requires: nodejs-electron%{_isa}`
in requirements.
+%%electron_check_native \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX sh
-c '! ldd -d -r XXX | \\\
+ grep '\\''^undefined symbol'\\'' | \\\
+ grep -v '\\''^undefined symbol: napi_'\\'' | \\\
+ grep -v '\\''^undefined symbol: uv_'\\'' ' \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX sh
-c '! objdump -p XXX | grep -F libuv.so.1' \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX env
ELECTRON_RUN_AS_NODE=1 %{_libdir}/electron/electron -e 'require("XXX")'
+
+# This one allows use of unstable APIs and should be paired with the
`â°electron_req` macro in requirements.
+%%electron_check_native_unstable \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX sh
-c '! ldd -d -r XXX | \\\
+ grep '\\''^undefined symbol'\\'' | \\\
+ grep -v '\\''^undefined symbol: node_'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZN12v8_inspector'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZN2v8'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZN4node'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZN5cppgc'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZN8electron'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZNK12v8_inspector'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZNK2v8'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZNK4node'\\'' | \\\
+ grep -v '\\''^undefined symbol: _ZNK5cppgc'\\'' | \\\
+ grep -v '\\''^undefined symbol: napi_'\\'' | \\\
+ grep -v '\\''^undefined symbol: uv_'\\'' ' \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX sh
-c '! objdump -p XXX | grep -F libuv.so.1' \
+ find '%%{buildroot}' -type f -name '*.node' -print0 | xargs -0 -t -IXXX env
ELECTRON_RUN_AS_NODE=1 %{_libdir}/electron/electron -e 'require("XXX")'
+
+
EOF
chmod -v 644 %{buildroot}%{_rpmconfigdir}/macros.d/macros.electron
@@ -1420,6 +1508,13 @@
%files devel
%{_includedir}/electron
%{_rpmconfigdir}/macros.d/macros.electron
+%dir %{_libexecdir}/electron-node
+%{_libexecdir}/electron-node/node
+%{_libexecdir}/electron-node/npm
+%{_libexecdir}/electron-node/npx
+%if 0%{?fedora}
+%{_libexecdir}/electron-node/yarn
+%endif
%files doc
%doc electron/README.md
++++++ common.gypi-compiler.patch ++++++
--- src/third_party/electron_node/common.gypi.orig 2024-05-09
09:30:23.202414200 +0000
+++ src/third_party/electron_node/common.gypi 2024-05-10 17:53:01.801592000
+0000
@@ -428,10 +428,15 @@
'ldflags': [ '-pthread' ],
}],
[ 'OS in "linux freebsd openbsd solaris android aix os400 cloudabi"', {
- 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
+ # Add some useful flags which need to be specified on all modules
anyway.
+ # `-fpic -fno-semantic-interposition` is the best relocation model for
code that will live in a dlopened library
+ # If a downstream package needs capital `-fPIC` (unlikely) it can
still override this (unlike CFLAGS which are injected at the very end)
+ # `-fvisibility=hidden` is something we're adding to fix downstream
overzealous exports.
+ # The electron headers annotate their visibility correctly, but many
third-party code does not which leads to bloated builds.
+ 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', '-fpic',
'-fno-semantic-interposition', '-fvisibility=hidden' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++17' ],
'defines': [ '__STDC_FORMAT_MACROS' ],
- 'ldflags': [ '-rdynamic' ],
+ #'ldflags': [ '-rdynamic' ], this is totally bogus â we are building
a plugin, not a plugin host
'target_conditions': [
# The 1990s toolchain on SmartOS can't handle thin archives.
['_type=="static_library" and OS=="solaris"', {
@@ -608,29 +613,7 @@
'-Wl,--export-dynamic',
],
}],
- # if node is built as an executable,
- # the openssl mechanism for keeping itself "dload"-ed to ensure
proper
- # atexit cleanup does not apply
- ['node_shared_openssl!="true" and node_shared!="true"', {
- 'defines': [
- # `OPENSSL_NO_PINSHARED` prevents openssl from dload
- # current node executable,
- # see https://github.com/nodejs/node/pull/21848
- # or https://github.com/nodejs/node/issues/27925
- 'OPENSSL_NO_PINSHARED'
- ],
- }],
- ['node_shared_openssl!="true"', {
- # `OPENSSL_THREADS` is defined via GYP for openSSL for all
architectures.
- 'defines': [
- 'OPENSSL_THREADS',
- ],
- }],
- ['node_shared_openssl!="true" and openssl_no_asm==1', {
- 'defines': [
- 'OPENSSL_NO_ASM',
- ],
- }],
+ # Electron does not export its openssl fork (boringssl). Removing these
defines which are bogus and can interfere with modules actually using openssl
(signal-desktop is known to use it)
['OS == "zos"', {
'defines': [
'_XOPEN_SOURCE_EXTENDED',