Parcourir la source

Optional chroot when installing nodejs

Bob Mottram il y a 7 ans
Parent
révision
95d12e1384
1 fichiers modifiés avec 10 ajouts et 6 suppressions
  1. 10
    6
      src/freedombone-utils-nodejs

+ 10
- 6
src/freedombone-utils-nodejs Voir le fichier

@@ -61,8 +61,12 @@ function get_npm_arch {
61 61
 }
62 62
 
63 63
 function mesh_install_nodejs {
64
-    chroot "$rootdir" apt-get -yq install g++ m4 libtool automake nodejs curl
65
-    chroot "$rootdir" apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
64
+    mesh_install_nodejs_prefix=
65
+    if [ $rootdir ]; then
66
+        mesh_install_nodejs_prefix="chroot $rootdir"
67
+    fi
68
+    $mesh_install_nodejs_prefix apt-get -yq install g++ m4 libtool automake nodejs curl
69
+    $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
66 70
 
67 71
     if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
68 72
         echo $'nodejs was not installed'
@@ -83,9 +87,9 @@ function mesh_install_nodejs {
83 87
         echo $'Unable to download npm installer'
84 88
         exit 8793636
85 89
     fi
86
-    chroot "$rootdir" chmod +x /root/npm_install.sh
90
+    $mesh_install_nodejs_prefix chmod +x /root/npm_install.sh
87 91
     sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh
88
-    chroot "$rootdir" /root/npm_install.sh
92
+    $mesh_install_nodejs_prefix /root/npm_install.sh
89 93
 
90 94
     if [ ! -f $rootdir/usr/bin/npm ]; then
91 95
         echo $'npm was not installed'
@@ -95,8 +99,8 @@ function mesh_install_nodejs {
95 99
 
96 100
     # update from the old debian nodejs version
97 101
     get_npm_arch
98
-    chroot "$rootdir" npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
99
-    chroot "$rootdir" n --arch $N_ARCH ${NODEJS_VERSION}
102
+    $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
103
+    $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
100 104
     cp $rootdir/root/npm $rootdir/usr/bin/npm
101 105
 }
102 106