Reputation: 13836
I have a script to get and setup the latest NodeJS on my .deb system:
echo "Downloading, building and installing latest NodeJS"
sudo apt-get install python g++ make checkinstall
mkdir /tmp/node_build && cd $_
curl -O "http://nodejs.org/dist/node-latest.tar.gz"
tar xf node-latest.tar.gz && cd node-v*
NODE_VERSION="${PWD#*v}"
#NODE_VERSION=python -c "print '$PWD'.split('-')[-1][1:]"
echo "Installing NodeJS" $NODE_VERSION
./configure
sudo checkinstall -y --install=no --pkgversion NODE_VERSION
sudo dpkg -i node_$NODE_VERSION
Unfortunately it doesn't work; as the echo
line outputs:
Installing NodeJS i8/dir-where-runnning-script-from/node-v0.10.24
It does work from the shell though:
$ cd /tmp/node_build/node-v0.10.24 && echo "${PWD#*v}"
0.10.24
Upvotes: 0
Views: 105
Reputation: 125998
Is there another "v" in the path, like right before the "i8/"? #*v
will remove through the first "v" in the variable; I'm pretty sure you want ##*v
which'll remove through the last "v" in the variable. (Technically, #
removes the shortest matching prefix, and ##
removes the longest match). Thus:
NODE_VERSION="${PWD##*v}"
Should work.
Upvotes: 1
Reputation: 11603
Try this
sudo checkinstall -y --install=no --pkgversion "${NODE_VERSION##*v}"
Upvotes: 0