[oe-commits] [openembedded-core] 08/62: npm.bbclass: Node module name and recipe name can be different

git at git.openembedded.org git at git.openembedded.org
Tue Feb 6 11:07:09 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 6b417c7c3a38463c64756beae9817fa2a80fd09e
Author: Böszörményi Zoltán <zboszor at pr.hu>
AuthorDate: Thu Feb 1 14:08:31 2018 +0100

    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.
    
    Signed-off-by: Zoltán Böszörményi <zboszor at pr.hu>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/classes/npm.bbclass | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index 898a54e..c351ff0 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -2,7 +2,15 @@ DEPENDS_prepend = "nodejs-native "
 RDEPENDS_${PN}_prepend = "nodejs "
 S = "${WORKDIR}/npmpkg"
 
-NPM_INSTALLDIR = "${D}${libdir}/node_modules/${PN}"
+def node_pkgname(d):
+    bpn = d.getVar('BPN')
+    if bpn.startswith("node-"):
+        return bpn[5:]
+    return bpn
+
+NPMPN ?= "${@node_pkgname(d)}"
+
+NPM_INSTALLDIR = "${D}${libdir}/node_modules/${NPMPN}"
 
 # function maps arch names to npm arch names
 def npm_oe_arch_map(target_arch, d):
@@ -46,7 +54,7 @@ npm_do_install() {
 	export HOME=${WORKDIR}
 	mkdir -p ${NPM_INSTALLDIR}/
 	npm pack .
-	npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${PN}-${PV}.tgz
+	npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${NPMPN}-${PV}.tgz
 	if [ -d ${D}${prefix}/etc ] ; then
 		# This will be empty
 		rmdir ${D}${prefix}/etc
@@ -54,13 +62,13 @@ npm_do_install() {
 }
 
 python populate_packages_prepend () {
-    instdir = d.expand('${D}${libdir}/node_modules/${PN}')
+    instdir = d.expand('${D}${libdir}/node_modules/${NPMPN}')
     extrapackages = oe.package.npm_split_package_dirs(instdir)
     pkgnames = extrapackages.keys()
     d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames))
     for pkgname in pkgnames:
         pkgrelpath, pdata = extrapackages[pkgname]
-        pkgpath = '${libdir}/node_modules/${PN}/' + pkgrelpath
+        pkgpath = '${libdir}/node_modules/${NPMPN}/' + pkgrelpath
         # package names can't have underscores but npm packages sometimes use them
         oe_pkg_name = pkgname.replace('_', '-')
         expanded_pkgname = d.expand(oe_pkg_name)
@@ -76,7 +84,7 @@ python populate_packages_prepend () {
 }
 
 FILES_${PN} += " \
-    ${libdir}/node_modules/${PN} \
+    ${libdir}/node_modules/${NPMPN} \
 "
 
 EXPORT_FUNCTIONS do_compile do_install

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list