|  | @@ -35,8 +35,8 @@ VARIANTS='mesh'
 | 
	
		
			
			| 35 | 35 |  
 | 
	
		
			
			| 36 | 36 |  # change these versions at your peril. Things will often crash if you don't
 | 
	
		
			
			| 37 | 37 |  # have specifically the correct versions
 | 
	
		
			
			| 38 |  | -NODEJS_VERSION='6.11.3'
 | 
	
		
			
			| 39 |  | -NODEJS_N_VERSION='2.1.7'
 | 
	
		
			
			|  | 38 | +NODEJS_VERSION='6.11.4'
 | 
	
		
			
			|  | 39 | +NODEJS_N_VERSION='2.1.8'
 | 
	
		
			
			| 40 | 40 |  NPM_VERSION='4.0.5'
 | 
	
		
			
			| 41 | 41 |  
 | 
	
		
			
			| 42 | 42 |  # This file keeps track of the apps needing nodejs
 | 
	
	
		
			
			|  | @@ -48,7 +48,7 @@ function get_npm_arch {
 | 
	
		
			
			| 48 | 48 |      NPM_ARCH='ia32'
 | 
	
		
			
			| 49 | 49 |      if [[ $ARCHITECTURE == 'arm'* ]]; then
 | 
	
		
			
			| 50 | 50 |          NPM_ARCH='armv7l'
 | 
	
		
			
			| 51 |  | -        N_ARCH='arm'
 | 
	
		
			
			|  | 51 | +        N_ARCH='armv7l'
 | 
	
		
			
			| 52 | 52 |      fi
 | 
	
		
			
			| 53 | 53 |      if [[ $ARCHITECTURE == *"aarch"* ]]; then
 | 
	
		
			
			| 54 | 54 |          NPM_ARCH='arm64'
 | 
	
	
		
			
			|  | @@ -68,40 +68,65 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 68 | 68 |          fi
 | 
	
		
			
			| 69 | 69 |          mesh_install_nodejs_prefix="chroot $rootdir"
 | 
	
		
			
			| 70 | 70 |      fi
 | 
	
		
			
			| 71 |  | -    $mesh_install_nodejs_prefix apt-get -yq install g++ m4 libtool automake nodejs curl
 | 
	
		
			
			|  | 71 | +
 | 
	
		
			
			|  | 72 | +    $mesh_install_nodejs_prefix apt-get -yq install wget curl g++ m4 libtool automake
 | 
	
		
			
			| 72 | 73 |      $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
 | 
	
		
			
			|  | 74 | +    $mesh_install_nodejs_prefix apt-get -yq install apt-transport-https
 | 
	
		
			
			|  | 75 | +    $mesh_install_nodejs_prefix wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O /root/node.gpg.key
 | 
	
		
			
			|  | 76 | +    if [ ! -f $rootdir/root/node.gpg.key ]; then
 | 
	
		
			
			|  | 77 | +        echo $'Unable to obtain gpg key for nodejs repo'
 | 
	
		
			
			|  | 78 | +        exit 6389252
 | 
	
		
			
			|  | 79 | +    fi
 | 
	
		
			
			|  | 80 | +    $mesh_install_nodejs_prefix apt-key add /root/node.gpg.key
 | 
	
		
			
			|  | 81 | +    echo "deb https://deb.nodesource.com/node_6.x stretch main" > $rootdir/etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			|  | 82 | +    echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> $rootdir/etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			| 73 | 83 |  
 | 
	
		
			
			| 74 |  | -    if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
 | 
	
		
			
			| 75 |  | -        echo $'nodejs was not installed'
 | 
	
		
			
			| 76 |  | -        exit 63962
 | 
	
		
			
			|  | 84 | +    $mesh_install_nodejs_prefix apt-get update
 | 
	
		
			
			|  | 85 | +    $mesh_install_nodejs_prefix apt-get -yq remove --purge nodejs
 | 
	
		
			
			|  | 86 | +
 | 
	
		
			
			|  | 87 | +    if [ -d $rootdir/usr/local/lib/node_modules ]; then
 | 
	
		
			
			|  | 88 | +        rm -rf $rootdir/usr/local/lib/node_modules
 | 
	
		
			
			|  | 89 | +    fi
 | 
	
		
			
			|  | 90 | +    if [ -f $rootdir/usr/local/bin/node ]; then
 | 
	
		
			
			|  | 91 | +        rm $rootdir/usr/local/bin/node
 | 
	
		
			
			|  | 92 | +    fi
 | 
	
		
			
			|  | 93 | +    if [ -f $rootdir/usr/bin/node ]; then
 | 
	
		
			
			|  | 94 | +        rm /usr/bin/node
 | 
	
		
			
			|  | 95 | +    fi
 | 
	
		
			
			|  | 96 | +    if [ -f $rootdir/usr/bin/nodejs ]; then
 | 
	
		
			
			|  | 97 | +        rm $rootdir/usr/bin/nodejs
 | 
	
		
			
			| 77 | 98 |      fi
 | 
	
		
			
			| 78 | 99 |  
 | 
	
		
			
			|  | 100 | +    $mesh_install_nodejs_prefix apt-get -yq install nodejs
 | 
	
		
			
			|  | 101 | +
 | 
	
		
			
			| 79 | 102 |      if [ -f $rootdir/usr/bin/nodejs ]; then
 | 
	
		
			
			| 80 | 103 |          cp $rootdir/usr/bin/nodejs $rootdir/usr/bin/node
 | 
	
		
			
			| 81 | 104 |      fi
 | 
	
		
			
			| 82 | 105 |  
 | 
	
		
			
			|  | 106 | +    if [ ! -f ${rootdir}/usr/bin/node ]; then
 | 
	
		
			
			|  | 107 | +        if [ ! -f ${rootdir}/usr/local/bin/node ]; then
 | 
	
		
			
			|  | 108 | +            if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
 | 
	
		
			
			|  | 109 | +                echo $'nodejs was not installed'
 | 
	
		
			
			|  | 110 | +                exit 63962
 | 
	
		
			
			|  | 111 | +            fi
 | 
	
		
			
			|  | 112 | +        fi
 | 
	
		
			
			|  | 113 | +    fi
 | 
	
		
			
			|  | 114 | +
 | 
	
		
			
			| 83 | 115 |      if [ ! -f $rootdir/usr/bin/node ]; then
 | 
	
		
			
			| 84 | 116 |          echo $'/usr/bin/node not found'
 | 
	
		
			
			| 85 | 117 |          exit 7235728
 | 
	
		
			
			| 86 | 118 |      fi
 | 
	
		
			
			| 87 | 119 |  
 | 
	
		
			
			| 88 |  | -    wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh
 | 
	
		
			
			| 89 |  | -    if [ ! -f $rootdir/root/npm_install.sh ]; then
 | 
	
		
			
			| 90 |  | -        echo $'Unable to download npm installer'
 | 
	
		
			
			| 91 |  | -        exit 8793636
 | 
	
		
			
			| 92 |  | -    fi
 | 
	
		
			
			| 93 |  | -    $mesh_install_nodejs_prefix chmod +x /root/npm_install.sh
 | 
	
		
			
			| 94 |  | -    sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh
 | 
	
		
			
			| 95 |  | -    $mesh_install_nodejs_prefix /root/npm_install.sh
 | 
	
		
			
			|  | 120 | +    get_npm_arch
 | 
	
		
			
			| 96 | 121 |  
 | 
	
		
			
			| 97 |  | -    if [ ! -f $rootdir/usr/bin/npm ]; then
 | 
	
		
			
			| 98 |  | -        echo $'npm was not installed'
 | 
	
		
			
			| 99 |  | -        exit 5290462
 | 
	
		
			
			|  | 122 | +    $mesh_install_nodejs_prefix npm config set unsafe-perm true
 | 
	
		
			
			|  | 123 | +    $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			|  | 124 | +    if [ -f $rootdir/usr/local/bin/npm ]; then
 | 
	
		
			
			|  | 125 | +        cp $rootdir/usr/local/bin/npm /usr/bin/npm
 | 
	
		
			
			| 100 | 126 |      fi
 | 
	
		
			
			| 101 | 127 |      cp $rootdir/usr/bin/npm $rootdir/root/npm
 | 
	
		
			
			| 102 | 128 |  
 | 
	
		
			
			| 103 | 129 |      # update from the old debian nodejs version
 | 
	
		
			
			| 104 |  | -    get_npm_arch
 | 
	
		
			
			| 105 | 130 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
 | 
	
		
			
			| 106 | 131 |      $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
 | 
	
		
			
			| 107 | 132 |      cp $rootdir/root/npm $rootdir/usr/bin/npm
 | 
	
	
		
			
			|  | @@ -182,55 +207,7 @@ function install_nodejs {
 | 
	
		
			
			| 182 | 207 |      rootdir=
 | 
	
		
			
			| 183 | 208 |      mesh_install_nodejs
 | 
	
		
			
			| 184 | 209 |  
 | 
	
		
			
			| 185 |  | -
 | 
	
		
			
			| 186 |  | -    #if [ ! -f /usr/bin/nodejs ]; then
 | 
	
		
			
			| 187 |  | -        # Note: this has to be jessie for now
 | 
	
		
			
			| 188 |  | -    #    wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
 | 
	
		
			
			| 189 |  | -    #    apt-key add /root/node.gpg.key
 | 
	
		
			
			| 190 |  | -    #    echo "deb https://deb.nodesource.com/node_6.x stretch main" > /etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			| 191 |  | -    #    echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> /etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			| 192 |  | -
 | 
	
		
			
			| 193 |  | -    #    apt-get update
 | 
	
		
			
			| 194 |  | -
 | 
	
		
			
			| 195 |  | -    #    apt-get -yq remove --purge nodejs
 | 
	
		
			
			| 196 |  | -
 | 
	
		
			
			| 197 |  | -    #    if [ -d /usr/local/lib/node_modules ]; then
 | 
	
		
			
			| 198 |  | -    #        rm -rf /usr/local/lib/node_modules
 | 
	
		
			
			| 199 |  | -    #    fi
 | 
	
		
			
			| 200 |  | -    #    if [ -f /usr/local/bin/node ]; then
 | 
	
		
			
			| 201 |  | -    #        rm /usr/local/bin/node
 | 
	
		
			
			| 202 |  | -    #    fi
 | 
	
		
			
			| 203 |  | -    #    if [ -f /usr/bin/node ]; then
 | 
	
		
			
			| 204 |  | -    #        rm /usr/bin/node
 | 
	
		
			
			| 205 |  | -    #    fi
 | 
	
		
			
			| 206 |  | -    #    if [ -f /usr/bin/nodejs ]; then
 | 
	
		
			
			| 207 |  | -    #        rm /usr/bin/nodejs
 | 
	
		
			
			| 208 |  | -    #    fi
 | 
	
		
			
			| 209 |  | -
 | 
	
		
			
			| 210 |  | -    #    apt-get -yq install nodejs
 | 
	
		
			
			| 211 |  | -    #    apt-get -yq install curl
 | 
	
		
			
			| 212 |  | -
 | 
	
		
			
			| 213 |  | -    #    if [ ! -f /usr/bin/nodejs ]; then
 | 
	
		
			
			| 214 |  | -    #        echo $'nodejs was not installed'
 | 
	
		
			
			| 215 |  | -    #        exit 63962
 | 
	
		
			
			| 216 |  | -    #    fi
 | 
	
		
			
			| 217 |  | -    #fi
 | 
	
		
			
			| 218 |  | -
 | 
	
		
			
			| 219 |  | -    #npm install -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 220 |  | -    #npm install -g n@${NODEJS_N_VERSION} --save
 | 
	
		
			
			| 221 |  | -    #n ${NODEJS_VERSION}
 | 
	
		
			
			| 222 |  | -    #npm install -g pug@2.0.0-beta6 --save
 | 
	
		
			
			| 223 |  | -    #npm install -g graceful-fs@4.1.10 --save
 | 
	
		
			
			| 224 |  | -    #npm install -g minimatch@3.0.3 --save
 | 
	
		
			
			| 225 |  | -    npm install -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 226 |  | -
 | 
	
		
			
			| 227 |  | -    #cp /usr/local/bin/node /usr/bin/nodejs
 | 
	
		
			
			| 228 |  | -    if [ -f /usr/local/bin/npm ]; then
 | 
	
		
			
			| 229 |  | -        cp /usr/local/bin/npm /usr/bin/npm
 | 
	
		
			
			| 230 |  | -    fi
 | 
	
		
			
			| 231 |  | -
 | 
	
		
			
			| 232 |  | -    # node seems tricky so here we're going to double check
 | 
	
		
			
			| 233 |  | -    # that the versions we expect did get installed
 | 
	
		
			
			|  | 210 | +    # verify nodejs versions are what we expect
 | 
	
		
			
			| 234 | 211 |      CURR_NODE_VERSION=$(node --version)
 | 
	
		
			
			| 235 | 212 |      CURR_NPM_VERSION=$(npm --version)
 | 
	
		
			
			| 236 | 213 |      CURR_N_VERSION=$(n --version)
 |