Skip to contentSkip to conversation

npm.bbclass: Fix file permissions before opening it for writing

PATCH In review Zoltan Boszormenyi 3 participants 6 messages May 13, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/3 npm.bbclass: Fix file permissions before opening it for writing

From: Zoltán Böszörményi <[email protected]>

Some node module archives in npmjs.org contain wrong permissions. I found a case with package.json in the archive being r-xr-xr-x for which open(..., "w") fails. Modify the manifest file permissions to add the write bit for the owner.

---
 meta/classes/npm.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/npm.bbclass +2 -0
index ba50fcac20..86ee0f665a 100644
@@ -81,6 +81,7 @@ python npm_do_configure() {
     import json
     import re
     import shlex
+    import stat
     import tempfile
     from bb.fetch2.npm import NpmEnvironment
     from bb.fetch2.npm import npm_unpack
@@ -202,6 +203,7 @@ python npm_do_configure() {
         if has_shrinkwrap_file:
             _update_manifest("devDependencies")
 
+    os.chmod(cached_manifest_file, os.stat(cached_manifest_file).st_mode | stat.S_IWUSR)
     with open(cached_manifest_file, "w") as f:
         json.dump(cached_manifest, f, indent=2)
 
Signature · 1 line
2.36.1
#2 lore raw

PATCH v2 2/3 npm.bbclass: Don't create /usr/lib/node symlink

From: Zoltán Böszörményi <[email protected]>

When a recipe DEPENDS on multiple other npm based recipes, the symlink will create a conflict.

---
 meta/classes/npm.bbclass | 4 ----
 1 file changed, 4 deletions(-)
meta/classes/npm.bbclass +0 -4
index 86ee0f665a..dbfc2e728e 100644
@@ -307,10 +307,6 @@ npm_do_install() {
     # Remove the shrinkwrap file which does not need to be packed
     rm -f ${D}/${nonarch_libdir}/node_modules/*/npm-shrinkwrap.json
     rm -f ${D}/${nonarch_libdir}/node_modules/@*/*/npm-shrinkwrap.json
-
-    # node(1) is using /usr/lib/node as default include directory and npm(1) is
-    # using /usr/lib/node_modules as install directory. Let's make both happy.
-    ln -fs node_modules ${D}/${nonarch_libdir}/node
 }
 
 FILES:${PN} += " \
Signature · 1 line
2.36.1
#3 lore raw

PATCH v2 3/3 nodejs: Add /usr/lib/node -> node_modules symlink

In reply to Zoltan Boszormenyi

From: Zoltán Böszörményi <[email protected]>

While /usr/lib/node_modules and all npm-related modules are shipped in the npm subpackage, keep the symlink in the main package because 3rd party modules that don't need npm are also installed into /usr/lib/node_modules.

---
 meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb | 5 +++++
 1 file changed, 5 insertions(+)
meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb +5 -0
index 62188f94a..be68afd4c 100644
@@ -159,6 +159,10 @@ do_compile () {
 
 do_install () {
     oe_runmake install DESTDIR=${D}
+
+    # node(1) is using /usr/lib/node as default include directory and npm(1) is
+    # using /usr/lib/node_modules as install directory. Let's make both happy.
+    ln -fs node_modules ${D}/${nonarch_libdir}/node
 }
 
 BINARIES = " \
@@ -176,6 +180,7 @@ do_install:append:class-native() {
 }
 
 PACKAGES =+ "${PN}-npm"
+FILES:${PN} += "${nonarch_libdir}/node"
 FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx"
 RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \
     python3-misc python3-multiprocessing"
Signature · 1 line
2.36.1
#4 lore raw

Re: [OE-core] [meta-oe][PATCH v2 3/3] nodejs: Add /usr/lib/node -> node_modules symlink

This needs to be sent to the openembedded-devel list.

Alex

Quoted 48 lines · Zoltan Boszormenyi via lists.openembedded.org

From: Zoltán Böszörményi <[email protected]>

While /usr/lib/node_modules and all npm-related modules are shipped in the npm subpackage, keep the symlink in the main package because 3rd party modules that don't need npm are also installed into /usr/lib/node_modules.

---
 meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb | 5 +++++
 1 file changed, 5 insertions(+)
meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb +5 -1
index 62188f94a..be68afd4c 100644
@@ -159,6 +159,10 @@ do_compile () {
 
 do_install () {
     oe_runmake install DESTDIR=${D}
+
+    # node(1) is using /usr/lib/node as default include directory and npm(1) is
+    # using /usr/lib/node_modules as install directory. Let's make both happy.
+    ln -fs node_modules ${D}/${nonarch_libdir}/node
 }
 
 BINARIES = " \
@@ -176,6 +180,7 @@ do_install:append:class-native() {
 }
 
 PACKAGES =+ "${PN}-npm"
+FILES:${PN} += "${nonarch_libdir}/node"
 FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx"
 RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \
     python3-misc python3-multiprocessing"
--

2.36.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#165573): https://lists.openembedded.org/g/openembedded-core/message/165573
Mute This Topic: https://lists.openembedded.org/mt/91083341/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#5 lore raw

Re: [OE-core] [meta-oe][PATCH v2 3/3] nodejs: Add /usr/lib/node -> node_modules symlink

2022. 05. 13. 17:42 keltezéssel, Alexander Kanavin írta:

Quoted 1 line

This needs to be sent to the openembedded-devel list.

Is it ok just to cc openembedded-devel? Because applying this 3rd patch to meta-oe without applying the second to oe-core will cause conflicts and has a high chance to be rejected.

Quoted 47 lines

Alex

Quoted 42 lines · Zoltan Boszormenyi via lists.openembedded.org

From: Zoltán Böszörményi <[email protected]>

While /usr/lib/node_modules and all npm-related modules are shipped in the npm subpackage, keep the symlink in the main package because 3rd party modules that don't need npm are also installed into /usr/lib/node_modules.

---
  meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb | 5 +++++
  1 file changed, 5 insertions(+)
meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb +5 -1
index 62188f94a..be68afd4c 100644
@@ -159,6 +159,10 @@ do_compile () {
 
  do_install () {
      oe_runmake install DESTDIR=${D}
+
+    # node(1) is using /usr/lib/node as default include directory and npm(1) is
+    # using /usr/lib/node_modules as install directory. Let's make both happy.
+    ln -fs node_modules ${D}/${nonarch_libdir}/node
  }
 
  BINARIES = " \
@@ -176,6 +180,7 @@ do_install:append:class-native() {
  }
 
  PACKAGES =+ "${PN}-npm"
+FILES:${PN} += "${nonarch_libdir}/node"
  FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx"
  RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \
      python3-misc python3-multiprocessing"
--

2.36.1

#6 lore raw

Re: [OE-core] [meta-oe][PATCH v2 3/3] nodejs: Add /usr/lib/node -> node_modules symlink

Quoted 8 lines · Zoltan Boszormenyi via lists.openembedded.org

2022. 05. 13. 17:42 keltezéssel, Alexander Kanavin írta:

Quoted 1 line

This needs to be sent to the openembedded-devel list.

Is it ok just to cc openembedded-devel? Because applying this 3rd patch to meta-oe without applying the second to oe-core will cause conflicts and has a high chance to be rejected.

get the oe-core things done first.

Quoted 58 lines
Quoted 37 lines

Alex

Quoted 31 lines · Zoltan Boszormenyi via lists.openembedded.org

From: Zoltán Böszörményi <[email protected]>

While /usr/lib/node_modules and all npm-related modules are shipped in the npm subpackage, keep the symlink in the main package because 3rd party modules that don't need npm are also installed into /usr/lib/node_modules.

---
  meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb | 5 +++++
  1 file changed, 5 insertions(+)
meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb +4 -0
index 62188f94a..be68afd4c 100644
@@ -159,6 +159,10 @@ do_compile () {
 
  do_install () {
      oe_runmake install DESTDIR=${D}
+
+    # node(1) is using /usr/lib/node as default include directory and npm(1) is
+    # using /usr/lib/node_modules as install directory. Let's make both happy.
+    ln -fs node_modules ${D}/${nonarch_libdir}/node
  }
 
  BINARIES = " \
@@ -176,6 +180,7 @@ do_install:append:class-native() {
  }
 
Quoted 11 lines
Quoted 11 lines
meta-oe/recipes-devtools/nodejs/nodejs_16.14.2.bb +1 -1
  PACKAGES =+ "${PN}-npm"
+FILES:${PN} += "${nonarch_libdir}/node"
  FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx"
  RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \
      python3-misc python3-multiprocessing"
--

2.36.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#165580): https://lists.openembedded.org/g/openembedded-core/message/165580
Mute This Topic: https://lists.openembedded.org/mt/91083341/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-