simp-rake-helpers 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6113186e329690af05d0b8ab80c1f9bcd49dce2d
4
- data.tar.gz: 5058893b87cabbc46c2644d82a70d1f2f1aecd8c
3
+ metadata.gz: f75d80c343427ef7c599ede4745e3130fbbb139a
4
+ data.tar.gz: 1b26121177b51da14a44b84eebf86bad97996160
5
5
  SHA512:
6
- metadata.gz: ef33179fc629100aab0347fba56ade32c1546c9b5b259daaaf726cd061b8fd9fab14dfc06f7584c7a4f1d5e53359a6ba1873805b5829040d0ee8c6d4701ea978
7
- data.tar.gz: a697cc85f44d2150ec67e47b13971cd2d06440c9e3a1b911446f9077a3b8707f66ec5989cf4448aa1910ac2712b2f06bfeceefc2f104f8dfca005870de394ae2
6
+ metadata.gz: 07f0e3a239091d9293de3d3fb882e42b0edd0f31348366298abad181905fb649e8b11cae4ac34fd81444edd557b71284e096fa1a5675b6fba68b66f12d872dba
7
+ data.tar.gz: 3b9d4028fd866e73073f0d8b90460a7f25a4c57a1312b014abc678064ac7401b0f83d8863cd35a9ccbf61386b8248077db46c7b03e3e97b65c647f9f21a9e92b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 4.1.1 / 2017-08-31
2
+ * Added the ability to read RPM release qualifier for checked out
3
+ module from `simp-core/build/rpm/dependencies.yaml`
4
+
1
5
  ### 4.1.0 / 2017-08-02
2
6
  * Added the ability to read from `simp-core/build/rpm/dependencies.yaml` in a
3
7
  checked out repo to add the necessary Obsoletes and Requires statements for
@@ -745,7 +745,7 @@ protect=1
745
745
  'dependencies.yaml')
746
746
 
747
747
  if File.exist?(rpm_dependency_file)
748
- rpm_dependency_metadata = YAML.load(File.read(rpm_dependency_file))
748
+ rpm_metadata = YAML.load(File.read(rpm_dependency_file))
749
749
  end
750
750
 
751
751
  metadata = Parallel.map(
@@ -769,10 +769,16 @@ protect=1
769
769
  # We're building a module, override anything down there
770
770
  if File.exist?('metadata.json')
771
771
 
772
- # Generate RPM dependency/obsoletes information from the
773
- # dependencies.yaml and the module's metadata.json
774
- Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(dir,
775
- rpm_dependency_metadata)
772
+ # Generate RPM metadata files
773
+ # - 'build/rpm_metadata/requires' file containing RPM
774
+ # dependency/obsoletes information from the
775
+ # 'dependencies.yaml' and the module's
776
+ # 'metadata.json'; always created
777
+ # - 'build/rpm_metadata/release' file containing RPM
778
+ # release qualifier from the 'dependencies.yaml';
779
+ # only created if release qualifier if specified in
780
+ # the 'dependencies.yaml'
781
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(dir, rpm_metadata)
776
782
 
777
783
  unique_namespace = (0...24).map{ (65 + rand(26)).chr }.join.downcase
778
784
 
@@ -7,7 +7,13 @@ module Simp::Rake::Build; end
7
7
  module Simp::Rake::Build::RpmDeps
8
8
 
9
9
  # returns array of RPM spec file 'Requires' lines derived
10
- # from a metadata.json dependency version specification.
10
+ # from a 'metadata.json' dependency version specification.
11
+ #
12
+ # +pkg+:: dependency package name
13
+ # +dep_version+:: dependency version string from a 'metadata.json'
14
+ #
15
+ # raises SIMPRpmDepVersionException if the dependency version
16
+ # string cannot be parsed
11
17
  def self.get_version_requires(pkg, dep_version)
12
18
  requires = []
13
19
  if dep_version =~ /^\s*(\d+\.\d+\.\d+)\s*$/
@@ -34,36 +40,58 @@ module Simp::Rake::Build::RpmDeps
34
40
  requires
35
41
  end
36
42
 
37
- # Generate 'Obsoletes' and 'Requires' lines, from a combination of
38
- # the module_dep_info and module_metadata. Only dependencies listed
39
- # in the module_dep_info hash will be included in the output. The
40
- # version requirements for each dependency will be pulled from
41
- # module_metadata.
43
+ # Generate 'Obsoletes' lines from obsoletes_hash.
42
44
  #
43
- # returns array of strings, each of which is an 'Obsoletes' or
44
- # 'Requires' line for use in an RPM spec file
45
- def self.generate_custom_rpm_requires(module_dep_info, module_metadata)
45
+ # returns array of strings, each of which is an 'Obsoletes' line for
46
+ # use in an RPM spec file
47
+ #
48
+ # +obsoletes_hash+:: Hash containing package names and their versions
49
+ # this module obsoletes from the `dependencies.yaml` file
50
+ # +module_metadata+:: Hash containing the contents of the module's
51
+ # 'metadata.json' file
52
+ def self.generate_custom_rpm_obsoletes(obsoletes_hash, module_metadata)
46
53
  rpm_metadata_content = []
47
54
 
48
- if module_dep_info[:obsoletes]
49
- module_dep_info[:obsoletes].each_pair do |pkg, version|
50
- module_version = module_metadata['version']
55
+ obsoletes_hash.each_pair do |pkg, version|
56
+ module_version = module_metadata['version']
51
57
 
52
- # We don't want to add this if we're building an older
53
- # version or the RPM will be malformed
54
- if Gem::Version.new(module_version) >
55
- Gem::Version.new(version.split('-').first)
58
+ # We don't want to add this if we're building an older
59
+ # version or the RPM will be malformed
60
+ if Gem::Version.new(module_version) >
61
+ Gem::Version.new(version.split('-').first)
56
62
 
57
- rpm_metadata_content << "Obsoletes: #{pkg} > #{version}"
58
- else
59
- puts "Ignoring 'obsoletes' for #{pkg}: module version" +
60
- " #{module_version} from metadata.json is not >" +
61
- " obsolete version #{version}"
62
- end
63
+ rpm_metadata_content << "Obsoletes: #{pkg} > #{version}"
64
+ else
65
+ puts "Ignoring 'obsoletes' for #{pkg}: module version" +
66
+ " #{module_version} from metadata.json is not >" +
67
+ " obsolete version #{version}"
63
68
  end
64
69
  end
70
+ rpm_metadata_content
71
+ end
72
+
73
+ # Generate 'Requires' lines, from a combination of the
74
+ # module_rpm_meta and module_metadata. Only dependencies listed
75
+ # in the module_rpm_meta hash will be included in the output. The
76
+ # version requirements for each dependency will be pulled from
77
+ # module_metadata.
78
+ #
79
+ # returns array of strings, each of which is a 'Requires' line
80
+ # for use in an RPM spec file
81
+ #
82
+ # raises SIMPRpmDepException if any 'metadata.json' dependency
83
+ # version string from module_metadata cannot be parsed or a
84
+ # dependency specified in module_rpm_meta is not found in
85
+ # module_metadata
86
+ #
87
+ # +requires_list+:: list of package this module should require
88
+ # from the 'dependencies.yaml'
89
+ # +module_metadata+:: Hash containing the contents of the
90
+ # module's 'metadata.json' file
91
+ def self.generate_custom_rpm_requires(requires_list, module_metadata)
92
+ rpm_metadata_content = []
65
93
 
66
- module_dep_info[:requires].each do |pkg|
94
+ requires_list.each do |pkg|
67
95
  pkg_parts = pkg.split(%r(-|/))[-2..-1]
68
96
 
69
97
  # Need to cover all base cases
@@ -96,67 +124,153 @@ module Simp::Rake::Build::RpmDeps
96
124
  #
97
125
  # returns array of strings, each of which is a 'Requires' line for
98
126
  # use in an RPM spec file
127
+ #
128
+ # raises SIMPRpmDepException if any 'metadata.json' dependency
129
+ # version string from module_metadata cannot be parsed
130
+ #
131
+ # +module_metadata+:: Hash containing the contents of the
132
+ # module's 'metadata.json' file
99
133
  def self.generate_module_rpm_requires(module_metadata)
100
134
  rpm_metadata_content = []
101
- module_metadata['dependencies'].each do |dep|
102
- pkg = "pupmod-#{dep['name'].gsub('/', '-')}"
103
- dep_version = dep['version_requirement']
135
+ # metadata.json should always contain dependencies list, even
136
+ # if it is empty, but we'll safely handle that error case here
137
+ if module_metadata['dependencies']
138
+ module_metadata['dependencies'].each do |dep|
139
+ pkg = "pupmod-#{dep['name'].gsub('/', '-')}"
140
+ dep_version = dep['version_requirement']
104
141
 
105
- begin
106
- rpm_metadata_content << get_version_requires(pkg, dep_version)
107
- rescue SIMPRpmDepVersionException => e
108
- err_msg = "Unable to parse #{dep['name']} dependency" +
109
- " version '#{dep_version}'"
110
- raise SIMPRpmDepException.new(err_msg)
142
+ begin
143
+ rpm_metadata_content << get_version_requires(pkg, dep_version)
144
+ rescue SIMPRpmDepVersionException => e
145
+ err_msg = "Unable to parse #{dep['name']} dependency" +
146
+ " version '#{dep_version}'"
147
+ raise SIMPRpmDepException.new(err_msg)
148
+ end
111
149
  end
112
150
  end
113
151
 
114
152
  rpm_metadata_content.flatten
115
153
  end
116
154
 
155
+ # Check to see if the contents of the requires file match the new requires info
156
+ #
157
+ # +new_requires_info+:: The new requires metadata Array
158
+ # +rpm_requires_file+:: The path to the module requires file
159
+ def self.rpm_requires_up_to_date?(new_requires, rpm_requires_file)
160
+ return false unless File.exist?(rpm_requires_file)
161
+
162
+ rpm_requires_content = File.read(rpm_requires_file).lines.map(&:strip) - ['']
163
+
164
+ return (new_requires.flatten - rpm_requires_content).empty?
165
+ end
166
+
117
167
  # Generate 'build/rpm_metadata/requires' file containing
118
- # 'Obsoletes' and/or 'Requires' lines for use in an RPM spec file
119
- # from a combination of the 'metadata.json' file in dir and
120
- # the rpm_dependency_metadata
121
- # hash.
122
- #
123
- # If the rpm_dependency_metadata hash as an entry for the
124
- # module named in the 'metadata.json' file, the generated
125
- # 'requires' file will contain
168
+ # 'Obsoletes' and/or 'Requires' lines for use in an RPM spec file.
169
+ #
170
+ # If the module_rpm_meta is not nil, the generated 'requires'
171
+ # file will contain
126
172
  # * 'Obsoletes' lines for any obsoletes specified in the
127
- # rpm_dependency_metadata hash
173
+ # module_rpm_meta hash
128
174
  # * 'Requires' lines for any requires specified in the
129
- # rpm_dependency_metadata hash, where the versions for those
130
- # dependencies are pulled from the 'metadata.json' file.
175
+ # module_rpm_meta hash, where the versions for those
176
+ # dependencies are pulled from module_metadata.
131
177
  #
132
178
  # Otherwise, the generated 'requires' file will contain
133
- # "Requires" lines for each dependency specified in the
134
- # 'metadata.json' file.
135
- def self.generate_rpm_requires_file(dir, rpm_dependency_metadata)
179
+ # "Requires" lines for each dependency specified module_metadata.
180
+ #
181
+ # raises SIMPRpmDepException if any 'metadata.json' dependency
182
+ # version string from module_metadata cannot be parsed or a
183
+ # dependency specified in module_rpm_meta is not found in
184
+ # module_metadata
185
+ #
186
+ # +dir+:: module root directory
187
+ # +module_metadata+:: Hash containing the contents of the
188
+ # module's 'metadata.json' file
189
+ # +module_rpm_meta+:: module entry from the top-level
190
+ # 'dependencies.yaml' file or nil, if no entry exists
191
+ def self.generate_rpm_requires_file(dir, module_metadata, module_rpm_meta)
192
+ rpm_metadata_content = []
193
+ if module_rpm_meta and module_rpm_meta[:obsoletes]
194
+ rpm_metadata_content = generate_custom_rpm_obsoletes(module_rpm_meta[:obsoletes], module_metadata)
195
+ end
196
+
197
+ if module_rpm_meta and module_rpm_meta[:requires]
198
+ rpm_metadata_content += generate_custom_rpm_requires(module_rpm_meta[:requires], module_metadata)
199
+ else
200
+ rpm_metadata_content += generate_module_rpm_requires(module_metadata)
201
+ end
202
+
203
+ rpm_metadata_file = File.join(dir, 'build', 'rpm_metadata', 'requires')
204
+
205
+ unless rpm_requires_up_to_date?(rpm_metadata_content, rpm_metadata_file)
206
+ FileUtils.mkdir_p(File.dirname(rpm_metadata_file))
207
+ File.open(rpm_metadata_file, 'w') do |fh|
208
+ fh.puts(rpm_metadata_content.flatten.join("\n"))
209
+ fh.flush
210
+ end
211
+ end
212
+ end
213
+
214
+ # Check to see if the contents of the release file match the new release info
215
+ #
216
+ # +new_release_info+:: The new release metadata string
217
+ # +rpm_release_file+:: The path to the module release file
218
+ def self.release_file_up_to_date?(new_release_info, rpm_release_file)
219
+ return false unless File.exist?(rpm_release_file)
220
+
221
+ return File.read(rpm_release_file).strip == new_release_info.strip
222
+ end
223
+
224
+ # Generate 'build/rpm_metadata/release' file containing release qualifier
225
+ # specified in the module_rpm_meta
226
+ #
227
+ # +dir+:: module root directory
228
+ # +module_rpm_meta+:: module entry from the top-level
229
+ # 'dependencies.yaml' file or nil, if no entry exists
230
+ def self.generate_rpm_release_file(dir, module_rpm_meta)
231
+ return unless (module_rpm_meta and module_rpm_meta[:release])
232
+
233
+ rpm_release_file = File.join(dir, 'build', 'rpm_metadata', 'release')
234
+
235
+ unless release_file_up_to_date?(module_rpm_meta[:release], rpm_release_file)
236
+ FileUtils.mkdir_p(File.dirname(rpm_release_file))
237
+ File.open(rpm_release_file, 'w') do |fh|
238
+ fh.puts('# release set by simp-core dependencies.yaml')
239
+ fh.puts(module_rpm_meta[:release])
240
+ fh.flush
241
+ end
242
+ end
243
+ end
244
+
245
+ # Generate RPM metadata files
246
+ # * 'build/rpm_metadata/requires' file containing RPM
247
+ # dependency/obsoletes information from the 'dependencies.yaml'
248
+ # and the module's 'metadata.json'; always created
249
+ # * 'build/rpm_metadata/release' file containing RPM release
250
+ # qualifier from the 'dependencies.yaml'; only created if release
251
+ # qualifier if specified in the 'dependencies.yaml'
252
+ #
253
+ # raises SIMPRpmDepException if any 'metadata.json' dependency
254
+ # version string from module_metadata cannot be parsed or a
255
+ # dependency specified in module_rpm_meta is not found in
256
+ # module_metadata
257
+ #
258
+ # +dir+:: module root directory
259
+ # +rpm_metadata+:: contents of top-level 'dependencies.yaml' file
260
+ def self.generate_rpm_meta_files(dir, rpm_metadata)
136
261
  require 'json'
137
262
 
138
263
  metadata_json_file = File.join(dir, 'metadata.json')
139
264
  module_metadata = JSON.parse(File.read(metadata_json_file))
140
265
  module_name = module_metadata['name'].split(%r(-|/)).last
266
+ module_rpm_meta = rpm_metadata[module_name]
141
267
 
142
- module_dep_info = rpm_dependency_metadata[module_name]
143
- rpm_metadata_content = []
144
268
  begin
145
- if module_dep_info
146
- rpm_metadata_content = generate_custom_rpm_requires(module_dep_info, module_metadata)
147
- else
148
- rpm_metadata_content = generate_module_rpm_requires(module_metadata)
149
- end
269
+ generate_rpm_requires_file(dir, module_metadata, module_rpm_meta)
150
270
  rescue SIMPRpmDepException => e
151
271
  fail "#{e.message} in #{metadata_json_file}"
152
272
  end
153
273
 
154
- rpm_metadata_file = File.join(dir, 'build', 'rpm_metadata', 'requires')
155
-
156
- FileUtils.mkdir_p(File.dirname(rpm_metadata_file))
157
- File.open(rpm_metadata_file, 'w') do |fh|
158
- fh.puts(rpm_metadata_content.flatten.join("\n"))
159
- fh.flush
160
- end
274
+ generate_rpm_release_file(dir, module_rpm_meta)
161
275
  end
162
276
  end
@@ -2,5 +2,5 @@ module Simp; end
2
2
  module Simp::Rake; end
3
3
 
4
4
  class Simp::Rake::Helpers
5
- VERSION = '4.1.0'
5
+ VERSION = '4.1.1'
6
6
  end
data/lib/simp/rake/pkg.rb CHANGED
@@ -48,9 +48,7 @@ module Simp::Rake
48
48
  @clean_list = []
49
49
  @ignore_changes_list = [
50
50
  'Gemfile.lock',
51
- 'spec/fixtures/modules',
52
- 'build/rpm_metadata', # this is generated
53
- 'build/rpm_metadata/requires' # this is generated
51
+ 'spec/fixtures/modules'
54
52
  ]
55
53
  @chroot_name = unique_name
56
54
 
@@ -21,6 +21,9 @@
21
21
  - 'pupmod-puppetlabs-stdlib'
22
22
  - 'pupmod-ceritsc-yum'
23
23
  - 'pupmod-richardc-datacat'
24
+ :release: '2017.0'
25
+ 'release_only_mod':
26
+ :release: '2017.2'
24
27
  'obsoletes_too_new_mod':
25
28
  :obsoletes:
26
29
  'pupmod-oldowner-obsoletes_too_new_mod': '2.5.0-2016.1'
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "owner-release_only_mod",
3
+ "version": "0.11.0",
4
+ "source": "https://github.com/owner/puppet-release_only_mod",
5
+ "author": "owner",
6
+ "license": "Apache-2.0",
7
+ "summary": "Module for release_only_mod",
8
+ "description": "Module for release_only_mod",
9
+ "project_page": "https://github.com/owner/puppet-release_only_mod",
10
+ "issues_url": "https://github.com/owner/puppet-release_only_mod/issues",
11
+ "dependencies": [
12
+ {
13
+ "name": "puppetlabs/stdlib",
14
+ "version_requirement": ">= 3.2.0 < 5.0.0"
15
+ }
16
+ ],
17
+ "operatingsystem_support": [
18
+ {
19
+ "operatingsystem": "RedHat",
20
+ "operatingsystemrelease": [
21
+ "5",
22
+ "6",
23
+ "7"
24
+ ]
25
+ },
26
+ {
27
+ "operatingsystem": "CentOS",
28
+ "operatingsystemrelease": [
29
+ "5",
30
+ "6",
31
+ "7"
32
+ ]
33
+ }
34
+ ],
35
+ "requirements": [
36
+ {
37
+ "name": "pe",
38
+ "version_requirement": ">= 3.3.2"
39
+ },
40
+ {
41
+ "name": "puppet",
42
+ "version_requirement": ">=3.2.0 <4.3.0"
43
+ }
44
+ ]
45
+ }
@@ -6,7 +6,7 @@ describe 'Simp::Rake::Build::RpmDeps#get_version_requires' do
6
6
  let(:pkg) { 'pupmod-foo-bar' }
7
7
 
8
8
  context 'with valid version specifications' do
9
- {
9
+ {
10
10
  "1.0.0" => ['Requires: pupmod-foo-bar = 1.0.0'],
11
11
  "> 2.0.0" => ['Requires: pupmod-foo-bar > 2.0.0'],
12
12
  "< 3.0.0" => ['Requires: pupmod-foo-bar < 3.0.0'],
@@ -25,24 +25,26 @@ describe 'Simp::Rake::Build::RpmDeps#get_version_requires' do
25
25
 
26
26
  context 'with invalid version specifications' do
27
27
  it do
28
- expect{ Simp::Rake::Build::RpmDeps::get_version_requires(pkg,
29
- '1.0.0.1') }.to raise_error(SIMPRpmDepVersionException)
28
+ expect{
29
+ Simp::Rake::Build::RpmDeps::get_version_requires(pkg, '1.0.0.1')
30
+ }.to raise_error(SIMPRpmDepVersionException)
30
31
  end
31
32
 
32
33
  # FIXME regex doesn't catch this
33
34
  pending do
34
- expect{ Simp::Rake::Build::RpmDeps::get_version_requires(pkg,
35
- '<= 3.0.0') }.to raise_error(SIMPRpmDepVersionException)
35
+ expect{
36
+ Simp::Rake::Build::RpmDeps::get_version_requires(pkg, '<= 3.0.0')
37
+ }.to raise_error(SIMPRpmDepVersionException)
36
38
  end
37
39
  end
38
40
  end
39
41
 
40
- describe 'Simp::Rake::Build::RpmDeps#generate_rpm_requires_file' do
42
+ describe 'Simp::Rake::Build::RpmDeps#generate_rpm_meta_files' do
41
43
  let(:files_dir) { File.join(File.dirname(__FILE__), 'files') }
42
- let(:rpm_dependency_metadata) {
44
+ let(:rpm_metadata) {
43
45
  YAML.load(File.read(File.join(files_dir, 'dependencies.yaml')))
44
46
  }
45
-
47
+
46
48
  before :each do
47
49
  @tmp_dir = Dir.mktmpdir( File.basename( __FILE__ ) )
48
50
  FileUtils.cp_r(files_dir, @tmp_dir)
@@ -55,8 +57,7 @@ describe 'Simp::Rake::Build::RpmDeps#generate_rpm_requires_file' do
55
57
  context 'managed component with a name change (obsoletes)' do
56
58
  it 'should generate requires file with obsoletes' do
57
59
  mod_dir = File.join(@tmp_dir, 'files', 'changed_name_mod')
58
- Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
59
- rpm_dependency_metadata)
60
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
60
61
 
61
62
  requires_file = File.join(mod_dir, 'build', 'rpm_metadata', 'requires')
62
63
  expect(File.exist?(requires_file)).to be true
@@ -74,14 +75,16 @@ Requires: pupmod-foo6-bar6 < 7.0.0
74
75
  EOM
75
76
  actual = IO.read(requires_file)
76
77
  expect(actual).to eq expected
78
+
79
+ release_file = File.join(mod_dir, 'build', 'rpm_metadata', 'release')
80
+ expect(File.exist?(release_file)).to be false
77
81
  end
78
82
  end
79
83
 
80
- context 'managed component with a subset of metadata.json dependencies' do
81
- it 'should generate requires file with dependencies only from dependencies.yaml' do
84
+ context 'managed component with a subset of metadata.json dependencies and a release' do
85
+ it 'should generate both a requires file and a release file from dependencies.yaml' do
82
86
  mod_dir = File.join(@tmp_dir, 'files', 'managed_mod')
83
- Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
84
- rpm_dependency_metadata)
87
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
85
88
 
86
89
  requires_file = File.join(mod_dir, 'build', 'rpm_metadata', 'requires')
87
90
  expect(File.exist?(requires_file)).to be true
@@ -97,14 +100,38 @@ Requires: pupmod-richardc-datacat < 1.0.0
97
100
  EOM
98
101
  actual = IO.read(requires_file)
99
102
  expect(actual).to eq expected
103
+
104
+ release_file = File.join(mod_dir, 'build', 'rpm_metadata', 'release')
105
+ expect(File.exist?(release_file)).to be true
106
+ expect(IO.read(release_file)).to match(/^2017.0$/)
107
+ end
108
+ end
109
+
110
+ context 'managed component with only a release' do
111
+ it 'should generate a release file from dependencies.yaml' do
112
+ mod_dir = File.join(@tmp_dir, 'files', 'release_only_mod')
113
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
114
+
115
+ requires_file = File.join(mod_dir, 'build', 'rpm_metadata', 'requires')
116
+ expect(File.exist?(requires_file)).to be true
117
+
118
+ expected = <<EOM
119
+ Requires: pupmod-puppetlabs-stdlib >= 3.2.0
120
+ Requires: pupmod-puppetlabs-stdlib < 5.0.0
121
+ EOM
122
+ actual = IO.read(requires_file)
123
+ expect(actual).to eq expected
124
+
125
+ release_file = File.join(mod_dir, 'build', 'rpm_metadata', 'release')
126
+ expect(File.exist?(release_file)).to be true
127
+ expect(IO.read(release_file)).to match(/^2017.2$/)
100
128
  end
101
129
  end
102
130
 
103
131
  context 'unmanaged component' do
104
132
  it 'should replace requires file with metadata.json dependencies' do
105
133
  mod_dir = File.join(@tmp_dir, 'files', 'unmanaged_mod')
106
- Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
107
- rpm_dependency_metadata)
134
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
108
135
 
109
136
  # expected should overwritten with simply dependencies in order
110
137
  # they were listed in metadata.json
@@ -127,14 +154,16 @@ EOM
127
154
  original = IO.readlines(File.join(files_dir, 'unmanaged_mod',
128
155
  'build', 'rpm_metadata', 'requires'))
129
156
  expect(actual).to_not eq original
157
+
158
+ release_file = File.join(mod_dir, 'build', 'rpm_metadata', 'release')
159
+ expect(File.exist?(release_file)).to be false
130
160
  end
131
161
  end
132
162
 
133
163
  context 'ignores obsoletes when version obsoleted is newer than this version' do
134
164
  it 'should generate requires file with no obsoletes' do
135
165
  mod_dir = File.join(@tmp_dir, 'files', 'obsoletes_too_new_mod')
136
- Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
137
- rpm_dependency_metadata)
166
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
138
167
 
139
168
  requires_file = File.join(mod_dir, 'build', 'rpm_metadata', 'requires')
140
169
  expect(File.exist?(requires_file)).to be true
@@ -153,8 +182,9 @@ EOM
153
182
  it 'should fail when dep in depedencies.yaml is not found in metadata.json' do
154
183
  mod_dir = File.join(@tmp_dir, 'files', 'unknown_dep_mod')
155
184
  err_msg = "Could not find oops/unknown dependency in #{mod_dir}/metadata.json"
156
- expect { Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
157
- rpm_dependency_metadata) }.to raise_error(err_msg)
185
+ expect {
186
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
187
+ }.to raise_error(err_msg)
158
188
  end
159
189
  end
160
190
 
@@ -162,18 +192,19 @@ EOM
162
192
  it 'should fail for managed component with invalid dep version in metadata.json' do
163
193
  mod_dir = File.join(@tmp_dir, 'files', 'malformed_dep_meta_mod')
164
194
  err_msg = "Unable to parse foo1/bar1 dependency version '1.0.0.1' in #{mod_dir}/metadata.json"
165
- expect { Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
166
- rpm_dependency_metadata) }.to raise_error(err_msg)
195
+ expect {
196
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_metadata)
197
+ }.to raise_error(err_msg)
167
198
  end
168
199
 
169
200
  it 'should fail for unmanaged component with invalid dep version in metadata.json' do
170
- rpm_dep_meta = rpm_dependency_metadata.dup
171
- rpm_dep_meta ['malformed_dep_meta_mod'] = nil
172
- puts rpm_dep_meta
201
+ rpm_meta = rpm_metadata.dup
202
+ rpm_meta ['malformed_dep_meta_mod'] = nil
173
203
  mod_dir = File.join(@tmp_dir, 'files', 'malformed_dep_meta_mod')
174
204
  err_msg = "Unable to parse foo1/bar1 dependency version '1.0.0.1' in #{mod_dir}/metadata.json"
175
- expect { Simp::Rake::Build::RpmDeps::generate_rpm_requires_file(mod_dir,
176
- rpm_dep_meta) }.to raise_error(err_msg)
205
+ expect {
206
+ Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(mod_dir, rpm_meta)
207
+ }.to raise_error(err_msg)
177
208
  end
178
209
  end
179
210
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-rake-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-30 00:00:00.000000000 Z
12
+ date: 2017-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -487,6 +487,7 @@ files:
487
487
  - spec/lib/simp/rake/build/files/malformed_dep_meta_mod/metadata.json
488
488
  - spec/lib/simp/rake/build/files/managed_mod/metadata.json
489
489
  - spec/lib/simp/rake/build/files/obsoletes_too_new_mod/metadata.json
490
+ - spec/lib/simp/rake/build/files/release_only_mod/metadata.json
490
491
  - spec/lib/simp/rake/build/files/unknown_dep_mod/metadata.json
491
492
  - spec/lib/simp/rake/build/files/unmanaged_mod/build/rpm_metadata/requires
492
493
  - spec/lib/simp/rake/build/files/unmanaged_mod/metadata.json
@@ -555,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
556
  version: '0'
556
557
  requirements: []
557
558
  rubyforge_project:
558
- rubygems_version: 2.6.11
559
+ rubygems_version: 2.6.13
559
560
  signing_key:
560
561
  specification_version: 4
561
562
  summary: SIMP rake helpers