summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBöszörményi Zoltán <zboszor@pr.hu>2018-02-01 14:08:31 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-06 11:06:27 +0000
commitfa9c077068a2acea04389fa2b44eb2e93548fce2 (patch)
tree6cc9a06620f102ef12060607ba475c263e849c50
parentd38e1e2c2ea4646b34ea6282d3d7620df5b0374b (diff)
downloadpoky-fa9c077068a2acea04389fa2b44eb2e93548fce2.tar.gz
npm.bbclass: Node module name and recipe name can be different
Some NPM modules have the same name as their low level dependencies. To prevent recipe naming conflicts, allow node module recipe names to start with the "node-" prefix. (From OE-Core rev: 6b417c7c3a38463c64756beae9817fa2a80fd09e) Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/npm.bbclass18
1 files changed, 13 insertions, 5 deletions
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index 898a54eb50..c351ff0866 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -2,7 +2,15 @@ DEPENDS_prepend = "nodejs-native "
2RDEPENDS_${PN}_prepend = "nodejs " 2RDEPENDS_${PN}_prepend = "nodejs "
3S = "${WORKDIR}/npmpkg" 3S = "${WORKDIR}/npmpkg"
4 4
5NPM_INSTALLDIR = "${D}${libdir}/node_modules/${PN}" 5def node_pkgname(d):
6 bpn = d.getVar('BPN')
7 if bpn.startswith("node-"):
8 return bpn[5:]
9 return bpn
10
11NPMPN ?= "${@node_pkgname(d)}"
12
13NPM_INSTALLDIR = "${D}${libdir}/node_modules/${NPMPN}"
6 14
7# function maps arch names to npm arch names 15# function maps arch names to npm arch names
8def npm_oe_arch_map(target_arch, d): 16def npm_oe_arch_map(target_arch, d):
@@ -46,7 +54,7 @@ npm_do_install() {
46 export HOME=${WORKDIR} 54 export HOME=${WORKDIR}
47 mkdir -p ${NPM_INSTALLDIR}/ 55 mkdir -p ${NPM_INSTALLDIR}/
48 npm pack . 56 npm pack .
49 npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${PN}-${PV}.tgz 57 npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${NPMPN}-${PV}.tgz
50 if [ -d ${D}${prefix}/etc ] ; then 58 if [ -d ${D}${prefix}/etc ] ; then
51 # This will be empty 59 # This will be empty
52 rmdir ${D}${prefix}/etc 60 rmdir ${D}${prefix}/etc
@@ -54,13 +62,13 @@ npm_do_install() {
54} 62}
55 63
56python populate_packages_prepend () { 64python populate_packages_prepend () {
57 instdir = d.expand('${D}${libdir}/node_modules/${PN}') 65 instdir = d.expand('${D}${libdir}/node_modules/${NPMPN}')
58 extrapackages = oe.package.npm_split_package_dirs(instdir) 66 extrapackages = oe.package.npm_split_package_dirs(instdir)
59 pkgnames = extrapackages.keys() 67 pkgnames = extrapackages.keys()
60 d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames)) 68 d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames))
61 for pkgname in pkgnames: 69 for pkgname in pkgnames:
62 pkgrelpath, pdata = extrapackages[pkgname] 70 pkgrelpath, pdata = extrapackages[pkgname]
63 pkgpath = '${libdir}/node_modules/${PN}/' + pkgrelpath 71 pkgpath = '${libdir}/node_modules/${NPMPN}/' + pkgrelpath
64 # package names can't have underscores but npm packages sometimes use them 72 # package names can't have underscores but npm packages sometimes use them
65 oe_pkg_name = pkgname.replace('_', '-') 73 oe_pkg_name = pkgname.replace('_', '-')
66 expanded_pkgname = d.expand(oe_pkg_name) 74 expanded_pkgname = d.expand(oe_pkg_name)
@@ -76,7 +84,7 @@ python populate_packages_prepend () {
76} 84}
77 85
78FILES_${PN} += " \ 86FILES_${PN} += " \
79 ${libdir}/node_modules/${PN} \ 87 ${libdir}/node_modules/${NPMPN} \
80" 88"
81 89
82EXPORT_FUNCTIONS do_compile do_install 90EXPORT_FUNCTIONS do_compile do_install