simp-rake-helpers 5.6.0 → 5.6.1
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 +7 -0
- data/lib/simp/rake/build/pkg.rb +5 -6
- data/lib/simp/rake/helpers/assets/rpm_spec/simp6.spec +289 -80
- data/lib/simp/rake/helpers/assets/rpm_spec/simpdefault.spec +3 -9
- data/lib/simp/rake/helpers/version.rb +1 -1
- data/lib/simp/rake/pkg.rb +9 -0
- data/lib/simp/yum.rb +1 -1
- data/spec/acceptance/10_pkg_rpm_spec.rb +1 -1
- data/spec/acceptance/files/testpackage/build/rpm_metadata/requires +2 -1
- data/spec/acceptance/files/testpackage/metadata.json +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6599aea873a06ae3cfaf152334a7effee7fed04f32fa5161b424475a2e350de8
|
|
4
|
+
data.tar.gz: 7034e551215bf0636963264f2c483179368d3ca653498929b0e1b563253d6324
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f336088887b860878ced18d3391cf7b682cf0cdf460827bfb3525330fc41437a76dae20ed73e1a89875b8a63cc354288746e96cffff83be400d015e898d0972b
|
|
7
|
+
data.tar.gz: 709eb08291c9944c3d3929f872bff72dc36fff4603503945e0d33f2ba06ad4569e65ac933e4d7a1e4691a671372e660f84b26222f4ce049613b7c1ca561454a6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### 5.6.1 / 2018-10-01
|
|
2
|
+
* Ensure that modules do not contain symlinks per the standard Puppet guidance.
|
|
3
|
+
* Do not try to only use the system cache for yum operations since this
|
|
4
|
+
silently causes all EL6 builds to be rebuilt and can't really work anyway
|
|
5
|
+
since there isn't a local cache unitl after yum runs. After yum runs, the
|
|
6
|
+
local cache will be preferred unless it has expired anyway.
|
|
7
|
+
|
|
1
8
|
### 5.6.0 / 2018-09-09
|
|
2
9
|
* Add support for Beaker 4
|
|
3
10
|
|
data/lib/simp/rake/build/pkg.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Simp::Rake::Build
|
|
|
18
18
|
|
|
19
19
|
@verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
|
|
20
20
|
@rpm_build_metadata = 'last_rpm_build_metadata.yaml'
|
|
21
|
+
@rpm_dependency_file = File.join(@base_dir, 'build', 'rpm', 'dependencies.yaml')
|
|
21
22
|
|
|
22
23
|
define_tasks
|
|
23
24
|
end
|
|
@@ -748,11 +749,7 @@ protect=1
|
|
|
748
749
|
result = false
|
|
749
750
|
|
|
750
751
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
if File.exist?(rpm_dependency_file)
|
|
754
|
-
rpm_metadata = YAML.load(File.read(rpm_dependency_file))
|
|
755
|
-
end
|
|
752
|
+
rpm_metadata = File.exist?(@rpm_dependency_file) ? YAML.load(File.read(@rpm_dependency_file)) : {}
|
|
756
753
|
|
|
757
754
|
Dir.chdir(dir) do
|
|
758
755
|
if File.exist?('metadata.json')
|
|
@@ -765,7 +762,7 @@ protect=1
|
|
|
765
762
|
# release qualifier from the 'dependencies.yaml';
|
|
766
763
|
# only created if release qualifier if specified in
|
|
767
764
|
# the 'dependencies.yaml'
|
|
768
|
-
Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(dir, rpm_metadata)
|
|
765
|
+
Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(dir, rpm_metadata)
|
|
769
766
|
|
|
770
767
|
new_rpm = Simp::Rake::Pkg.new(Dir.pwd, opts[:unique_namespace], @simp_version)
|
|
771
768
|
new_rpm_info = Simp::RPM.new(new_rpm.spec_file)
|
|
@@ -892,6 +889,8 @@ protect=1
|
|
|
892
889
|
_verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
|
|
893
890
|
dbg_prefix = ' ' # prefix for debug messages
|
|
894
891
|
|
|
892
|
+
fail("Could not find RPM dependency file '#{@rpm_dependency_file}'") unless File.exist?(@rpm_dependency_file)
|
|
893
|
+
|
|
895
894
|
begin
|
|
896
895
|
yum_helper = Simp::YUM.new(
|
|
897
896
|
Simp::YUM.generate_yum_conf(File.join(@distro_build_dir, 'yum_data'))
|
|
@@ -1,70 +1,160 @@
|
|
|
1
1
|
%{lua:
|
|
2
2
|
|
|
3
|
+
-- This RPM spec file can build
|
|
3
4
|
--
|
|
4
|
-
--
|
|
5
|
-
--
|
|
6
|
-
--
|
|
7
|
-
--
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
--
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
-- - 'name' - package name
|
|
15
|
-
-- - 'version' - package version
|
|
16
|
-
-- - 'license' - package license
|
|
17
|
-
-- - 'summary' - package summary
|
|
18
|
-
-- - 'source' - package source
|
|
5
|
+
-- ## Usage
|
|
6
|
+
--
|
|
7
|
+
-- ### pup_module_info_dir
|
|
8
|
+
--
|
|
9
|
+
-- When you build, you must define the macro 'pup_module_info_dir' so that rpm
|
|
10
|
+
-- knows where to find preliminary information.
|
|
11
|
+
--
|
|
12
|
+
-- If 'pup_module_info_dir' isn't defined or available, rpm will look in
|
|
13
|
+
-- '_sourcedir' for the files, falling back to the current directory as a last
|
|
14
|
+
-- resort.
|
|
19
15
|
--
|
|
20
16
|
-- Example:
|
|
21
|
-
-- rpmbuild -D 'pup_module_info_dir /home/user/project/puppet_module' -ba SPECS/specfile.spec
|
|
22
17
|
--
|
|
23
|
-
--
|
|
24
|
-
--
|
|
18
|
+
-- rpmbuild -D 'pup_module_info_dir /home/user/project/puppet_module' -ba SPECS/specfile.spec
|
|
19
|
+
--
|
|
20
|
+
-- ### relevant files
|
|
21
|
+
--
|
|
22
|
+
-- 'pup_module_info_dir' should be a directory that contains the following items:
|
|
25
23
|
--
|
|
24
|
+
-- * 'metadata.json' <- REQUIRED file that must contain the
|
|
25
|
+
-- following metadata:
|
|
26
|
+
-- - 'name' - package name
|
|
27
|
+
-- - 'version' - package version
|
|
28
|
+
-- - 'license' - package license
|
|
29
|
+
-- - 'summary' - package summary
|
|
30
|
+
-- - 'source' - package source
|
|
31
|
+
-- * 'build/rpm_metadata/requires' <- optional list of 'Requires',
|
|
32
|
+
-- 'Provides', and 'Obsoletes' to
|
|
33
|
+
-- supplement those auto-generated in
|
|
34
|
+
-- this spec file.
|
|
35
|
+
-- * 'build/rpm_metadata/release' <- optional RPM release number to use in
|
|
36
|
+
-- lieu of the number '0' hard-coded in
|
|
37
|
+
-- this spec file.
|
|
38
|
+
-- * 'CHANGELOG' <- optional RPM-formatted CHANGELOG to
|
|
39
|
+
-- use in lieu of the minimal changelog
|
|
40
|
+
-- entry auto-generated in this file.
|
|
41
|
+
-- * 'build/rpm_metadata/custom/' <- optional directory to place files to
|
|
42
|
+
-- add custom scriptlets and triggers.
|
|
43
|
+
--
|
|
44
|
+
--
|
|
45
|
+
|
|
46
|
+
local LUA_DEBUG = ((rpm.expand('%{lua_debug}') or '0') == '1')
|
|
47
|
+
|
|
48
|
+
-- Print debugging info to STDERR (if LUA_DEBUG is true)
|
|
49
|
+
function lua_stderr( msg )
|
|
50
|
+
if LUA_DEBUG then
|
|
51
|
+
-- io.stderr:write(tostring(msg):gsub("%f[^%z\n]","LUA #stderr#: "))
|
|
52
|
+
-- io.stderr:write(tostring(msg))
|
|
53
|
+
io.stderr:write(msg)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
local function get_src_dir()
|
|
59
|
+
local src_dir = rpm.expand('%{pup_module_info_dir}')
|
|
60
|
+
if src_dir:match('^%%') or (posix.stat(src_dir, 'type') ~= 'directory') then
|
|
61
|
+
lua_stderr("WARNING: -D pup_module_info_dir ("..tostring(src_dir)..") could not be used!\n")
|
|
62
|
+
lua_stderr(" falling back to src_dir = _sourcedir\n")
|
|
28
63
|
|
|
29
|
-
|
|
30
|
-
|
|
64
|
+
-- FIXME?: rpmlint considers the use of _sourcedir to be an Error:
|
|
65
|
+
-- (see: https://fedoraproject.org/wiki/Packaging:RPM_Source_Dir)
|
|
66
|
+
src_dir = rpm.expand('%{_sourcedir}')
|
|
31
67
|
|
|
32
|
-
|
|
33
|
-
|
|
68
|
+
if (posix.stat((src_dir .. "/metadata.json"), 'type') ~= 'regular') then
|
|
69
|
+
lua_stderr("WARNING: couldn't find metadata.json in '"..tostring(src_dir).."'!\n")
|
|
70
|
+
lua_stderr(" falling back to src_dir = posix.getcwd() ("..posix.getcwd()..")\n")
|
|
71
|
+
|
|
72
|
+
src_dir = posix.getcwd()
|
|
73
|
+
end
|
|
34
74
|
end
|
|
75
|
+
return src_dir
|
|
35
76
|
end
|
|
36
77
|
|
|
78
|
+
-- path to project directory / source files
|
|
79
|
+
src_dir = get_src_dir()
|
|
80
|
+
|
|
81
|
+
-- directory to look for customizations (e.g., scriptlets, triggers)
|
|
82
|
+
custom_content_dir = src_dir .. "/build/rpm_metadata/custom/"
|
|
83
|
+
|
|
84
|
+
-- list of custom content to inject into the spec file
|
|
85
|
+
custom_content_table = {}
|
|
86
|
+
|
|
87
|
+
-- list of scriptlets/triggers that have been declared (to avoid duplicates)
|
|
88
|
+
declared_scriptlets_table = {}
|
|
89
|
+
|
|
90
|
+
-- patterns to recognize scriptlet and trigger declarations
|
|
91
|
+
--
|
|
92
|
+
-- NOTE: Lua patterns are not regexes , and do not support alternation.
|
|
93
|
+
-- So, we try to stay efficient by iterating through as few patterns as
|
|
94
|
+
-- possible by short-ciruiting several matches.
|
|
95
|
+
-- (e.g. '^%%pre' matches both '%pre' and '%pretrans')
|
|
96
|
+
--
|
|
97
|
+
SCRIPTLET_PATTERNS = {
|
|
98
|
+
'^%%pre',
|
|
99
|
+
'^%%post',
|
|
100
|
+
'^%%trigger'
|
|
101
|
+
}
|
|
102
|
+
|
|
37
103
|
-- These UNKNOWN entries should break the build if something bad happens
|
|
38
104
|
|
|
39
105
|
package_name = "UNKNOWN"
|
|
40
106
|
package_version = "UNKNOWN"
|
|
41
107
|
module_license = "UNKNOWN"
|
|
42
108
|
|
|
43
|
-
--
|
|
44
109
|
-- Default to 0
|
|
45
|
-
--
|
|
46
|
-
|
|
47
110
|
package_release = 0
|
|
48
|
-
}
|
|
49
111
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
112
|
+
lua_stderr("\n")
|
|
113
|
+
lua_stderr("--------------------------------------------------------------------------------\n")
|
|
114
|
+
lua_stderr("RPM/LUA build environment:\n")
|
|
115
|
+
lua_stderr("------:\n")
|
|
116
|
+
lua_stderr("LUA _VERSION = '".._VERSION.."'\n")
|
|
117
|
+
lua_stderr("posix.getcwd() = '"..posix.getcwd().."'\n")
|
|
118
|
+
lua_stderr("\n")
|
|
119
|
+
lua_stderr("macros:\n")
|
|
120
|
+
lua_stderr("------:\n")
|
|
121
|
+
lua_stderr("'%{pup_module_info_dir}' = '"..rpm.expand('%{pup_module_info_dir}').."'\n")
|
|
122
|
+
lua_stderr("_specdir = '"..rpm.expand('%{_specdir}').."'\n")
|
|
123
|
+
lua_stderr("_buildrootdir = '"..rpm.expand('%{_buildrootdir}').."'\n")
|
|
124
|
+
lua_stderr("buildroot = '"..rpm.expand('%{buildroot}').."'\n")
|
|
125
|
+
lua_stderr("RPM_BUILD_ROOT = '"..rpm.expand('%{RPM_BUILD_ROOT}').."'\n")
|
|
126
|
+
lua_stderr("\n")
|
|
127
|
+
lua_stderr("local variables:\n")
|
|
128
|
+
lua_stderr("------:\n")
|
|
129
|
+
lua_stderr("src_dir = '".. src_dir .."'\n")
|
|
130
|
+
lua_stderr("custom_content_dir = '"..custom_content_dir.."'\n# ---\n")
|
|
131
|
+
lua_stderr("--------------------------------------------------------------------------------\n")
|
|
132
|
+
lua_stderr("\n")
|
|
57
133
|
|
|
58
|
-
-- Ignore the first curly brace
|
|
59
|
-
metadata = metadata:gsub("{}?", '|', 1)
|
|
60
134
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
metadata =
|
|
64
|
-
|
|
65
|
-
|
|
135
|
+
-- Pull the Relevant Metadata out of the Puppet module metadata.json.
|
|
136
|
+
function read_metadata(src_dir)
|
|
137
|
+
local metadata = ''
|
|
138
|
+
local metadata_file = src_dir .. "/metadata.json"
|
|
139
|
+
local metadata_fh = io.open(metadata_file,'r')
|
|
140
|
+
if metadata_fh then
|
|
141
|
+
metadata = metadata_fh:read("*all")
|
|
142
|
+
|
|
143
|
+
-- Ignore the first curly brace
|
|
144
|
+
metadata = metadata:gsub("{}?", '|', 1)
|
|
145
|
+
|
|
146
|
+
-- Ignore all keys that are below the first level
|
|
147
|
+
metadata = metadata:gsub("{.-}", '')
|
|
148
|
+
metadata = metadata:gsub("%[.-%]", '')
|
|
149
|
+
else
|
|
150
|
+
error("Could not open 'metadata.json': ".. metadata_file, 0)
|
|
151
|
+
end
|
|
152
|
+
return metadata
|
|
66
153
|
end
|
|
67
154
|
|
|
155
|
+
|
|
156
|
+
metadata = read_metadata(src_dir)
|
|
157
|
+
|
|
68
158
|
-- This starts as an empty string so that we can build it later
|
|
69
159
|
module_requires = ''
|
|
70
160
|
|
|
@@ -74,7 +164,7 @@ module_requires = ''
|
|
|
74
164
|
|
|
75
165
|
-- Get the Module Name and put it in the correct format
|
|
76
166
|
|
|
77
|
-
local name_match =
|
|
167
|
+
local name_match = metadata:match('"name":%s+"(.-)"%s*,')
|
|
78
168
|
|
|
79
169
|
module_author = ''
|
|
80
170
|
module_name = ''
|
|
@@ -83,7 +173,7 @@ if name_match then
|
|
|
83
173
|
package_name = ('pupmod-' .. name_match)
|
|
84
174
|
|
|
85
175
|
local i = 0
|
|
86
|
-
for str in
|
|
176
|
+
for str in name_match:gmatch('[^-]+') do
|
|
87
177
|
if i == 0 then
|
|
88
178
|
module_author = str
|
|
89
179
|
else
|
|
@@ -106,7 +196,7 @@ end
|
|
|
106
196
|
|
|
107
197
|
-- Get the Module Version
|
|
108
198
|
|
|
109
|
-
local version_match =
|
|
199
|
+
local version_match = metadata:match('"version":%s+"(.-)"%s*,')
|
|
110
200
|
|
|
111
201
|
if version_match then
|
|
112
202
|
package_version = version_match
|
|
@@ -120,7 +210,7 @@ end
|
|
|
120
210
|
|
|
121
211
|
-- Get the Module License
|
|
122
212
|
|
|
123
|
-
local license_match =
|
|
213
|
+
local license_match = metadata:match('"license":%s+"(.-)"%s*,')
|
|
124
214
|
|
|
125
215
|
if license_match then
|
|
126
216
|
module_license = license_match
|
|
@@ -134,7 +224,7 @@ end
|
|
|
134
224
|
|
|
135
225
|
-- Get the Module Summary
|
|
136
226
|
|
|
137
|
-
local summary_match =
|
|
227
|
+
local summary_match = metadata:match('"summary":%s+"(.-)"%s*,')
|
|
138
228
|
|
|
139
229
|
if summary_match then
|
|
140
230
|
module_summary = summary_match
|
|
@@ -148,7 +238,7 @@ end
|
|
|
148
238
|
|
|
149
239
|
-- Get the Module Source line for the URL string
|
|
150
240
|
|
|
151
|
-
local source_match =
|
|
241
|
+
local source_match = metadata:match('"source":%s+"(.-)"%s*,')
|
|
152
242
|
|
|
153
243
|
if source_match then
|
|
154
244
|
module_source = source_match
|
|
@@ -173,8 +263,8 @@ end
|
|
|
173
263
|
|
|
174
264
|
if rel_file then
|
|
175
265
|
for line in rel_file:lines() do
|
|
176
|
-
is_comment =
|
|
177
|
-
is_blank =
|
|
266
|
+
is_comment = line:match("^%s*#")
|
|
267
|
+
is_blank = line:match("^%s*$")
|
|
178
268
|
|
|
179
269
|
if not (is_comment or is_blank) then
|
|
180
270
|
package_release = line
|
|
@@ -197,7 +287,7 @@ end
|
|
|
197
287
|
|
|
198
288
|
if req_file then
|
|
199
289
|
for line in req_file:lines() do
|
|
200
|
-
valid_line = (
|
|
290
|
+
valid_line = (line:match("^Requires: ") or line:match("^Obsoletes: ") or line:match("^Provides: "))
|
|
201
291
|
|
|
202
292
|
if valid_line then
|
|
203
293
|
module_requires = (module_requires .. "\n" .. line)
|
|
@@ -238,16 +328,10 @@ URL: %{lua: print(module_source)}
|
|
|
238
328
|
BuildRoot: %{_tmppath}/%{package_name}-%{version}-%{release}-buildroot
|
|
239
329
|
BuildArch: noarch
|
|
240
330
|
|
|
241
|
-
Requires(pre
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Requires:
|
|
245
|
-
%endif
|
|
246
|
-
|
|
247
|
-
%if "%{package_name}" != "pupmod-puppetlabs-stdlib"
|
|
248
|
-
Requires: pupmod-puppetlabs-stdlib >= 4.9.0
|
|
249
|
-
Requires: pupmod-puppetlabs-stdlib < 6.0.0
|
|
250
|
-
%endif
|
|
331
|
+
Requires(pre): simp-adapter >= 0.0.1
|
|
332
|
+
Requires(preun): simp-adapter >= 0.0.1
|
|
333
|
+
Requires(preun): simp-adapter >= 0.0.1
|
|
334
|
+
Requires(postun): simp-adapter >= 0.0.1
|
|
251
335
|
|
|
252
336
|
%{lua: print(module_requires)}
|
|
253
337
|
|
|
@@ -287,6 +371,9 @@ curdir=`pwd`
|
|
|
287
371
|
dirname=`basename $curdir`
|
|
288
372
|
cp -r ../$dirname %{buildroot}/%{prefix}/%{module_name}
|
|
289
373
|
|
|
374
|
+
# Modules should *never* contain symlinks
|
|
375
|
+
find %{buildroot} -type l -delete
|
|
376
|
+
|
|
290
377
|
# Remove unnecessary assets
|
|
291
378
|
rm -rf %{buildroot}/%{prefix}/%{module_name}/.git
|
|
292
379
|
rm -f %{buildroot}/%{prefix}/%{module_name}/*.lock
|
|
@@ -300,29 +387,151 @@ rm -rf %{buildroot}/%{prefix}/%{module_name}/log
|
|
|
300
387
|
|
|
301
388
|
mkdir -p %{buildroot}/%{prefix}
|
|
302
389
|
|
|
303
|
-
%
|
|
304
|
-
|
|
305
|
-
|
|
390
|
+
%{lua:
|
|
391
|
+
|
|
392
|
+
-- returns true if 'scriptlet_name' has already been declared
|
|
393
|
+
function is_scriplet_declared(scriptlet_name, declared_scriptlets_table)
|
|
394
|
+
for _,name in ipairs(declared_scriptlets_table) do
|
|
395
|
+
if (name == scriptlet_name) then
|
|
396
|
+
return true
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
return false
|
|
400
|
+
end
|
|
306
401
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
402
|
+
-- returns true if 'line' is a scriptlet or trigger header
|
|
403
|
+
function is_valid_scriptlet_header(line)
|
|
404
|
+
local match = false
|
|
405
|
+
for _, patt in ipairs(SCRIPTLET_PATTERNS) do
|
|
406
|
+
if line:match(patt) then
|
|
407
|
+
match = true
|
|
408
|
+
break
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
return match
|
|
412
|
+
end
|
|
311
413
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
414
|
+
--
|
|
415
|
+
-- adds content to the custom_content_table
|
|
416
|
+
--
|
|
417
|
+
function define_custom_content(
|
|
418
|
+
content,
|
|
419
|
+
custom_content_table,
|
|
420
|
+
declared_scriptlets_table
|
|
421
|
+
)
|
|
422
|
+
lua_stderr("# evaluating extra content: \n".. (content:gsub("%f[^%z\n]"," | ")) .."\n")
|
|
423
|
+
|
|
424
|
+
if content then
|
|
425
|
+
local _content = ''
|
|
426
|
+
local recording = true
|
|
427
|
+
|
|
428
|
+
for line in content:gmatch("([^\n]*)\n?") do
|
|
429
|
+
|
|
430
|
+
-- skip duplicate scriptlets
|
|
431
|
+
if is_valid_scriptlet_header(line) then
|
|
432
|
+
local _line = line:gsub("^%s+",""):gsub("%s+$","")
|
|
433
|
+
if is_scriplet_declared(_line, declared_scriptlets_table) then
|
|
434
|
+
lua_stderr("WARNING: scriptlet '".._line..
|
|
435
|
+
"' has already been declared (skipping scriptlet).\n")
|
|
436
|
+
recording = false
|
|
437
|
+
else
|
|
438
|
+
lua_stderr('+ "'.._line..'" is recognized as a scriptlet/trigger.\n')
|
|
439
|
+
recording = true
|
|
440
|
+
table.insert(declared_scriptlets_table, _line)
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
if recording then
|
|
445
|
+
_content = _content .. line .. "\n"
|
|
446
|
+
else
|
|
447
|
+
lua_stderr(" skipping line '"..line.."'\n")
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
table.insert(custom_content_table, _content )
|
|
451
|
+
end
|
|
452
|
+
end
|
|
316
453
|
|
|
317
|
-
# when $1 = 1, this is the uninstall of the previous version during an upgrade
|
|
318
|
-
# when $1 = 0, this is the uninstall of the only version during an erase
|
|
319
|
-
%preun
|
|
320
|
-
/usr/local/sbin/simp_rpm_helper --rpm_dir=%{prefix}/%{module_name} --rpm_section='preun' --rpm_status=$1
|
|
321
454
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
455
|
+
function load_custom_content_files(custom_content_dir, custom_content_table, declared_scriptlets_table)
|
|
456
|
+
if (posix.stat(custom_content_dir, 'type') == 'directory') then
|
|
457
|
+
for i,basename in pairs(posix.dir(custom_content_dir)) do
|
|
458
|
+
local file = custom_content_dir .. basename
|
|
459
|
+
-- only accept files that are not dot files (".filename")
|
|
460
|
+
if (basename:match('^[^%.]') and (posix.stat(file, 'type') == 'regular')) then
|
|
461
|
+
lua_stderr("INFO: found custom RPM spec file snippet: '" .. file .. "'\n")
|
|
462
|
+
local file_handle = io.open(file,'r')
|
|
463
|
+
if file_handle then
|
|
464
|
+
local _content = file_handle:read("*all")
|
|
465
|
+
define_custom_content(_content, custom_content_table, declared_scriptlets_table)
|
|
466
|
+
else
|
|
467
|
+
lua_stderr("WARNING: could not read '"..file.."'\n")
|
|
468
|
+
end
|
|
469
|
+
file_handle:close()
|
|
470
|
+
else
|
|
471
|
+
lua_stderr("WARNING: skipping invalid filename '"..basename.."'\n")
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
else
|
|
475
|
+
lua_stderr("WARNING: not found: " .. custom_content_dir .. "\n")
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
-- Declares default scriptlets for SIMP 6.X (referenced from 6.1.0)
|
|
480
|
+
--
|
|
481
|
+
-- In order to keep the package-maintained pupmod-*-* packages.
|
|
482
|
+
-- Packages notify /usr/local/sbin/simp_rpm_helper.
|
|
483
|
+
-- See: https://github.com/simp/simp-adapter/blob/master/src/sbin/simp_rpm_helper
|
|
484
|
+
--
|
|
485
|
+
-- This function should be called last
|
|
486
|
+
--
|
|
487
|
+
function declare_default_scriptlets(custom_content_table, declared_scriptlets_table)
|
|
488
|
+
local DEFAULT_SCRIPTLETS = {
|
|
489
|
+
['pre'] = {upgrade = 2},
|
|
490
|
+
['post'] = {upgrade = 2},
|
|
491
|
+
['preun'] = {upgrade = 0},
|
|
492
|
+
['postun'] = {upgrade = 0}
|
|
493
|
+
}
|
|
494
|
+
local rpm_dir = rpm.expand('%{prefix}/' .. module_name)
|
|
495
|
+
|
|
496
|
+
for name,data in pairs(DEFAULT_SCRIPTLETS) do
|
|
497
|
+
local content = ('%'..name.."\n"..
|
|
498
|
+
'# (default scriptlet for SIMP 6.x)\n'..
|
|
499
|
+
'# when $1 = 1, this is an install\n'..
|
|
500
|
+
'# when $1 = '.. data.upgrade ..', this is an upgrade\n'..
|
|
501
|
+
'if [ -x /usr/local/sbin/simp_rpm_helper ] ; then\n'..
|
|
502
|
+
' /usr/local/sbin/simp_rpm_helper --rpm_dir='..
|
|
503
|
+
rpm_dir.." --rpm_section='"..name.."' --rpm_status=$1\n"..
|
|
504
|
+
'fi\n\n'
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
define_custom_content(content, custom_content_table, declared_scriptlets_table)
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
-- insert custom content (e.g., rpm_metadata/custom/*, scriptlets)
|
|
513
|
+
function print_extra_content( custom_content_table )
|
|
514
|
+
local extra_content = table.concat(custom_content_table, "\n") .. "\n"
|
|
515
|
+
lua_stderr("\n========== DYNAMIC CONTENT SUMMARY ========== (begin)\n" ..
|
|
516
|
+
rpm.expand( extra_content ) ..
|
|
517
|
+
"\n========== DYNAMIC CONTENT SUMMARY ========== (end)\n")
|
|
518
|
+
print(extra_content)
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
load_custom_content_files(
|
|
523
|
+
custom_content_dir,
|
|
524
|
+
custom_content_table,
|
|
525
|
+
declared_scriptlets_table
|
|
526
|
+
)
|
|
527
|
+
declare_default_scriptlets(custom_content_table, declared_scriptlets_table)
|
|
528
|
+
print_extra_content(custom_content_table)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
%files
|
|
533
|
+
%defattr(0640,root,root,0750)
|
|
534
|
+
%{prefix}/%{module_name}
|
|
326
535
|
|
|
327
536
|
%changelog
|
|
328
537
|
%{lua:
|
|
@@ -345,7 +554,7 @@ default_lookup_table = {
|
|
|
345
554
|
changelog = io.open(src_dir .. "/CHANGELOG","r")
|
|
346
555
|
if changelog then
|
|
347
556
|
first_line = changelog:read()
|
|
348
|
-
if
|
|
557
|
+
if first_line:match("^*%s+%a%a%a%s+%a%a%a%s+%d%d?%s+%d%d%d%d%s+.+") then
|
|
349
558
|
changelog:seek("set",0)
|
|
350
559
|
print(changelog:read("*all"))
|
|
351
560
|
else
|
|
@@ -333,15 +333,6 @@ Requires(preun): simp-adapter >= 0.0.1
|
|
|
333
333
|
Requires(preun): simp-adapter >= 0.0.1
|
|
334
334
|
Requires(postun): simp-adapter >= 0.0.1
|
|
335
335
|
|
|
336
|
-
%if ("%{package_name}" != "pupmod-simp-simplib") && ("%{package_name}" != "pupmod-puppetlabs-stdlib")
|
|
337
|
-
Requires: pupmod-simp-simplib >= 1.2.6
|
|
338
|
-
%endif
|
|
339
|
-
|
|
340
|
-
%if "%{package_name}" != "pupmod-puppetlabs-stdlib"
|
|
341
|
-
Requires: pupmod-puppetlabs-stdlib >= 4.9.0
|
|
342
|
-
Requires: pupmod-puppetlabs-stdlib < 6.0.0
|
|
343
|
-
%endif
|
|
344
|
-
|
|
345
336
|
%{lua: print(module_requires)}
|
|
346
337
|
|
|
347
338
|
Provides: pupmod-%{lua: print(module_name)} = %{lua: print(package_version .. "-" .. package_release)}
|
|
@@ -380,6 +371,9 @@ curdir=`pwd`
|
|
|
380
371
|
dirname=`basename $curdir`
|
|
381
372
|
cp -r ../$dirname %{buildroot}/%{prefix}/%{module_name}
|
|
382
373
|
|
|
374
|
+
# Modules should *never* contain symlinks
|
|
375
|
+
find %{buildroot} -type l -delete
|
|
376
|
+
|
|
383
377
|
# Remove unnecessary assets
|
|
384
378
|
rm -rf %{buildroot}/%{prefix}/%{module_name}/.git
|
|
385
379
|
rm -f %{buildroot}/%{prefix}/%{module_name}/*.lock
|
data/lib/simp/rake/pkg.rb
CHANGED
|
@@ -9,6 +9,7 @@ require 'find'
|
|
|
9
9
|
require 'simp/relchecks'
|
|
10
10
|
require 'simp/rpm'
|
|
11
11
|
require 'simp/rake/helpers/rpm_spec'
|
|
12
|
+
require 'simp/rake/build/rpmdeps'
|
|
12
13
|
|
|
13
14
|
module Simp; end
|
|
14
15
|
module Simp::Rake
|
|
@@ -216,12 +217,17 @@ module Simp::Rake
|
|
|
216
217
|
# :pkg:rpm
|
|
217
218
|
# -----------------------------
|
|
218
219
|
namespace :pkg do
|
|
220
|
+
=begin
|
|
221
|
+
WARNING: THIS DOES NOT PULL FROM THE simp-core RPM DEPENDENCIES FILE
|
|
222
|
+
WARNING: YOU WILL PROBABLY NOT GET PROPER FULL SIMP RPMS FROM THIS TASK
|
|
223
|
+
|
|
219
224
|
desc <<-EOM
|
|
220
225
|
Build the #{@pkg_name} RPM.
|
|
221
226
|
|
|
222
227
|
By default, the package will be built to support a SIMP-6.X file structure.
|
|
223
228
|
To build the package for a different version of SIMP, export SIMP_BUILD_version=<5.X,4.X>
|
|
224
229
|
EOM
|
|
230
|
+
=end
|
|
225
231
|
task :rpm => [:tar] do |t,args|
|
|
226
232
|
rpm_opts = [
|
|
227
233
|
%(-D 'buildroot #{@pkg_dir}/rpmbuild/BUILDROOT'),
|
|
@@ -275,6 +281,9 @@ module Simp::Rake
|
|
|
275
281
|
|
|
276
282
|
srpms = [@full_pkg_name + '.src.rpm']
|
|
277
283
|
if require_rebuild?(srpms.first, @tar_dest)
|
|
284
|
+
# TODO: Uncomment this after revamping the tests to use a dependencies.yaml file
|
|
285
|
+
# Simp::Rake::Build::RpmDeps.generate_rpm_meta_files(@base_dir, {})
|
|
286
|
+
|
|
278
287
|
# Need to build the SRPM so that we can get the build dependencies
|
|
279
288
|
cmd = %(rpmbuild #{rpm_opts.join(' ')} -bs #{@spec_file} > logs/build.srpm.out 2> logs/build.srpm.err)
|
|
280
289
|
puts "==== pkg:rpm SRPM BUILD: #{cmd}" if @verbose
|
data/lib/simp/yum.rb
CHANGED
|
@@ -124,7 +124,7 @@ describe 'rake pkg:rpm' do
|
|
|
124
124
|
|
|
125
125
|
comment 'produces RPM with appropriate dependencies'
|
|
126
126
|
on host, %(rpm -qpR #{testpackage_rpm} | grep -q simp-adapter)
|
|
127
|
-
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo)
|
|
127
|
+
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo), :acceptable_exit_codes => [1]
|
|
128
128
|
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-simplib)
|
|
129
129
|
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-puppetlabs-stdlib)
|
|
130
130
|
on host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x 'pupmod-testpackage = 0.0.1-0')
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
Requires: pupmod-simp-
|
|
1
|
+
Requires: pupmod-simp-simplib >= 1.2.3
|
|
2
|
+
Requires: pupmod-puppetlabs-stdlib >= 1.2.3
|
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: 5.6.
|
|
4
|
+
version: 5.6.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: 2018-
|
|
12
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: simp-beaker-helpers
|