omnibus 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module Omnibus
22
22
 
23
23
 
24
24
  PADDING = 3
25
-
25
+
26
26
  # Determine how wide a column should be, taking into account both
27
27
  # the column name as well as all data in that column. If no data
28
28
  # will be stored in the column, the width is 0 (i.e., nothing
@@ -43,9 +43,9 @@ module Omnibus
43
43
 
44
44
  def pretty_version_map(project)
45
45
  out = ""
46
- version_map = Omnibus.library.version_map(project)
46
+ version_map = project.library.version_map
47
+
47
48
 
48
-
49
49
  # Pull out data to print out
50
50
  versions = non_nil_values(version_map.values, :version)
51
51
  guids = non_nil_values(version_map.values, :version_guid)
@@ -55,7 +55,7 @@ module Omnibus
55
55
  # overridden, but nothing if no packages were changed
56
56
  overridden_versions = non_nil_values(version_map.values.select{|v| v[:overridden]},
57
57
  :given_version)
58
-
58
+
59
59
 
60
60
  # Determine how wide the printed table columns need to be
61
61
  name_width = column_width(version_map.keys, "Component")
@@ -65,7 +65,7 @@ module Omnibus
65
65
 
66
66
  total_width = name_width + version_width + guid_width + override_width
67
67
  divider = "-" * total_width
68
-
68
+
69
69
  # Print out the column headers
70
70
  out << "Component".ljust(name_width)
71
71
  out << "Installed Version".ljust(version_width)
@@ -89,7 +89,7 @@ module Omnibus
89
89
 
90
90
  # Set override information after the DSL file has been consumed
91
91
  @override_version = overrides[name]
92
-
92
+
93
93
  render_tasks
94
94
  end
95
95
 
@@ -233,7 +233,7 @@ module Omnibus
233
233
  #
234
234
  # @return [String] an absolute filesystem path
235
235
  def build_dir
236
- "#{config.build_dir}/#{camel_case_path(install_dir)}"
236
+ "#{config.build_dir}/#{@project.name}"
237
237
  end
238
238
 
239
239
  # @todo Why the different name (i.e. *_dir instead of *_path, or
@@ -368,7 +368,7 @@ module Omnibus
368
368
  #
369
369
  (@dependencies - [@name]).uniq.each do |dep|
370
370
  task @name => dep
371
- file manifest_file => manifest_file_from_name(dep)
371
+ file manifest_file => manifest_file_from_name(dep)
372
372
  end
373
373
 
374
374
  directory source_dir
@@ -395,8 +395,8 @@ module Omnibus
395
395
  end
396
396
  end
397
397
 
398
- else
399
- # if fetch has occurred, or the component is configured to
398
+ else
399
+ # if fetch has occurred, or the component is configured to
400
400
  # always build, do a clean and build.
401
401
  execute_build(fetcher)
402
402
  end
@@ -414,7 +414,7 @@ module Omnibus
414
414
 
415
415
  file manifest_file => (file latest_file)
416
416
 
417
- file fetch_file => "#{name}:fetch"
417
+ file fetch_file => "#{name}:fetch"
418
418
  file manifest_file => "#{name}:build"
419
419
 
420
420
  file fetch_file => (file @source_config)
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
- VERSION = "1.0.3"
19
+ VERSION = "1.0.4"
20
20
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency "mixlib-config", "~> 1.1.2"
26
26
  gem.add_dependency "ohai", ">= 0.6.12"
27
27
  gem.add_dependency "rake", ">= 0.9"
28
- gem.add_dependency "fpm", "= 0.3.11"
28
+ gem.add_dependency "fpm", "~> 0.4.33"
29
29
  gem.add_dependency "uber-s3"
30
30
  gem.add_dependency "thor", ">= 0.16.0"
31
31
 
@@ -0,0 +1,106 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'omnibus/artifact'
19
+ require 'spec_helper'
20
+
21
+ describe Omnibus::Artifact do
22
+
23
+ let(:path) { "build_os=centos-5,machine_architecture=x86,role=oss-builder/pkg/demoproject-11.4.0-1.el5.x86_64.rpm" }
24
+
25
+ let(:content) { StringIO.new("this is the package content\n") }
26
+
27
+ let(:md5) { "d41d8cd98f00b204e9800998ecf8427e" }
28
+
29
+ let(:sha256) { "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
30
+
31
+ let(:platforms) { [ [ "el", "5", "x86_64" ], [ "sles","11.2","x86_64" ] ] }
32
+
33
+ let(:artifact) { Omnibus::Artifact.new(path, platforms, { :version => "11.4.0-1" }) }
34
+
35
+ it "has the path to the package" do
36
+ artifact.path.should == path
37
+ end
38
+
39
+ it "has a list of platforms the package supports" do
40
+ artifact.platforms.should == platforms
41
+ end
42
+
43
+ it "generates a MD5 of an artifact" do
44
+ File.should_receive(:open).with(path).and_return(content)
45
+ artifact.md5.should == md5
46
+ end
47
+
48
+ it "generates a SHA256 of an artifact" do
49
+ File.should_receive(:open).with(path).and_return(content)
50
+ artifact.sha256.should == sha256
51
+ end
52
+
53
+ it "generates 'flat' metadata" do
54
+ File.should_receive(:open).twice.with(path).and_return(content)
55
+ flat_metadata = artifact.flat_metadata
56
+ flat_metadata["platform"].should == "el"
57
+ flat_metadata["platform_version"].should == "5"
58
+ flat_metadata["arch"].should == "x86_64"
59
+ flat_metadata["version"].should == "11.4.0-1"
60
+ flat_metadata["basename"].should == "demoproject-11.4.0-1.el5.x86_64.rpm"
61
+ flat_metadata["md5"].should == md5
62
+ flat_metadata["sha256"].should == sha256
63
+ end
64
+
65
+ it "adds the package to a release manifest" do
66
+ expected = {
67
+ "el" => {
68
+ "5" => { "x86_64" => { "11.4.0-1" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm" } }
69
+ },
70
+ "sles" => {
71
+ "11.2" => { "x86_64" => { "11.4.0-1" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm" } }
72
+ }
73
+ }
74
+
75
+ manifest = artifact.add_to_release_manifest!({})
76
+ manifest.should == expected
77
+ end
78
+
79
+ it "adds the package to a v2 release manifest" do
80
+ File.should_receive(:open).with(path).twice.and_return(content)
81
+ expected = {
82
+ "el" => {
83
+ "5" => { "x86_64" => { "11.4.0-1" => {
84
+ "relpath" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm",
85
+ "md5" => md5,
86
+ "sha256" => sha256
87
+ }
88
+ }
89
+ }
90
+ },
91
+ "sles" => {
92
+ "11.2" => { "x86_64" => { "11.4.0-1" => {
93
+ "relpath" => "/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm",
94
+ "md5" => md5,
95
+ "sha256" => sha256
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ v2_manifest = artifact.add_to_v2_release_manifest!({})
102
+ v2_manifest.should == expected
103
+ end
104
+
105
+ end
106
+
@@ -0,0 +1,197 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'omnibus/package_release'
19
+ require 'spec_helper'
20
+
21
+ describe Omnibus::PackageRelease do
22
+ let(:s3_key) { "s3key" }
23
+ let(:s3_secret) { "hey-bezos-store-my-stuff" }
24
+ let(:s3_bucket) { "myorg-omnibus-packages" }
25
+ let(:pkg_path) { "pkg/chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm" }
26
+ let(:pkg_metadata_path) { "#{pkg_path}.metadata.json" }
27
+
28
+ let(:config) do
29
+ {
30
+ :release_s3_access_key => s3_key,
31
+ :release_s3_secret_key => s3_secret,
32
+ :release_s3_bucket => s3_bucket
33
+ }
34
+ end
35
+ subject(:package_release) do
36
+ Omnibus::PackageRelease.new(pkg_path)
37
+ end
38
+
39
+ it "has a package path" do
40
+ package_release.package_path.should == pkg_path
41
+ end
42
+
43
+ it "defaults to `:private' access policy" do
44
+ package_release.access_policy.should == :private
45
+ end
46
+
47
+ describe "validating configuration" do
48
+
49
+ before do
50
+ Omnibus.stub!(:config).and_return(config)
51
+ end
52
+
53
+ it "validates that the s3 key is set" do
54
+ config.delete(:release_s3_access_key)
55
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
56
+ end
57
+
58
+ it "validates that the s3 secret key is set" do
59
+ config.delete(:release_s3_secret_key)
60
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
61
+ end
62
+
63
+ it "validates that the s3 bucket is set" do
64
+ config.delete(:release_s3_bucket)
65
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
66
+ end
67
+
68
+ it "does not error on a valid configuration" do
69
+ lambda { package_release.validate_config! }.should_not raise_error
70
+ end
71
+ end
72
+
73
+ describe "validating package for upload" do
74
+ it "ensures that the package file exists" do
75
+ lambda { package_release.validate_package! }.should raise_error(Omnibus::NoPackageFile)
76
+ end
77
+
78
+ it "ensures that there is a metadata file for the package" do
79
+ File.should_receive(:exist?).with(pkg_path).and_return(true)
80
+ File.should_receive(:exist?).with(pkg_metadata_path).and_return(false)
81
+ lambda { package_release.validate_package! }.should raise_error(Omnibus::NoPackageMetadataFile)
82
+ end
83
+ end
84
+
85
+ context "with a valid config and package" do
86
+
87
+ let(:basename) { "chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm" }
88
+ let(:md5) { "016f2e0854c69901b3f0ad8f99ffdb75" }
89
+ let(:platform_path) { "el/6/x86_64" }
90
+ let(:pkg_content) { "expected package content" }
91
+
92
+ let(:metadata_json) do
93
+ <<-E
94
+ {
95
+ "platform": "el",
96
+ "platform_version": "6",
97
+ "arch": "x86_64",
98
+ "version": "11.4.0-183-g2c0040c",
99
+ "basename": "#{basename}",
100
+ "md5": "#{md5}",
101
+ "sha256": "21191ab698d1663a5e738e470fad16a2c6efee05ed597002f2e846ec80ade38c"
102
+ }
103
+ E
104
+ end
105
+
106
+ before do
107
+ package_release.stub!(:config).and_return(config)
108
+ File.stub(:exist?).with(pkg_metadata_path).and_return(true)
109
+ File.stub(:exist?).with(pkg_path).and_return(true)
110
+ IO.stub(:read).with(pkg_metadata_path).and_return(metadata_json)
111
+ IO.stub(:read).with(pkg_path).and_return(pkg_content)
112
+ end
113
+
114
+ it "configures s3 with the given credentials" do
115
+ expected_s3_config = {
116
+ :access_key => s3_key,
117
+ :secret_access_key => s3_secret,
118
+ :bucket => s3_bucket,
119
+ :adaper => :net_http
120
+ }
121
+ UberS3.should_receive(:new).with(expected_s3_config)
122
+ package_release.s3_client
123
+ end
124
+
125
+ it "generates the relative path for the package s3 key" do
126
+ package_release.platform_path.should == platform_path
127
+ end
128
+
129
+
130
+ it "uploads the package and metadata" do
131
+ package_release.s3_client.should_receive(:store).with(
132
+ "#{platform_path}/#{basename}.metadata.json",
133
+ metadata_json,
134
+ :access => :private
135
+ )
136
+ package_release.s3_client.should_receive(:store).with(
137
+ "#{platform_path}/#{basename}",
138
+ pkg_content,
139
+ :access => :private,
140
+ :content_md5 => md5
141
+ )
142
+ package_release.release
143
+ end
144
+
145
+ context "and a callback is given for after upload" do
146
+ let(:upload_records) { [] }
147
+
148
+ subject(:package_release) do
149
+ Omnibus::PackageRelease.new(pkg_path) do |uploaded|
150
+ upload_records << uploaded
151
+ end
152
+ end
153
+
154
+ it "fires the after_upload callback for each item uploaded" do
155
+ package_release.s3_client.should_receive(:store).with(
156
+ "#{platform_path}/#{basename}.metadata.json",
157
+ metadata_json,
158
+ :access => :private
159
+ )
160
+ package_release.s3_client.should_receive(:store).with(
161
+ "#{platform_path}/#{basename}",
162
+ pkg_content,
163
+ :access => :private,
164
+ :content_md5 => md5
165
+ )
166
+ package_release.release
167
+
168
+ upload_records.should == [ "#{platform_path}/#{basename}.metadata.json",
169
+ "#{platform_path}/#{basename}" ]
170
+ end
171
+ end
172
+
173
+ context "and the package is public" do
174
+
175
+ subject(:package_release) do
176
+ Omnibus::PackageRelease.new(pkg_path, :access => :public_read)
177
+ end
178
+
179
+ it "uploads the package and metadata" do
180
+ package_release.s3_client.should_receive(:store).with(
181
+ "#{platform_path}/#{basename}.metadata.json",
182
+ metadata_json,
183
+ :access => :public_read
184
+ )
185
+ package_release.s3_client.should_receive(:store).with(
186
+ "#{platform_path}/#{basename}",
187
+ pkg_content,
188
+ :access => :public_read,
189
+ :content_md5 => md5
190
+ )
191
+ package_release.release
192
+ end
193
+ end
194
+
195
+ end
196
+
197
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Opscode
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-02 00:00:00.000000000 Z
11
+ date: 2013-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: fpm
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 0.3.11
75
+ version: 0.4.33
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 0.3.11
82
+ version: 0.4.33
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: uber-s3
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - bin/makeself.sh
158
158
  - bin/omnibus
159
159
  - lib/omnibus.rb
160
+ - lib/omnibus/artifact.rb
160
161
  - lib/omnibus/build_version.rb
161
162
  - lib/omnibus/builder.rb
162
163
  - lib/omnibus/clean_tasks.rb
@@ -165,6 +166,7 @@ files:
165
166
  - lib/omnibus/cli/base.rb
166
167
  - lib/omnibus/cli/build.rb
167
168
  - lib/omnibus/cli/cache.rb
169
+ - lib/omnibus/cli/release.rb
168
170
  - lib/omnibus/config.rb
169
171
  - lib/omnibus/exceptions.rb
170
172
  - lib/omnibus/fetcher.rb
@@ -176,6 +178,7 @@ files:
176
178
  - lib/omnibus/health_check.rb
177
179
  - lib/omnibus/library.rb
178
180
  - lib/omnibus/overrides.rb
181
+ - lib/omnibus/package_release.rb
179
182
  - lib/omnibus/project.rb
180
183
  - lib/omnibus/reports.rb
181
184
  - lib/omnibus/s3_cacher.rb
@@ -196,6 +199,7 @@ files:
196
199
  - lib/omnibus/util.rb
197
200
  - lib/omnibus/version.rb
198
201
  - omnibus.gemspec
202
+ - spec/artifact_spec.rb
199
203
  - spec/build_version_spec.rb
200
204
  - spec/data/overrides/bad_line.overrides
201
205
  - spec/data/overrides/good.overrides
@@ -203,6 +207,7 @@ files:
203
207
  - spec/data/software/erchef.rb
204
208
  - spec/fetchers/net_fetcher_spec.rb
205
209
  - spec/overrides_spec.rb
210
+ - spec/package_release_spec.rb
206
211
  - spec/software_spec.rb
207
212
  - spec/spec_helper.rb
208
213
  homepage: https://github.com/opscode/omnibus-ruby
@@ -230,6 +235,7 @@ signing_key:
230
235
  specification_version: 4
231
236
  summary: Omnibus helps you build self-installing, full-stack software builds.
232
237
  test_files:
238
+ - spec/artifact_spec.rb
233
239
  - spec/build_version_spec.rb
234
240
  - spec/data/overrides/bad_line.overrides
235
241
  - spec/data/overrides/good.overrides
@@ -237,6 +243,7 @@ test_files:
237
243
  - spec/data/software/erchef.rb
238
244
  - spec/fetchers/net_fetcher_spec.rb
239
245
  - spec/overrides_spec.rb
246
+ - spec/package_release_spec.rb
240
247
  - spec/software_spec.rb
241
248
  - spec/spec_helper.rb
242
249
  has_rdoc: