Fix nodejs image install

This commit is contained in:
Bob Mottram 2017-06-15 23:13:17 +01:00
parent eaa53b3bed
commit 86370db1d5
2 changed files with 51 additions and 48 deletions

View File

@ -1219,7 +1219,7 @@ function image_setup_utils {
function image_install_nodejs {
mesh_install_nodejs
echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
#echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
}
function image_preinstall_repos {

View File

@ -57,25 +57,26 @@ function mesh_install_nodejs {
exit 63962
fi
cat <<EOF > ${rootdir}/root/install-nodejs.sh
#!/bin/bash
npm install -g npm@${NPM_VERSION} --save
npm install -g n@${NODEJS_N_VERSION} --save
n ${NODEJS_VERSION}
npm install -g pug@2.0.0-beta6 --save
npm install -g graceful-fs@4.1.10 --save
npm install -g minimatch@3.0.3 --save
npm install -g npm@${NPM_VERSION} --save
cp /usr/local/bin/node /usr/bin/nodejs
cp /usr/local/bin/npm /usr/bin/npm
EOF
chroot "${rootdir}" chmod +x /root/install-nodejs.sh
chroot "${rootdir}" /root/install-nodejs.sh
if [ ! "$?" = "0" ]; then
chroot "${rootdir}" rm -f /root/install-nodejs.sh
exit 7632572
fi
chroot "${rootdir}" rm -f /root/install-nodejs.sh
# TODO this doesn't work
# cat <<EOF > ${rootdir}/root/install-nodejs.sh
##!/bin/bash
#npm install -g npm@${NPM_VERSION} --save
#npm install -g n@${NODEJS_N_VERSION} --save
#n ${NODEJS_VERSION}
#npm install -g pug@2.0.0-beta6 --save
#npm install -g graceful-fs@4.1.10 --save
#npm install -g minimatch@3.0.3 --save
#npm install -g npm@${NPM_VERSION} --save
#cp /usr/local/bin/node /usr/bin/nodejs
#cp /usr/local/bin/npm /usr/bin/npm
#EOF
# chroot "${rootdir}" chmod +x /root/install-nodejs.sh
# chroot "${rootdir}" /root/install-nodejs.sh
# if [ ! "$?" = "0" ]; then
# chroot "${rootdir}" rm -f /root/install-nodejs.sh
# exit 7632572
# fi
# chroot "${rootdir}" rm -f /root/install-nodejs.sh
}
function remove_nodejs {
@ -147,35 +148,37 @@ function install_nodejs {
return
fi
# Note: this has to be jessie for now
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
apt-key add /root/node.gpg.key
echo "deb https://deb.nodesource.com/node_7.x jessie main" > /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_7.x jessie main" >> /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get -yq remove --purge nodejs
if [ -d /usr/local/lib/node_modules ]; then
rm -rf /usr/local/lib/node_modules
fi
if [ -f /usr/local/bin/node ]; then
rm /usr/local/bin/node
fi
if [ -f /usr/bin/node ]; then
rm /usr/bin/node
fi
if [ -f /usr/bin/nodejs ]; then
rm /usr/bin/nodejs
fi
apt-get -yq install nodejs
apt-get -yq install curl
if [ ! -f /usr/bin/nodejs ]; then
echo $'nodejs was not installed'
exit 63962
# Note: this has to be jessie for now
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /root/node.gpg.key
apt-key add /root/node.gpg.key
echo "deb https://deb.nodesource.com/node_7.x jessie main" > /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_7.x jessie main" >> /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get -yq remove --purge nodejs
if [ -d /usr/local/lib/node_modules ]; then
rm -rf /usr/local/lib/node_modules
fi
if [ -f /usr/local/bin/node ]; then
rm /usr/local/bin/node
fi
if [ -f /usr/bin/node ]; then
rm /usr/bin/node
fi
if [ -f /usr/bin/nodejs ]; then
rm /usr/bin/nodejs
fi
apt-get -yq install nodejs
apt-get -yq install curl
if [ ! -f /usr/bin/nodejs ]; then
echo $'nodejs was not installed'
exit 63962
fi
fi
npm install -g npm@${NPM_VERSION} --save