[meta-oe,master] nodejs_16.11.1.bb: only handle npm if configured

Message ID 20220111162327.33864-1-nishaparrakat@gmail.com
State New
Headers show
Series [meta-oe,master] nodejs_16.11.1.bb: only handle npm if configured | expand

Commit Message

Nisha Parrakat Jan. 11, 2022, 4:23 p.m. UTC
npm-cli.js should be symlinked only when the file is present
the file may not be available if the configure option is --without-npm

Signed-off-by: Nisha Parrakat <nishaparrakat@gmail.com>
---
 meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Konrad Weihmann Jan. 11, 2022, 4:27 p.m. UTC | #1
That needs to go to the openembedded-devel@list.openembedded.org as 
nodejs isn't part of core

On 11.01.22 17:23, Nisha Parrakat wrote:
> Signed-off-by: Nisha Parrakat <nishaparrakat@gmail.com>
> ---
>   meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> index 11034420a..c8d942538 100644
> --- a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> +++ b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> @@ -175,8 +175,9 @@ do_install:append:class-native() {
>       # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js
>       # use sed on npm-cli.js because otherwise symlink is replaced with normal file and
>       # npm-cli.js continues to use old shebang
> -    sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> -
> +    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]]; then
> +        sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    fi
>       # Install the native binaries to provide it within sysroot for the target compilation
>       install -d ${D}${bindir}
>       install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque
> @@ -189,7 +190,9 @@ do_install:append:class-native() {
>   }
>   
>   do_install:append:class-target() {
> -    sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]]; then
> +        sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    fi
>   }
>   
>   PACKAGES =+ "${PN}-npm"
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#160418): https://lists.openembedded.org/g/openembedded-core/message/160418
> Mute This Topic: https://lists.openembedded.org/mt/88352467/3647476
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [kweihmann@outlook.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Jan. 11, 2022, 4:28 p.m. UTC | #2
This needs to go into openembedded-devel mailing list so it can be picked
by lore and other tools

On Tue, Jan 11, 2022 at 8:23 AM Nisha Parrakat <nishaparrakat@gmail.com>
wrote:

> npm-cli.js should be symlinked only when the file is present
> the file may not be available if the configure option is --without-npm
>
> Signed-off-by: Nisha Parrakat <nishaparrakat@gmail.com>
> ---
>  meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> index 11034420a..c8d942538 100644
> --- a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> +++ b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
> @@ -175,8 +175,9 @@ do_install:append:class-native() {
>      # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js
>      # use sed on npm-cli.js because otherwise symlink is replaced with
> normal file and
>      # npm-cli.js continues to use old shebang
> -    sed "1s^.*^#\!/usr/bin/env node^g" -i
> ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> -
> +    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]];
> then
> +        sed "1s^.*^#\!/usr/bin/env node^g" -i
> ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    fi
>      # Install the native binaries to provide it within sysroot for the
> target compilation
>      install -d ${D}${bindir}
>      install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque
> @@ -189,7 +190,9 @@ do_install:append:class-native() {
>  }
>
>  do_install:append:class-target() {
> -    sed "1s^.*^#\!${bindir}/env node^g" -i
> ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]];
> then
> +        sed "1s^.*^#\!${bindir}/env node^g" -i
> ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
> +    fi
>  }
>
>  PACKAGES =+ "${PN}-npm"
> --
> 2.17.1
>
>

Patch

diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
index 11034420a..c8d942538 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_16.11.1.bb
@@ -175,8 +175,9 @@  do_install:append:class-native() {
     # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js
     # use sed on npm-cli.js because otherwise symlink is replaced with normal file and
     # npm-cli.js continues to use old shebang
-    sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
-
+    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]]; then
+        sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
+    fi
     # Install the native binaries to provide it within sysroot for the target compilation
     install -d ${D}${bindir}
     install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque
@@ -189,7 +190,9 @@  do_install:append:class-native() {
 }
 
 do_install:append:class-target() {
-    sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
+    if [[ -f "${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js" ]]; then
+        sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js
+    fi
 }
 
 PACKAGES =+ "${PN}-npm"