summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com>2019-05-17 17:14:09 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-21 12:56:33 +0100
commita34d0d539e5fdf341541fb628652d22289e80512 (patch)
tree66c1cccdd83020ef44262aa9563065a8931fc2f3 /meta
parenteecba41822e86b69ebdb9cbc8fbfd512ad9a47d7 (diff)
downloadpoky-a34d0d539e5fdf341541fb628652d22289e80512.tar.gz
npm: fix node and npm default directory conflict
Fixes [YOCTO #13349] When dealing with node modules which have declared "bin" files [1], npm will create a link in '/usr/bin' with a relative link to '../lib/node_modules/<module bin file>'. The commits e9270af4296ce2af292059617a717e42fc17425c and 2713d9bcc39c712ef34003ce8424416441be558e explicitely use '/usr/lib/node/' as install directory, but does not care about the "bin" symbolic linked files. In order to keep valid links, and to keep it as simple as possible, the path '/usr/lib/node_modules/' is used as install directory for npm. And a symbolic link is created to have a valid '/usr/lib/node/' path, needed for node. [1]: https://docs.npmjs.com/files/package.json#bin (From OE-Core rev: 2d72007deea7ed529f82b8a6e67e2715dd0a0dca) Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/npm.bbclass6
1 files changed, 4 insertions, 2 deletions
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index 3dd2d13804..9703f4c1ec 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -10,7 +10,7 @@ def node_pkgname(d):
10 10
11NPMPN ?= "${@node_pkgname(d)}" 11NPMPN ?= "${@node_pkgname(d)}"
12 12
13NPM_INSTALLDIR = "${libdir}/node/${NPMPN}" 13NPM_INSTALLDIR = "${libdir}/node_modules/${NPMPN}"
14 14
15# function maps arch names to npm arch names 15# function maps arch names to npm arch names
16def npm_oe_arch_map(target_arch, d): 16def npm_oe_arch_map(target_arch, d):
@@ -55,7 +55,7 @@ npm_do_install() {
55 mkdir -p ${D}${libdir}/node_modules 55 mkdir -p ${D}${libdir}/node_modules
56 local NPM_PACKFILE=$(npm pack .) 56 local NPM_PACKFILE=$(npm pack .)
57 npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${NPM_PACKFILE} 57 npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${NPM_PACKFILE}
58 mv ${D}${libdir}/node_modules ${D}${libdir}/node 58 ln -fs node_modules ${D}${libdir}/node
59 if [ -d ${D}${prefix}/etc ] ; then 59 if [ -d ${D}${prefix}/etc ] ; then
60 # This will be empty 60 # This will be empty
61 rmdir ${D}${prefix}/etc 61 rmdir ${D}${prefix}/etc
@@ -85,6 +85,8 @@ python populate_packages_prepend () {
85} 85}
86 86
87FILES_${PN} += " \ 87FILES_${PN} += " \
88 ${bindir} \
89 ${libdir}/node \
88 ${NPM_INSTALLDIR} \ 90 ${NPM_INSTALLDIR} \
89" 91"
90 92