From: wchang kim Date: Tue, 22 Dec 2015 22:52:20 +0000 (+0900) Subject: meta-tizen: Description:Insatll npm modules into target except npm Adding the npm... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=589d2236008d9957847c5df41150a67421a31d97;p=scm%2Fbb%2Ftizen-distro.git meta-tizen: Description:Insatll npm modules into target except npm Adding the npm.class and modifying the recipe of nodejs to install npm modules. Adding the scripts to instert the NODE_PATH to /etc/porfile. Signed-off-by: wchang kim Change-Id: I67300339bd3550563ec27503b68a63eedfeeae6e (From meta-tizen rev: b82b23014763f998eb87b8ebb7dd1bf63afb2935) Signed-off-by: wchang kim --- diff --git a/meta-tizen/meta-tizen-micro/classes/npm.bbclass b/meta-tizen/meta-tizen-micro/classes/npm.bbclass new file mode 100755 index 0000000..45e78a5 --- /dev/null +++ b/meta-tizen/meta-tizen-micro/classes/npm.bbclass @@ -0,0 +1,63 @@ +#DEPENDS += " node-native" + +#RDEPENDS_${PN} += " node" + +PACKAGE_DEBUG_SPLIT_STYLE = "debug-file-directory" + +CCACHE = "" + +NPM ?= "npm" +NPM_CACHE_DIR = "${WORKDIR}/npm_cache" +NPM_ARCH ?= "${TARGET_ARCH}" +NPM_LD ?= "${CXX}" +NPM_FLAGS ?= "" + +# Target npm + +oe_runnpm() { + + export NPM_CONFIG_CACHE="${NPM_CACHE_DIR}" + + [ -n "${http_proxy}" ] && export NPM_CONFIG_PROXY="${http_proxy}" + [ -n "${https_proxy}" ] && export NPM_CONFIG_HTTPS_PROXY="${https_proxy}" + [ -n "${HTTP_PROXY}" ] && export NPM_CONFIG_PROXY="${HTTP_PROXY}" + [ -n "${HTTPS_PROXY}" ] && export NPM_CONFIG_HTTPS_PROXY="${HTTPS_PROXY}" + + bbnote NPM target architecture: ${NPM_ARCH} + bbnote NPM cache directory: ${NPM_CONFIG_CACHE} + bbnote NPM HTTP proxy: ${NPM_CONFIG_PROXY} + bbnote NPM HTTPS proxy: ${NPM_CONFIG_HTTPS_PROXY} + + bbnote ${NPM} --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} ${NPM_FLAGS} "$@" + + LD="${NPM_LD}" ${NPM} --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} ${NPM_FLAGS} "$@" || die "oe_runnpm failed" + +} + +# Native npm + +NPM_NATIVE ?= "npm" +NPM_CACHE_DIR_NATIVE = "${WORKDIR}/npm_cache" +NPM_ARCH_NATIVE ?= "${BUILD_ARCH}" +NPM_LD_NATIVE ?= "${BUILD_CXX}" +NPM_FLAGS_NATIVE ?= "" + +oe_runnpm_native() { + + export NPM_CONFIG_CACHE="${NPM_CACHE_DIR_NATIVE}" + + [ -n "${http_proxy}" ] && export NPM_CONFIG_PROXY="${http_proxy}" + [ -n "${https_proxy}" ] && export NPM_CONFIG_HTTPS_PROXY="${https_proxy}" + [ -n "${HTTP_PROXY}" ] && export NPM_CONFIG_PROXY="${HTTP_PROXY}" + [ -n "${HTTPS_PROXY}" ] && export NPM_CONFIG_HTTPS_PROXY="${HTTPS_PROXY}" + + bbnote NPM native architecture: ${NPM_ARCH_NATIVE} + bbnote NPM cache directory: ${NPM_CONFIG_CACHE} + bbnote NPM HTTP proxy: ${NPM_CONFIG_PROXY} + bbnote NPM HTTPS proxy: ${NPM_CONFIG_HTTPS_PROXY} + + bbnote ${NPM_NATIVE} --arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE} ${NPM_FLAGS_NATIVE} "$@" + + LD="${NPM_LD_NATIVE}" ${NPM_NATIVE} --arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE} ${NPM_FLAGS_NATIVE} "$@" || die "oe_runnpm_native failed" + +} diff --git a/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.service b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.service new file mode 100755 index 0000000..2b8d667 --- /dev/null +++ b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.service @@ -0,0 +1,9 @@ +[Unit] +Description=nodejs service + +[Service] + +ExecStart=/etc/init.d/nodejs.sh + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.sh b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.sh new file mode 100755 index 0000000..49d3629 --- /dev/null +++ b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs/nodejs.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +if [ ! -d "/opt/vc/bin" ]; then +echo "export NODE_PATH=/usr/lib/node_modules/" >>/etc/profile +fi + +mkdir -p /opt/vc/bin +ln -sf /usr/bin/raspistill /opt/vc/bin/ +ln -sf /usr/bin/raspivid /opt/vc/bin/ diff --git a/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs_0.12.7.bb b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs_0.12.7.bb old mode 100644 new mode 100755 index 41eb5ee..10b134c --- a/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs_0.12.7.bb +++ b/meta-tizen/meta-tizen-micro/recipes-devtools/nodejs/nodejs_0.12.7.bb @@ -8,12 +8,18 @@ DEPENDS = "openssl" SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.gz \ file://enable-armv5e-build.patch \ file://no-registry.patch \ + file://nodejs.sh \ + file://nodejs.service \ " SRC_URI[md5sum] = "5523ec4347d7fe6b0f6dda1d1c7799d5" SRC_URI[sha256sum] = "b23d64df051c9c969b0c583f802d5d71de342e53067127a5061415be7e12f39d" S = "${WORKDIR}/node-v${PV}" +inherit npm +NPM_INSTALL ?= "mqtt onoff request" +NPM_INSTALL_FLAGS ?= "" + # v8 errors out if you have set CCACHE CCACHE = "" @@ -48,6 +54,32 @@ do_compile () { do_install () { oe_runmake install DESTDIR=${D} + + cd ${D}/usr/lib + oe_runnpm config set registry=http://registry.npmjs.org/ + oe_runnpm ${NPM_INSTALL_FLAGS} install ${NPM_INSTALL} + + for i in ${NPM_INSTALL}; + do + rm -rf ${D}/usr/lib/node_modules/$i/doc + rm -rf ${D}/usr/lib/node_modules/$i/example* + rm -rf ${D}/usr/lib/node_modules/$i/test + done + + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/nodejs.sh ${D}${sysconfdir}/init.d + update-rc.d -r ${D} nodejs.sh start 92 5 . + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then + install -d ${D}${systemd_unitdir}/system + install -m 0644 ${WORKDIR}/nodejs.service ${D}${systemd_unitdir}/system/ + + install -d ${D}${systemd_unitdir}/system/multi-user.target.wants + cd ${D}${systemd_unitdir}/system/multi-user.target.wants/ + ln -sf ../nodejs.service ${D}${systemd_unitdir}/system/multi-user.target.wants/nodejs.service + fi + + rm -rf ${D}/usr/lib/node_modules/npm } do_install_append_class-native() { @@ -62,19 +94,23 @@ do_install_append_class-native() { # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js # use sed on npm-cli.js because otherwise symlink is replaced with normal file and # npm-cli.js continues to use old shebang - sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js +# sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js } do_install_append_class-target() { - sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js +# sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js } PACKAGES =+ "${PN}-npm" -FILES_${PN}-npm = "${exec_prefix}/lib/node_modules ${bindir}/npm" +FILES_${PN}-npm = "${bindir}/npm" RDEPENDS_${PN}-npm = "bash python-shell python-datetime python-subprocess python-textutils" PACKAGES =+ "${PN}-systemtap" FILES_${PN}-systemtap = "${datadir}/systemtap" +FILES_${PN} += "${systemd_unitdir}/system/nodejs.service \ + ${systemd_unitdir}/system/multi-user.target.wants/nodejs.service \ + ${exec_prefix}/lib/node_modules \ + " BBCLASSEXTEND = "native"