From 95d12e138455bfcd01d3a18bef2803d9f335fead Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Tue, 19 Sep 2017 11:03:45 +0100 Subject: [PATCH] Optional chroot when installing nodejs --- src/freedombone-utils-nodejs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index 545e92690..e715ead97 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -61,8 +61,12 @@ function get_npm_arch { } function mesh_install_nodejs { - chroot "$rootdir" apt-get -yq install g++ m4 libtool automake nodejs curl - chroot "$rootdir" apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev + mesh_install_nodejs_prefix= + if [ $rootdir ]; then + 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 -yq install libxext-dev libxtst-dev libxkbfile-dev if [ ! -f ${rootdir}/usr/bin/nodejs ]; then echo $'nodejs was not installed' @@ -83,9 +87,9 @@ function mesh_install_nodejs { echo $'Unable to download npm installer' exit 8793636 fi - chroot "$rootdir" chmod +x /root/npm_install.sh + $mesh_install_nodejs_prefix 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 + $mesh_install_nodejs_prefix /root/npm_install.sh if [ ! -f $rootdir/usr/bin/npm ]; then echo $'npm was not installed' @@ -95,8 +99,8 @@ function mesh_install_nodejs { # update from the old debian nodejs version get_npm_arch - chroot "$rootdir" npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save - chroot "$rootdir" n --arch $N_ARCH ${NODEJS_VERSION} + $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 } -- GitLab