diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index ae0d8080..ea4c719d 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -68,8 +68,31 @@ function mesh_install_nodejs { fi mesh_install_nodejs_prefix="chroot $rootdir" fi - $mesh_install_nodejs_prefix apt-get -yq install g++ m4 libtool automake nodejs curl + + $mesh_install_nodejs_prefix apt-get -qy install wget curl g++ m4 libtool automake $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev + $mesh_install_nodejs_prefix wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key + $mesh_install_nodejs_prefix apt-key add /root/node.gpg.key + echo "deb https://deb.nodesource.com/node_6.x stretch main" > $rootdir/etc/apt/sources.list.d/nodesource.list + echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> $rootdir/etc/apt/sources.list.d/nodesource.list + + $mesh_install_nodejs_prefix apt-get update + $mesh_install_nodejs_prefix apt-get -yq remove --purge nodejs + + if [ -d $rootdir/usr/local/lib/node_modules ]; then + rm -rf $rootdir/usr/local/lib/node_modules + fi + if [ -f $rootdir/usr/local/bin/node ]; then + rm $rootdir/usr/local/bin/node + fi + if [ -f $rootdir/usr/bin/node ]; then + rm /usr/bin/node + fi + if [ -f $rootdir/usr/bin/nodejs ]; then + rm $rootdir/usr/bin/nodejs + fi + + $mesh_install_nodejs_prefix apt-get -yq install nodejs if [ ! -f ${rootdir}/usr/bin/nodejs ]; then echo $'nodejs was not installed' @@ -85,28 +108,33 @@ function mesh_install_nodejs { exit 7235728 fi - $mesh_install_nodejs_prefix apt-get -qy install wget - $mesh_install_nodejs_prefix wget https://www.npmjs.com/install.sh -O /root/npm_install.sh - if [ ! -f $rootdir/root/npm_install.sh ]; then - echo $'Unable to download npm installer' - exit 8793636 - fi - if ! grep -q "t=\"\${npm_install}\"" $rootdir/root/npm_install.sh; then - echo $'Unable to set npm version within npm_install.sh' - exit 629052 - fi - $mesh_install_nodejs_prefix chmod +x /root/npm_install.sh - $mesh_install_nodejs_prefix sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" /root/npm_install.sh - $mesh_install_nodejs_prefix /root/npm_install.sh + #$mesh_install_nodejs_prefix wget https://www.npmjs.com/install.sh -O /root/npm_install.sh + #if [ ! -f $rootdir/root/npm_install.sh ]; then + # echo $'Unable to download npm installer' + # exit 8793636 + #fi + #if ! grep -q "t=\"\${npm_install}\"" $rootdir/root/npm_install.sh; then + # echo $'Unable to set npm version within npm_install.sh' + # exit 629052 + #fi + #$mesh_install_nodejs_prefix chmod +x /root/npm_install.sh + #$mesh_install_nodejs_prefix sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" /root/npm_install.sh + #$mesh_install_nodejs_prefix /root/npm_install.sh + # + #if [ ! -f $rootdir/usr/bin/npm ]; then + # echo $'npm was not installed' + # exit 5290462 + #fi + #cp $rootdir/usr/bin/npm $rootdir/root/npm - if [ ! -f $rootdir/usr/bin/npm ]; then - echo $'npm was not installed' - exit 5290462 + get_npm_arch + $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save + if [ -f $rootdir/usr/local/bin/npm ]; then + cp $rootdir/usr/local/bin/npm /usr/bin/npm fi cp $rootdir/usr/bin/npm $rootdir/root/npm # update from the old debian nodejs version - get_npm_arch $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION} cp $rootdir/root/npm $rootdir/usr/bin/npm @@ -189,7 +217,6 @@ function install_nodejs { #if [ ! -f /usr/bin/nodejs ]; then - # Note: this has to be jessie for now # wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key # apt-key add /root/node.gpg.key # echo "deb https://deb.nodesource.com/node_6.x stretch main" > /etc/apt/sources.list.d/nodesource.list @@ -227,12 +254,6 @@ function install_nodejs { #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 - if [ -f /usr/local/bin/npm ]; then - cp /usr/local/bin/npm /usr/bin/npm - fi # node seems tricky so here we're going to double check # that the versions we expect did get installed