From a8afecb718db27ae928032cad6ef0785dd66bc12 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Fri, 14 Oct 2011 16:17:19 -0500 Subject: [PATCH 1/7] Merge remote branch 'datadog/master' Conflicts: README.md From 9f4b14cd47ba083968b95575d90569c644bbc609 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 25 Oct 2011 14:04:55 -0500 Subject: [PATCH 2/7] Import nodejs version 0.5.1 --- README.rdoc | 49 +++++++++++++++++++++++++++++++++++++++++++ attributes/default.rb | 22 +++++++++++++++++++ metadata.json | 34 ++++++++++++++++++++++++++++++ metadata.rb | 10 +++++++++ recipes/default.rb | 42 +++++++++++++++++++++++++++++++++++++ recipes/npm.rb | 36 +++++++++++++++++++++++++++++++ 6 files changed, 193 insertions(+) create mode 100644 README.rdoc create mode 100644 attributes/default.rb create mode 100644 metadata.json create mode 100644 metadata.rb create mode 100644 recipes/default.rb create mode 100644 recipes/npm.rb diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..83be9a8 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,49 @@ += DESCRIPTION: + +Installs Node.JS from source. + += REQUIREMENTS: + +== Platform: + +Tested on Debian Lenny. Should work fine on Ubuntu, Centos, etc. + +== Cookbooks: + +Opscode cookbooks (http://github.com/opscode/cookbooks/tree/master) + +* build-essential + += ATTRIBUTES: + +* nodejs[:version] - release version of node to install +* nodejs[:dir] - location where node will be installed, default /usr/local +* nodejs[:npm] - version of npm to install + += USAGE: + +Include the nodejs recipe to install node from source on your system: + + include_recipe "nodejs" + +Include the npm recipe to install npm: + + include_recipe "nodejs::npm" + += LICENSE and AUTHOR: + +Author:: Marius Ducea (marius@promethost.com) + +Copyright:: 2010, Promet Solutions + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..e74a86e --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1,22 @@ +# +# Cookbook Name:: nodejs +# Attributes:: nodejs +# +# Copyright 2010, Promet Solutions +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +default.nodejs[:version] = "0.4.8" +default.nodejs[:dir] = "/usr/local" +default.nodejs[:npm] = "1.0.10" diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..aa249ba --- /dev/null +++ b/metadata.json @@ -0,0 +1,34 @@ +{ + "maintainer_email": "marius@promethost.com", + "groupings": { + }, + "attributes": { + }, + "recommendations": { + }, + "dependencies": { + "build-essential": [ + + ] + }, + "recipes": { + "nodejs::npm": "Installs npm - a package manager for node", + "nodejs": "Installs Node.JS from source" + }, + "suggestions": { + }, + "platforms": { + }, + "license": "Apache 2.0", + "version": "0.5.1", + "conflicting": { + }, + "providing": { + }, + "long_description": "= DESCRIPTION:\n\nInstalls Node.JS from source.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Debian Lenny. Should work fine on Ubuntu, Centos, etc.\n\n== Cookbooks:\n\nOpscode cookbooks (http://github.com/opscode/cookbooks/tree/master)\n\n* build-essential\n\n= ATTRIBUTES:\n\n* nodejs[:version] - release version of node to install\n* nodejs[:dir] - location where node will be installed, default /usr/local\n* nodejs[:npm] - version of npm to install\n\n= USAGE:\n\nInclude the nodejs recipe to install node from source on your system:\n\n include_recipe \"nodejs\"\n\nInclude the npm recipe to install npm:\n \n include_recipe \"nodejs::npm\"\n\n= LICENSE and AUTHOR:\n\nAuthor:: Marius Ducea (marius@promethost.com)\n\nCopyright:: 2010, Promet Solutions\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", + "name": "nodejs", + "maintainer": "Promet Solutions", + "description": "Installs/Configures nodejs", + "replacing": { + } +} \ No newline at end of file diff --git a/metadata.rb b/metadata.rb new file mode 100644 index 0000000..508e2c0 --- /dev/null +++ b/metadata.rb @@ -0,0 +1,10 @@ +maintainer "Promet Solutions" +maintainer_email "marius@promethost.com" +license "Apache 2.0" +description "Installs/Configures nodejs" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) +version "0.5.1" +recipe "nodejs", "Installs Node.JS from source" +recipe "nodejs::npm", "Installs npm - a package manager for node" + +depends "build-essential" diff --git a/recipes/default.rb b/recipes/default.rb new file mode 100644 index 0000000..3a41dac --- /dev/null +++ b/recipes/default.rb @@ -0,0 +1,42 @@ +# +# Author:: Marius Ducea (marius@promethost.com) +# Cookbook Name:: nodejs +# Recipe:: default +# +# Copyright 2010, Promet Solutions +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "build-essential" + +case node[:platform] + when "centos","redhat","fedora" + package "openssl-devel" + when "debian","ubuntu" + package "libssl-dev" +end + +bash "install nodejs from source" do + cwd "/usr/local/src" + user "root" + code <<-EOH + wget http://nodejs.org/dist/node-v#{node[:nodejs][:version]}.tar.gz && \ + tar zxf node-v#{node[:nodejs][:version]}.tar.gz && \ + cd node-v#{node[:nodejs][:version]} && \ + ./configure --prefix=#{node[:nodejs][:dir]} && \ + make && \ + make install + EOH + not_if "#{node[:nodejs][:dir]}/bin/node -v 2>&1 | grep 'v#{node[:nodejs][:version]}'" +end diff --git a/recipes/npm.rb b/recipes/npm.rb new file mode 100644 index 0000000..8ca9394 --- /dev/null +++ b/recipes/npm.rb @@ -0,0 +1,36 @@ +# +# Author:: Marius Ducea (marius@promethost.com) +# Cookbook Name:: nodejs +# Recipe:: npm +# +# Copyright 2010, Promet Solutions +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "nodejs" + +package "curl" + +bash "install npm - package manager for node" do + cwd "/usr/local/src" + user "root" + code <<-EOH + mkdir -p npm-v#{node[:nodejs][:npm]} && \ + cd npm-v#{node[:nodejs][:npm]} + curl -L http://registry.npmjs.org/npm/-/npm-#{node[:nodejs][:npm]}.tgz | tar xzf - --strip-components=1 && \ + make uninstall dev + EOH + not_if "#{node[:nodejs][:dir]}/bin/npm -v 2>&1 | grep '#{node[:nodejs][:npm]}'" +end + From 9caa979a81de0e3796aecec3fd666ae66dce4815 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 25 Oct 2011 14:21:10 -0500 Subject: [PATCH 3/7] update npm version --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index e74a86e..76e51cc 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,4 +19,4 @@ default.nodejs[:version] = "0.4.8" default.nodejs[:dir] = "/usr/local" -default.nodejs[:npm] = "1.0.10" +default.nodejs[:npm] = "1.0.101" From 175d4e13627331f3785c6e15cae2664d67420db1 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Fri, 24 Feb 2012 08:53:21 -0600 Subject: [PATCH 4/7] Import nodejs version 0.6.8 --- attributes/default.rb | 5 +++-- metadata.json | 38 ++++++++++++++++++-------------------- metadata.rb | 2 +- recipes/default.rb | 40 ++++++++++++++++++++++++++++++---------- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index e74a86e..f58405e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -17,6 +17,7 @@ # limitations under the License. # -default.nodejs[:version] = "0.4.8" +default.nodejs[:version] = "0.6.8" +default.nodejs[:checksum] = "e6cbfc5ccdbe10128dbbd4dc7a88c154d80f8a39c3a8477092cf7d25eef78c9c" default.nodejs[:dir] = "/usr/local" -default.nodejs[:npm] = "1.0.10" +default.nodejs[:npm] = "1.0.105" diff --git a/metadata.json b/metadata.json index aa249ba..2e4e342 100644 --- a/metadata.json +++ b/metadata.json @@ -1,34 +1,32 @@ { + "name": "nodejs", + "description": "Installs/Configures nodejs", + "long_description": "= DESCRIPTION:\n\nInstalls Node.JS from source.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Debian Lenny. Should work fine on Ubuntu, Centos, etc.\n\n== Cookbooks:\n\nOpscode cookbooks (http://github.com/opscode/cookbooks/tree/master)\n\n* build-essential\n\n= ATTRIBUTES:\n\n* nodejs[:version] - release version of node to install\n* nodejs[:dir] - location where node will be installed, default /usr/local\n* nodejs[:npm] - version of npm to install\n\n= USAGE:\n\nInclude the nodejs recipe to install node from source on your system:\n\n include_recipe \"nodejs\"\n\nInclude the npm recipe to install npm:\n \n include_recipe \"nodejs::npm\"\n\n= LICENSE and AUTHOR:\n\nAuthor:: Marius Ducea (marius@promethost.com)\n\nCopyright:: 2010, Promet Solutions\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", + "maintainer": "Promet Solutions", "maintainer_email": "marius@promethost.com", - "groupings": { - }, - "attributes": { - }, - "recommendations": { + "license": "Apache 2.0", + "platforms": { }, "dependencies": { - "build-essential": [ - - ] + "build-essential": ">= 0.0.0" }, - "recipes": { - "nodejs::npm": "Installs npm - a package manager for node", - "nodejs": "Installs Node.JS from source" + "recommendations": { }, "suggestions": { }, - "platforms": { - }, - "license": "Apache 2.0", - "version": "0.5.1", "conflicting": { }, "providing": { }, - "long_description": "= DESCRIPTION:\n\nInstalls Node.JS from source.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Debian Lenny. Should work fine on Ubuntu, Centos, etc.\n\n== Cookbooks:\n\nOpscode cookbooks (http://github.com/opscode/cookbooks/tree/master)\n\n* build-essential\n\n= ATTRIBUTES:\n\n* nodejs[:version] - release version of node to install\n* nodejs[:dir] - location where node will be installed, default /usr/local\n* nodejs[:npm] - version of npm to install\n\n= USAGE:\n\nInclude the nodejs recipe to install node from source on your system:\n\n include_recipe \"nodejs\"\n\nInclude the npm recipe to install npm:\n \n include_recipe \"nodejs::npm\"\n\n= LICENSE and AUTHOR:\n\nAuthor:: Marius Ducea (marius@promethost.com)\n\nCopyright:: 2010, Promet Solutions\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", - "name": "nodejs", - "maintainer": "Promet Solutions", - "description": "Installs/Configures nodejs", "replacing": { - } + }, + "attributes": { + }, + "groupings": { + }, + "recipes": { + "nodejs": "Installs Node.JS from source", + "nodejs::npm": "Installs npm - a package manager for node" + }, + "version": "0.6.8" } \ No newline at end of file diff --git a/metadata.rb b/metadata.rb index 508e2c0..4789f6f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ license "Apache 2.0" description "Installs/Configures nodejs" long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) -version "0.5.1" +version "0.6.8" recipe "nodejs", "Installs Node.JS from source" recipe "nodejs::npm", "Installs npm - a package manager for node" diff --git a/recipes/default.rb b/recipes/default.rb index 3a41dac..2a5dc72 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -8,9 +8,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,16 +27,36 @@ package "libssl-dev" end -bash "install nodejs from source" do +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 + +remote_file "/usr/local/src/#{nodejs_tar}" do + source "http://nodejs.org/dist/#{nodejs_tar_path}" + checksum node[:nodejs][:checksum] + mode 0644 +end + +# --no-same-owner required overcome "Cannot change ownership" bug +# on NFS-mounted filesystem +execute "tar --no-same-owner -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/node-v#{node[:nodejs][:version]}.tar.gz && \ - 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 From 947cf463b19b7437c4d5977f3116a945ec0855d5 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 28 Feb 2012 21:29:49 -0600 Subject: [PATCH 5/7] Import nodejs version 0.6.11 --- attributes/default.rb | 6 +++--- metadata.json | 2 +- metadata.rb | 2 +- recipes/default.rb | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index f58405e..764cd58 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -17,7 +17,7 @@ # limitations under the License. # -default.nodejs[:version] = "0.6.8" -default.nodejs[:checksum] = "e6cbfc5ccdbe10128dbbd4dc7a88c154d80f8a39c3a8477092cf7d25eef78c9c" +default.nodejs[:version] = "0.6.11" +default.nodejs[:checksum] = "94bbdb2d62645fd2ad5b96e41cfec68abf004fd03fabaaf7d71c48b39013cbd1" default.nodejs[:dir] = "/usr/local" -default.nodejs[:npm] = "1.0.105" +default.nodejs[:npm] = "1.1.2" diff --git a/metadata.json b/metadata.json index 2e4e342..77dfb4e 100644 --- a/metadata.json +++ b/metadata.json @@ -28,5 +28,5 @@ "nodejs": "Installs Node.JS from source", "nodejs::npm": "Installs npm - a package manager for node" }, - "version": "0.6.8" + "version": "0.6.11" } \ No newline at end of file diff --git a/metadata.rb b/metadata.rb index 4789f6f..8aa9b5d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ license "Apache 2.0" description "Installs/Configures nodejs" long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) -version "0.6.8" +version "0.6.11" recipe "nodejs", "Installs Node.JS from source" recipe "nodejs::npm", "Installs npm - a package manager for node" diff --git a/recipes/default.rb b/recipes/default.rb index 2a5dc72..678be4c 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -56,7 +56,8 @@ creates "/usr/local/src/node-v#{node[:nodejs][:version]}/node" end -execute "make install" do +execute "nodejs make install" do + command "make install" cwd "/usr/local/src/node-v#{node[:nodejs][:version]}" - not_if "test `#{node[:nodejs][:dir]}/bin/node` == 'v#{node[:nodejs][:version]}'" + not_if {File.exists?("#{node[:nodejs][:dir]}/bin/node") && `#{node[:nodejs][:dir]}/bin/node --version`.chomp == "v#{node[:nodejs][:version]}" } end From 945c20eea1132d43df84d6917011f633b93d3420 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 28 Feb 2012 21:40:56 -0600 Subject: [PATCH 6/7] install node from package on ubuntu --- metadata.json | 32 ----------------------- metadata.rb | 1 + recipes/default.rb | 60 +++++++++++++------------------------------ recipes/source.rb | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 75 deletions(-) delete mode 100644 metadata.json create mode 100644 recipes/source.rb diff --git a/metadata.json b/metadata.json deleted file mode 100644 index 77dfb4e..0000000 --- a/metadata.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "nodejs", - "description": "Installs/Configures nodejs", - "long_description": "= DESCRIPTION:\n\nInstalls Node.JS from source.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Debian Lenny. Should work fine on Ubuntu, Centos, etc.\n\n== Cookbooks:\n\nOpscode cookbooks (http://github.com/opscode/cookbooks/tree/master)\n\n* build-essential\n\n= ATTRIBUTES:\n\n* nodejs[:version] - release version of node to install\n* nodejs[:dir] - location where node will be installed, default /usr/local\n* nodejs[:npm] - version of npm to install\n\n= USAGE:\n\nInclude the nodejs recipe to install node from source on your system:\n\n include_recipe \"nodejs\"\n\nInclude the npm recipe to install npm:\n \n include_recipe \"nodejs::npm\"\n\n= LICENSE and AUTHOR:\n\nAuthor:: Marius Ducea (marius@promethost.com)\n\nCopyright:: 2010, Promet Solutions\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", - "maintainer": "Promet Solutions", - "maintainer_email": "marius@promethost.com", - "license": "Apache 2.0", - "platforms": { - }, - "dependencies": { - "build-essential": ">= 0.0.0" - }, - "recommendations": { - }, - "suggestions": { - }, - "conflicting": { - }, - "providing": { - }, - "replacing": { - }, - "attributes": { - }, - "groupings": { - }, - "recipes": { - "nodejs": "Installs Node.JS from source", - "nodejs::npm": "Installs npm - a package manager for node" - }, - "version": "0.6.11" -} \ No newline at end of file diff --git a/metadata.rb b/metadata.rb index 8aa9b5d..6806c0c 100644 --- a/metadata.rb +++ b/metadata.rb @@ -8,3 +8,4 @@ recipe "nodejs::npm", "Installs npm - a package manager for node" depends "build-essential" +depends "apt" diff --git a/recipes/default.rb b/recipes/default.rb index 678be4c..a8017a7 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,9 +1,9 @@ # -# Author:: Marius Ducea (marius@promethost.com) +# Author:: Nathan L Smith (nlloyds@gmail.com) # Cookbook Name:: nodejs # Recipe:: default # -# Copyright 2010, Promet Solutions +# Copyright 2012, Cramer Development, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,46 +18,20 @@ # limitations under the License. # -include_recipe "build-essential" - case node[:platform] - when "centos","redhat","fedora" - package "openssl-devel" - when "debian","ubuntu" - package "libssl-dev" -end - -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 - -remote_file "/usr/local/src/#{nodejs_tar}" do - source "http://nodejs.org/dist/#{nodejs_tar_path}" - checksum node[:nodejs][:checksum] - mode 0644 -end - -# --no-same-owner required overcome "Cannot change ownership" bug -# on NFS-mounted filesystem -execute "tar --no-same-owner -zxf #{nodejs_tar}" do - cwd "/usr/local/src" - 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 - ./configure --prefix=#{node[:nodejs][:dir]} && \ - make - EOH - creates "/usr/local/src/node-v#{node[:nodejs][:version]}/node" -end - -execute "nodejs make install" do - command "make install" - cwd "/usr/local/src/node-v#{node[:nodejs][:version]}" - not_if {File.exists?("#{node[:nodejs][:dir]}/bin/node") && `#{node[:nodejs][:dir]}/bin/node --version`.chomp == "v#{node[:nodejs][:version]}" } + when "centos","redhat","fedora","debian" + include_recipe 'nodejs::source' + when "ubuntu" + apt_repository 'node.js' do + uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu' + distribution node['lsb']['codename'] + components ['main'] + keyserver "keyserver.ubuntu.com" + key "C7917B12" + action :add + end + + %w{ nodejs npm }.each do |pkg| + package pkg + end end diff --git a/recipes/source.rb b/recipes/source.rb new file mode 100644 index 0000000..678be4c --- /dev/null +++ b/recipes/source.rb @@ -0,0 +1,63 @@ +# +# Author:: Marius Ducea (marius@promethost.com) +# Cookbook Name:: nodejs +# Recipe:: default +# +# Copyright 2010, Promet Solutions +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "build-essential" + +case node[:platform] + when "centos","redhat","fedora" + package "openssl-devel" + when "debian","ubuntu" + package "libssl-dev" +end + +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 + +remote_file "/usr/local/src/#{nodejs_tar}" do + source "http://nodejs.org/dist/#{nodejs_tar_path}" + checksum node[:nodejs][:checksum] + mode 0644 +end + +# --no-same-owner required overcome "Cannot change ownership" bug +# on NFS-mounted filesystem +execute "tar --no-same-owner -zxf #{nodejs_tar}" do + cwd "/usr/local/src" + 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 + ./configure --prefix=#{node[:nodejs][:dir]} && \ + make + EOH + creates "/usr/local/src/node-v#{node[:nodejs][:version]}/node" +end + +execute "nodejs make install" do + command "make install" + cwd "/usr/local/src/node-v#{node[:nodejs][:version]}" + not_if {File.exists?("#{node[:nodejs][:dir]}/bin/node") && `#{node[:nodejs][:dir]}/bin/node --version`.chomp == "v#{node[:nodejs][:version]}" } +end From 80f1716329c70dd9a5eb5d075de62f41bdfbcde4 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 28 Feb 2012 22:45:12 -0600 Subject: [PATCH 7/7] redhat packaging for node --- recipes/default.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index a8017a7..76c0cf8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -19,9 +19,23 @@ # case node[:platform] - when "centos","redhat","fedora","debian" - include_recipe 'nodejs::source' - when "ubuntu" + when 'centos', 'redhat', 'scientific' + file = '/usr/local/src/nodejs-stable-release.noarch.rpm' + + remote_file file do + source 'http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm' + action :create_if_missing + end + + yum_package 'nodejs-stable-release' do + source file + options '--nogpgcheck' + end + + %w{ nodejs nodejs-compat-symlinks npm }.each do |pkg| + package pkg + end + when 'ubuntu' apt_repository 'node.js' do uri 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu' distribution node['lsb']['codename'] @@ -34,4 +48,6 @@ %w{ nodejs npm }.each do |pkg| package pkg end + else + include_recipe 'nodejs::source' end