simp-rake-helpers 2.5.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -1
- data/lib/simp/rake/build/iso.rb +11 -2
- data/lib/simp/rake/build/pkg.rb +60 -65
- data/lib/simp/rake/build/tar.rb +3 -0
- data/lib/simp/rake/build/vermap.yaml +1 -0
- data/lib/simp/rake/helpers/rpm_spec.rb +8 -370
- data/lib/simp/rake/helpers/rpm_spec/assets/simp4.spec +387 -0
- data/lib/simp/rake/helpers/rpm_spec/assets/simp5.spec +387 -0
- data/lib/simp/rake/helpers/rpm_spec/assets/simpdefault.spec +356 -0
- data/lib/simp/rake/helpers/version.rb +1 -1
- data/lib/simp/rake/pkg.rb +63 -60
- data/lib/simp/rpm.rb +52 -25
- data/spec/acceptance/files/simplib/CHANGELOG +2 -0
- data/spec/acceptance/files/simplib/Rakefile +3 -0
- data/spec/acceptance/files/simplib/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/simplib/metadata.json +33 -0
- data/spec/acceptance/files/testpackage_missing_license/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_license/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_license/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_license/metadata.json +32 -0
- data/spec/acceptance/files/testpackage_missing_metadata_file/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_metadata_file/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_metadata_file/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_name/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_name/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_name/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_name/metadata.json +32 -0
- data/spec/acceptance/files/testpackage_missing_source/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_source/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_source/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_source/metadata.json +32 -0
- data/spec/acceptance/files/testpackage_missing_summary/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_summary/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_summary/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_summary/metadata.json +32 -0
- data/spec/acceptance/files/testpackage_missing_version/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_missing_version/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_missing_version/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_missing_version/metadata.json +32 -0
- data/spec/acceptance/files/testpackage_with_bad_changelog_date/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_with_bad_changelog_date/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_with_bad_changelog_date/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_with_bad_changelog_date/metadata.json +33 -0
- data/spec/acceptance/files/testpackage_with_release/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_with_release/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_with_release/build/rpm_metadata/release +1 -0
- data/spec/acceptance/files/testpackage_with_release/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_with_release/metadata.json +33 -0
- data/spec/acceptance/files/testpackage_without_changelog/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_without_changelog/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_without_changelog/metadata.json +33 -0
- data/spec/acceptance/pkg_rpm_spec.rb +215 -41
- metadata +44 -2
@@ -0,0 +1,356 @@
|
|
1
|
+
%{lua:
|
2
|
+
|
3
|
+
--
|
4
|
+
-- When you build you must to pass this along so that we know how
|
5
|
+
-- to get the preliminary information.
|
6
|
+
-- This directory should hold the following items:
|
7
|
+
-- * 'build/rpm_metadata/requires' <- optional list of 'Requires', 'Provides',
|
8
|
+
-- and 'Obsoletes' to supplement those auto-generated in this spec file
|
9
|
+
-- * 'build/rpm_metadata/release' <- optional RPM release number to use in
|
10
|
+
-- lieu of number hard-coded in this spec file
|
11
|
+
-- * 'CHANGELOG' <- optional RPM formatted Changelog to use in lieu of minimal,
|
12
|
+
-- changelog entry auto-generated in this spec file
|
13
|
+
-- * 'metadata.json' <- required file that must contain the following metadata:
|
14
|
+
-- - 'name' - package name
|
15
|
+
-- - 'version' - package version
|
16
|
+
-- - 'license' - package license
|
17
|
+
-- - 'summary' - package summary
|
18
|
+
-- - 'source' - package source
|
19
|
+
--
|
20
|
+
-- Example:
|
21
|
+
-- rpmbuild -D 'pup_module_info_dir /home/user/project/puppet_module' -ba SPECS/specfile.spec
|
22
|
+
--
|
23
|
+
-- If this is not found, we will look in %{_sourcedir} for the files and fall
|
24
|
+
-- back to the current directory
|
25
|
+
--
|
26
|
+
|
27
|
+
src_dir = rpm.expand('%{pup_module_info_dir}')
|
28
|
+
|
29
|
+
if string.match(src_dir, '^%%') or (posix.stat(src_dir, 'type') ~= 'directory') then
|
30
|
+
src_dir = rpm.expand('%{_sourcedir}')
|
31
|
+
|
32
|
+
if (posix.stat((src_dir .. "/metadata.json"), 'type') ~= 'regular') then
|
33
|
+
src_dir = './'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
-- These UNKNOWN entries should break the build if something bad happens
|
38
|
+
|
39
|
+
package_name = "UNKNOWN"
|
40
|
+
package_version = "UNKNOWN"
|
41
|
+
module_license = "UNKNOWN"
|
42
|
+
|
43
|
+
--
|
44
|
+
-- Default to 2016
|
45
|
+
-- This was done due to the change in naming scheme across all of the modules.
|
46
|
+
-- The '.1' bump is there for the SIMP 6 path changes
|
47
|
+
--
|
48
|
+
|
49
|
+
package_release = '2016.1'
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
%{lua:
|
54
|
+
-- Pull the Relevant Metadata out of the Puppet module metadata.json.
|
55
|
+
|
56
|
+
metadata = ''
|
57
|
+
metadata_file = io.open(src_dir .. "/metadata.json","r")
|
58
|
+
if metadata_file then
|
59
|
+
metadata = metadata_file:read("*all")
|
60
|
+
|
61
|
+
-- Ignore the first curly brace
|
62
|
+
metadata = metadata:gsub("{}?", '|', 1)
|
63
|
+
|
64
|
+
-- Ignore all keys that are below the first level
|
65
|
+
metadata = metadata:gsub("{.-}", '')
|
66
|
+
metadata = metadata:gsub("%[.-%]", '')
|
67
|
+
else
|
68
|
+
error("Could not open 'metadata.json'", 0)
|
69
|
+
end
|
70
|
+
|
71
|
+
-- This starts as an empty string so that we can build it later
|
72
|
+
module_requires = ''
|
73
|
+
|
74
|
+
}
|
75
|
+
|
76
|
+
%{lua:
|
77
|
+
|
78
|
+
-- Get the Module Name and put it in the correct format
|
79
|
+
|
80
|
+
local name_match = string.match(metadata, '"name":%s+"(.-)"%s*,')
|
81
|
+
|
82
|
+
module_author = ''
|
83
|
+
module_name = ''
|
84
|
+
|
85
|
+
if name_match then
|
86
|
+
package_name = ('pupmod-' .. name_match)
|
87
|
+
|
88
|
+
local i = 0
|
89
|
+
for str in string.gmatch(name_match,'[^-]+') do
|
90
|
+
if i == 0 then
|
91
|
+
module_author = str
|
92
|
+
else
|
93
|
+
if module_name == '' then
|
94
|
+
module_name = str
|
95
|
+
else
|
96
|
+
module_name = (module_name .. '-' .. str)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
i = i+1
|
101
|
+
end
|
102
|
+
else
|
103
|
+
error("Could not find valid package name in 'metadata.json'", 0)
|
104
|
+
end
|
105
|
+
|
106
|
+
}
|
107
|
+
|
108
|
+
%{lua:
|
109
|
+
|
110
|
+
-- Get the Module Version
|
111
|
+
|
112
|
+
local version_match = string.match(metadata, '"version":%s+"(.-)"%s*,')
|
113
|
+
|
114
|
+
if version_match then
|
115
|
+
package_version = version_match
|
116
|
+
else
|
117
|
+
error("Could not find valid package version in 'metadata.json'", 0)
|
118
|
+
end
|
119
|
+
|
120
|
+
}
|
121
|
+
|
122
|
+
%{lua:
|
123
|
+
|
124
|
+
-- Get the Module License
|
125
|
+
|
126
|
+
local license_match = string.match(metadata, '"license":%s+"(.-)"%s*,')
|
127
|
+
|
128
|
+
if license_match then
|
129
|
+
module_license = license_match
|
130
|
+
else
|
131
|
+
error("Could not find valid package license in 'metadata.json'", 0)
|
132
|
+
end
|
133
|
+
|
134
|
+
}
|
135
|
+
|
136
|
+
%{lua:
|
137
|
+
|
138
|
+
-- Get the Module Summary
|
139
|
+
|
140
|
+
local summary_match = string.match(metadata, '"summary":%s+"(.-)"%s*,')
|
141
|
+
|
142
|
+
if summary_match then
|
143
|
+
module_summary = summary_match
|
144
|
+
else
|
145
|
+
error("Could not find valid package summary in 'metadata.json'", 0)
|
146
|
+
end
|
147
|
+
|
148
|
+
}
|
149
|
+
|
150
|
+
%{lua:
|
151
|
+
|
152
|
+
-- Get the Module Source line for the URL string
|
153
|
+
|
154
|
+
local source_match = string.match(metadata, '"source":%s+"(.-)"%s*,')
|
155
|
+
|
156
|
+
if source_match then
|
157
|
+
module_source = source_match
|
158
|
+
else
|
159
|
+
error("Could not find valid package source in 'metadata.json'", 0)
|
160
|
+
end
|
161
|
+
|
162
|
+
}
|
163
|
+
|
164
|
+
%{lua:
|
165
|
+
|
166
|
+
-- Snag the RPM-specific items out of the 'build/rpm_metadata' directory
|
167
|
+
|
168
|
+
-- First, the Release Number
|
169
|
+
|
170
|
+
rel_file = io.open(src_dir .. "/build/rpm_metadata/release", "r")
|
171
|
+
|
172
|
+
if not rel_file then
|
173
|
+
-- Need this for the SRPM case
|
174
|
+
rel_file = io.open(src_dir .. "/release", "r")
|
175
|
+
end
|
176
|
+
|
177
|
+
if rel_file then
|
178
|
+
for line in rel_file:lines() do
|
179
|
+
is_comment = string.match(line, "^%s*#")
|
180
|
+
is_blank = string.match(line, "^%s*$")
|
181
|
+
|
182
|
+
if not (is_comment or is_blank) then
|
183
|
+
package_release = line
|
184
|
+
break
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
%{lua:
|
192
|
+
|
193
|
+
-- Next, the Requirements
|
194
|
+
req_file = io.open(src_dir .. "/build/rpm_metadata/requires", "r")
|
195
|
+
|
196
|
+
if not req_file then
|
197
|
+
-- Need this for the SRPM case
|
198
|
+
req_file = io.open(src_dir .. "/requires", "r")
|
199
|
+
end
|
200
|
+
|
201
|
+
if req_file then
|
202
|
+
for line in req_file:lines() do
|
203
|
+
valid_line = (string.match(line, "^Requires: ") or string.match(line, "^Obsoletes: ") or string.match(line, "^Provides: "))
|
204
|
+
|
205
|
+
if valid_line then
|
206
|
+
module_requires = (module_requires .. "\n" .. line)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
}
|
211
|
+
|
212
|
+
%define module_name %{lua: print(module_name)}
|
213
|
+
%define package_name %{lua: print(package_name)}
|
214
|
+
|
215
|
+
Summary: %{module_name} Puppet Module
|
216
|
+
Name: %{package_name}
|
217
|
+
|
218
|
+
Version: %{lua: print(package_version)}
|
219
|
+
Release: %{lua: print(package_release)}
|
220
|
+
License: %{lua: print(module_license)}
|
221
|
+
Group: Applications/System
|
222
|
+
Source0: %{package_name}-%{version}-%{release}.tar.gz
|
223
|
+
Source1: %{lua: print("metadata.json")}
|
224
|
+
%{lua:
|
225
|
+
-- Include our sources as appropriate
|
226
|
+
changelog = io.open(src_dir .. "/CHANGELOG","r")
|
227
|
+
if changelog then
|
228
|
+
print("Source2: " .. "CHANGELOG\n")
|
229
|
+
end
|
230
|
+
|
231
|
+
if rel_file then
|
232
|
+
print("Source3: " .. "release\n")
|
233
|
+
end
|
234
|
+
if req_file then
|
235
|
+
print("Source4: " .. "requires\n")
|
236
|
+
end
|
237
|
+
}
|
238
|
+
URL: %{lua: print(module_source)}
|
239
|
+
BuildRoot: %{_tmppath}/%{package_name}-%{version}-%{release}-buildroot
|
240
|
+
BuildArch: noarch
|
241
|
+
|
242
|
+
Requires(pre,preun,post,postun): simp-adapter >= 0.0.1
|
243
|
+
|
244
|
+
%if ("%{package_name}" != "pupmod-simp-simplib") && ("%{package_name}" != "pupmod-puppetlabs-stdlib")
|
245
|
+
Requires: pupmod-simp-simplib >= 1.2.6
|
246
|
+
%endif
|
247
|
+
|
248
|
+
%if "%{package_name}" != "pupmod-puppetlabs-stdlib"
|
249
|
+
Requires: pupmod-puppetlabs-stdlib >= 4.9.0
|
250
|
+
Requires: pupmod-puppetlabs-stdlib < 6.0.0
|
251
|
+
%endif
|
252
|
+
|
253
|
+
%{lua: print(module_requires)}
|
254
|
+
|
255
|
+
Provides: pupmod-%{lua: print(module_name)} = %{lua: print(package_version .. "-" .. package_release)}
|
256
|
+
Obsoletes: pupmod-%{lua: print(module_name)} < %{lua: print(package_version .. "-" .. package_release)}
|
257
|
+
|
258
|
+
%{lua:
|
259
|
+
|
260
|
+
-- This is a workaround for the 'simp-rsync' real RPM conflict but is
|
261
|
+
-- required by some external modules.
|
262
|
+
-- This should be removed when SIMP 6 is stable
|
263
|
+
|
264
|
+
author_rpm_name = module_author .. "-" .. module_name
|
265
|
+
|
266
|
+
if author_rpm_name ~= 'simp-rsync' then
|
267
|
+
print("Provides: " .. author_rpm_name .. " = " .. package_version .. "-" .. package_release .. "\n")
|
268
|
+
print("Obsoletes: " .. author_rpm_name .. " < " .. package_version .. "-" .. package_release .. "\n")
|
269
|
+
end
|
270
|
+
}
|
271
|
+
|
272
|
+
Prefix: /usr/share/simp/modules
|
273
|
+
|
274
|
+
%description
|
275
|
+
%{lua: print(module_summary)}
|
276
|
+
|
277
|
+
%prep
|
278
|
+
%setup -q -n %{package_name}-%{version}
|
279
|
+
|
280
|
+
%build
|
281
|
+
|
282
|
+
%install
|
283
|
+
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
|
284
|
+
|
285
|
+
mkdir -p %{buildroot}/%{prefix}
|
286
|
+
|
287
|
+
curdir=`pwd`
|
288
|
+
dirname=`basename $curdir`
|
289
|
+
cp -r ../$dirname %{buildroot}/%{prefix}/%{module_name}
|
290
|
+
rm -rf %{buildroot}/%{prefix}/%{module_name}/.git
|
291
|
+
rm -f %{buildroot}/%{prefix}/*.lock
|
292
|
+
rm -rf %{buildroot}/%{prefix}/spec/fixtures/modules
|
293
|
+
rm -rf %{buildroot}/%{prefix}/dist
|
294
|
+
rm -rf %{buildroot}/%{prefix}/junit
|
295
|
+
rm -rf %{buildroot}/%{prefix}/log
|
296
|
+
|
297
|
+
%clean
|
298
|
+
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
|
299
|
+
|
300
|
+
mkdir -p %{buildroot}/%{prefix}
|
301
|
+
|
302
|
+
%files
|
303
|
+
%defattr(0640,root,root,0750)
|
304
|
+
%{prefix}/%{module_name}
|
305
|
+
|
306
|
+
# when $1 = 1, this is an install
|
307
|
+
# when $1 = 2, this is an upgrade
|
308
|
+
%pre
|
309
|
+
/usr/local/sbin/simp_rpm_helper --rpm_dir=%{prefix}/%{module_name} --rpm_section='pre' --rpm_status=$1
|
310
|
+
|
311
|
+
# when $1 = 1, this is an install
|
312
|
+
# when $1 = 2, this is an upgrade
|
313
|
+
%post
|
314
|
+
/usr/local/sbin/simp_rpm_helper --rpm_dir=%{prefix}/%{module_name} --rpm_section='post' --rpm_status=$1
|
315
|
+
|
316
|
+
# when $1 = 1, this is the uninstall of the previous version during an upgrade
|
317
|
+
# when $1 = 0, this is the uninstall of the only version during an erase
|
318
|
+
%preun
|
319
|
+
/usr/local/sbin/simp_rpm_helper --rpm_dir=%{prefix}/%{module_name} --rpm_section='preun' --rpm_status=$1
|
320
|
+
|
321
|
+
# when $1 = 1, this is the uninstall of the previous version during an upgrade
|
322
|
+
# when $1 = 0, this is the uninstall of the only version during an erase
|
323
|
+
%postun
|
324
|
+
/usr/local/sbin/simp_rpm_helper --rpm_dir=%{prefix}/%{module_name} --rpm_section='postun' --rpm_status=$1
|
325
|
+
|
326
|
+
%changelog
|
327
|
+
%{lua:
|
328
|
+
-- Finally, the CHANGELOG
|
329
|
+
|
330
|
+
-- A default CHANGELOG in case we cannot find a real one
|
331
|
+
|
332
|
+
default_changelog = [===[
|
333
|
+
* $date Auto Changelog <auto@no.body> - $version-$release
|
334
|
+
- Latest release of $name
|
335
|
+
]===]
|
336
|
+
|
337
|
+
default_lookup_table = {
|
338
|
+
date = os.date("%a %b %d %Y"),
|
339
|
+
version = package_version,
|
340
|
+
release = package_release,
|
341
|
+
name = package_name
|
342
|
+
}
|
343
|
+
|
344
|
+
changelog = io.open(src_dir .. "/CHANGELOG","r")
|
345
|
+
if changelog then
|
346
|
+
first_line = changelog:read()
|
347
|
+
if string.match(first_line, "^*%s+%a%a%a%s+%a%a%a%s+%d%d?%s+%d%d%d%d%s+.+") then
|
348
|
+
changelog:seek("set",0)
|
349
|
+
print(changelog:read("*all"))
|
350
|
+
else
|
351
|
+
print((default_changelog:gsub('$(%w+)', default_lookup_table)))
|
352
|
+
end
|
353
|
+
else
|
354
|
+
print((default_changelog:gsub('$(%w+)', default_lookup_table)))
|
355
|
+
end
|
356
|
+
}
|
data/lib/simp/rake/pkg.rb
CHANGED
@@ -31,9 +31,6 @@ module Simp::Rake
|
|
31
31
|
# array of items to additionally clean
|
32
32
|
attr_accessor :clean_list
|
33
33
|
|
34
|
-
# directory that contains all the mock chroots
|
35
|
-
attr_accessor :mock_root_dir
|
36
|
-
|
37
34
|
# array of items to ignore when checking if the tarball needs to be rebuilt
|
38
35
|
attr_accessor :ignore_changes_list
|
39
36
|
|
@@ -48,7 +45,6 @@ module Simp::Rake
|
|
48
45
|
@clean_list = []
|
49
46
|
@ignore_changes_list = []
|
50
47
|
@chroot_name = unique_name
|
51
|
-
@mock_root_dir = ENV.fetch('SIMP_BUILD_MOCK_root','/var/lib/mock')
|
52
48
|
|
53
49
|
local_spec = Dir.glob(File.join(@base_dir, 'build', '*.spec'))
|
54
50
|
unless local_spec.empty?
|
@@ -57,7 +53,7 @@ module Simp::Rake
|
|
57
53
|
FileUtils.mkdir_p(@pkg_tmp_dir) unless File.directory?(@pkg_tmp_dir)
|
58
54
|
|
59
55
|
@spec_tempfile = File.open(File.join(@pkg_tmp_dir, "#{@pkg_name}.spec"), 'w')
|
60
|
-
@spec_tempfile.write(Simp::Rake::Helpers::
|
56
|
+
@spec_tempfile.write(Simp::Rake::Helpers::RPMSpec.template)
|
61
57
|
|
62
58
|
@spec_file = @spec_tempfile.path
|
63
59
|
|
@@ -149,8 +145,6 @@ module Simp::Rake
|
|
149
145
|
if @tar_dest =~ /UNKNOWN/
|
150
146
|
fail("Error: Could not determine package information from 'metadata.json'. Got '#{File.basename(@tar_dest)}'")
|
151
147
|
end
|
152
|
-
|
153
|
-
@variants = (ENV['SIMP_BUILD_VARIANTS'].to_s.split(',') + ['default'])
|
154
148
|
end
|
155
149
|
end
|
156
150
|
|
@@ -205,15 +199,27 @@ module Simp::Rake
|
|
205
199
|
target_dir = File.basename(@base_dir)
|
206
200
|
|
207
201
|
Dir.chdir(%(#{@base_dir}/..)) do
|
208
|
-
|
209
|
-
|
210
|
-
Find.
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
202
|
+
require_rebuild = false
|
203
|
+
if File.exist?(@tar_dest)
|
204
|
+
Find.find(target_dir) do |path|
|
205
|
+
filename = File.basename(path)
|
206
|
+
Find.prune if filename =~ /^\./
|
207
|
+
Find.prune if ((filename == File.basename(@pkg_dir)) && File.directory?(path))
|
208
|
+
Find.prune if ((filename == 'spec') && File.directory?(path))
|
209
|
+
Find.prune if @ignore_changes_list.include?(path)
|
210
|
+
|
211
|
+
next if File.directory?(path)
|
212
|
+
unless uptodate?(@tar_dest,[path])
|
213
|
+
require_rebuild = true
|
214
|
+
break
|
215
|
+
end
|
216
216
|
end
|
217
|
+
else
|
218
|
+
require_rebuild = true
|
219
|
+
end
|
220
|
+
|
221
|
+
if require_rebuild
|
222
|
+
sh %Q(tar --owner 0 --group 0 --exclude-vcs --exclude=#{@exclude_list.join(' --exclude=')} --transform='s/^#{@pkg_name}/#{@dir_name}/' -cpzf "#{@tar_dest}" #{@pkg_name})
|
217
223
|
end
|
218
224
|
end
|
219
225
|
end
|
@@ -230,7 +236,9 @@ module Simp::Rake
|
|
230
236
|
This can be very useful for parallel builds of all modules.
|
231
237
|
* :snapshot_release - Add snapshot_release (date and time) to rpm version.
|
232
238
|
Rpm spec file must have macro for this to work.
|
233
|
-
|
239
|
+
EOM
|
240
|
+
=begin
|
241
|
+
This functionality has been (temporarily?) removed.
|
234
242
|
Environment Variables
|
235
243
|
SIMP_BUILD_VARIANTS - A comma delimted list of the target versions of Puppet/PE to build toward.
|
236
244
|
|
@@ -243,7 +251,7 @@ module Simp::Rake
|
|
243
251
|
|
244
252
|
NOTE: Different RPM spec files may have different
|
245
253
|
behaviors based on the value passed.
|
246
|
-
|
254
|
+
=end
|
247
255
|
task :srpm,[:chroot,:unique,:snapshot_release] => [:tar] do |t,args|
|
248
256
|
args.with_defaults(:unique => false)
|
249
257
|
args.with_defaults(:snapshot_release => false)
|
@@ -257,33 +265,25 @@ module Simp::Rake
|
|
257
265
|
|
258
266
|
mock_cmd = mock_pre_check( args.chroot, @chroot_name, args.unique )
|
259
267
|
|
260
|
-
@
|
261
|
-
if variant != 'default'
|
262
|
-
suffix = "-#{variant}"
|
263
|
-
end
|
264
|
-
|
265
|
-
srpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}#{suffix}-#{@spec_info[:version]}-#{@spec_info[:release]}#{l_date}.*.src.rpm))
|
266
|
-
|
267
|
-
if require_rebuild?(@tar_dest,srpms) || require_rebuild?("#{@base_dir}/metadata.json")
|
268
|
+
srpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}-#{@spec_info[:version]}-#{@spec_info[:release]}#{l_date}.*src.rpm))
|
268
269
|
|
269
|
-
|
270
|
-
next unless File.exist?(file)
|
270
|
+
if require_rebuild?(srpms, @tar_dest)
|
271
271
|
|
272
|
-
|
273
|
-
|
272
|
+
@puppet_module_info_files.each do |file|
|
273
|
+
next unless File.exist?(file)
|
274
274
|
|
275
|
-
|
276
|
-
|
277
|
-
FileUtils.cp(path, @pkg_dir) if File.exist?(path)
|
278
|
-
end
|
279
|
-
end
|
275
|
+
Find.find(file) do |path|
|
276
|
+
next if File.directory?(path)
|
280
277
|
|
281
|
-
|
282
|
-
|
283
|
-
|
278
|
+
tgt_file = File.join(@pkg_dir, File.basename(path))
|
279
|
+
FileUtils.rm_rf(tgt_file) if File.exist?(tgt_file)
|
280
|
+
FileUtils.cp(path, @pkg_dir) if File.exist?(path)
|
284
281
|
end
|
285
|
-
sh cmd
|
286
282
|
end
|
283
|
+
|
284
|
+
cmd = %Q(#{mock_cmd} --root #{args.chroot} #{mocksnap} --buildsrpm --spec #{@spec_file} --sources #{@pkg_dir})
|
285
|
+
|
286
|
+
sh cmd
|
287
287
|
end
|
288
288
|
end
|
289
289
|
end
|
@@ -300,6 +300,9 @@ module Simp::Rake
|
|
300
300
|
* :snapshot_release - Add snapshot_release (date and time) to rpm version.
|
301
301
|
Rpm spec file must have macro for this to work.
|
302
302
|
|
303
|
+
EOM
|
304
|
+
=begin
|
305
|
+
This functionality has been (temporarily?) removed.
|
303
306
|
Environment Variables
|
304
307
|
SIMP_BUILD_VARIANTS - A comma delimted list of the target versions of Puppet/PE to build toward.
|
305
308
|
|
@@ -312,7 +315,7 @@ module Simp::Rake
|
|
312
315
|
|
313
316
|
NOTE: Different RPM spec files may have different
|
314
317
|
behaviors based on the value passed.
|
315
|
-
|
318
|
+
=end
|
316
319
|
task :rpm,[:chroot,:unique,:snapshot_release] do |t,args|
|
317
320
|
args.with_defaults(:unique => false)
|
318
321
|
args.with_defaults(:snapshot_release => false)
|
@@ -328,23 +331,18 @@ module Simp::Rake
|
|
328
331
|
|
329
332
|
mock_cmd = mock_pre_check(args.chroot, @chroot_name, args.unique)
|
330
333
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
end
|
334
|
+
rpms = Dir.glob(%(#{@pkg_dir}/#{@spec_info[:name]}-#{@spec_info[:version]}-#{@spec_info[:release]}#{l_date}.*rpm))
|
335
|
+
srpms = rpms.select{|x| x =~ /src\.rpm$/}
|
336
|
+
rpms = (rpms - srpms)
|
335
337
|
|
336
|
-
|
337
|
-
|
338
|
-
|
338
|
+
srpms.each do |srpm|
|
339
|
+
dirname = File.dirname(srpm)
|
340
|
+
basename = File.basename(srpm,'.src.rpm')
|
341
|
+
rpm = File.join(dirname, basename, 'rpm')
|
342
|
+
if require_rebuild?(rpm, srpm)
|
343
|
+
cmd = %Q(#{mock_cmd} --root #{args.chroot} #{mocksnap} #{srpm})
|
339
344
|
|
340
|
-
|
341
|
-
if require_rebuild?(srpm,rpms)
|
342
|
-
cmd = %Q(#{mock_cmd} --root #{args.chroot} #{mocksnap} #{srpm})
|
343
|
-
if suffix
|
344
|
-
cmd += %( -D "_variant #{variant}")
|
345
|
-
end
|
346
|
-
sh cmd
|
347
|
-
end
|
345
|
+
sh cmd
|
348
346
|
end
|
349
347
|
end
|
350
348
|
|
@@ -384,20 +382,25 @@ module Simp::Rake
|
|
384
382
|
Dir.glob('/etc/mock/*.cfg').sort.map{ |x| x = File.basename(x,'.cfg')}
|
385
383
|
end
|
386
384
|
|
387
|
-
# Return True if any of the '
|
388
|
-
def require_rebuild?(
|
385
|
+
# Return True if any of the 'old' Array are newer than the 'new' Array
|
386
|
+
def require_rebuild?(new, old)
|
389
387
|
require_rebuild = false
|
390
|
-
require_rebuild = true if
|
388
|
+
require_rebuild = true if ( Array(old).empty? || Array(new).empty?)
|
391
389
|
unless require_rebuild
|
392
|
-
|
393
|
-
unless
|
390
|
+
Array(new).each do |new_file|
|
391
|
+
unless File.exist?(new_file)
|
392
|
+
require_rebuild = true
|
393
|
+
break
|
394
|
+
end
|
395
|
+
|
396
|
+
unless uptodate?(new_file, Array(old))
|
394
397
|
require_rebuild = true
|
395
398
|
break
|
396
399
|
end
|
397
400
|
end
|
398
401
|
end
|
399
402
|
|
400
|
-
require_rebuild
|
403
|
+
return require_rebuild
|
401
404
|
end
|
402
405
|
|
403
406
|
# Run some pre-checks to make sure that mock will work properly.
|