vanagon 0.12.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vanagon.rb +4 -0
- data/lib/vanagon/component.rb +4 -0
- data/lib/vanagon/driver.rb +1 -0
- data/lib/vanagon/project.rb +39 -0
- data/spec/lib/vanagon/project_spec.rb +51 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1862a2a62a15ce507d5fade3b65736fcfc1e4b90
|
4
|
+
data.tar.gz: b317b66ef360dd1c87c73d6a743b2677bc0f108b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da5849324a741b84e3db25778605fc5eb60cc81bbd7cf6fa17989ee6ff634245cf06570ef55eff70df46075e03156a16019d13b6abdd1b7a4162e05e17b9a68d
|
7
|
+
data.tar.gz: 7f1a382f3b438022825ff6e43955b65ba5a8dffd51029281dc175d859ccac408876646a29023af53422c9d61eb336d7e983f01d59c148b2a4d30e1ac2bb549b5
|
data/lib/vanagon.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
1
3
|
LIBDIR = File.expand_path(File.dirname(__FILE__))
|
2
4
|
VANAGON_ROOT = File.join(File.expand_path(File.dirname(__FILE__)), "..")
|
5
|
+
BUILD_TIME = Time.now.iso8601
|
6
|
+
VANAGON_VERSION = Gem.loaded_specs["vanagon"].version.to_s
|
3
7
|
|
4
8
|
$:.unshift(LIBDIR) unless
|
5
9
|
$:.include?(File.dirname(__FILE__)) || $:.include?(LIBDIR)
|
data/lib/vanagon/component.rb
CHANGED
@@ -289,6 +289,10 @@ class Vanagon
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
|
+
def get_dependency_hash
|
293
|
+
{ name => { 'version' => version, 'ref' => options[:ref] }.delete_if { |_, v| !v } }
|
294
|
+
end
|
295
|
+
|
292
296
|
# Fetches secondary sources for the component. These are just dumped into the workdir currently.
|
293
297
|
#
|
294
298
|
# @param workdir [String] working directory to put the source into
|
data/lib/vanagon/driver.rb
CHANGED
@@ -124,6 +124,7 @@ class Vanagon
|
|
124
124
|
@project.make_makefile(@workdir)
|
125
125
|
@project.make_bill_of_materials(@workdir)
|
126
126
|
@project.generate_packaging_artifacts(@workdir)
|
127
|
+
@project.save_manifest_json
|
127
128
|
@engine.ship_workdir(@workdir)
|
128
129
|
@engine.dispatch("(cd #{@engine.remote_workdir}; #{@platform.make})")
|
129
130
|
@engine.retrieve_built_artifact
|
data/lib/vanagon/project.rb
CHANGED
@@ -475,5 +475,44 @@ class Vanagon
|
|
475
475
|
def generate_packaging_artifacts(workdir)
|
476
476
|
@platform.generate_packaging_artifacts(workdir, @name, binding)
|
477
477
|
end
|
478
|
+
|
479
|
+
# Generate a json hash which lists all of the dependant components of the
|
480
|
+
# project.
|
481
|
+
#
|
482
|
+
# @return [Hash] where the top level keys are components and their values
|
483
|
+
# are hashes with additional information on the component.
|
484
|
+
def generate_dependencies_info
|
485
|
+
@components.each_with_object({}) do |component, hsh|
|
486
|
+
hsh.merge!(component.get_dependency_hash)
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
# Generate a hash which contains relevant information regarding components
|
491
|
+
# of a package, what vanagon built the package, time of build, as well as
|
492
|
+
# version of the thing we were building.
|
493
|
+
#
|
494
|
+
# @return [Hash] of information which is useful to know about how a package
|
495
|
+
# was built and what went into the package.
|
496
|
+
def build_manifest_json
|
497
|
+
manifest = {
|
498
|
+
"packaging_type" => {
|
499
|
+
"vanagon" => VANAGON_VERSION,
|
500
|
+
},
|
501
|
+
"version" => version,
|
502
|
+
"components" => generate_dependencies_info,
|
503
|
+
"build_time" => BUILD_TIME,
|
504
|
+
}
|
505
|
+
end
|
506
|
+
|
507
|
+
# Writes a json file at `ext/build_metadata.json` containing information
|
508
|
+
# about what went into a built artifact
|
509
|
+
#
|
510
|
+
# @return [Hash] of build information
|
511
|
+
def save_manifest_json
|
512
|
+
manifest = build_manifest_json
|
513
|
+
File.open(File.join('ext', 'build_metadata.json'), 'w') do |f|
|
514
|
+
f.write(JSON.pretty_generate(manifest))
|
515
|
+
end
|
516
|
+
end
|
478
517
|
end
|
479
518
|
end
|
@@ -115,4 +115,55 @@ describe 'Vanagon::Project' do
|
|
115
115
|
expect(@proj.filter_component(comp1.name)).to eq([comp1, comp2, comp3])
|
116
116
|
end
|
117
117
|
end
|
118
|
+
|
119
|
+
describe '#generate_dependencies_info' do
|
120
|
+
before(:each) do
|
121
|
+
@proj = Vanagon::Project.new('test-project', {})
|
122
|
+
end
|
123
|
+
|
124
|
+
it "returns a hash of components and their versions" do
|
125
|
+
comp1 = Vanagon::Component.new('test-component1', {}, {})
|
126
|
+
comp1.version = '1.0.0'
|
127
|
+
comp2 = Vanagon::Component.new('test-component2', {}, {})
|
128
|
+
comp2.version = '2.0.0'
|
129
|
+
comp2.options[:ref] = '123abcd'
|
130
|
+
comp3 = Vanagon::Component.new('test-component3', {}, {})
|
131
|
+
@proj.components << comp1
|
132
|
+
@proj.components << comp2
|
133
|
+
@proj.components << comp3
|
134
|
+
|
135
|
+
expect(@proj.generate_dependencies_info()).to eq({
|
136
|
+
'test-component1' => { 'version' => '1.0.0' },
|
137
|
+
'test-component2' => { 'version' => '2.0.0', 'ref' => '123abcd' },
|
138
|
+
'test-component3' => {},
|
139
|
+
})
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#build_manifest_json' do
|
144
|
+
before(:each) do
|
145
|
+
class Vanagon
|
146
|
+
class Project
|
147
|
+
BUILD_TIME = '2017-07-10T13:34:25-07:00'
|
148
|
+
VANAGON_VERSION = '0.0.0-rspec'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
@proj = Vanagon::Project.new('test-project', {})
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should generate a hash with the expected build metadata' do
|
156
|
+
comp1 = Vanagon::Component.new('test-component1', {}, {})
|
157
|
+
comp1.version = '1.0.0'
|
158
|
+
@proj.components << comp1
|
159
|
+
@proj.version = '123abcde'
|
160
|
+
|
161
|
+
expect(@proj.build_manifest_json()).to eq({
|
162
|
+
'packaging_type' => { 'vanagon' => '0.0.0-rspec' },
|
163
|
+
'version' => '123abcde',
|
164
|
+
'components' => { 'test-component1' => { 'version' => '1.0.0' } },
|
165
|
+
'build_time' => '2017-07-10T13:34:25-07:00',
|
166
|
+
})
|
167
|
+
end
|
168
|
+
end
|
118
169
|
end
|
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.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
241
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.2.5
|
243
243
|
signing_key:
|
244
244
|
specification_version: 3
|
245
245
|
summary: All of your packages will fit into this van with this one simple trick.
|