fpm-cookery 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzkyZWRmNjI3Yjc0ZGUxMmEyMTBiMjZhOTE4Mzg4ZWMxOWYzODI5Zg==
5
- data.tar.gz: !binary |-
6
- OGM1ZGNlOTc1YTcxYTdmMDBlOWM2ZWRiNzBiNGIwMjcyMjZlNmU5ZA==
2
+ SHA1:
3
+ metadata.gz: eb9277f23528fc7aeb48ba0a8a10d9861c70917b
4
+ data.tar.gz: e1379467c6ffe436d779e6d32ed472352aa31e43
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZmY4NjMwNjc5NGI0MzFiYmU0MWU0NzA1ZjE2Nzk4Y2Q5MDA4YTRkZDFmMDhk
10
- MzQxYzc0NmY2YjRkMTIxZWEwZDliZTU3OGE3ZjQ0MjVhNjg3OGU5MDQzMWJh
11
- NzQ4ZDhmOGY2MGNiNTU5ODhiOWExZTFlODZkYTZlYmI5ODZjN2E=
12
- data.tar.gz: !binary |-
13
- MGQwMWJhMjYyZWQwODExMzM3MmU1NDc5YWQ4OThlNDkwNjY1MWRjNTkzZjI4
14
- ODMwNzM0NzcyZDc2YjQ1OTBhMWQ3ZjNjNmVhNjk5ODBjZTQ0ZjczNTIwZmQw
15
- MjI3MDVlMzRkNTg0Y2JlYmE4ZWM5YWZkMTEwMzkyMGUzNTVmZTA=
6
+ metadata.gz: c703e14db35cff6e1a95778a7d7e0abc0519ff1f1ede27c11daf6d27bd8128cb18e1a36960187c3bcee0c4450af41939817706fbfc0d0fbad9bb839a7aa4d810
7
+ data.tar.gz: 1a833e697752e67acb1b0eda8a44ec825cc1d8e084ebd72ea72462e0b5ef3890a554f4d2397371cc61a4faabf170e96e4992326165c7115d8ec29b1ea3b6eb27
data/.gitignore CHANGED
@@ -8,6 +8,7 @@ tmp-build/
8
8
  tmp-dest/
9
9
  .buildpath
10
10
  .project
11
+ .rspec
11
12
  .vagrant
12
13
  Vagrantfile
13
14
  /vendor
data/.travis.yml CHANGED
@@ -1,11 +1,11 @@
1
- script: bundle exec rake test
1
+ script: bundle exec rake spec
2
2
  rvm:
3
3
  - 1.8.7
4
4
  - 1.9.3
5
5
  - 2.0.0
6
+ - 2.1.1
6
7
  - ruby-head
7
8
 
8
9
  matrix:
9
10
  allow_failures:
10
11
  - rvm: ruby-head
11
- - rvm: 2.1.0 # Problem with puppet monkey patch... waiting for >3.4.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.20.0 (2014-03-07)
2
+ * Add `--tmp-root` command line option.
3
+ * Add `--pkg-dir` command line option.
4
+ * Add `--cache-dir` command line option.
5
+ * Fix `%files` section in rpms. (unakatsuo / #67)
6
+
1
7
  # v0.19.0 (2014-03-03)
2
8
  * Correctly set version, iteration and vendor on the FPM object.
3
9
  __WARNING__: This changes the default package names!
data/Rakefile CHANGED
@@ -1,10 +1,7 @@
1
- require 'rake/testtask'
1
+ require 'rspec/core/rake_task'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
- Rake::TestTask.new do |t|
5
- t.pattern = "spec/*_spec.rb"
6
- t.libs << 'spec'
7
- t.verbose = false
8
- end
4
+ desc 'Run all specs'
5
+ RSpec::Core::RakeTask.new(:spec)
9
6
 
10
- task :default => :test
7
+ task :default => :spec
data/fpm-cookery.gemspec CHANGED
@@ -18,7 +18,7 @@ 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 "minitest", "~> 5.0"
21
+ s.add_development_dependency "rspec", "~> 2.14"
22
22
  s.add_development_dependency "rake"
23
23
  s.add_runtime_dependency "fpm", "~> 1.0.0"
24
24
  s.add_runtime_dependency "facter"
@@ -13,7 +13,7 @@ module FPM
13
13
  # anonymous module to avoid namespace cluttering. (see Kernel.load)
14
14
  def load_recipe(filename, &callback)
15
15
  Kernel.load(filename, true)
16
- callback.call(@recipe.new(filename))
16
+ callback.call(@recipe)
17
17
  end
18
18
 
19
19
  def add_recipe_class(klass)
@@ -21,6 +21,12 @@ module FPM
21
21
  option ['-V', '--version'], :flag, 'show fpm-cookery and fpm version'
22
22
  option '--[no-]deps', :flag, 'enable/disable dependency checking',
23
23
  :attribute_name => 'dependency_check'
24
+ option '--tmp-root', 'DIR', 'directory root for temporary files',
25
+ :attribute_name => 'tmp_root'
26
+ option '--pkg-dir', 'DIR', 'directory for built packages',
27
+ :attribute_name => 'pkg_dir'
28
+ option '--cache-dir', 'DIR', 'directory for downloaded sources',
29
+ :attribute_name => 'cache_dir'
24
30
 
25
31
  class Command < self
26
32
  def recipe_file
@@ -62,7 +68,8 @@ module FPM
62
68
 
63
69
  FPM::Cookery::BaseRecipe.send(:include, FPM::Cookery::BookHook)
64
70
 
65
- FPM::Cookery::Book.instance.load_recipe(recipe_file) do |recipe|
71
+ FPM::Cookery::Book.instance.load_recipe(recipe_file) do |recipe_class|
72
+ recipe = recipe_class.new(recipe_file, config)
66
73
  packager = FPM::Cookery::Packager.new(recipe, config.to_hash)
67
74
  packager.target = FPM::Cookery::Facts.target.to_s
68
75
 
@@ -6,7 +6,8 @@ module FPM
6
6
  class Config
7
7
  ATTRIBUTES = [
8
8
  :color, :debug, :target, :platform, :maintainer, :vendor,
9
- :skip_package, :keep_destdir, :dependency_check, :quiet
9
+ :skip_package, :keep_destdir, :dependency_check, :quiet,
10
+ :tmp_root, :pkg_dir, :cache_dir
10
11
  ].freeze
11
12
 
12
13
  DEFAULTS = {
@@ -33,6 +33,7 @@ module FPM
33
33
  @fpm.attributes[:rpm_group] = 'root'
34
34
  @fpm.attributes[:rpm_defattrfile] = '-'
35
35
  @fpm.attributes[:rpm_defattrdir] = '-'
36
+ @fpm.attributes[:rpm_auto_add_directories?] = true
36
37
 
37
38
  # TODO replace remove_excluded_files() in packager with this.
38
39
  @fpm.attributes[:excludes] = []
@@ -77,24 +77,32 @@ module FPM
77
77
  end
78
78
  end
79
79
 
80
- def initialize(filename)
80
+ def initialize(filename, config)
81
81
  @filename = Path.new(filename).expand_path
82
+ @config = config
83
+
84
+ @workdir = @filename.dirname
85
+ @tmp_root = @config.tmp_root ? Path.new(@config.tmp_root) : @workdir
86
+ @pkgdir = @config.pkg_dir && Path.new(@config.pkg_dir)
87
+ @cachedir = @config.cache_dir && Path.new(@config.cache_dir)
82
88
 
83
89
  # Set some defaults.
84
90
  revision || self.class.revision(1)
85
91
  end
86
92
 
87
93
  def workdir=(value) @workdir = Path.new(value) end
94
+ def tmp_root=(value) @tmp_root = Path.new(value) end
88
95
  def destdir=(value) @destdir = Path.new(value) end
89
96
  def builddir=(value) @builddir = Path.new(value) end
90
97
  def pkgdir=(value) @pkgdir = Path.new(value) end
91
98
  def cachedir=(value) @cachedir = Path.new(value) end
92
99
 
93
- def workdir(path = nil) (@workdir ||= filename.dirname)/path end
94
- def destdir(path = nil) (@destdir ||= workdir('tmp-dest'))/path end
95
- def builddir(path = nil) (@builddir ||= workdir('tmp-build'))/path end
96
- def pkgdir(path = nil) (@pkgdir ||= workdir('pkg'))/path end
97
- def cachedir(path = nil) (@cachedir ||= workdir('cache'))/path end
100
+ def workdir(path = nil) @workdir/path end
101
+ def tmp_root(path = nil) @tmp_root/path end
102
+ def destdir(path = nil) (@destdir || tmp_root('tmp-dest'))/path end
103
+ def builddir(path = nil) (@builddir || tmp_root('tmp-build'))/path end
104
+ def pkgdir(path = nil) (@pkgdir || workdir('pkg'))/path end
105
+ def cachedir(path = nil) (@cachedir || workdir('cache'))/path end
98
106
 
99
107
  # Resolve dependencies from omnibus package.
100
108
  def depends_all
@@ -116,8 +124,8 @@ module FPM
116
124
  FPM::Cookery::Package::Dir.new(self, config)
117
125
  end
118
126
 
119
- def initialize(filename)
120
- super(filename)
127
+ def initialize(filename, config)
128
+ super(filename, config)
121
129
  @source_handler = SourceHandler.new(Source.new(source, spec), cachedir, builddir)
122
130
  end
123
131
 
@@ -1,5 +1,5 @@
1
1
  module FPM
2
2
  module Cookery
3
- VERSION = '0.19.0'
3
+ VERSION = '0.20.0'
4
4
  end
5
5
  end
data/spec/config_spec.rb CHANGED
@@ -11,24 +11,25 @@ describe 'Config' do
11
11
  it 'can be set on init' do
12
12
  data[name.to_sym] = '__set__'
13
13
 
14
- config.__send__(name).must_equal '__set__'
14
+ expect(config.__send__(name)).to eq('__set__')
15
15
  end
16
16
 
17
17
  it 'can be set' do
18
18
  config.__send__("#{name}=", '__SET__')
19
- config.__send__(name).must_equal '__SET__'
19
+
20
+ expect(config.__send__(name)).to eq('__SET__')
20
21
  end
21
22
 
22
23
  it 'provides a ? method' do
23
24
  data[name.to_sym] = false
24
25
 
25
- config.__send__("#{name}?").must_equal false
26
+ expect(config.__send__("#{name}?")).to eq(false)
26
27
  end
27
28
  end
28
29
 
29
30
  describe '#color' do
30
31
  it 'defaults to true' do
31
- default_config.color.must_equal true
32
+ expect(default_config.color).to eq(true)
32
33
  end
33
34
 
34
35
  common_tests(:color)
@@ -36,7 +37,7 @@ describe 'Config' do
36
37
 
37
38
  describe '#debug' do
38
39
  it 'defaults to true' do
39
- default_config.debug.must_equal false
40
+ expect(default_config.debug).to eq(false)
40
41
  end
41
42
 
42
43
  common_tests(:debug)
@@ -44,7 +45,7 @@ describe 'Config' do
44
45
 
45
46
  describe '#target' do
46
47
  it 'defaults to nil' do
47
- default_config.target.must_equal nil
48
+ expect(default_config.target).to eq(nil)
48
49
  end
49
50
 
50
51
  common_tests(:target)
@@ -52,7 +53,7 @@ describe 'Config' do
52
53
 
53
54
  describe '#platform' do
54
55
  it 'defaults to nil' do
55
- default_config.platform.must_equal nil
56
+ expect(default_config.platform).to eq(nil)
56
57
  end
57
58
 
58
59
  common_tests(:platform)
@@ -60,7 +61,7 @@ describe 'Config' do
60
61
 
61
62
  describe '#maintainer' do
62
63
  it 'defaults to nil' do
63
- default_config.maintainer.must_equal nil
64
+ expect(default_config.maintainer).to eq(nil)
64
65
  end
65
66
 
66
67
  common_tests(:maintainer)
@@ -68,7 +69,7 @@ describe 'Config' do
68
69
 
69
70
  describe '#vendor' do
70
71
  it 'defaults to nil' do
71
- default_config.vendor.must_equal nil
72
+ expect(default_config.vendor).to eq(nil)
72
73
  end
73
74
 
74
75
  common_tests(:vendor)
@@ -76,7 +77,7 @@ describe 'Config' do
76
77
 
77
78
  describe '#quiet' do
78
79
  it 'defaults to false' do
79
- default_config.quiet.must_equal false
80
+ expect(default_config.quiet).to eq(false)
80
81
  end
81
82
 
82
83
  common_tests(:quiet)
@@ -84,7 +85,7 @@ describe 'Config' do
84
85
 
85
86
  describe '#skip_package' do
86
87
  it 'defaults to false' do
87
- default_config.skip_package.must_equal false
88
+ expect(default_config.skip_package).to eq(false)
88
89
  end
89
90
 
90
91
  common_tests(:skip_package)
@@ -92,7 +93,7 @@ describe 'Config' do
92
93
 
93
94
  describe '#keep_destdir' do
94
95
  it 'defaults to false' do
95
- default_config.keep_destdir.must_equal false
96
+ expect(default_config.keep_destdir).to eq(false)
96
97
  end
97
98
 
98
99
  common_tests(:keep_destdir)
@@ -100,20 +101,47 @@ describe 'Config' do
100
101
 
101
102
  describe '#dependency_check' do
102
103
  it 'defaults to false' do
103
- default_config.dependency_check.must_equal true
104
+ expect(default_config.dependency_check).to eq(true)
104
105
  end
105
106
 
106
107
  common_tests(:dependency_check)
107
108
  end
108
109
 
110
+ describe '#tmp_root' do
111
+ it 'defaults to nil' do
112
+ expect(default_config.tmp_root).to be_nil
113
+ end
114
+
115
+ common_tests(:tmp_root)
116
+ end
117
+
118
+ describe '#pkg_dir' do
119
+ it 'defaults to nil' do
120
+ expect(default_config.pkg_dir).to be_nil
121
+ end
122
+
123
+ common_tests(:pkg_dir)
124
+ end
125
+
126
+ describe '#cache_dir' do
127
+ it 'defaults to nil' do
128
+ expect(default_config.cache_dir).to be_nil
129
+ end
130
+
131
+ common_tests(:cache_dir)
132
+ end
133
+
109
134
  describe '#to_hash' do
110
135
  it 'returns a hash representation of the object' do
111
- default_config.to_hash.must_equal({
136
+ expect(default_config.to_hash).to eq({
112
137
  :color => true,
113
138
  :debug => false,
114
139
  :target => nil,
115
140
  :platform => nil,
116
141
  :maintainer => nil,
142
+ :tmp_root => nil,
143
+ :pkg_dir => nil,
144
+ :cache_dir => nil,
117
145
  :vendor => nil,
118
146
  :skip_package => false,
119
147
  :keep_destdir => false,
@@ -127,7 +155,7 @@ describe 'Config' do
127
155
  it 'raises an error' do
128
156
  data[:__foo__] = true
129
157
 
130
- proc { config }.must_raise FPM::Cookery::Error::InvalidConfigKey
158
+ expect { config }.to raise_error(FPM::Cookery::Error::InvalidConfigKey)
131
159
  end
132
160
 
133
161
  it 'adds the invalid keys' do
@@ -138,13 +166,13 @@ describe 'Config' do
138
166
  begin; config; rescue => e; error = e; end
139
167
 
140
168
  # Sort array for Ruby 1.8.7 compat.
141
- error.invalid_keys.sort.must_equal [:__bar__, :__foo__]
169
+ expect(error.invalid_keys.sort).to eq([:__bar__, :__foo__])
142
170
  end
143
171
 
144
172
  it 'works with strings' do
145
173
  data['maintainer'] = 'John'
146
174
 
147
- config.maintainer.must_equal 'John'
175
+ expect(config.maintainer).to eq('John')
148
176
  end
149
177
  end
150
178
 
@@ -159,7 +187,7 @@ describe 'Config' do
159
187
  it 'loads first found file' do
160
188
  config = FPM::Cookery::Config.load_file(paths)
161
189
 
162
- config.maintainer.must_equal 'John Doe <john@example.com>'
190
+ expect(config.maintainer).to eq('John Doe <john@example.com>')
163
191
  end
164
192
  end
165
193
 
@@ -170,8 +198,8 @@ describe 'Config' do
170
198
 
171
199
  config = FPM::Cookery::Config.from_cli(cli)
172
200
 
173
- config.debug.must_equal true
174
- config.target.must_equal 'rpm'
201
+ expect(config.debug).to eq(true)
202
+ expect(config.target).to eq('rpm')
175
203
  end
176
204
  end
177
205
  end
data/spec/facts_spec.rb CHANGED
@@ -17,7 +17,7 @@ describe "Facts" do
17
17
  end
18
18
 
19
19
  it "is returns the current platform" do
20
- FPM::Cookery::Facts.arch.must_equal :x86_64
20
+ expect(FPM::Cookery::Facts.arch).to eq(:x86_64)
21
21
  end
22
22
  end
23
23
 
@@ -31,12 +31,12 @@ describe "Facts" do
31
31
  end
32
32
 
33
33
  it "is using Facter to autodetect the platform" do
34
- FPM::Cookery::Facts.platform.must_equal :centos
34
+ expect(FPM::Cookery::Facts.platform).to eq(:centos)
35
35
  end
36
36
 
37
37
  it "can be set" do
38
38
  FPM::Cookery::Facts.platform = 'CentOS'
39
- FPM::Cookery::Facts.platform.must_equal :centos
39
+ expect(FPM::Cookery::Facts.platform).to eq(:centos)
40
40
  end
41
41
  end
42
42
 
@@ -44,55 +44,55 @@ describe "Facts" do
44
44
  describe "with platform CentOS" do
45
45
  it "returns rpm" do
46
46
  FPM::Cookery::Facts.platform = 'CentOS'
47
- FPM::Cookery::Facts.target.must_equal :rpm
47
+ expect(FPM::Cookery::Facts.target).to eq(:rpm)
48
48
  end
49
49
  end
50
50
 
51
51
  describe "with platform RedHat" do
52
52
  it "returns rpm" do
53
53
  FPM::Cookery::Facts.platform = 'RedHat'
54
- FPM::Cookery::Facts.target.must_equal :rpm
54
+ expect(FPM::Cookery::Facts.target).to eq(:rpm)
55
55
  end
56
56
  end
57
57
 
58
58
  describe "with platform Fedora" do
59
59
  it "returns rpm" do
60
60
  FPM::Cookery::Facts.platform = 'Fedora'
61
- FPM::Cookery::Facts.target.must_equal :rpm
61
+ expect(FPM::Cookery::Facts.target).to eq(:rpm)
62
62
  end
63
63
  end
64
64
 
65
65
  describe "with platform Debian" do
66
66
  it "returns rpm" do
67
67
  FPM::Cookery::Facts.platform = 'Debian'
68
- FPM::Cookery::Facts.target.must_equal :deb
68
+ expect(FPM::Cookery::Facts.target).to eq(:deb)
69
69
  end
70
70
  end
71
71
 
72
72
  describe "with platform Ubuntu" do
73
73
  it "returns rpm" do
74
74
  FPM::Cookery::Facts.platform = 'Ubuntu'
75
- FPM::Cookery::Facts.target.must_equal :deb
75
+ expect(FPM::Cookery::Facts.target).to eq(:deb)
76
76
  end
77
77
  end
78
78
 
79
79
  describe "with platform Darwin" do
80
80
  it "returns osxpkg" do
81
81
  FPM::Cookery::Facts.platform = 'Darwin'
82
- FPM::Cookery::Facts.target.must_equal :osxpkg
82
+ expect(FPM::Cookery::Facts.target).to eq(:osxpkg)
83
83
  end
84
84
  end
85
85
 
86
86
  describe "with an unknown platform" do
87
87
  it "returns nil" do
88
88
  FPM::Cookery::Facts.platform = '___X___'
89
- FPM::Cookery::Facts.target.must_equal nil
89
+ expect(FPM::Cookery::Facts.target).to eq(nil)
90
90
  end
91
91
  end
92
92
 
93
93
  it "can be set" do
94
94
  FPM::Cookery::Facts.target = 'rpm'
95
- FPM::Cookery::Facts.target.must_equal :rpm
95
+ expect(FPM::Cookery::Facts.target).to eq(:rpm)
96
96
  end
97
97
  end
98
98
  end