Hello community,

here is the log from the commit of package nodejs-common for openSUSE:Factory 
checked in at 2019-03-01 20:29:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nodejs-common (Old)
 and      /work/SRC/openSUSE:Factory/.nodejs-common.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nodejs-common"

Fri Mar  1 20:29:30 2019 rev:4 rq:679505 version:3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/nodejs-common/nodejs-common.changes      
2018-07-13 10:13:23.405889237 +0200
+++ /work/SRC/openSUSE:Factory/.nodejs-common.new.28833/nodejs-common.changes   
2019-03-01 20:29:31.442009856 +0100
@@ -1,0 +2,5 @@
+Fri Feb  1 15:03:12 UTC 2019 - [email protected]
+
+- Change the shell script to regular executable
+
+-------------------------------------------------------------------

Old:
----
  node

New:
----
  node.c

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nodejs-common.spec ++++++
--- /var/tmp/diff_new_pack.ecbLUA/_old  2019-03-01 20:29:32.070009705 +0100
+++ /var/tmp/diff_new_pack.ecbLUA/_new  2019-03-01 20:29:32.070009705 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package nodejs-common
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
@@ -26,22 +26,20 @@
 ###########################################################
 
 Name:           nodejs-common
-Version:        2.0
+Version:        3.0
 Release:        0
 Summary:        Common files for the NodeJS ecosystem
 License:        MIT
 Group:          Development/Languages/NodeJS
 Url:            https://github.com/AdamMajer/nodejs-packaging
-Source1:        node
+Source1:        node.c
 Source2:        LICENSE
 Requires:       nodejs
 Conflicts:      nodejs4 < 4.8.4
 Conflicts:      nodejs6 < 6.11.1
 Conflicts:      nodejs7 < 7.10.1
 Conflicts:      nodejs8 < 8.1.4
-
-BuildArch:      noarch
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+BuildRequires:  gcc
 
 %description
 Common NodeJS files that allow recursive invocation of Node executable
@@ -50,17 +48,17 @@
 %prep
 %build
 cp %{S:2} .
+gcc ${RPM_OPT_FLAGS} -g -o node %{S:1}
 
 %install
-install -D -m 0755 %{S:1} %{buildroot}%{_bindir}/node
-ln -s node %{buildroot}%{_bindir}/npm
-ln -s node %{buildroot}%{_bindir}/npx
+install -D -m 0755 node %{buildroot}%{_bindir}/node
+ln node %{buildroot}%{_bindir}/npm
+ln node %{buildroot}%{_bindir}/npx
 
 %files
-%defattr(-,root,root)
+%license LICENSE
 %{_bindir}/node
 %{_bindir}/npm
 %{_bindir}/npx
-%license LICENSE
 
 %changelog

++++++ node.c ++++++
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

const unsigned min_version = 4;
const unsigned max_version = 20;
const char *default_version = "-default";

const char * const supported_execs[] = {
        "node",
        "npm",
        "npx",
        NULL
};


static void __attribute__((noreturn)) printInvalidVersion(const char *version) {
        fprintf(stderr, "Invalid node version: %s\n", version);
        exit(-2);
}


int main(int argc, char *argv[])
{
        if (argc < 1) {
                fprintf(stderr, "Invalid parameters ... no basename?\n");
                return 128;
        }

        /* Verify we are called with supported name */
        const char *program_name = basename(argv[0]);
        const char * const * bn = supported_execs;

        for (; *bn!=NULL; bn++) {
                if (strcmp(*bn, program_name) == 0)
                        break;
        }

        if (*bn == NULL) {
                fprintf(stderr, "Invalid program called: '%s'\n", program_name);
                return 129;
        }

        /* Verify we have one of probably supported versions */
        const char *version = getenv("NODE_VERSION");
        char *endptr = 0;
        if (version == NULL || strcmp(version, default_version) == 0)
                version = default_version;

        unsigned long node_ver = strtoul(version, &endptr, 10);

        if (*endptr == '\0' &&
            ( node_ver < min_version || node_ver > max_version))
        {
                printInvalidVersion(version);
        }
        else if (*endptr != '\0' && version != default_version)
        {
                printInvalidVersion(version);
        }

        /* Generate our program path and check that we can execute it */
        char *program_path, *program;
        if (asprintf(&program, "%s%s", *bn, version) == -1 ||
            asprintf(&program_path, "/usr/bin/%s", program) == -1) {

                fputs("Memory allocation error... terminating\n", stderr);
                return 130;
        }

        if (access(program_path, X_OK) != 0) {
                perror(program_path);
                return -1;
        }

        argv[0] = program;

        execv(program_path, argv);
        perror("execv failed");
        return -1;
}


Reply via email to