Browse Source

Make mesh npm install similar to previous methos

Bob Mottram 7 years ago
parent
commit
2ae9c79f9d
1 changed files with 46 additions and 25 deletions
  1. 46
    25
      src/freedombone-utils-nodejs

+ 46
- 25
src/freedombone-utils-nodejs View File

68
         fi
68
         fi
69
         mesh_install_nodejs_prefix="chroot $rootdir"
69
         mesh_install_nodejs_prefix="chroot $rootdir"
70
     fi
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 -qy install wget curl g++ m4 libtool automake
72
     $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
73
     $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
74
+    $mesh_install_nodejs_prefix wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
75
+    $mesh_install_nodejs_prefix apt-key add /root/node.gpg.key
76
+    echo "deb https://deb.nodesource.com/node_6.x stretch main" > $rootdir/etc/apt/sources.list.d/nodesource.list
77
+    echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> $rootdir/etc/apt/sources.list.d/nodesource.list
78
+
79
+    $mesh_install_nodejs_prefix apt-get update
80
+    $mesh_install_nodejs_prefix apt-get -yq remove --purge nodejs
81
+
82
+    if [ -d $rootdir/usr/local/lib/node_modules ]; then
83
+        rm -rf $rootdir/usr/local/lib/node_modules
84
+    fi
85
+    if [ -f $rootdir/usr/local/bin/node ]; then
86
+        rm $rootdir/usr/local/bin/node
87
+    fi
88
+    if [ -f $rootdir/usr/bin/node ]; then
89
+        rm /usr/bin/node
90
+    fi
91
+    if [ -f $rootdir/usr/bin/nodejs ]; then
92
+        rm $rootdir/usr/bin/nodejs
93
+    fi
94
+
95
+    $mesh_install_nodejs_prefix apt-get -yq install nodejs
73
 
96
 
74
     if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
97
     if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
75
         echo $'nodejs was not installed'
98
         echo $'nodejs was not installed'
85
         exit 7235728
108
         exit 7235728
86
     fi
109
     fi
87
 
110
 
88
-    $mesh_install_nodejs_prefix apt-get -qy install wget
89
-    $mesh_install_nodejs_prefix wget https://www.npmjs.com/install.sh -O /root/npm_install.sh
90
-    if [ ! -f $rootdir/root/npm_install.sh ]; then
91
-        echo $'Unable to download npm installer'
92
-        exit 8793636
93
-    fi
94
-    if ! grep -q "t=\"\${npm_install}\"" $rootdir/root/npm_install.sh; then
95
-        echo $'Unable to set npm version within npm_install.sh'
96
-        exit 629052
97
-    fi
98
-    $mesh_install_nodejs_prefix chmod +x /root/npm_install.sh
99
-    $mesh_install_nodejs_prefix sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" /root/npm_install.sh
100
-    $mesh_install_nodejs_prefix /root/npm_install.sh
111
+    #$mesh_install_nodejs_prefix wget https://www.npmjs.com/install.sh -O /root/npm_install.sh
112
+    #if [ ! -f $rootdir/root/npm_install.sh ]; then
113
+    #    echo $'Unable to download npm installer'
114
+    #    exit 8793636
115
+    #fi
116
+    #if ! grep -q "t=\"\${npm_install}\"" $rootdir/root/npm_install.sh; then
117
+    #    echo $'Unable to set npm version within npm_install.sh'
118
+    #    exit 629052
119
+    #fi
120
+    #$mesh_install_nodejs_prefix chmod +x /root/npm_install.sh
121
+    #$mesh_install_nodejs_prefix sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" /root/npm_install.sh
122
+    #$mesh_install_nodejs_prefix /root/npm_install.sh
123
+    #
124
+    #if [ ! -f $rootdir/usr/bin/npm ]; then
125
+    #    echo $'npm was not installed'
126
+    #    exit 5290462
127
+    #fi
128
+    #cp $rootdir/usr/bin/npm $rootdir/root/npm
101
 
129
 
102
-    if [ ! -f $rootdir/usr/bin/npm ]; then
103
-        echo $'npm was not installed'
104
-        exit 5290462
130
+    get_npm_arch
131
+    $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
132
+    if [ -f $rootdir/usr/local/bin/npm ]; then
133
+        cp $rootdir/usr/local/bin/npm /usr/bin/npm
105
     fi
134
     fi
106
     cp $rootdir/usr/bin/npm $rootdir/root/npm
135
     cp $rootdir/usr/bin/npm $rootdir/root/npm
107
 
136
 
108
     # update from the old debian nodejs version
137
     # update from the old debian nodejs version
109
-    get_npm_arch
110
     $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
138
     $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
111
     $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
139
     $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
112
     cp $rootdir/root/npm $rootdir/usr/bin/npm
140
     cp $rootdir/root/npm $rootdir/usr/bin/npm
189
 
217
 
190
 
218
 
191
     #if [ ! -f /usr/bin/nodejs ]; then
219
     #if [ ! -f /usr/bin/nodejs ]; then
192
-        # Note: this has to be jessie for now
193
     #    wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
220
     #    wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
194
     #    apt-key add /root/node.gpg.key
221
     #    apt-key add /root/node.gpg.key
195
     #    echo "deb https://deb.nodesource.com/node_6.x stretch main" > /etc/apt/sources.list.d/nodesource.list
222
     #    echo "deb https://deb.nodesource.com/node_6.x stretch main" > /etc/apt/sources.list.d/nodesource.list
227
     #npm install -g pug@2.0.0-beta6 --save
254
     #npm install -g pug@2.0.0-beta6 --save
228
     #npm install -g graceful-fs@4.1.10 --save
255
     #npm install -g graceful-fs@4.1.10 --save
229
     #npm install -g minimatch@3.0.3 --save
256
     #npm install -g minimatch@3.0.3 --save
230
-    npm install -g npm@${NPM_VERSION} --save
231
-
232
-    #cp /usr/local/bin/node /usr/bin/nodejs
233
-    if [ -f /usr/local/bin/npm ]; then
234
-        cp /usr/local/bin/npm /usr/bin/npm
235
-    fi
236
 
257
 
237
     # node seems tricky so here we're going to double check
258
     # node seems tricky so here we're going to double check
238
     # that the versions we expect did get installed
259
     # that the versions we expect did get installed