Fix rubocop
Esse commit está contido em:
@@ -18,10 +18,10 @@
|
||||
#
|
||||
|
||||
case node['platform_family']
|
||||
when "smartos", "rhel", "debian", "fedora"
|
||||
default['nodejs']['install_method'] = 'package'
|
||||
else
|
||||
default['nodejs']['install_method'] = 'source'
|
||||
when 'smartos', 'rhel', 'debian', 'fedora'
|
||||
default['nodejs']['install_method'] = 'package'
|
||||
else
|
||||
default['nodejs']['install_method'] = 'source'
|
||||
end
|
||||
|
||||
default['nodejs']['version'] = '0.10.26'
|
||||
@@ -31,7 +31,7 @@ default['nodejs']['checksum_linux_x86'] = '8fa2d952556c8b5aa37c077e2735c972c5225
|
||||
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']['src_url'] = 'http://nodejs.org/dist'
|
||||
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
|
||||
default['nodejs']['check_sha'] = true
|
||||
|
||||
|
||||
+13
-13
@@ -1,22 +1,22 @@
|
||||
maintainer "Promet Solutions"
|
||||
maintainer_email "marius@promethost.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs/Configures nodejs"
|
||||
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.md'))
|
||||
version "1.3.0"
|
||||
name "nodejs"
|
||||
provides "nodejs"
|
||||
version '1.3.0'
|
||||
name 'nodejs'
|
||||
provides 'nodejs'
|
||||
|
||||
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"
|
||||
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
|
||||
supports os
|
||||
end
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
# 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
|
||||
arch = 'arm-pi' # assume a raspberry pi
|
||||
else
|
||||
arch = node['kernel']['machine'] =~ /x86_64/ ? "x64" : "x86"
|
||||
arch = node['kernel']['machine'] =~ /x86_64/ ? 'x64' : 'x86'
|
||||
end
|
||||
|
||||
distro_suffix = "-linux-#{arch}"
|
||||
@@ -51,30 +50,29 @@ 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']}"
|
||||
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
|
||||
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
|
||||
not_if { !node['nodejs']['check_sha'] or install_not_needed }
|
||||
end
|
||||
not_if { !node['nodejs']['check_sha'] || 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 }
|
||||
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
|
||||
|
||||
@@ -21,33 +21,33 @@
|
||||
#
|
||||
|
||||
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 }
|
||||
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
|
||||
Chef::Log.error "There are no nodejs packages for this platform; please use the source or binary method to install node"
|
||||
return
|
||||
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|
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "build-essential"
|
||||
include_recipe 'build-essential'
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel','fedora'
|
||||
package "openssl-devel"
|
||||
when 'debian'
|
||||
package "libssl-dev"
|
||||
when 'rhel', 'fedora'
|
||||
package 'openssl-devel'
|
||||
when 'debian'
|
||||
package 'libssl-dev'
|
||||
end
|
||||
|
||||
nodejs_tar = "node-v#{node['nodejs']['version']}.tar.gz"
|
||||
@@ -45,7 +45,7 @@ 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"
|
||||
cwd '/usr/local/src'
|
||||
creates "/usr/local/src/node-v#{node['nodejs']['version']}"
|
||||
end
|
||||
|
||||
@@ -60,9 +60,9 @@ bash "compile node.js (on #{node['nodejs']['make_threads']} cpu)" do
|
||||
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"
|
||||
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']}" }
|
||||
not_if { ::File.exists?("#{node['nodejs']['dir']}/bin/node") && `#{node['nodejs']['dir']}/bin/node --version`.chomp == "v#{node['nodejs']['version']}" }
|
||||
end
|
||||
|
||||
+7
-8
@@ -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.
|
||||
@@ -18,15 +18,15 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "nodejs"
|
||||
include_recipe 'nodejs'
|
||||
|
||||
package "curl"
|
||||
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"
|
||||
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']}
|
||||
@@ -35,4 +35,3 @@ bash "install npm - package manager for node" do
|
||||
EOH
|
||||
not_if "#{node['nodejs']['dir']}/bin/npm -v 2>&1 | grep '#{node['nodejs']['npm']}'"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
source "https://rubygems.org"
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
gem 'foodcritic'
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário