From 3c1e4e4e9f0019799c52e6c9d288e9bff893cdc7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 Apr 2018 18:06:58 +0100 Subject: [PATCH] Condition to avoid cpu detection bug --- src/freedombone-utils-nodejs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index 1a4d8c01..5f84bdbc 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -175,17 +175,22 @@ function mesh_install_nodejs { # update from the old debian 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} - #nodejs_fix_cpu_detection - #cp "$rootdir/root/npm" "$rootdir/usr/bin/npm" - #cp "$rootdir/root/npm" "$rootdir/usr/local/bin/npm" + if [ ! "$rootdir" ]; then + # Don't do this if we're building an image, + # because cpu detection faults occur. + # This condition may no longer be needed in future once the bug is fixed + $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION} + nodejs_fix_cpu_detection + cp "$rootdir/root/npm" "$rootdir/usr/bin/npm" + cp "$rootdir/root/npm" "$rootdir/usr/local/bin/npm" - # deliberate second install of npm - #$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" "$rootdir/usr/bin/npm" - #fi - #cp "$rootdir/usr/bin/npm" "$rootdir/root/npm" + # deliberate second install of npm + $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" "$rootdir/usr/bin/npm" + fi + cp "$rootdir/usr/bin/npm" "$rootdir/root/npm" + fi if [ -f "$rootdir/usr/bin/node" ]; then cp "$rootdir/usr/bin/node" "$rootdir/usr/local/bin/node" fi