From 0e7fdd5c02df2b259e6aaed49a8adc8357bb24b038c088629b8a48cfc2f2e825 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Mon, 31 May 2021 16:33:47 +0000 Subject: [PATCH 1/6] Add libalternatives support, but no changelog so not accidetalied into Factory yet OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=41 --- node.c | 12 ++++++++++++ nodejs-common.spec | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/node.c b/node.c index 303c627..ef320ee 100644 --- a/node.c +++ b/node.c @@ -5,6 +5,10 @@ #include #include +#ifdef HAVE_LIBALTERNATIVES_H +#include +#endif + const unsigned min_version = 4; const unsigned max_version = 42; const char *default_version = "-default"; @@ -62,6 +66,14 @@ int main(int argc, char *argv[]) printInvalidVersion(version); } +#ifdef HAVE_LIBALTERNATIVES_H + // if we want default version and not using update-alternatives + if (version == default_version) + { + return execDefault(argv); + } +#endif + /* Generate our program path and check that we can execute it */ char *program_path, *program; if (asprintf(&program, "%s%s", *bn, version) == -1 || diff --git a/nodejs-common.spec b/nodejs-common.spec index d7ac546..9b9f571 100644 --- a/nodejs-common.spec +++ b/nodejs-common.spec @@ -28,6 +28,8 @@ %define NODEJS_LTS 16 %define NODEJS_CURRENT 16 +%bcond_with libalternatives + # SLE-12 variants %if 0%{?suse_version} < 1500 %define default_node_ver %NODEJS_LTS @@ -78,6 +80,10 @@ Conflicts: nodejs6 < 6.11.1 Conflicts: nodejs7 < 7.10.1 Conflicts: nodejs8 < 8.1.4 BuildRequires: gcc +%if %{with libalternatives} +BuildRequires: libalternatives-devel +%define libalternatives_flags -DHAVE_LIBALTERNATIVES_H -lalternatives +%endif %description Common NodeJS files that allow recursive invocation of Node executable @@ -120,7 +126,7 @@ the current architecture and codestream. %prep %build cp %{S:2} . -gcc ${RPM_OPT_FLAGS} -o node %{S:1} +gcc ${RPM_OPT_FLAGS} %?libalternatives_flags -o node %{S:1} echo "Default Node version: " %{default_node_ver} From e11fd2e560bc524e93fed269eed290e2b9a7e0ed5637c1ce16b7c68e0a89412f Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Mon, 31 May 2021 16:43:15 +0000 Subject: [PATCH 2/6] OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=42 --- nodejs-common.spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nodejs-common.spec b/nodejs-common.spec index 9b9f571..dc755a9 100644 --- a/nodejs-common.spec +++ b/nodejs-common.spec @@ -82,7 +82,8 @@ Conflicts: nodejs8 < 8.1.4 BuildRequires: gcc %if %{with libalternatives} BuildRequires: libalternatives-devel -%define libalternatives_flags -DHAVE_LIBALTERNATIVES_H -lalternatives +%define libalternatives_cflags -DHAVE_LIBALTERNATIVES_H +%define libalternatives_lflags -lalternatives %endif %description @@ -126,7 +127,7 @@ the current architecture and codestream. %prep %build cp %{S:2} . -gcc ${RPM_OPT_FLAGS} %?libalternatives_flags -o node %{S:1} +gcc ${RPM_OPT_FLAGS} %?libalternatives_cflags -o node %{S:1} %?libalternatives_lflags echo "Default Node version: " %{default_node_ver} From d6cf24e47474de58dd138abfa3d7e5e175013ff8801731fd5c004463ee1b29d7 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Tue, 1 Jun 2021 13:20:34 +0000 Subject: [PATCH 3/6] - Add libalternatives support OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=43 --- nodejs-common.changes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodejs-common.changes b/nodejs-common.changes index a8122f2..b22e606 100644 --- a/nodejs-common.changes +++ b/nodejs-common.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon May 31 16:32:18 UTC 2021 - Adam Majer + +- Add libalternatives support + ------------------------------------------------------------------- Thu May 6 12:50:02 UTC 2021 - Adam Majer From 316795e835b0af79694d65b2ebe8f99de05ec6ca6be88683b46736ae56e30dac Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Thu, 10 Jun 2021 10:30:57 +0000 Subject: [PATCH 4/6] - Use libalternatives on TW by default OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=44 --- node.c | 2 +- nodejs-common.changes | 5 +++++ nodejs-common.spec | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/node.c b/node.c index ef320ee..74771a8 100644 --- a/node.c +++ b/node.c @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) // if we want default version and not using update-alternatives if (version == default_version) { - return execDefault(argv); + return libalts_exec_default(argv); } #endif diff --git a/nodejs-common.changes b/nodejs-common.changes index b22e606..c58ec45 100644 --- a/nodejs-common.changes +++ b/nodejs-common.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jun 10 10:27:58 UTC 2021 - Adam Majer + +- Use libalternatives on TW by default + ------------------------------------------------------------------- Mon May 31 16:32:18 UTC 2021 - Adam Majer diff --git a/nodejs-common.spec b/nodejs-common.spec index dc755a9..467558c 100644 --- a/nodejs-common.spec +++ b/nodejs-common.spec @@ -28,7 +28,11 @@ %define NODEJS_LTS 16 %define NODEJS_CURRENT 16 +%if 0%{?suse_version} > 1500 +%bcond_without libalternatives +%else %bcond_with libalternatives +%endif # SLE-12 variants %if 0%{?suse_version} < 1500 From d5d95bd2a7068d205c5efddf852b399a568bc07e7a3a633cb126680ebf2346e4 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 11 Jun 2021 07:38:29 +0000 Subject: [PATCH 5/6] OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=45 --- nodejs-common.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodejs-common.spec b/nodejs-common.spec index 467558c..c6ad49f 100644 --- a/nodejs-common.spec +++ b/nodejs-common.spec @@ -70,7 +70,7 @@ %endif Name: nodejs-common -Version: 4.1 +Version: 5.0 Release: 0 Summary: Common files for the NodeJS ecosystem License: MIT From da73788f4ae4910719e0bf3dd4148a8e8e003f62ca3f141215db1ff72c08f049 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 11 Jun 2021 11:27:52 +0000 Subject: [PATCH 6/6] Add fallback for update-alterntatives symlinks OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-common?expand=0&rev=46 --- node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node.c b/node.c index 74771a8..cceadb3 100644 --- a/node.c +++ b/node.c @@ -70,7 +70,10 @@ int main(int argc, char *argv[]) // if we want default version and not using update-alternatives if (version == default_version) { - return libalts_exec_default(argv); + // should not return, and if it does, it probably means + // we should fall back to using node-default fallback. + libalts_exec_default(argv); + fputs("Falling back to using -default symlink.\n", stderr); } #endif