fpm-cookery 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bc3a1f69bcffcb2a64150d54766a2816273cbd6
4
- data.tar.gz: 5b77e8699f5124bef85174643f368cb17b726b33
3
+ metadata.gz: 0077d390146dfa67ba944b30cc6d2e0bc75d9290
4
+ data.tar.gz: 69c813e70e20ecfa9587b11d8c5ca4c69c26948f
5
5
  SHA512:
6
- metadata.gz: 1bf422e20d2e4249c285acd5483b1522c73dcb36eb393055fe0c72d37e8f400f04fa5bc007c602735ecc60d2da6c9238b443cf53d3f5004e5efeff6d0a144ddc
7
- data.tar.gz: bbeae7a0b3519aff36fb0510f27f98abf45d078a6b0e7e773a1da9e98a0a1ede060f1d6091db06dc9f0d1a8edcf79c44f97cb57c14de3a87bbef5d830e6f1338
6
+ metadata.gz: 66179d17020b8f94464cf92a01d9c19780506c0953fa761db56188722f05460465f419478e9f337870c79b49d8073b6313c38a42b39f6bd28e56041a3d42a06e
7
+ data.tar.gz: 3d677fcab730b224094c13bbdac83fd4d27ccec1dc13e529aa42b0054bb0aba54bb4031e824c7db0e4aa20b8016c934e96773d4a8e174590e9d35c4bbf166791
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v0.25.0 (2014-08-03)
2
+ * Add `environment` method to recipe to handle environment settings.
3
+ * Allow newer FPM versions than 1.1.
4
+ * Unbreak `configure` call without arguments on Ruby 1.8. (#92)
5
+ * Basic Scientific Linux support. (jjuarez / #93)
6
+ * Update internal recipes. (smasset / #89)
7
+
1
8
  # v0.24.0 (2014-06-03)
2
9
  * Add amazon linux to the list of RPM-based distros. (skottler / #88)
3
10
  * Add support for PEAR packages. (mlafeldt / #85)
data/fpm-cookery.gemspec CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency "rspec", "~> 2.14"
21
+ s.add_development_dependency "rspec", "~> 3.0"
22
22
  s.add_development_dependency "rake"
23
- s.add_runtime_dependency "fpm", "~> 1.1.0"
23
+ s.add_runtime_dependency "fpm", "~> 1.1"
24
24
  s.add_runtime_dependency "facter"
25
25
  s.add_runtime_dependency "puppet", ">= 3.4.3"
26
26
  s.add_runtime_dependency "addressable"
@@ -0,0 +1,49 @@
1
+ require 'fpm/cookery/log'
2
+
3
+ module FPM
4
+ module Cookery
5
+ class Environment
6
+ REMOVALS = %w(
7
+ BUNDLE_GEMFILE RUBYOPT BUNDLE_BIN_PATH GEM_HOME GEM_PATH
8
+ ).freeze
9
+
10
+ def initialize
11
+ @env = {}
12
+ end
13
+
14
+ def [](key)
15
+ @env[key.to_s]
16
+ end
17
+
18
+ def []=(key, value)
19
+ if value.nil?
20
+ @env.delete(key.to_s)
21
+ else
22
+ @env[key.to_s] = value.to_s
23
+ end
24
+ end
25
+
26
+ def with_clean
27
+ saved_env = ENV.to_hash
28
+
29
+ REMOVALS.each do |var|
30
+ value = ENV.delete(var)
31
+ Log.debug("Removing '#{var}' => '#{value}' from environment")
32
+ end
33
+
34
+ @env.each do |k, v|
35
+ Log.debug("Adding '#{k}' => '#{v}' to environment")
36
+ ENV[k] = v
37
+ end
38
+
39
+ yield
40
+ ensure
41
+ ENV.replace(saved_env.to_hash)
42
+ end
43
+
44
+ def to_hash
45
+ @env.dup
46
+ end
47
+ end
48
+ end
49
+ end
@@ -17,9 +17,9 @@ module FPM
17
17
 
18
18
  def self.target
19
19
  @target ||= case platform
20
- when :centos, :redhat, :fedora, :amazon then :rpm
21
- when :debian, :ubuntu then :deb
22
- when :darwin then :osxpkg
20
+ when :centos, :redhat, :fedora, :amazon, :scientific then :rpm
21
+ when :debian, :ubuntu then :deb
22
+ when :darwin then :osxpkg
23
23
  end
24
24
  end
25
25
 
@@ -18,7 +18,7 @@ module FPM
18
18
  inputs = config.fetch(:input, nil) || '.'
19
19
 
20
20
  Array(inputs).each do |path|
21
- fpm.input(path)
21
+ fpm.input(path.to_s)
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,6 @@
1
1
  require 'fpm/package/gem'
2
2
  require 'fpm/cookery/package/package'
3
+ require 'fpm/cookery/utils'
3
4
 
4
5
  module FPM
5
6
  module Cookery
@@ -17,7 +18,9 @@ module FPM
17
18
  end
18
19
 
19
20
  def package_input
20
- fpm.input(recipe.name)
21
+ recipe.environment.with_clean do
22
+ fpm.input(recipe.name)
23
+ end
21
24
  end
22
25
  end
23
26
  end
@@ -5,6 +5,7 @@ require 'fpm/cookery/source'
5
5
  require 'fpm/cookery/source_handler'
6
6
  require 'fpm/cookery/utils'
7
7
  require 'fpm/cookery/path_helper'
8
+ require 'fpm/cookery/environment'
8
9
  require 'fpm/cookery/package/cpan'
9
10
  require 'fpm/cookery/package/dir'
10
11
  require 'fpm/cookery/package/gem'
@@ -38,6 +39,7 @@ module FPM
38
39
  # Apply class data inheritable pattern to @fpm_attributes
39
40
  # class variable.
40
41
  klass.instance_variable_set(:@fpm_attributes, self.fpm_attributes.dup)
42
+ klass.instance_variable_set(:@environment, self.environment.dup)
41
43
  end
42
44
 
43
45
  def self.platforms(valid_platforms)
@@ -95,8 +97,13 @@ module FPM
95
97
  end
96
98
  @fpm_attributes
97
99
  end
100
+
101
+ def environment
102
+ @environment
103
+ end
98
104
  end
99
105
  @fpm_attributes = {}
106
+ @environment = FPM::Cookery::Environment.new
100
107
 
101
108
  def initialize(filename, config)
102
109
  @filename = Path.new(filename).expand_path
@@ -122,6 +129,7 @@ module FPM
122
129
  def pkgdir(path = nil) (@pkgdir || workdir('pkg'))/path end
123
130
  def cachedir(path = nil) (@cachedir || workdir('cache'))/path end
124
131
  def fpm_attributes() self.class.fpm_attributes end
132
+ def environment() self.class.environment end
125
133
 
126
134
  # Resolve dependencies from omnibus package.
127
135
  def depends_all
@@ -1,10 +1,13 @@
1
+ require 'fpm/cookery/log'
2
+
1
3
  module FPM
2
4
  module Cookery
3
5
  module Utils
4
6
  protected
5
7
  # From fpm. (lib/fpm/util.rb)
6
8
  def safesystem(*args)
7
- success = system(*args.flatten)
9
+ # Make sure to avoid nil elements in args. This might happen on 1.8.
10
+ success = system(*args.compact.flatten)
8
11
  if !success
9
12
  raise "'system(#{args.inspect})' failed with error code: #{$?.exitstatus}"
10
13
  end
@@ -12,12 +15,8 @@ module FPM
12
15
  end
13
16
 
14
17
  def cleanenv_safesystem(*args)
15
- bundler_vars = %w(BUNDLE_GEMFILE RUBYOPT BUNDLE_BIN_PATH GEM_HOME GEM_PATH)
16
- bundled_env = ENV.to_hash
17
- bundler_vars.each {|var| ENV.delete(var)}
18
- result = safesystem(*args)
19
- ENV.replace(bundled_env.to_hash)
20
- result
18
+ Log.warn("[DEPRECATED] Use `environment.with_clean { safesystem(...) }` instead of `cleanenv_safesystem(...)` in the recipe")
19
+ environment.with_clean { safesystem(*args) }
21
20
  end
22
21
 
23
22
  # From brew2deb. (lib/debian_formula.rb)
@@ -1,5 +1,5 @@
1
1
  module FPM
2
2
  module Cookery
3
- VERSION = '0.24.0'
3
+ VERSION = '0.25.0'
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
1
  class ArrPmRubyGem < FPM::Cookery::RubyGemRecipe
2
2
  name "arr-pm"
3
- version "0.0.8"
3
+ version "0.0.9"
4
4
  end
@@ -1,7 +1,7 @@
1
1
  class FpmRubyGem < FPM::Cookery::RubyGemRecipe
2
2
  name "fpm"
3
- version "1.0.2"
3
+ version "1.1.0"
4
4
 
5
5
  chain_package true
6
- chain_recipes "json", "cabin", "backports", "arr-pm", "clamp", "childprocess", "ftw"
6
+ chain_recipes "json", "cabin", "backports", "arr-pm", "clamp", "childprocess"
7
7
  end
@@ -1,6 +1,6 @@
1
1
  class FpmCookeryRubyGem < FPM::Cookery::RubyGemRecipe
2
2
  name "fpm-cookery"
3
- version "0.20.1"
3
+ version "0.24.0"
4
4
 
5
5
  chain_package true
6
6
  chain_recipes "fpm", "facter", "puppet", "addressable", "systemu"
@@ -6,9 +6,15 @@ class OmnibusTest < FPM::Cookery::Recipe
6
6
  version '1.0.0'
7
7
  description 'Testing Omnibus package'
8
8
  revision 0
9
+ source '', :with => :noop
9
10
 
10
11
  omnibus_package true
11
12
  omnibus_recipes "ruby", "bundler-gem"
12
13
  omnibus_dir '/opt/omnibustest'
13
14
 
15
+ def build
16
+ end
17
+
18
+ def install
19
+ end
14
20
  end
@@ -1,12 +1,12 @@
1
- class Ruby200 < FPM::Cookery::Recipe
1
+ class Ruby210 < FPM::Cookery::Recipe
2
2
  description 'The Ruby virtual machine'
3
3
 
4
4
  name 'ruby'
5
- version '2.0.0.0'
5
+ version '2.1.2'
6
6
  revision 0
7
7
  homepage 'http://www.ruby-lang.org/'
8
- source 'http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2'
9
- sha256 'c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295f'
8
+ source 'http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2'
9
+ sha256 '6948b02570cdfb89a8313675d4aa665405900e27423db408401473f30fc6e901'
10
10
 
11
11
  vendor 'fpm'
12
12
  license 'The Ruby License'
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+ require 'fpm/cookery/environment'
3
+ require 'pathname'
4
+
5
+ describe FPM::Cookery::Environment do
6
+ let(:env) { described_class.new }
7
+
8
+ it 'behaves like a hash' do
9
+ env['foo'] = 'bar'
10
+
11
+ expect(env['foo']).to eq('bar')
12
+ end
13
+
14
+ it 'converts keys to strings on set' do
15
+ env[:foo] = 'bar'
16
+
17
+ expect(env['foo']).to eq('bar')
18
+ end
19
+
20
+ it 'converts keys to strings on get' do
21
+ env['foo'] = 'bar'
22
+
23
+ expect(env[:foo]).to eq('bar')
24
+ end
25
+
26
+ it 'converts values to string' do
27
+ env['foo'] = 1
28
+ env['bar'] = Pathname.new('/')
29
+
30
+ expect(env['foo']).to eq('1')
31
+ expect(env['bar']).to eq('/')
32
+ end
33
+
34
+ it 'deletes a key if the value is set to nil' do
35
+ env['foo'] = 'bar'
36
+ env['foo'] = nil
37
+
38
+ expect(env.to_hash).to_not have_key('foo')
39
+ end
40
+
41
+ describe '#to_hash' do
42
+ it 'returns the data as a hash' do
43
+ env['foo'] = 'bar'
44
+
45
+ expect(env.to_hash).to eq({'foo' => 'bar'})
46
+ end
47
+
48
+ it 'returns a copy of the data' do
49
+ env['foo'] = 'bar'
50
+
51
+ data = env.to_hash
52
+
53
+ env['foo'] = 'nope'
54
+
55
+ expect(data).to eq({'foo' => 'bar'})
56
+ end
57
+ end
58
+
59
+ describe '#with_clean' do
60
+ it 'returns the return value of the given block' do
61
+ expect(env.with_clean { 'nice' }).to eq('nice')
62
+ end
63
+
64
+ it 'removes BUNDLE_GEMFILE from env' do
65
+ env.with_clean do
66
+ expect(ENV).to_not have_key('BUNDLE_GEMFILE')
67
+ end
68
+ end
69
+
70
+ it 'removes RUBYOPT from env' do
71
+ env.with_clean do
72
+ expect(ENV).to_not have_key('RUBYOPT')
73
+ end
74
+ end
75
+
76
+ it 'removes BUNDLE_BIN_PATH from env' do
77
+ env.with_clean do
78
+ expect(ENV).to_not have_key('BUNDLE_BIN_PATH')
79
+ end
80
+ end
81
+
82
+ it 'removes GEM_HOME from env' do
83
+ env.with_clean do
84
+ expect(ENV).to_not have_key('GEM_HOME')
85
+ end
86
+ end
87
+
88
+ it 'removes GEM_PATH from env' do
89
+ env.with_clean do
90
+ expect(ENV).to_not have_key('GEM_PATH')
91
+ end
92
+ end
93
+
94
+ it 'restores the old environment' do
95
+ env.with_clean { }
96
+
97
+ expect(ENV).to have_key('GEM_HOME')
98
+ end
99
+
100
+ it 'adds set environment variables' do
101
+ env['GEM_PATH'] = '/custom/path'
102
+ env['FOO'] = 'bar'
103
+
104
+ env.with_clean do
105
+ expect(ENV['GEM_PATH']).to eq('/custom/path')
106
+ expect(ENV['FOO']).to eq('bar')
107
+ end
108
+ end
109
+
110
+ it 'removes custom variables as well' do
111
+ env['FOO'] = 'bar'
112
+
113
+ env.with_clean { }
114
+
115
+ expect(ENV).to_not have_key('FOO')
116
+ end
117
+ end
118
+ end
data/spec/facts_spec.rb CHANGED
@@ -41,6 +41,13 @@ describe "Facts" do
41
41
  end
42
42
 
43
43
  describe "target" do
44
+
45
+ describe "with platform Scientific" do
46
+ it "returns rpm" do
47
+ FPM::Cookery::Facts.platform = 'Scientific'
48
+ expect(FPM::Cookery::Facts.target).to eq(:rpm)
49
+ end
50
+ end
44
51
  describe "with platform CentOS" do
45
52
  it "returns rpm" do
46
53
  FPM::Cookery::Facts.platform = 'CentOS'
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'fpm/cookery/package/gem'
3
+ require 'fpm/cookery/recipe'
4
+
5
+ describe FPM::Cookery::Package::Gem do
6
+ let(:config) { {} }
7
+
8
+ let(:recipe) do
9
+ Class.new(FPM::Cookery::RubyGemRecipe) do
10
+ description 'a test package'
11
+ name 'foo'
12
+ version '1.1.1'
13
+ end
14
+ end
15
+
16
+ let(:package) do
17
+ described_class.new(recipe, config)
18
+ end
19
+
20
+ let(:fpm) do
21
+ double('FPM').as_null_object
22
+ end
23
+
24
+ before do
25
+ allow(FPM::Package::Gem).to receive(:new).and_return(fpm)
26
+ end
27
+
28
+ context '#package_input' do
29
+ it 'calls the fpm package creation with a clean environment' do
30
+ expect(fpm).to receive(:input) do |*args|
31
+ expect(ENV).to_not have_key('GEM_HOME')
32
+ end
33
+
34
+ package # Trigger object creation and package_input call.
35
+ end
36
+ end
37
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  RSpec.configure do |config|
2
- config.treat_symbols_as_metadata_keys_with_true_values = true
3
2
  config.run_all_when_everything_filtered = true
4
3
  config.filter_run :focus
5
4
 
@@ -8,6 +7,8 @@ RSpec.configure do |config|
8
7
  # the seed, which is printed after each run.
9
8
  # --seed 1234
10
9
  config.order = 'random'
10
+
11
+ config.raise_errors_for_deprecations!
11
12
  end
12
13
 
13
14
  def fixture_path(file)
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'fpm/cookery/utils'
3
+
4
+ describe FPM::Cookery::Utils do
5
+ class TestUtils
6
+ include FPM::Cookery::Utils
7
+
8
+ def run_configure_no_arg
9
+ configure
10
+ end
11
+ end
12
+
13
+ let(:test) { TestUtils.new }
14
+
15
+ before do
16
+ # Avoid shellout.
17
+ allow(test).to receive(:system).and_return('success')
18
+ end
19
+
20
+ describe '#configure' do
21
+ context 'without any arguments' do
22
+ it 'calls ./configure without any arguments' do
23
+ expect(test).to receive(:system).with('./configure')
24
+ test.run_configure_no_arg
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-cookery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernd Ahlers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.14'
19
+ version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.14'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.1.0
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.0
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: facter
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - lib/fpm/cookery/cli.rb
132
132
  - lib/fpm/cookery/config.rb
133
133
  - lib/fpm/cookery/dependency_inspector.rb
134
+ - lib/fpm/cookery/environment.rb
134
135
  - lib/fpm/cookery/exceptions.rb
135
136
  - lib/fpm/cookery/facts.rb
136
137
  - lib/fpm/cookery/log.rb
@@ -179,9 +180,7 @@ files:
179
180
  - recipes/fpm-cookery-gem/facter.rb
180
181
  - recipes/fpm-cookery-gem/ffi.rb
181
182
  - recipes/fpm-cookery-gem/fpm.rb
182
- - recipes/fpm-cookery-gem/ftw.rb
183
183
  - recipes/fpm-cookery-gem/hiera.rb
184
- - recipes/fpm-cookery-gem/http_parser.rb.rb
185
184
  - recipes/fpm-cookery-gem/json.rb
186
185
  - recipes/fpm-cookery-gem/json_pure.rb
187
186
  - recipes/fpm-cookery-gem/puppet.rb
@@ -203,9 +202,11 @@ files:
203
202
  - recipes/redis/recipe.rb
204
203
  - recipes/redis/redis-server.init.d
205
204
  - spec/config_spec.rb
205
+ - spec/environment_spec.rb
206
206
  - spec/facts_spec.rb
207
207
  - spec/fixtures/test-config-1.yml
208
208
  - spec/fixtures/test-source-1.0.tar.gz
209
+ - spec/package_gem_spec.rb
209
210
  - spec/package_maintainer_spec.rb
210
211
  - spec/package_spec.rb
211
212
  - spec/package_version_spec.rb
@@ -215,6 +216,7 @@ files:
215
216
  - spec/source_integrity_check_spec.rb
216
217
  - spec/source_spec.rb
217
218
  - spec/spec_helper.rb
219
+ - spec/utils_spec.rb
218
220
  homepage: ''
219
221
  licenses: []
220
222
  metadata: {}
@@ -1,7 +0,0 @@
1
- class FtwRubyGem < FPM::Cookery::RubyGemRecipe
2
- name "ftw"
3
- version "0.0.34"
4
-
5
- chain_package true
6
- chain_recipes "http_parser.rb"
7
- end
@@ -1,4 +0,0 @@
1
- class HttpParserRbRubyGem < FPM::Cookery::RubyGemRecipe
2
- name "http_parser.rb"
3
- version "0.5.3"
4
- end