Skip to content
Browse files

[nodejs]: made download, compilation and installation a bit more gran…

…ular.
  • Loading branch information...
1 parent 65f9e95 commit e6c3f6b6961fa35ee9985837dbec35c3cb53dac8 @laggyluke laggyluke committed Jan 21, 2012
Showing with 23 additions and 10 deletions.
  1. +2 −1 attributes/default.rb
  2. +21 −9 recipes/default.rb
View
3 attributes/default.rb
@@ -17,6 +17,7 @@
# limitations under the License.
#
-default.nodejs[:version] = "0.6.5"
+default.nodejs[:version] = "0.6.8"
+default.nodejs[:checksum] = "e6cbfc5ccdbe10128dbbd4dc7a88c154d80f8a39c3a8477092cf7d25eef78c9c"
default.nodejs[:dir] = "/usr/local"
default.nodejs[:npm] = "1.0.105"
View
30 recipes/default.rb
@@ -27,22 +27,34 @@
package "libssl-dev"
end
-nodejs_tar_path = "node-v#{node[:nodejs][:version]}.tar.gz"
+nodejs_tar = "node-v#{node[:nodejs][:version]}.tar.gz"
+nodejs_tar_path = nodejs_tar
if node[:nodejs][:version].split('.')[1].to_i >= 5
nodejs_tar_path = "v#{node[:nodejs][:version]}/#{nodejs_tar_path}"
end
-bash "install nodejs from source" do
+remote_file "/usr/local/src/#{nodejs_tar}" do
+ source "http://nodejs.org/dist/#{nodejs_tar_path}"
+ checksum node[:nodejs][:checksum]
+ mode 0644
+end
+
+execute "tar zxf #{nodejs_tar}" do
cwd "/usr/local/src"
- user "root"
+ creates "/usr/local/src/node-v#{node[:nodejs][:version]}"
+end
+
+bash "compile node.js" do
+ cwd "/usr/local/src/node-v#{node[:nodejs][:version]}"
code <<-EOH
- wget http://nodejs.org/dist/#{nodejs_tar_path} && \
- tar zxf node-v#{node[:nodejs][:version]}.tar.gz && \
- cd node-v#{node[:nodejs][:version]} && \
./configure --prefix=#{node[:nodejs][:dir]} && \
- make && \
- make install
+ make
EOH
- not_if "#{node[:nodejs][:dir]}/bin/node -v 2>&1 | grep 'v#{node[:nodejs][:version]}'"
+ creates "/usr/local/src/node-v#{node[:nodejs][:version]}/node"
+end
+
+execute "make install" do
+ cwd "/usr/local/src/node-v#{node[:nodejs][:version]}"
+ not_if "test `#{node[:nodejs][:dir]}/bin/node` == 'v#{node[:nodejs][:version]}'"
end

0 comments on commit e6c3f6b

Please sign in to comment.
Something went wrong with that request. Please try again.