[meta-oe,master,1/2] nodejs_12.21.0.bb: only handle npm if configured

Message ID 20220112091529.4853-1-nishaparrakat@gmail.com
State New
Headers show
Series [meta-oe,master,1/2] nodejs_12.21.0.bb: only handle npm if configured | expand

Commit Message

Nisha Parrakat Jan. 12, 2022, 9:15 a.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_12.21.0.bb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Khem Raj Jan. 12, 2022, 5:28 p.m. UTC | #1
On 1/12/22 1:15 AM, Nisha Parrakat 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_12.21.0.bb | 8 ++++++--


we do not have nodejs 12.21.0 on master, is it meant for some other 
release branch ?

>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> index b9e382177..22191a157 100644
> --- a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> +++ b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> @@ -133,7 +133,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}
> @@ -147,7 +149,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"
Nisha Parrakat Jan. 13, 2022, 8:13 a.m. UTC | #2
Sorry Sent for dunfell again now.

regards
Nisha

On Wed, 12 Jan 2022 at 18:28, Khem Raj <raj.khem@gmail.com> wrote:

>
>
> On 1/12/22 1:15 AM, Nisha Parrakat 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_12.21.0.bb | 8 ++++++--
>
>
> we do not have nodejs 12.21.0 on master, is it meant for some other
> release branch ?
>
> >   1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> > index b9e382177..22191a157 100644
> > --- a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> > +++ b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
> > @@ -133,7 +133,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}
> > @@ -147,7 +149,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"
>

Patch

diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
index b9e382177..22191a157 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_12.21.0.bb
@@ -133,7 +133,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}
@@ -147,7 +149,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"