From 370561d40f6dfbba4c1ab6d50fffbe421f1156bd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 13 Sep 2017 20:10:28 +0100 Subject: [PATCH] Tidying of mesh install of nodejs --- src/freedombone-image-customise | 25 +---------------- src/freedombone-utils-nodejs | 50 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 2bb4464c..70a95345 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -562,29 +562,6 @@ INSTALL_DIR=$HOME/build INSTALLING_MESH= install_patchwork() { - chroot "$rootdir" apt-get -yq install g++ m4 libtool automake nodejs curl - chroot "$rootdir" apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev - - if [ -f $rootdir/usr/bin/nodejs ]; then - cp $rootdir/usr/bin/nodejs $rootdir/usr/bin/node - fi - if [ ! -f $rootdir/usr/bin/node ]; then - echo $'/usr/bin/node not found' - exit 7235728 - fi - if [ -f /usr/share/npm/bin/npm-cli.js ]; then - ln -s /usr/share/npm/bin/npm-cli.js /usr/bin/npm - else - wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh - if [ ! -f $rootdir/root/npm_install.sh ]; then - echo $'Unable to download npm installer' - exit 8793636 - fi - chroot "$rootdir" chmod +x /root/npm_install.sh - sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh - chroot "$rootdir" /root/npm_install.sh - fi - git clone https://github.com/ssbc/patchwork $rootdir/etc/patchwork cat < $rootdir/usr/bin/install_patchwork @@ -1506,12 +1483,12 @@ admin_user_sudo create_generic_image atheros_wifi continue_installation +image_install_nodejs initialise_mesh configure_wifi configure_user_interface image_setup_utils image_install_inadyn -image_install_nodejs image_preinstall_repos # remove downloaded packages diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index 78d9ce4b..4fdb4a4c 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -44,39 +44,35 @@ NPM_VERSION='4.0.5' NODEJS_INSTALLED_APPS_FILE=$HOME/.nodejs-apps function mesh_install_nodejs { - # Note: this has to be jessie for now - wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > ${rootdir}/root/node.gpg.key - chroot "${rootdir}" apt-key add /root/node.gpg.key - echo "deb https://deb.nodesource.com/node_6.x jessie main" > ${rootdir}/etc/apt/sources.list.d/nodesource.list - echo "deb-src https://deb.nodesource.com/node_6.x jessie main" >> ${rootdir}/etc/apt/sources.list.d/nodesource.list - chroot "${rootdir}" apt-get update - chroot "${rootdir}" apt-get -yq install nodejs curl + chroot "$rootdir" apt-get -yq install g++ m4 libtool automake nodejs curl + chroot "$rootdir" apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev if [ ! -f ${rootdir}/usr/bin/nodejs ]; then echo $'nodejs was not installed' exit 63962 fi - # TODO this doesn't work -# cat < ${rootdir}/root/install-nodejs.sh -##!/bin/bash -#npm install -g npm@${NPM_VERSION} --save -#npm install -g n@${NODEJS_N_VERSION} --save -#n ${NODEJS_VERSION} -#npm install -g pug@2.0.0-beta6 --save -#npm install -g graceful-fs@4.1.10 --save -#npm install -g minimatch@3.0.3 --save -#npm install -g npm@${NPM_VERSION} --save -#cp /usr/local/bin/node /usr/bin/nodejs -#cp /usr/local/bin/npm /usr/bin/npm -#EOF -# chroot "${rootdir}" chmod +x /root/install-nodejs.sh -# chroot "${rootdir}" /root/install-nodejs.sh -# if [ ! "$?" = "0" ]; then -# chroot "${rootdir}" rm -f /root/install-nodejs.sh -# exit 7632572 -# fi -# chroot "${rootdir}" rm -f /root/install-nodejs.sh + if [ -f $rootdir/usr/bin/nodejs ]; then + cp $rootdir/usr/bin/nodejs $rootdir/usr/bin/node + fi + + if [ ! -f $rootdir/usr/bin/node ]; then + echo $'/usr/bin/node not found' + exit 7235728 + fi + + if [ -f /usr/share/npm/bin/npm-cli.js ]; then + ln -s /usr/share/npm/bin/npm-cli.js /usr/bin/npm + else + wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh + if [ ! -f $rootdir/root/npm_install.sh ]; then + echo $'Unable to download npm installer' + exit 8793636 + fi + chroot "$rootdir" chmod +x /root/npm_install.sh + sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh + chroot "$rootdir" /root/npm_install.sh + fi } function remove_nodejs {