vanagon 0.15.9 → 0.15.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vanagon/driver.rb +1 -0
- data/lib/vanagon/project.rb +58 -0
- data/lib/vanagon/project/dsl.rb +17 -1
- data/resources/rpm/project.spec.erb +1 -1
- data/spec/lib/vanagon/project_spec.rb +114 -0
- metadata +31 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c881a94010be196e7f3ca83630dcd5992942e05e
|
4
|
+
data.tar.gz: aa92f93959346079d3860751d901319a5b94c86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 614fb484ead28a97271a5de18fa03a2772b6026a2af72c64666afbb01fb06d0e866528c0ae3dc623ab2b51ad87e0b3a63bd29807be2b019424143c46785c5397
|
7
|
+
data.tar.gz: a330ed57d45a948ab45d8949e078f9d9efbefa0a33d1c0b21c8a96993a076b3c5e1487e83def372b66f074b603bc0962de22e4c4ee6232ed4c9ca4a8cef96dcc
|
data/lib/vanagon/driver.rb
CHANGED
@@ -144,6 +144,7 @@ class Vanagon
|
|
144
144
|
@engine.ship_workdir(workdir)
|
145
145
|
@engine.dispatch("(cd #{@engine.remote_workdir}; #{@platform.make} #{make_target})")
|
146
146
|
@engine.retrieve_built_artifact(@project.artifacts_to_fetch, @project.no_packaging)
|
147
|
+
@project.publish_yaml_settings(@platform)
|
147
148
|
|
148
149
|
if %i[never on-failure].include? @preserve
|
149
150
|
@engine.teardown
|
data/lib/vanagon/project.rb
CHANGED
@@ -61,6 +61,9 @@ class Vanagon
|
|
61
61
|
# !refactor
|
62
62
|
attr_accessor :version_file
|
63
63
|
|
64
|
+
# Store whether Vanagon should write the project's settings to a yaml file during builds
|
65
|
+
attr_accessor :yaml_settings
|
66
|
+
|
64
67
|
# Stores the location for the bill-of-materials (a receipt of all
|
65
68
|
# files written during) project package assembly
|
66
69
|
attr_accessor :bill_of_materials
|
@@ -145,6 +148,7 @@ class Vanagon
|
|
145
148
|
@source_artifacts = false
|
146
149
|
@compiled_archive = false
|
147
150
|
@generate_packages = true
|
151
|
+
@yaml_settings = false
|
148
152
|
@no_packaging = false
|
149
153
|
@artifacts_to_fetch = []
|
150
154
|
end
|
@@ -665,6 +669,28 @@ class Vanagon
|
|
665
669
|
end
|
666
670
|
end
|
667
671
|
|
672
|
+
# Writes a yaml file at `output/<name>-<version>.<platform>.settings.yaml`
|
673
|
+
# containing settings used to build the current project on the platform
|
674
|
+
# provided (and a corresponding sha1sum file) if `yaml_settings` has been
|
675
|
+
# set in the project definition.
|
676
|
+
#
|
677
|
+
# @param [Vanagon::Platform] the platform to publish settings for
|
678
|
+
def publish_yaml_settings(platform)
|
679
|
+
return unless yaml_settings
|
680
|
+
raise(Vanagon::Error, "You must specify a project version") unless version
|
681
|
+
|
682
|
+
filename = "#{name}-#{version}.#{platform.name}.settings.yaml"
|
683
|
+
filepath = File.join('output', filename)
|
684
|
+
|
685
|
+
File.open(filepath, 'w') do |f|
|
686
|
+
f.write(@settings.to_yaml)
|
687
|
+
end
|
688
|
+
|
689
|
+
File.open("#{filepath}.sha1", 'w') do |f|
|
690
|
+
f.write(system("#{platform.shasum} #{filepath}", err: File::NULL))
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
668
694
|
# Load the settings hash from an upstream vanagon project.
|
669
695
|
# This will clone a git repo at a specified branch and load the specified
|
670
696
|
# vanagon project (with no components). The settings hash of the upstream
|
@@ -692,5 +718,37 @@ class Vanagon
|
|
692
718
|
upstream_project.cleanup
|
693
719
|
end
|
694
720
|
end
|
721
|
+
|
722
|
+
# Load the settings hash for the current project/platform combination from a
|
723
|
+
# yaml file as produced by `publish_yaml_settings`. file:// and http:// URIs
|
724
|
+
# are accepted. If the URI uses http://, a sha1 URI is also required.
|
725
|
+
#
|
726
|
+
# @param settings_uri [String] A URI to a yaml settings file
|
727
|
+
# @param settings_sha1_uri [String] A URI to a sha1sum file for the yaml settings file
|
728
|
+
# @raise [Vanagon::Error] when the settings file can't be found
|
729
|
+
def load_yaml_settings(settings_uri, settings_sha1_uri = nil) # rubocop:disable Metrics/AbcSize
|
730
|
+
source_type = Vanagon::Component::Source.determine_source_type(settings_uri)
|
731
|
+
|
732
|
+
if %i[unknown git].include?(source_type)
|
733
|
+
message = "Can't inherit settings from '#{settings_uri}'. Only http and file URIs are valid."
|
734
|
+
if settings_uri =~ /^file/
|
735
|
+
message = "Tried to load YAML settings from '#{settings_uri}', but the file doesn't exist."
|
736
|
+
end
|
737
|
+
raise Vanagon::Error, message
|
738
|
+
end
|
739
|
+
|
740
|
+
if (source_type == :http) && !settings_sha1_uri
|
741
|
+
raise Vanagon::Error, "You must provide a sha1sum URI for the YAML file when inheriting YAML settings over http"
|
742
|
+
end
|
743
|
+
|
744
|
+
Dir.mktmpdir do |working_directory|
|
745
|
+
source = Vanagon::Component::Source.source(settings_uri,
|
746
|
+
workdir: working_directory,
|
747
|
+
sum: settings_sha1_uri,
|
748
|
+
sum_type: 'sha1')
|
749
|
+
source.fetch
|
750
|
+
@settings.merge!(YAML.safe_load(File.read(File.join(working_directory, source.file)), [Symbol]))
|
751
|
+
end
|
752
|
+
end
|
695
753
|
end
|
696
754
|
end
|
data/lib/vanagon/project/dsl.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'vanagon/errors'
|
1
2
|
require 'vanagon/project'
|
2
3
|
require 'vanagon/utilities'
|
3
4
|
require 'vanagon/component/source'
|
4
|
-
require 'set'
|
5
5
|
require 'git/rev_list'
|
6
|
+
require 'set'
|
7
|
+
require 'yaml'
|
6
8
|
|
7
9
|
class Vanagon
|
8
10
|
class Project
|
@@ -302,6 +304,11 @@ class Vanagon
|
|
302
304
|
@project.version_file = Vanagon::Common::Pathname.file(target)
|
303
305
|
end
|
304
306
|
|
307
|
+
# This method will write the project's settings (per-platform) to the output directory as yaml after building
|
308
|
+
def publish_yaml_settings
|
309
|
+
@project.yaml_settings = true
|
310
|
+
end
|
311
|
+
|
305
312
|
# This method will write the project's bill-of-materials to a designated directory during package creation.
|
306
313
|
# @param target [String] a full path to the directory for the bill-of-materials for the project
|
307
314
|
def bill_of_materials(target)
|
@@ -322,6 +329,15 @@ class Vanagon
|
|
322
329
|
@project.load_upstream_settings(upstream_project_name, upstream_git_url, upstream_git_branch)
|
323
330
|
end
|
324
331
|
|
332
|
+
# Inherit the settings hash for the current project and platform from a
|
333
|
+
# yaml file as generated by `publish_yaml_settings`
|
334
|
+
#
|
335
|
+
# @param yaml_settings_uri [String] URI (file://... or http://...) to a file containing a yaml representation of vanagon settings
|
336
|
+
# @param yaml_settings_sha1_uri [String] URI (file://... or http://...) to a file the sha1sum for the settings file
|
337
|
+
def inherit_yaml_settings(yaml_settings_uri, yaml_settings_sha1_uri = nil)
|
338
|
+
@project.load_yaml_settings(yaml_settings_uri, yaml_settings_sha1_uri)
|
339
|
+
end
|
340
|
+
|
325
341
|
# Set a package override. Will call the platform-specific implementation
|
326
342
|
# This will get set in the spec file, deb rules, etc.
|
327
343
|
#
|
@@ -161,7 +161,7 @@ install -d %{buildroot}
|
|
161
161
|
# Here we turn all dirs in the file-list into %dir entries to avoid duplicate files
|
162
162
|
while read entry; do
|
163
163
|
if [ -n "$entry" -a -d "$entry" -a ! -L "$entry" ]; then
|
164
|
-
|
164
|
+
<%= @platform.sed %> -i "\|^$entry\$|s|^|%dir |" %{SOURCE1}
|
165
165
|
fi
|
166
166
|
done < %{SOURCE1}
|
167
167
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'vanagon/project'
|
2
2
|
require 'vanagon/driver'
|
3
|
+
require 'vanagon/errors'
|
3
4
|
|
4
5
|
describe 'Vanagon::Project' do
|
5
6
|
let(:component) { double(Vanagon::Component) }
|
@@ -126,6 +127,75 @@ describe 'Vanagon::Project' do
|
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
130
|
+
describe "#load_yaml_settings" do
|
131
|
+
subject(:project) do
|
132
|
+
project = Vanagon::Project.new('yaml-inheritance-test', Vanagon::Platform.new('aix-7.2-ppc'))
|
133
|
+
project.settings = { merged: 'nope', original: 'original' }
|
134
|
+
project
|
135
|
+
end
|
136
|
+
|
137
|
+
let(:yaml_filename) { 'settings.yaml' }
|
138
|
+
let(:sha1_filename) { "#{yaml_filename}.sha1" }
|
139
|
+
|
140
|
+
let(:yaml_path) { "/path/to/#{yaml_filename}" }
|
141
|
+
let(:sha1_path) { "/path/to/#{sha1_filename}" }
|
142
|
+
|
143
|
+
let(:yaml_content) { { other: 'other', merged: 'yup' }.to_yaml }
|
144
|
+
|
145
|
+
let(:local_yaml_uri) { "file://#{yaml_path}" }
|
146
|
+
let(:http_yaml_uri) { "http:/#{yaml_path}" }
|
147
|
+
|
148
|
+
before(:each) do
|
149
|
+
allow(Dir).to receive(:mktmpdir) { |&block| block.yield '' }
|
150
|
+
end
|
151
|
+
|
152
|
+
it "fails for a local source if the settings file doesn't exist" do
|
153
|
+
expect { project.load_yaml_settings(local_yaml_uri) }.to raise_error(Vanagon::Error)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "fails if given a git source" do
|
157
|
+
expect { project.load_yaml_settings('git://some/repo.uri') }.to raise_error(Vanagon::Error)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "fails when given an unknown source" do
|
161
|
+
expect { project.load_yaml_settings("fake://source.uri") }.to raise_error(Vanagon::Error)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "fails if downloading over HTTP without a valid sha1sum URI" do
|
165
|
+
allow(Vanagon::Component::Source::Http).to receive(:valid_url?).with(http_yaml_uri).and_return(true)
|
166
|
+
http_source = instance_double(Vanagon::Component::Source::Http)
|
167
|
+
allow(Vanagon::Component::Source).to receive(:source).and_return(http_source)
|
168
|
+
|
169
|
+
expect { project.load_yaml_settings(http_yaml_uri) }.to raise_error(Vanagon::Error)
|
170
|
+
end
|
171
|
+
|
172
|
+
context "given a valid source" do
|
173
|
+
before(:each) do
|
174
|
+
local_source = instance_double(Vanagon::Component::Source::Local)
|
175
|
+
allow(local_source).to receive(:fetch)
|
176
|
+
allow(local_source).to receive(:file).and_return(yaml_path)
|
177
|
+
|
178
|
+
allow(Vanagon::Component::Source).to receive(:determine_source_type).and_return(:local)
|
179
|
+
allow(Vanagon::Component::Source).to receive(:source).and_return(local_source)
|
180
|
+
allow(File).to receive(:read).with(yaml_path).and_return(yaml_content)
|
181
|
+
|
182
|
+
expect { project.load_yaml_settings(local_yaml_uri) }.not_to raise_exception
|
183
|
+
end
|
184
|
+
|
185
|
+
it "overwrites the current project's settings when they conflict" do
|
186
|
+
expect(project.settings[:merged]).to eq('yup')
|
187
|
+
end
|
188
|
+
|
189
|
+
it "adopts new settings found in the other project" do
|
190
|
+
expect(project.settings[:other]).to eq('other')
|
191
|
+
end
|
192
|
+
|
193
|
+
it "keeps its own settings when there are no conflicts" do
|
194
|
+
expect(project.settings[:original]).to eq('original')
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
129
199
|
describe "#filter_component" do
|
130
200
|
|
131
201
|
# All of the following tests should be run with one project level
|
@@ -308,6 +378,50 @@ describe 'Vanagon::Project' do
|
|
308
378
|
end
|
309
379
|
end
|
310
380
|
|
381
|
+
describe '#publish_yaml_settings' do
|
382
|
+
let(:platform_name) { 'aix-7.2-ppc' }
|
383
|
+
let(:platform) { Vanagon::Platform.new(platform_name) }
|
384
|
+
|
385
|
+
subject(:project) do
|
386
|
+
project = Vanagon::Project.new('test-project', platform)
|
387
|
+
project.settings = { key: 'value' }
|
388
|
+
project.version = 'version'
|
389
|
+
project.yaml_settings = true
|
390
|
+
project
|
391
|
+
end
|
392
|
+
|
393
|
+
let(:yaml_output_path) { "output/test-project-version.#{platform_name}.settings.yaml" }
|
394
|
+
let(:sha1_output_path) { "output/test-project-version.#{platform_name}.settings.yaml.sha1" }
|
395
|
+
|
396
|
+
let(:yaml_file) { double('yaml_file') }
|
397
|
+
let(:sha1_file) { double('sha1_file') }
|
398
|
+
|
399
|
+
it 'writes project settings as yaml and a sha1sum for the settings to the output directory' do
|
400
|
+
expect(File).to receive(:open).with(yaml_output_path, "w").and_yield(yaml_file)
|
401
|
+
expect(File).to receive(:open).with(sha1_output_path, "w").and_yield(sha1_file)
|
402
|
+
expect(yaml_file).to receive(:write).with({key: 'value'}.to_yaml)
|
403
|
+
expect(sha1_file).to receive(:write)
|
404
|
+
expect { project.publish_yaml_settings(platform) }.not_to raise_error
|
405
|
+
end
|
406
|
+
|
407
|
+
it 'does not write yaml settings or a sha1sum unless told to' do
|
408
|
+
project.yaml_settings = false
|
409
|
+
expect(File).not_to receive(:open)
|
410
|
+
expect { project.publish_yaml_settings(platform) }.not_to raise_error
|
411
|
+
end
|
412
|
+
|
413
|
+
it "fails if the output directory doesn't exist" do
|
414
|
+
allow_any_instance_of(File).to receive(:open).with(yaml_output_path).and_raise(Errno::ENOENT)
|
415
|
+
allow_any_instance_of(File).to receive(:open).with(sha1_output_path).and_raise(Errno::ENOENT)
|
416
|
+
expect { project.publish_yaml_settings(platform) }.to raise_error(Errno::ENOENT)
|
417
|
+
end
|
418
|
+
|
419
|
+
it "fails unless the project has a version" do
|
420
|
+
project.version = nil
|
421
|
+
expect { project.publish_yaml_settings(platform) }.to raise_error(Vanagon::Error)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
311
425
|
describe '#generate_package' do
|
312
426
|
it "builds packages by default" do
|
313
427
|
platform = Vanagon::Platform::DSL.new('el-7-x86_64')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -264,41 +264,41 @@ signing_key:
|
|
264
264
|
specification_version: 3
|
265
265
|
summary: All of your packages will fit into this van with this one simple trick.
|
266
266
|
test_files:
|
267
|
-
- spec/lib/git/rev_list_spec.rb
|
268
|
-
- spec/lib/makefile_spec.rb
|
269
|
-
- spec/lib/vanagon/common/pathname_spec.rb
|
270
|
-
- spec/lib/vanagon/common/user_spec.rb
|
271
|
-
- spec/lib/vanagon/component/dsl_spec.rb
|
272
|
-
- spec/lib/vanagon/component/rules_spec.rb
|
273
|
-
- spec/lib/vanagon/component/source/git_spec.rb
|
274
|
-
- spec/lib/vanagon/component/source/http_spec.rb
|
275
|
-
- spec/lib/vanagon/component/source/local_spec.rb
|
276
|
-
- spec/lib/vanagon/component/source/rewrite_spec.rb
|
277
|
-
- spec/lib/vanagon/component/source_spec.rb
|
278
267
|
- spec/lib/vanagon/component_spec.rb
|
268
|
+
- spec/lib/vanagon/project_spec.rb
|
269
|
+
- spec/lib/vanagon/optparse_spec.rb
|
279
270
|
- spec/lib/vanagon/driver_spec.rb
|
280
|
-
- spec/lib/vanagon/engine/always_be_scheduling_spec.rb
|
281
|
-
- spec/lib/vanagon/engine/base_spec.rb
|
282
|
-
- spec/lib/vanagon/engine/docker_spec.rb
|
283
|
-
- spec/lib/vanagon/engine/ec2_spec.rb
|
284
|
-
- spec/lib/vanagon/engine/hardware_spec.rb
|
285
|
-
- spec/lib/vanagon/engine/local_spec.rb
|
286
|
-
- spec/lib/vanagon/engine/pooler_spec.rb
|
287
271
|
- spec/lib/vanagon/environment_spec.rb
|
288
|
-
- spec/lib/vanagon/
|
289
|
-
- spec/lib/vanagon/
|
290
|
-
- spec/lib/vanagon/
|
291
|
-
- spec/lib/vanagon/optparse_spec.rb
|
292
|
-
- spec/lib/vanagon/platform/deb_spec.rb
|
272
|
+
- spec/lib/vanagon/platform/windows_spec.rb
|
273
|
+
- spec/lib/vanagon/platform/solaris_11_spec.rb
|
274
|
+
- spec/lib/vanagon/platform/solaris_10_spec.rb
|
293
275
|
- spec/lib/vanagon/platform/dsl_spec.rb
|
294
276
|
- spec/lib/vanagon/platform/osx_spec.rb
|
295
|
-
- spec/lib/vanagon/platform/
|
277
|
+
- spec/lib/vanagon/platform/deb_spec.rb
|
296
278
|
- spec/lib/vanagon/platform/rpm_spec.rb
|
297
|
-
- spec/lib/vanagon/platform/
|
298
|
-
- spec/lib/vanagon/
|
299
|
-
- spec/lib/vanagon/
|
300
|
-
- spec/lib/vanagon/
|
279
|
+
- spec/lib/vanagon/platform/rpm/aix_spec.rb
|
280
|
+
- spec/lib/vanagon/component/source/rewrite_spec.rb
|
281
|
+
- spec/lib/vanagon/component/source/git_spec.rb
|
282
|
+
- spec/lib/vanagon/component/source/local_spec.rb
|
283
|
+
- spec/lib/vanagon/component/source/http_spec.rb
|
284
|
+
- spec/lib/vanagon/component/dsl_spec.rb
|
285
|
+
- spec/lib/vanagon/component/source_spec.rb
|
286
|
+
- spec/lib/vanagon/component/rules_spec.rb
|
287
|
+
- spec/lib/vanagon/extensions/string_spec.rb
|
288
|
+
- spec/lib/vanagon/extensions/set/json_spec.rb
|
289
|
+
- spec/lib/vanagon/extensions/ostruct/json_spec.rb
|
301
290
|
- spec/lib/vanagon/project/dsl_spec.rb
|
302
|
-
- spec/lib/vanagon/project_spec.rb
|
303
291
|
- spec/lib/vanagon/utilities/shell_utilities_spec.rb
|
304
292
|
- spec/lib/vanagon/utilities_spec.rb
|
293
|
+
- spec/lib/vanagon/common/pathname_spec.rb
|
294
|
+
- spec/lib/vanagon/common/user_spec.rb
|
295
|
+
- spec/lib/vanagon/platform_spec.rb
|
296
|
+
- spec/lib/vanagon/engine/always_be_scheduling_spec.rb
|
297
|
+
- spec/lib/vanagon/engine/docker_spec.rb
|
298
|
+
- spec/lib/vanagon/engine/ec2_spec.rb
|
299
|
+
- spec/lib/vanagon/engine/hardware_spec.rb
|
300
|
+
- spec/lib/vanagon/engine/local_spec.rb
|
301
|
+
- spec/lib/vanagon/engine/base_spec.rb
|
302
|
+
- spec/lib/vanagon/engine/pooler_spec.rb
|
303
|
+
- spec/lib/makefile_spec.rb
|
304
|
+
- spec/lib/git/rev_list_spec.rb
|