diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c941f48..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -Gemfile.lock -Berksfile.lock -tmp/ -.kitchen -.kitchen.local.yml diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index 7402651..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -driver_plugin: vagrant -driver_config: - require_chef_omnibus: true - customize: - memory: 512 - cpus: 4 -platforms: -- name: ubuntu-12.04 - driver_config: - box: opscode-ubuntu-12.04 - box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-12.04.box - run_list: - - recipe[apt] -- name: ubuntu-10.04 - driver_config: - box: opscode-ubuntu-10.04 - box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-10.04.box - run_list: - - recipe[apt] -- name: centos-6.3 - driver_config: - box: opscode-centos-6.3 - box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box -- name: centos-5.8 - driver_config: - box: opscode-centos-5.8 - box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-5.8.box -suites: -- name: package - run_list: - - recipe[nodejs] - attributes: - nodejs: - install_method: package -- name: binary - run_list: - - recipe[nodejs] - attributes: - nodejs: - install_method: binary -- name: source - run_list: - - recipe[nodejs] - - recipe[nodejs::npm] - attributes: - nodejs: - install_method: source diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dc5e438..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: ruby -gemfile: -- test/support/Gemfile -rvm: -- 1.9.3 -script: bundle exec rake foodcritic diff --git a/Berksfile b/Berksfile deleted file mode 100644 index 8496a59..0000000 --- a/Berksfile +++ /dev/null @@ -1,5 +0,0 @@ -site :opscode -metadata - -cookbook 'apt', '~> 1.7.0' -cookbook 'build-essential' diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 54701f4..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,56 +0,0 @@ -## v1.3.0 - * update default versions to the latest: node - v0.10.15 and npm - v1.3.5 - * default to package installation of nodejs on smartos ([@wanelo-pair][]) - * Add Raspberry pi support ([@robertkowalski][]) - -## v1.2.0 - * implement installation from package on RedHat - ([@vaskas][]) - -## v1.1.3: - * update default version of node to 0.10.13 - and npm - v1.3.4 ([@jodosha][]) - -## v1.1.2: - * update default version of node to 0.10.2 - ([@bakins][]) - * fully migrated to test-kitchen 1.alpha and vagrant 1.1.x/berkshelf 1.3.1 - -## v1.1.1: - * update default versions to the latest: node - v0.10.0 and npm - v1.2.14 - * `make_thread` is now a real attribute - ([@ChrisLundquist][]) - - -## v1.1.0: - * rewrite the package install; remove rpm support since there are no longer any packages available anywhere - * add support to install `legacy_packages` from ubuntu repo as well as the latest 0.10.x branch (this is default). - -## v1.0.4: - * add support for binary installation method ([@JulesAU][]) - -## v1.0.3: - - unreleased - -## v1.0.2: - * add smartos support for package install ([@sax][]) - * support to compile with all processors available (default 2 if unknown) - ([@ChrisLundquist][]) - * moved to `platform_family` syntax - * ensure npm recipe honours the 'source' or 'package' setting - ([@markbirbeck][]) - * updated the default versions to the latest stable node/npm - -## v1.0.1: - - * fixed bug that prevented overwritting the node/npm versions (moved the `src_url`s as local variables instead of attributes) - ([@johannesbecker][]) - * updated the default versions to the latest node/npm - -## v1.0.0: - -* added packages installation support ([@smith][]) - -[@JulesAU]: https://github.com/JulesAU -[@sax]: https://github.com/sax -[@ChrisLundquist]: https://github.com/ChrisLundquist -[@markbirbeck]: https://github.com/markbirbeck -[@johannesbecker]: https://github.com/johannesbecker -[@smith]: https://github.com/smith -[@bakins]: https://github.com/bakins -[@vaskas]: https://github.com/vaskas -[@robertkowalski]: https://github.com/robertkowalski -[@wanelo-pair]: https://github.com/wanelo-pair diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 5840424..0000000 --- a/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' - -gem 'foodcritic' -gem 'thor-foodcritic' - -group :integration do - gem 'berkshelf' - gem 'test-kitchen', '~> 1.0.0.beta' - gem 'kitchen-vagrant', '~> 0.11.0' -end diff --git a/README.md b/README.md deleted file mode 100644 index f2d7108..0000000 --- a/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# nodejs-cookbook [![Build Status](https://secure.travis-ci.org/mdxp/nodejs-cookbook.png)](http://travis-ci.org/mdxp/nodejs-cookbook) - -DESCRIPTION -=========== - -Installs Node.JS - -REQUIREMENTS -============ - - -## Platform - -* Tested on Debian 6 and Ubuntu 10.04 -* Should work fine on Centos, RHEL, etc. - -## Cookbooks: - -* [build-essential](https://github.com/opscode-cookbooks/build-essential) -* [apt](https://github.com/cookbooks/apt) -* [yum](https://github.com/cookbooks/yum) - -Opscode cookbooks (http://github.com/opscode/cookbooks/tree/master) - -ATTRIBUTES -========== - -* nodejs['install_method'] = source or package -* nodejs['version'] - release version of node to install -* nodejs['src_url'] - download location for node source tarball -* nodejs['dir'] - location where node will be installed, default /usr/local -* nodejs['npm'] - version of npm to install -* nodejs['npm_src_url'] - download location for npm source tarball -* nodejs['check_sha'] - test for valid sha_sum, default: true - -USAGE -===== - -Include the nodejs recipe to install node on your system based on the default installation method: - -* include_recipe "nodejs" - -Include the install_from_source recipe to install node from sources: - -* include_recipe "nodejs::install_from_source" - -Include the install_from_package recipe to install node from packages: -Note that only apt (Ubuntu, Debian) appears to have up to date packages available. -Centos, RHEL, etc are non-functional. (Try install_from_binary for those) - -* include_recipe "nodejs::install_from_package" - -Include the install_from_binary recipe to install node from official prebuilt binaries: -(Currently Linux x86, x86_64, armv6l only) - -* include_recipe "nodejs::install_from_binary" - -Include the npm recipe to install npm: - -* include_recipe "nodejs::npm" - -LICENSE and AUTHOR -================== - -Author:: Marius Ducea (marius@promethost.com) -Author:: Nathan L Smith (nlloyds@gmail.com) - -Copyright:: 2010-2012, 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. -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/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/Rakefile b/Rakefile deleted file mode 100644 index d7aee31..0000000 --- a/Rakefile +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env rake - -@cookbook = "nodejs" - -desc "Runs foodcritic linter" -task :foodcritic do - if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup) - sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic}, @cookbook) - prepare_foodcritic_sandbox(sandbox) - - sh "foodcritic --tags ~FC048 --epic-fail any #{File.dirname(sandbox)}" - else - puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2." - end -end - -task :default => 'foodcritic' - -private - -def prepare_foodcritic_sandbox(sandbox) - files = %w{*.md *.rb attributes definitions files providers -recipes resources templates} - - rm_rf sandbox - mkdir_p sandbox - cp_r Dir.glob("{#{files.join(',')}}"), sandbox - puts "\n\n" -end - -begin - require 'kitchen/rake_tasks' - Kitchen::RakeTasks.new -rescue LoadError - puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] -end diff --git a/attributes/default.rb b/attributes/default.rb index 956955a..764cd58 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,7 +2,7 @@ # Cookbook Name:: nodejs # Attributes:: nodejs # -# Copyright 2010-2012, Promet Solutions +# 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. @@ -17,23 +17,7 @@ # limitations under the License. # -case node['platform_family'] - when "smartos", "rhel", "debian", "fedora" - default['nodejs']['install_method'] = 'package' - else - default['nodejs']['install_method'] = 'source' -end - -default['nodejs']['version'] = '0.10.26' -default['nodejs']['checksum'] = 'ef5e4ea6f2689ed7f781355012b942a2347e0299da0804a58de8e6281c4b1daa' -default['nodejs']['checksum_linux_x64'] = '305bf2983c65edea6dd2c9f3669b956251af03523d31cf0a0471504fd5920aac' -default['nodejs']['checksum_linux_x86'] = '8fa2d952556c8b5aa37c077e2735c972c522510facaa4df76d4244be88f4dc0f' -default['nodejs']['checksum_linux_arm-pi'] = '561ec2ebfe963be8d6129f82a7d1bc112fb8fbfc0a1323ebe38ef55850f25517' -default['nodejs']['dir'] = '/usr/local' -default['nodejs']['npm'] = '1.4.4' -default['nodejs']['src_url'] = "http://nodejs.org/dist" -default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2 -default['nodejs']['check_sha'] = true - -# Set this to true to install the legacy packages (0.8.x) from ubuntu/debian repositories; default is false (using the latest stable 0.10.x) -default['nodejs']['legacy_packages'] = false +default.nodejs[:version] = "0.6.11" +default.nodejs[:checksum] = "94bbdb2d62645fd2ad5b96e41cfec68abf004fd03fabaaf7d71c48b39013cbd1" +default.nodejs[:dir] = "/usr/local" +default.nodejs[:npm] = "1.1.2" diff --git a/metadata.rb b/metadata.rb index a91d17d..6806c0c 100644 --- a/metadata.rb +++ b/metadata.rb @@ -2,21 +2,10 @@ maintainer_email "marius@promethost.com" license "Apache 2.0" description "Installs/Configures nodejs" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.3.0" -name "nodejs" -provides "nodejs" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) +version "0.6.11" +recipe "nodejs", "Installs Node.JS from source" +recipe "nodejs::npm", "Installs npm - a package manager for node" -recipe "nodejs", "Installs Node.JS based on the default installation method" -recipe "nodejs::install_from_source", "Installs Node.JS from source" -recipe "nodejs::install_from_binary", "Installs Node.JS from official binaries" -recipe "nodejs::install_from_package", "Installs Node.JS from packages" -recipe "nodejs::npm", "Installs npm from source - a package manager for node" - -%w{ apt yum-epel build-essential }.each do |c| - depends c -end - -%w{ debian ubuntu centos redhat smartos }.each do |os| - supports os -end +depends "build-essential" +depends "apt" diff --git a/recipes/default.rb b/recipes/default.rb index 5093340..76c0cf8 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-2012, 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,4 +18,36 @@ # limitations under the License. # -include_recipe "nodejs::install_from_#{node['nodejs']['install_method']}" +case node[:platform] + 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'] + components ['main'] + keyserver "keyserver.ubuntu.com" + key "C7917B12" + action :add + end + + %w{ nodejs npm }.each do |pkg| + package pkg + end + else + include_recipe 'nodejs::source' +end diff --git a/recipes/install_from_binary.rb b/recipes/install_from_binary.rb deleted file mode 100644 index 768af64..0000000 --- a/recipes/install_from_binary.rb +++ /dev/null @@ -1,80 +0,0 @@ -# -# Author:: Julian Wilde (jules@jules.com.au) -# Cookbook Name:: nodejs -# Recipe:: install_from_binary -# -# 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. -# - - -# Shamelessly borrowed from http://docs.opscode.com/dsl_recipe_method_platform.html -# Surely there's a more canonical way to get arch? -if node['kernel']['machine'] =~ /armv6l/ - arch = "arm-pi" # assume a raspberry pi -else - arch = node['kernel']['machine'] =~ /x86_64/ ? "x64" : "x86" -end - -distro_suffix = "-linux-#{arch}" - -# package_stub is for example: "node-v0.8.20-linux-x64" -package_stub = "node-v#{node['nodejs']['version']}#{distro_suffix}" -nodejs_tar = "#{package_stub}.tar.gz" -expected_checksum = node['nodejs']["checksum_linux_#{arch}"] - -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 - -# Let the user override the source url in the attributes -nodejs_bin_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}" - -# Download it: -remote_file "/usr/local/src/#{nodejs_tar}" do - source nodejs_bin_url - checksum expected_checksum - mode 0644 - action :create_if_missing -end - -# Where we will install the binaries and libs to (normally /usr/local): -destination_dir = node['nodejs']['dir'] - -install_not_needed = File.exists?("#{node['nodejs']['dir']}/bin/node") && `#{node['nodejs']['dir']}/bin/node --version`.chomp == "v#{node['nodejs']['version']}" - -# Verify the SHA sum of the downloaded file: -ruby_block "verify_sha_sum" do - block do - require 'digest/sha1' - calculated_sha256_hash = Digest::SHA256.file("/usr/local/src/#{nodejs_tar}") - if calculated_sha256_hash != expected_checksum - raise "SHA256 Hash of #{nodejs_tar} did not match! Expected #{expected_checksum} found #{calculated_sha256_hash}" - end - end - not_if { !node['nodejs']['check_sha'] or install_not_needed } -end - -# One hopes that we can trust the contents of the node tarball not to overwrite anything it shouldn't! -execute "install package to system" do - command <<-EOF - tar xf /usr/local/src/#{nodejs_tar} \ - --strip-components=1 --no-same-owner \ - -C #{destination_dir} \ - #{package_stub}/bin \ - #{package_stub}/lib \ - #{package_stub}/share - EOF - - not_if { install_not_needed } -end diff --git a/recipes/install_from_package.rb b/recipes/install_from_package.rb deleted file mode 100644 index 795bae3..0000000 --- a/recipes/install_from_package.rb +++ /dev/null @@ -1,55 +0,0 @@ -# -# Author:: Nathan L Smith (nlloyds@gmail.com) -# Author:: Marius Ducea (marius@promethost.com) -# Cookbook Name:: nodejs -# Recipe:: package -# -# Copyright 2012, Cramer Development, Inc. -# Copyright 2013, Opscale -# -# 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. -# - -case node['platform_family'] - when 'debian' - include_recipe "apt" - if node['nodejs']['legacy_packages'] == true - repo = 'http://ppa.launchpad.net/chris-lea/node.js-legacy/ubuntu' - packages = %w{ nodejs npm } - else - repo = 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu' - packages = %w{ nodejs } - end - apt_repository 'node.js' do - uri repo - distribution node['lsb']['codename'] - components ['main'] - keyserver "hkp://keyserver.ubuntu.com:80" - key "C7917B12" - action :add - end - when 'rhel' - include_recipe 'yum-epel' - packages = %w{ nodejs nodejs-devel npm } - when 'fedora' - packages = %w{ nodejs nodejs-devel npm } - when 'smartos' - packages = %w{ nodejs } - else - Chef::Log.error "There are no nodejs packages for this platform; please use the source or binary method to install node" - return -end - -packages.each do |node_pkg| - package node_pkg -end diff --git a/recipes/install_from_source.rb b/recipes/install_from_source.rb deleted file mode 100644 index 710604a..0000000 --- a/recipes/install_from_source.rb +++ /dev/null @@ -1,68 +0,0 @@ -# -# Author:: Marius Ducea (marius@promethost.com) -# Cookbook Name:: nodejs -# Recipe:: source -# -# Copyright 2010-2012, 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_family'] - when 'rhel','fedora' - package "openssl-devel" - when 'debian' - 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 -# Let the user override the source url in the attributes -nodejs_src_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}" - -remote_file "/usr/local/src/#{nodejs_tar}" do - source nodejs_src_url - checksum node['nodejs']['checksum'] - mode 0644 - action :create_if_missing -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 (on #{node['nodejs']['make_threads']} cpu)" do - # OSX doesn't have the attribute so arbitrarily default 2 - cwd "/usr/local/src/node-v#{node['nodejs']['version']}" - code <<-EOH - PATH="/usr/local/bin:$PATH" - ./configure --prefix=#{node['nodejs']['dir']} && \ - make -j #{node['nodejs']['make_threads']} - EOH - creates "/usr/local/src/node-v#{node['nodejs']['version']}/node" -end - -execute "nodejs make install" do - environment({"PATH" => "/usr/local/bin:/usr/bin:/bin:$PATH"}) - 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 diff --git a/recipes/npm.rb b/recipes/npm.rb index a16f27a..8ca9394 100644 --- a/recipes/npm.rb +++ b/recipes/npm.rb @@ -3,7 +3,7 @@ # Cookbook Name:: nodejs # Recipe:: npm # -# Copyright 2010-2012, Promet Solutions +# 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. @@ -22,17 +22,15 @@ package "curl" -npm_src_url = "http://registry.npmjs.org/npm/-/npm-#{node['nodejs']['npm']}.tgz" - 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 #{npm_src_url} | tar xzf - --strip-components=1 && \ + 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']}'" + not_if "#{node[:nodejs][:dir]}/bin/npm -v 2>&1 | grep '#{node[:nodejs][:npm]}'" 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 diff --git a/test/integration/package/bats/package.bats b/test/integration/package/bats/package.bats deleted file mode 100644 index 508b9ca..0000000 --- a/test/integration/package/bats/package.bats +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bats - -@test "node should be in the path" { - [ "$(command -v node)" ] -} - -@test "npm should be in the path" { - [ "$(command -v npm)" ] -} diff --git a/test/integration/source/bats/source.bats b/test/integration/source/bats/source.bats deleted file mode 100644 index 508b9ca..0000000 --- a/test/integration/source/bats/source.bats +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bats - -@test "node should be in the path" { - [ "$(command -v node)" ] -} - -@test "npm should be in the path" { - [ "$(command -v npm)" ] -} diff --git a/test/support/Gemfile b/test/support/Gemfile deleted file mode 100644 index d45a670..0000000 --- a/test/support/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem 'rake' -gem 'foodcritic' -