1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

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>
This commit is contained in:
Böszörményi Zoltán
2018-02-01 14:08:31 +01:00
committed by Richard Purdie
parent d38e1e2c2e
commit fa9c077068
+13 -5
View File
@@ -2,7 +2,15 @@ DEPENDS_prepend = "nodejs-native "
RDEPENDS_${PN}_prepend = "nodejs " RDEPENDS_${PN}_prepend = "nodejs "
S = "${WORKDIR}/npmpkg" 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 # function maps arch names to npm arch names
def npm_oe_arch_map(target_arch, d): def npm_oe_arch_map(target_arch, d):
@@ -46,7 +54,7 @@ npm_do_install() {
export HOME=${WORKDIR} export HOME=${WORKDIR}
mkdir -p ${NPM_INSTALLDIR}/ mkdir -p ${NPM_INSTALLDIR}/
npm pack . 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 if [ -d ${D}${prefix}/etc ] ; then
# This will be empty # This will be empty
rmdir ${D}${prefix}/etc rmdir ${D}${prefix}/etc
@@ -54,13 +62,13 @@ npm_do_install() {
} }
python populate_packages_prepend () { 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) extrapackages = oe.package.npm_split_package_dirs(instdir)
pkgnames = extrapackages.keys() pkgnames = extrapackages.keys()
d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames)) d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames))
for pkgname in pkgnames: for pkgname in pkgnames:
pkgrelpath, pdata = extrapackages[pkgname] 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 # package names can't have underscores but npm packages sometimes use them
oe_pkg_name = pkgname.replace('_', '-') oe_pkg_name = pkgname.replace('_', '-')
expanded_pkgname = d.expand(oe_pkg_name) expanded_pkgname = d.expand(oe_pkg_name)
@@ -76,7 +84,7 @@ python populate_packages_prepend () {
} }
FILES_${PN} += " \ FILES_${PN} += " \
${libdir}/node_modules/${PN} \ ${libdir}/node_modules/${NPMPN} \
" "
EXPORT_FUNCTIONS do_compile do_install EXPORT_FUNCTIONS do_compile do_install