diff options
| -rw-r--r-- | meta/classes/npm.bbclass | 18 |
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 " | |||
| 2 | RDEPENDS_${PN}_prepend = "nodejs " | 2 | RDEPENDS_${PN}_prepend = "nodejs " |
| 3 | S = "${WORKDIR}/npmpkg" | 3 | S = "${WORKDIR}/npmpkg" |
| 4 | 4 | ||
| 5 | NPM_INSTALLDIR = "${D}${libdir}/node_modules/${PN}" | 5 | def node_pkgname(d): |
| 6 | bpn = d.getVar('BPN') | ||
| 7 | if bpn.startswith("node-"): | ||
| 8 | return bpn[5:] | ||
| 9 | return bpn | ||
| 10 | |||
| 11 | NPMPN ?= "${@node_pkgname(d)}" | ||
| 12 | |||
| 13 | NPM_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 |
| 8 | def npm_oe_arch_map(target_arch, d): | 16 | def 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 | ||
| 56 | python populate_packages_prepend () { | 64 | python 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 | ||
| 78 | FILES_${PN} += " \ | 86 | FILES_${PN} += " \ |
| 79 | ${libdir}/node_modules/${PN} \ | 87 | ${libdir}/node_modules/${NPMPN} \ |
| 80 | " | 88 | " |
| 81 | 89 | ||
| 82 | EXPORT_FUNCTIONS do_compile do_install | 90 | EXPORT_FUNCTIONS do_compile do_install |
