forked from pool/nodejs-common
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
This commit is contained in:
parent
0fb4b5559d
commit
0e7fdd5c02
12
node.c
12
node.c
@ -5,6 +5,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBALTERNATIVES_H
|
||||||
|
#include <libalternatives.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
const unsigned min_version = 4;
|
const unsigned min_version = 4;
|
||||||
const unsigned max_version = 42;
|
const unsigned max_version = 42;
|
||||||
const char *default_version = "-default";
|
const char *default_version = "-default";
|
||||||
@ -62,6 +66,14 @@ int main(int argc, char *argv[])
|
|||||||
printInvalidVersion(version);
|
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 */
|
/* Generate our program path and check that we can execute it */
|
||||||
char *program_path, *program;
|
char *program_path, *program;
|
||||||
if (asprintf(&program, "%s%s", *bn, version) == -1 ||
|
if (asprintf(&program, "%s%s", *bn, version) == -1 ||
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
%define NODEJS_LTS 16
|
%define NODEJS_LTS 16
|
||||||
%define NODEJS_CURRENT 16
|
%define NODEJS_CURRENT 16
|
||||||
|
|
||||||
|
%bcond_with libalternatives
|
||||||
|
|
||||||
# SLE-12 variants
|
# SLE-12 variants
|
||||||
%if 0%{?suse_version} < 1500
|
%if 0%{?suse_version} < 1500
|
||||||
%define default_node_ver %NODEJS_LTS
|
%define default_node_ver %NODEJS_LTS
|
||||||
@ -78,6 +80,10 @@ Conflicts: nodejs6 < 6.11.1
|
|||||||
Conflicts: nodejs7 < 7.10.1
|
Conflicts: nodejs7 < 7.10.1
|
||||||
Conflicts: nodejs8 < 8.1.4
|
Conflicts: nodejs8 < 8.1.4
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
|
%if %{with libalternatives}
|
||||||
|
BuildRequires: libalternatives-devel
|
||||||
|
%define libalternatives_flags -DHAVE_LIBALTERNATIVES_H -lalternatives
|
||||||
|
%endif
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Common NodeJS files that allow recursive invocation of Node executable
|
Common NodeJS files that allow recursive invocation of Node executable
|
||||||
@ -120,7 +126,7 @@ the current architecture and codestream.
|
|||||||
%prep
|
%prep
|
||||||
%build
|
%build
|
||||||
cp %{S:2} .
|
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}
|
echo "Default Node version: " %{default_node_ver}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user