omnibus 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/omnibus.rb +1 -0
- data/lib/omnibus/fetchers/git_fetcher.rb +1 -0
- data/lib/omnibus/licensing.rb +227 -0
- data/lib/omnibus/manifest.rb +5 -3
- data/lib/omnibus/manifest_entry.rb +4 -2
- data/lib/omnibus/packagers/rpm.rb +30 -12
- data/lib/omnibus/project.rb +66 -1
- data/lib/omnibus/software.rb +54 -1
- data/lib/omnibus/version.rb +1 -1
- data/resources/rpm/spec.erb +1 -1
- data/spec/functional/builder_spec.rb +1 -1
- data/spec/functional/licensing_spec.rb +141 -0
- data/spec/unit/manifest_spec.rb +4 -0
- data/spec/unit/packagers/rpm_spec.rb +40 -10
- data/spec/unit/project_spec.rb +15 -0
- data/spec/unit/software_spec.rb +8 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d909e83257599b77c57d11ad3f4cad644286d005
|
4
|
+
data.tar.gz: ff63967a1b6a5189f29bb6524e73af08ecfc2d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c02188f92090b922772ffc0c9c50a92ae32224a90ae36d0c5b3fe3bf79c56e3e32043ef797ade533ac783700665ea8b8874bfea24954c8db5190a21321565ef
|
7
|
+
data.tar.gz: 67be7899e3af5eff14c57d54c2d414165daa3b4811a65e8f4491a355a2725274f6522ca6daa4a7b8a3df1251657659e71b1ed8d664afecdd6e7561522ff16726
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
Omnibus CHANGELOG
|
2
2
|
=================
|
3
3
|
|
4
|
+
v5.2.0 (March 15, 2016)
|
5
|
+
-----------------------
|
6
|
+
### New Features
|
7
|
+
|
8
|
+
- License reporting (#635):
|
9
|
+
- Add `license` & `license_file` DSL methods to software.
|
10
|
+
- `license` (String): Sets the license of the software component.
|
11
|
+
- `license_file` (String): The relative path or the url of the license file of the software to be included in `"LICENSES"` directory.
|
12
|
+
- Can be used multiple times.
|
13
|
+
- You can use `:project_license` as a special value if the software is build related code and if it is using project's license.
|
14
|
+
- Add `license`, `license_file` and `license_file_path` DSL methods to project.
|
15
|
+
- `license` (String): Sets the license of the project.
|
16
|
+
- `license_file` (String): The relative path or the url of the license file of the project to be included in the file that will be created at project.license_file_path.
|
17
|
+
- `license_file_path` (String): The relative path of the main license file that will be created for the project. Default: `"LICENSE"`.
|
18
|
+
|
19
|
+
With this omnibus will:
|
20
|
+
|
21
|
+
1. Collect all the license files specified in software components into `install_dir/LICENSES` directory.
|
22
|
+
2. Create a license file at `install_dir/LICENSE` which will contain license of the project and license information for all the software components that are being included.
|
23
|
+
- Ability to change `dist_tag` in RPM packager. (#634)
|
24
|
+
- Ability to update submodules during git checkout. (#603)
|
25
|
+
|
4
26
|
v5.1.0 (March 10, 2016)
|
5
27
|
-----------------------
|
6
28
|
### New Features
|
data/lib/omnibus.rb
CHANGED
@@ -62,6 +62,7 @@ module Omnibus
|
|
62
62
|
autoload :Templating, 'omnibus/templating'
|
63
63
|
autoload :ThreadPool, 'omnibus/thread_pool'
|
64
64
|
autoload :Util, 'omnibus/util'
|
65
|
+
autoload :Licensing, 'omnibus/licensing'
|
65
66
|
|
66
67
|
autoload :GitFetcher, 'omnibus/fetchers/git_fetcher'
|
67
68
|
autoload :NetFetcher, 'omnibus/fetchers/net_fetcher'
|
@@ -0,0 +1,227 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'uri'
|
18
|
+
require 'fileutils'
|
19
|
+
|
20
|
+
module Omnibus
|
21
|
+
class Licensing
|
22
|
+
include Logging
|
23
|
+
|
24
|
+
OUTPUT_DIRECTORY = "LICENSES".freeze
|
25
|
+
|
26
|
+
class << self
|
27
|
+
# @see (Licensing#create!)
|
28
|
+
def create!(project)
|
29
|
+
new(project).create!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# The project to create licenses for.
|
35
|
+
#
|
36
|
+
# @return [Project]
|
37
|
+
#
|
38
|
+
attr_reader :project
|
39
|
+
|
40
|
+
#
|
41
|
+
# @param [Project] project
|
42
|
+
# the project to create licenses for.
|
43
|
+
#
|
44
|
+
def initialize(project)
|
45
|
+
@project = project
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Creates the license files for given project.
|
50
|
+
# It is assumed that the project has already been built.
|
51
|
+
#
|
52
|
+
# @return [void]
|
53
|
+
#
|
54
|
+
def create!
|
55
|
+
prepare
|
56
|
+
create_software_license_files
|
57
|
+
create_project_license_file
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Creates the required directories for licenses.
|
62
|
+
#
|
63
|
+
# @return [void]
|
64
|
+
#
|
65
|
+
def prepare
|
66
|
+
FileUtils.rm_rf(output_dir)
|
67
|
+
FileUtils.mkdir_p(output_dir)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Creates the top level license file for the project.
|
72
|
+
# Top level file is created at #{project.license_file_path}
|
73
|
+
# and contains the name of the project, version of the project,
|
74
|
+
# text of the license of the project and a summary of the licenses
|
75
|
+
# of the included software components.
|
76
|
+
#
|
77
|
+
# @return [void]
|
78
|
+
#
|
79
|
+
def create_project_license_file
|
80
|
+
File.open(project.license_file_path, 'w') do |f|
|
81
|
+
f.puts "#{project.name} #{project.build_version} license: \"#{project.license}\""
|
82
|
+
f.puts ""
|
83
|
+
f.puts project_license_content
|
84
|
+
f.puts ""
|
85
|
+
f.puts components_license_summary
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Copies the license files specified by the software components into the
|
91
|
+
# output directory.
|
92
|
+
#
|
93
|
+
# @return [void]
|
94
|
+
#
|
95
|
+
def create_software_license_files
|
96
|
+
license_map.each do |name, values|
|
97
|
+
license_files = values[:license_files]
|
98
|
+
|
99
|
+
license_files.each do |license_file|
|
100
|
+
if license_file && local?(license_file)
|
101
|
+
input_file = File.expand_path(license_file, values[:project_dir])
|
102
|
+
output_file = license_package_location(name, license_file)
|
103
|
+
FileUtils.cp(input_file, output_file) if File.exist?(input_file)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Contents of the project's license
|
111
|
+
#
|
112
|
+
# @return [String]
|
113
|
+
#
|
114
|
+
def project_license_content
|
115
|
+
project.license_file.nil? ? "" : IO.read(File.join(Config.project_root,project.license_file))
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# Summary of the licenses included by the softwares of the project.
|
120
|
+
# It is in the form of:
|
121
|
+
# ...
|
122
|
+
# This product bundles python 2.7.9,
|
123
|
+
# which is available under a "Python" License.
|
124
|
+
# For details, see:
|
125
|
+
# /opt/opscode/LICENSES/python-LICENSE
|
126
|
+
# ...
|
127
|
+
#
|
128
|
+
# @return [String]
|
129
|
+
#
|
130
|
+
def components_license_summary
|
131
|
+
out = "\n\n"
|
132
|
+
|
133
|
+
license_map.keys.sort.each do |name|
|
134
|
+
license = license_map[name][:license]
|
135
|
+
license_files = license_map[name][:license_files]
|
136
|
+
version = license_map[name][:version]
|
137
|
+
|
138
|
+
out << "This product bundles #{name} #{version},\n"
|
139
|
+
out << "which is available under a \"#{license}\" License.\n"
|
140
|
+
if !license_files.empty?
|
141
|
+
out << "For details, see:\n"
|
142
|
+
license_files.each do |license_file|
|
143
|
+
out << "#{license_package_location(name, license_file)}\n"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
out << "\n"
|
147
|
+
end
|
148
|
+
|
149
|
+
out
|
150
|
+
end
|
151
|
+
|
152
|
+
#
|
153
|
+
# Map that collects information about the licenses of the softwares
|
154
|
+
# included in the project.
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
# {
|
158
|
+
# ...
|
159
|
+
# "python" => {
|
160
|
+
# "license" => "Python",
|
161
|
+
# "license_files" => "LICENSE",
|
162
|
+
# "version" => "2.7.9",
|
163
|
+
# "project_dir" => "/var/cache/omnibus/src/python/Python-2.7.9/"
|
164
|
+
# },
|
165
|
+
# ...
|
166
|
+
# }
|
167
|
+
#
|
168
|
+
# @return [Hash]
|
169
|
+
#
|
170
|
+
def license_map
|
171
|
+
@license_map ||= begin
|
172
|
+
map = {}
|
173
|
+
|
174
|
+
project.library.each do |component|
|
175
|
+
# Some of the components do not bundle any software but contain
|
176
|
+
# some logic that we use during the build. These components are
|
177
|
+
# covered under the project's license and they do not need specific
|
178
|
+
# license files.
|
179
|
+
next if component.license == :project_license
|
180
|
+
|
181
|
+
map[component.name] = {
|
182
|
+
license: component.license,
|
183
|
+
license_files: component.license_files,
|
184
|
+
version: component.version,
|
185
|
+
project_dir: component.project_dir,
|
186
|
+
}
|
187
|
+
end
|
188
|
+
|
189
|
+
map
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
#
|
194
|
+
# Returns the location where the license file should reside in the package.
|
195
|
+
# License file is named as <project_name>-<license_file_name> and created
|
196
|
+
# under the output licenses directory.
|
197
|
+
#
|
198
|
+
# @return [String]
|
199
|
+
#
|
200
|
+
def license_package_location(component_name, where)
|
201
|
+
if local?(where)
|
202
|
+
File.join(output_dir, "#{component_name}-#{File.split(where).last}")
|
203
|
+
else
|
204
|
+
where
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
#
|
209
|
+
# Output directory to create the licenses in.
|
210
|
+
#
|
211
|
+
# @return [String]
|
212
|
+
#
|
213
|
+
def output_dir
|
214
|
+
File.expand_path(OUTPUT_DIRECTORY, project.install_dir)
|
215
|
+
end
|
216
|
+
|
217
|
+
#
|
218
|
+
# Returns if the given path to a license is local or a remote url.
|
219
|
+
#
|
220
|
+
# @return [Boolean]
|
221
|
+
#
|
222
|
+
def local?(license)
|
223
|
+
u = URI(license)
|
224
|
+
return u.scheme.nil?
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
data/lib/omnibus/manifest.rb
CHANGED
@@ -24,13 +24,14 @@ module Omnibus
|
|
24
24
|
|
25
25
|
include Logging
|
26
26
|
|
27
|
-
LATEST_MANIFEST_FORMAT =
|
27
|
+
LATEST_MANIFEST_FORMAT = 2
|
28
28
|
|
29
|
-
attr_reader :build_version, :build_git_revision
|
30
|
-
def initialize(version=nil, git_rev=nil)
|
29
|
+
attr_reader :build_version, :build_git_revision, :license
|
30
|
+
def initialize(version=nil, git_rev=nil, license="Unspecified")
|
31
31
|
@data = {}
|
32
32
|
@build_version = version
|
33
33
|
@build_git_revision = git_rev
|
34
|
+
@license = license
|
34
35
|
end
|
35
36
|
|
36
37
|
def entry_for(name)
|
@@ -75,6 +76,7 @@ module Omnibus
|
|
75
76
|
}
|
76
77
|
ret['build_version'] = build_version if build_version
|
77
78
|
ret['build_git_revision'] = build_git_revision if build_git_revision
|
79
|
+
ret['license'] = license
|
78
80
|
ret
|
79
81
|
end
|
80
82
|
|
@@ -16,13 +16,14 @@
|
|
16
16
|
|
17
17
|
module Omnibus
|
18
18
|
class ManifestEntry
|
19
|
-
attr_reader :locked_version, :locked_source, :source_type, :described_version, :name
|
19
|
+
attr_reader :locked_version, :locked_source, :source_type, :described_version, :name, :license
|
20
20
|
def initialize(name, manifest_data)
|
21
21
|
@name = name
|
22
22
|
@locked_version = manifest_data[:locked_version]
|
23
23
|
@locked_source = manifest_data[:locked_source]
|
24
24
|
@source_type = manifest_data[:source_type]
|
25
25
|
@described_version = manifest_data[:described_version]
|
26
|
+
@license = manifest_data[:license]
|
26
27
|
end
|
27
28
|
|
28
29
|
def to_hash
|
@@ -30,7 +31,8 @@ module Omnibus
|
|
30
31
|
"locked_version" => @locked_version,
|
31
32
|
"locked_source" => @locked_source,
|
32
33
|
"source_type" => @source_type,
|
33
|
-
"described_version" => @described_version
|
34
|
+
"described_version" => @described_version,
|
35
|
+
"license" => @license
|
34
36
|
}
|
35
37
|
end
|
36
38
|
|
@@ -202,6 +202,31 @@ module Omnibus
|
|
202
202
|
end
|
203
203
|
expose :category
|
204
204
|
|
205
|
+
#
|
206
|
+
# Set or return the dist_tag for this package
|
207
|
+
#
|
208
|
+
# The Dist Tag for this RPM package as per the Fedora packaging guidlines.
|
209
|
+
#
|
210
|
+
# @see http://fedoraproject.org/wiki/Packaging:DistTag
|
211
|
+
#
|
212
|
+
# @example
|
213
|
+
# dist_tag ".#{Omnibus::Metadata.platform_shortname}#{Omnibus::Metadata.platform_version}"
|
214
|
+
#
|
215
|
+
# @param [String] val
|
216
|
+
# the dist_tag for this package
|
217
|
+
#
|
218
|
+
# @return [String]
|
219
|
+
# the dist_tag for this package
|
220
|
+
#
|
221
|
+
def dist_tag(val = NULL)
|
222
|
+
if null?(val)
|
223
|
+
@dist_tag || ".#{Omnibus::Metadata.platform_shortname}#{Omnibus::Metadata.platform_version}"
|
224
|
+
else
|
225
|
+
@dist_tag = val
|
226
|
+
end
|
227
|
+
end
|
228
|
+
expose :dist_tag
|
229
|
+
|
205
230
|
#
|
206
231
|
# @!endgroup
|
207
232
|
# --------------------------------------------------
|
@@ -210,7 +235,11 @@ module Omnibus
|
|
210
235
|
# @return [String]
|
211
236
|
#
|
212
237
|
def package_name
|
213
|
-
|
238
|
+
if dist_tag
|
239
|
+
"#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}#{dist_tag}.#{safe_architecture}.rpm"
|
240
|
+
else
|
241
|
+
"#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.rpm"
|
242
|
+
end
|
214
243
|
end
|
215
244
|
|
216
245
|
#
|
@@ -435,17 +464,6 @@ module Omnibus
|
|
435
464
|
.gsub("%", "[%]")
|
436
465
|
end
|
437
466
|
|
438
|
-
#
|
439
|
-
# The Dist Tag for this RPM package per the Fedora packaging guidlines.
|
440
|
-
#
|
441
|
-
# @see http://fedoraproject.org/wiki/Packaging:DistTag
|
442
|
-
#
|
443
|
-
# @return [String]
|
444
|
-
#
|
445
|
-
def dist_tag
|
446
|
-
".#{Omnibus::Metadata.platform_shortname}#{Omnibus::Metadata.platform_version}"
|
447
|
-
end
|
448
|
-
|
449
467
|
#
|
450
468
|
# Return the RPM-ready base package name, converting any invalid characters to
|
451
469
|
# dashes (+-+).
|
data/lib/omnibus/project.rb
CHANGED
@@ -691,6 +691,70 @@ module Omnibus
|
|
691
691
|
end
|
692
692
|
expose :ohai
|
693
693
|
|
694
|
+
#
|
695
|
+
# Set or retrieve the {#license} of the project.
|
696
|
+
#
|
697
|
+
# @example
|
698
|
+
# license 'Apache 2.0'
|
699
|
+
#
|
700
|
+
# @param [String] val
|
701
|
+
# the license to set for the project.
|
702
|
+
#
|
703
|
+
# @return [String]
|
704
|
+
#
|
705
|
+
def license(val = NULL)
|
706
|
+
if null?(val)
|
707
|
+
@license || 'Unspecified'
|
708
|
+
else
|
709
|
+
@license = val
|
710
|
+
end
|
711
|
+
end
|
712
|
+
expose :license
|
713
|
+
|
714
|
+
#
|
715
|
+
# Set or retrieve the location of the {#license_file}
|
716
|
+
# of the project. It can either be a relative path inside
|
717
|
+
# the project source directory or a URL.
|
718
|
+
#
|
719
|
+
#
|
720
|
+
# @example
|
721
|
+
# license_file 'LICENSES/artistic.txt'
|
722
|
+
#
|
723
|
+
# @param [String] val
|
724
|
+
# the location of the license file for the project.
|
725
|
+
#
|
726
|
+
# @return [String]
|
727
|
+
#
|
728
|
+
def license_file(val = NULL)
|
729
|
+
if null?(val)
|
730
|
+
@license_file
|
731
|
+
else
|
732
|
+
@license_file = val
|
733
|
+
end
|
734
|
+
end
|
735
|
+
expose :license_file
|
736
|
+
|
737
|
+
#
|
738
|
+
# Location of license file that omnibus will create and that will contain
|
739
|
+
# the information about the license of the project plus the details about
|
740
|
+
# the licenses of the software components included in the project.
|
741
|
+
#
|
742
|
+
# If no path is specified install_dir/LICENSE is used.
|
743
|
+
#
|
744
|
+
# @example
|
745
|
+
# license_file_path
|
746
|
+
#
|
747
|
+
# @return [String]
|
748
|
+
#
|
749
|
+
def license_file_path(path = NULL)
|
750
|
+
if null?(path)
|
751
|
+
@license_file_path || File.join(install_dir, "LICENSE")
|
752
|
+
else
|
753
|
+
@license_file_path = File.join(install_dir, path)
|
754
|
+
end
|
755
|
+
end
|
756
|
+
expose :license_file_path
|
757
|
+
|
694
758
|
#
|
695
759
|
# Location of json-formated version manifest, written at at the
|
696
760
|
# end of the build. If no path is specified
|
@@ -983,7 +1047,7 @@ module Omnibus
|
|
983
1047
|
#
|
984
1048
|
def built_manifest
|
985
1049
|
log.info(log_key) { "Building version manifest" }
|
986
|
-
m = Omnibus::Manifest.new(build_version, build_git_revision)
|
1050
|
+
m = Omnibus::Manifest.new(build_version, build_git_revision, license)
|
987
1051
|
softwares.each do |software|
|
988
1052
|
m.add(software.name, software.manifest_entry)
|
989
1053
|
end
|
@@ -1008,6 +1072,7 @@ module Omnibus
|
|
1008
1072
|
|
1009
1073
|
write_json_manifest
|
1010
1074
|
write_text_manifest
|
1075
|
+
Licensing.create!(self)
|
1011
1076
|
HealthCheck.run!(self)
|
1012
1077
|
package_me
|
1013
1078
|
compress_me
|
data/lib/omnibus/software.rb
CHANGED
@@ -327,6 +327,46 @@ module Omnibus
|
|
327
327
|
end
|
328
328
|
expose :default_version
|
329
329
|
|
330
|
+
#
|
331
|
+
# Set or retrieve the {#license} of the software to build.
|
332
|
+
#
|
333
|
+
# @example
|
334
|
+
# license 'Apache 2.0'
|
335
|
+
#
|
336
|
+
# @param [String] val
|
337
|
+
# the license to set for the software.
|
338
|
+
#
|
339
|
+
# @return [String]
|
340
|
+
#
|
341
|
+
def license(val = NULL)
|
342
|
+
if null?(val)
|
343
|
+
@license || 'Unspecified'
|
344
|
+
else
|
345
|
+
@license = val
|
346
|
+
end
|
347
|
+
end
|
348
|
+
expose :license
|
349
|
+
|
350
|
+
#
|
351
|
+
# Set or retrieve the location of a {#license_file}
|
352
|
+
# of the software. It can either be a relative path inside
|
353
|
+
# the source package or a URL.
|
354
|
+
#
|
355
|
+
#
|
356
|
+
# @example
|
357
|
+
# license_file 'LICENSES/artistic.txt'
|
358
|
+
#
|
359
|
+
# @param [String] val
|
360
|
+
# the location of the license file for the software.
|
361
|
+
#
|
362
|
+
# @return [String]
|
363
|
+
#
|
364
|
+
def license_file(file)
|
365
|
+
license_files << file
|
366
|
+
license_files.dup
|
367
|
+
end
|
368
|
+
expose :license_file
|
369
|
+
|
330
370
|
#
|
331
371
|
# Evaluate a block only if the version matches.
|
332
372
|
#
|
@@ -727,7 +767,9 @@ module Omnibus
|
|
727
767
|
source_type: source_type,
|
728
768
|
described_version: version,
|
729
769
|
locked_version: Fetcher.resolve_version(version, source),
|
730
|
-
locked_source: source
|
770
|
+
locked_source: source,
|
771
|
+
license: license
|
772
|
+
})
|
731
773
|
end
|
732
774
|
|
733
775
|
#
|
@@ -770,6 +812,17 @@ module Omnibus
|
|
770
812
|
@whitelist_files ||= []
|
771
813
|
end
|
772
814
|
|
815
|
+
#
|
816
|
+
# The list of license files for this software
|
817
|
+
#
|
818
|
+
# @see #license_file
|
819
|
+
#
|
820
|
+
# @return [Array<String>]
|
821
|
+
#
|
822
|
+
def license_files
|
823
|
+
@license_files ||= []
|
824
|
+
end
|
825
|
+
|
773
826
|
#
|
774
827
|
# The path (on disk) where this software came from. Warning: this can be
|
775
828
|
# +nil+ if a software was dynamically created!
|
data/lib/omnibus/version.rb
CHANGED
data/resources/rpm/spec.erb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# Metadata
|
18
18
|
Name: <%= name %>
|
19
19
|
Version: <%= version %>
|
20
|
-
Release: <%= iteration %><%= dist_tag %>
|
20
|
+
Release: <%= iteration %><%= dist_tag ? dist_tag : '' %>
|
21
21
|
Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
|
22
22
|
AutoReqProv: no
|
23
23
|
BuildRoot: %buildroot
|
@@ -608,7 +608,7 @@ module Omnibus
|
|
608
608
|
end
|
609
609
|
end
|
610
610
|
|
611
|
-
describe '#update_config_guess', :not_supported_on_windows
|
611
|
+
describe '#update_config_guess', :not_supported_on_windows do
|
612
612
|
let(:config_guess_dir) { "#{install_dir}/embedded/lib/config_guess" }
|
613
613
|
|
614
614
|
before do
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Omnibus
|
4
|
+
describe Licensing do
|
5
|
+
let(:license) { nil }
|
6
|
+
let(:license_file_path) { nil }
|
7
|
+
let(:license_file) { nil }
|
8
|
+
|
9
|
+
let(:install_dir) { File.join(tmp_path, "install_dir")}
|
10
|
+
let(:software_project_dir) { File.join(tmp_path, "software_project_dir")}
|
11
|
+
|
12
|
+
before do
|
13
|
+
FileUtils.mkdir_p(install_dir)
|
14
|
+
FileUtils.mkdir_p(software_project_dir)
|
15
|
+
allow_any_instance_of(Software).to receive(:project_dir).and_return(software_project_dir)
|
16
|
+
%w{README LICENSE NOTICE}.each do |file|
|
17
|
+
File.open(File.join(software_project_dir, file), "w+") do |f|
|
18
|
+
f.puts "This file is #{file}."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
shared_examples "correctly created licenses" do
|
24
|
+
it "creates the main license file for the project correctly" do
|
25
|
+
project_license = File.join(install_dir, expected_project_license_path)
|
26
|
+
expect(File.exist?(project_license)).to be(true)
|
27
|
+
project_license = File.read(project_license)
|
28
|
+
expect(project_license).to match /test-project 1.2.3 license: "#{expected_project_license}"/
|
29
|
+
expect(project_license).to match /#{expected_project_license_content}/
|
30
|
+
expect(project_license).to match /This product bundles private_code 1.7.2,\nwhich is available under a "Unspecified"/
|
31
|
+
expect(project_license).to match /This product bundles snoopy 1.0.0,\nwhich is available under a "GPL v2"/
|
32
|
+
expect(project_license).to match /This product bundles zlib 1.7.2,\nwhich is available under a "Zlib"/
|
33
|
+
expect(project_license).not_to match /preparation/
|
34
|
+
expect(project_license).to match /LICENSES\/snoopy-README/
|
35
|
+
expect(project_license).to match /LICENSES\/snoopy-NOTICE/
|
36
|
+
expect(project_license).to match /LICENSES\/zlib-LICENSE/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "creates the license files of software components correctly" do
|
40
|
+
license_dir = File.join(install_dir, "LICENSES")
|
41
|
+
expect(Dir.glob("#{license_dir}/**/*").length).to be(3)
|
42
|
+
|
43
|
+
%w{snoopy-NOTICE snoopy-README zlib-LICENSE}.each do |software_license|
|
44
|
+
license_path = File.join(license_dir, software_license)
|
45
|
+
expect(File.exist?(license_path)).to be(true)
|
46
|
+
expect(File.read(license_path)).to match /#{software_license.split("-").last}/
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:project) do
|
52
|
+
Project.new.tap do |project|
|
53
|
+
project.name('test-project')
|
54
|
+
project.install_dir(install_dir)
|
55
|
+
project.license(license) unless license.nil?
|
56
|
+
project.license_file_path(license_file_path) unless license_file_path.nil?
|
57
|
+
project.license_file(license_file) unless license_file.nil?
|
58
|
+
project.build_version('1.2.3')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:private_code) do
|
63
|
+
Software.new(project, 'private_code.rb').evaluate do
|
64
|
+
name 'private_code'
|
65
|
+
default_version '1.7.2'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
let(:zlib) do
|
70
|
+
Software.new(project, 'zlib.rb').evaluate do
|
71
|
+
name 'zlib'
|
72
|
+
default_version '1.7.2'
|
73
|
+
license "Zlib"
|
74
|
+
license_file "LICENSE"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
let(:snoopy) do
|
79
|
+
Software.new(project, 'snoopy.rb').evaluate do
|
80
|
+
name 'snoopy'
|
81
|
+
default_version '1.0.0'
|
82
|
+
license "GPL v2"
|
83
|
+
license_file "README"
|
84
|
+
license_file "NOTICE"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
let(:preparation) do
|
89
|
+
Software.new(project, 'preparation.rb').evaluate do
|
90
|
+
name 'preparation'
|
91
|
+
default_version '1.0.0'
|
92
|
+
license :project_license
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_licenses
|
97
|
+
project.library.component_added(preparation)
|
98
|
+
project.library.component_added(snoopy)
|
99
|
+
project.library.component_added(zlib)
|
100
|
+
project.library.component_added(private_code)
|
101
|
+
|
102
|
+
Licensing.create!(project)
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "without license definitions in the project" do
|
106
|
+
let(:expected_project_license_path) { "LICENSE" }
|
107
|
+
let(:expected_project_license) { "Unspecified" }
|
108
|
+
let(:expected_project_license_content) { "" }
|
109
|
+
|
110
|
+
before do
|
111
|
+
create_licenses
|
112
|
+
end
|
113
|
+
|
114
|
+
it_behaves_like "correctly created licenses"
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "with license definitions in the project" do
|
118
|
+
let(:license) { "Custom Chef" }
|
119
|
+
let(:license_file_path) { "CHEF.LICENSE" }
|
120
|
+
let(:license_file) { "CUSTOM_CHEF" }
|
121
|
+
|
122
|
+
let(:expected_project_license_path) { license_file_path }
|
123
|
+
let(:expected_project_license) { license }
|
124
|
+
let(:expected_project_license_content) { "Chef Custom License" }
|
125
|
+
|
126
|
+
before do
|
127
|
+
File.open(File.join(Config.project_root, license_file), "w+") do |f|
|
128
|
+
f.puts "Chef Custom License is awesome."
|
129
|
+
end
|
130
|
+
|
131
|
+
create_licenses
|
132
|
+
end
|
133
|
+
|
134
|
+
after do
|
135
|
+
FileUtils.rm_rf(license_file)
|
136
|
+
end
|
137
|
+
|
138
|
+
it_behaves_like "correctly created licenses"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/spec/unit/manifest_spec.rb
CHANGED
@@ -71,6 +71,10 @@ module Omnibus
|
|
71
71
|
it "returns a build_git_revision if one was passed in" do
|
72
72
|
expect(Omnibus::Manifest.new("1.2.3", "e8e8e8").to_hash["build_git_revision"]).to eq("e8e8e8")
|
73
73
|
end
|
74
|
+
|
75
|
+
it "returns a license if one was passed in" do
|
76
|
+
expect(Omnibus::Manifest.new("1.2.3", "e8e8e8", "Apache").to_hash["license"]).to eq("Apache")
|
77
|
+
end
|
74
78
|
end
|
75
79
|
|
76
80
|
describe "#from_hash" do
|
@@ -105,6 +105,16 @@ module Omnibus
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
+
describe '#dist_tag' do
|
109
|
+
it 'is a DSL method' do
|
110
|
+
expect(subject).to have_exposed_method(:dist_tag)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'has a default value' do
|
114
|
+
expect(subject.dist_tag).to eq('.el6')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
108
118
|
describe '#id' do
|
109
119
|
it 'is :rpm' do
|
110
120
|
expect(subject.id).to eq(:rpm)
|
@@ -112,12 +122,24 @@ module Omnibus
|
|
112
122
|
end
|
113
123
|
|
114
124
|
describe '#package_name' do
|
115
|
-
|
116
|
-
|
125
|
+
context 'when dist_tag is enabled' do
|
126
|
+
before do
|
127
|
+
allow(subject).to receive(:safe_architecture).and_return('x86_64')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'includes the name, version, and build iteration' do
|
131
|
+
expect(subject.package_name).to eq('project-1.2.3-2.el6.x86_64.rpm')
|
132
|
+
end
|
117
133
|
end
|
118
134
|
|
119
|
-
|
120
|
-
|
135
|
+
context 'when dist_tag is disabled' do
|
136
|
+
before do
|
137
|
+
allow(subject).to receive(:dist_tag).and_return(false)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'excludes dist tag' do
|
141
|
+
expect(subject.package_name).to eq('project-1.2.3-2.x86_64.rpm')
|
142
|
+
end
|
121
143
|
end
|
122
144
|
end
|
123
145
|
|
@@ -254,6 +276,20 @@ module Omnibus
|
|
254
276
|
expect(contents).not_to include("BuildArch")
|
255
277
|
end
|
256
278
|
end
|
279
|
+
|
280
|
+
context 'when dist_tag is disabled' do
|
281
|
+
let(:spec_file) { "#{staging_dir}/SPECS/project-1.2.3-2.x86_64.rpm.spec" }
|
282
|
+
|
283
|
+
before do
|
284
|
+
allow(subject).to receive(:dist_tag).and_return(false)
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'has the correct release' do
|
288
|
+
subject.write_rpm_spec
|
289
|
+
contents = File.read(spec_file)
|
290
|
+
expect(contents).to include("Release: 2")
|
291
|
+
end
|
292
|
+
end
|
257
293
|
end
|
258
294
|
|
259
295
|
describe '#create_rpm_file' do
|
@@ -319,12 +355,6 @@ module Omnibus
|
|
319
355
|
end
|
320
356
|
end
|
321
357
|
|
322
|
-
describe '#dist_tag' do
|
323
|
-
it 'returns the Fedora packaging guidelines dist tag for the package' do
|
324
|
-
expect(subject.dist_tag).to eq('.el6')
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
358
|
describe '#safe_base_package_name' do
|
329
359
|
context 'when the project name is "safe"' do
|
330
360
|
it 'returns the value without logging a message' do
|
data/spec/unit/project_spec.rb
CHANGED
@@ -45,6 +45,9 @@ module Omnibus
|
|
45
45
|
it_behaves_like 'a cleanroom setter', :json_manifest_path, %|json_manifest_path '/path/to/manifest.txt'|
|
46
46
|
it_behaves_like 'a cleanroom setter', :build_git_revision, %|build_git_revision 'wombats'|
|
47
47
|
it_behaves_like 'a cleanroom getter', :files_path
|
48
|
+
it_behaves_like 'a cleanroom setter', :license, %|license 'Apache 2.0'|
|
49
|
+
it_behaves_like 'a cleanroom setter', :license_file, %|license_file 'LICENSES/artistic.txt'|
|
50
|
+
it_behaves_like 'a cleanroom setter', :license_file_path, %|license_file_path 'CHEF_LICENSE'|
|
48
51
|
|
49
52
|
describe 'basics' do
|
50
53
|
it 'returns a name' do
|
@@ -142,6 +145,18 @@ module Omnibus
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
148
|
+
describe '#license' do
|
149
|
+
it "sets the default to Unspecified" do
|
150
|
+
expect(subject.license).to eq ('Unspecified')
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#license_file_path' do
|
155
|
+
it "sets the default to LICENSE" do
|
156
|
+
expect(subject.license_file_path).to eq ('/sample/LICENSE')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
145
160
|
describe '#dirty!' do
|
146
161
|
let(:software) { double(Omnibus::Software) }
|
147
162
|
|
data/spec/unit/software_spec.rb
CHANGED
@@ -39,6 +39,8 @@ module Omnibus
|
|
39
39
|
it_behaves_like 'a cleanroom setter', :source, %|source url: 'https://source.example.com'|
|
40
40
|
it_behaves_like 'a cleanroom setter', :default_version, %|default_version '1.2.3'|
|
41
41
|
it_behaves_like 'a cleanroom setter', :version, %|version '1.2.3'|
|
42
|
+
it_behaves_like 'a cleanroom setter', :license, %|license 'Apache 2.0'|
|
43
|
+
it_behaves_like 'a cleanroom setter', :license_file, %|license_file 'LICENSES/artistic.txt'|
|
42
44
|
it_behaves_like 'a cleanroom setter', :whitelist_file, %|whitelist_file '/opt/whatever'|
|
43
45
|
it_behaves_like 'a cleanroom setter', :relative_path, %|relative_path '/path/to/extracted'|
|
44
46
|
it_behaves_like 'a cleanroom setter', :build, %|build {}|
|
@@ -56,6 +58,12 @@ module Omnibus
|
|
56
58
|
it_behaves_like 'a cleanroom getter', :project_file
|
57
59
|
end
|
58
60
|
|
61
|
+
context 'when no license is present' do
|
62
|
+
it "sets the defaults" do
|
63
|
+
expect(subject.license).to eq ('Unspecified')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
59
67
|
describe "with_standard_compiler_flags helper" do
|
60
68
|
context "on ubuntu" do
|
61
69
|
before { stub_ohai(platform: 'ubuntu', version: '12.04') }
|
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: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-sugar
|
@@ -330,6 +330,7 @@ files:
|
|
330
330
|
- lib/omnibus/health_check.rb
|
331
331
|
- lib/omnibus/instrumentation.rb
|
332
332
|
- lib/omnibus/library.rb
|
333
|
+
- lib/omnibus/licensing.rb
|
333
334
|
- lib/omnibus/logger.rb
|
334
335
|
- lib/omnibus/logging.rb
|
335
336
|
- lib/omnibus/manifest.rb
|
@@ -400,6 +401,7 @@ files:
|
|
400
401
|
- spec/functional/fetchers/net_fetcher_spec.rb
|
401
402
|
- spec/functional/fetchers/path_fetcher_spec.rb
|
402
403
|
- spec/functional/file_syncer_spec.rb
|
404
|
+
- spec/functional/licensing_spec.rb
|
403
405
|
- spec/functional/templating_spec.rb
|
404
406
|
- spec/spec_helper.rb
|
405
407
|
- spec/support/env_helpers.rb
|
@@ -497,6 +499,7 @@ test_files:
|
|
497
499
|
- spec/functional/fetchers/net_fetcher_spec.rb
|
498
500
|
- spec/functional/fetchers/path_fetcher_spec.rb
|
499
501
|
- spec/functional/file_syncer_spec.rb
|
502
|
+
- spec/functional/licensing_spec.rb
|
500
503
|
- spec/functional/templating_spec.rb
|
501
504
|
- spec/spec_helper.rb
|
502
505
|
- spec/support/env_helpers.rb
|