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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dc63bb56b51334e5e5a31fa9a6d843889174561
|
4
|
+
data.tar.gz: 7eee12246c9f05e1c2af04ab158ee2c6bcb8e266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa82d78040ca5e394ef902e09552099810267729b4c285a464ce80c6f05b07031bcf20f6cabf5d6bb935c8f689ec01c7722410670bdaf2b796f255c05c4e3012
|
7
|
+
data.tar.gz: 1cb550b16bc737f5ee25e2fffd23b3fdedf466ce4b5e73f68275be40a47527c277c03417a03491573a21a7fa2cd7f2daaa032efc296ba27d202eeece057c6225
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -131,7 +131,9 @@ specification.
|
|
131
131
|
It is likely that you will want to declare your dependencies in your RPM. To do
|
132
132
|
this, you can create a `build/rpm_metadata` directory at the root of your
|
133
133
|
project. A file named `requires` in the `build/rpm_metadata` directory will be
|
134
|
-
used to declare the dependencies of the RPM.
|
134
|
+
used to declare the dependencies of the RPM. A file named `release` in the
|
135
|
+
`build/rpm_metadata` directory will be used to declare the RPM release
|
136
|
+
number.
|
135
137
|
|
136
138
|
The following directives may be declared in the `requires` file:
|
137
139
|
* Provides
|
data/lib/simp/rake/build/iso.rb
CHANGED
@@ -145,7 +145,7 @@ module Simp::Rake::Build
|
|
145
145
|
|
146
146
|
# NOTE: RHEL7 discs claim [general] section is deprecated.
|
147
147
|
if sections.include?('general')
|
148
|
-
h = Hash[ ini.get_section('general').entries ]
|
148
|
+
h = Hash[ ini.get_section('general').entries.map{|k,v| [k,v]} ]
|
149
149
|
arch = h.fetch('arch', arch).strip
|
150
150
|
baseosver = h.fetch('version', baseosver).strip
|
151
151
|
baseosver += '.0' if (baseosver.count('.') < 1)
|
@@ -153,7 +153,13 @@ module Simp::Rake::Build
|
|
153
153
|
# ------------------------------------
|
154
154
|
|
155
155
|
# Skip if SIMP version doesn't match target base OS version
|
156
|
-
|
156
|
+
unless Array(vermap[simpver.split('.').first]).include?(baseosver.split('.').first)
|
157
|
+
if verbose
|
158
|
+
warn("Could not find SIMP version mapping for #{simpver} for Base OS #{baseosver}")
|
159
|
+
end
|
160
|
+
|
161
|
+
next
|
162
|
+
end
|
157
163
|
|
158
164
|
mkrepo = baseosver.split('.').first == '5' ? 'createrepo -s sha -p' : 'createrepo -p'
|
159
165
|
|
@@ -288,6 +294,9 @@ module Simp::Rake::Build
|
|
288
294
|
system(mkisofs_cmd.join(' '))
|
289
295
|
end
|
290
296
|
end # End of tarfiles loop
|
297
|
+
|
298
|
+
# If we got here and didn't generate any ISOs, something went horribly wrong
|
299
|
+
fail('Error: No ISO was built!') unless @simp_output_iso
|
291
300
|
end
|
292
301
|
|
293
302
|
desc <<-EOM
|
data/lib/simp/rake/build/pkg.rb
CHANGED
@@ -39,15 +39,19 @@ module Simp::Rake::Build
|
|
39
39
|
:modules => get_module_dirs(args[:method]),
|
40
40
|
:aux => [
|
41
41
|
"#{@build_dir}/GPGKEYS",
|
42
|
-
"#{@src_dir}/puppet/bootstrap",
|
43
42
|
"#{@src_dir}/rsync",
|
44
|
-
|
43
|
+
# Anything in here gets built!
|
44
|
+
"#{@src_dir}/assets/*"
|
45
45
|
],
|
46
46
|
:doc => "#{@src_dir}/doc",
|
47
47
|
:simp_cli => "#{@src_dir}/rubygems/simp_cli",
|
48
48
|
:simp => "#{@src_dir}",
|
49
49
|
}
|
50
50
|
|
51
|
+
@build_dirs[:aux].map!{|dir| dir = Dir.glob(dir)}
|
52
|
+
@build_dirs[:aux].flatten!
|
53
|
+
@build_dirs[:aux].delete_if{|f| !File.directory?(f)}
|
54
|
+
|
51
55
|
@pkg_dirs = {
|
52
56
|
:simp => "#{@build_dir}/SIMP",
|
53
57
|
:ext => "#{@build_dir}/Ext_*"
|
@@ -86,7 +90,7 @@ module Simp::Rake::Build
|
|
86
90
|
Dir.chdir(dir) do
|
87
91
|
begin
|
88
92
|
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
89
|
-
|
93
|
+
%x{rake clean[#{args.chroot}] #{rake_flags}}
|
90
94
|
clean_failures_lock.synchronize do
|
91
95
|
clean_failures << dir unless $?.success?
|
92
96
|
end
|
@@ -292,12 +296,12 @@ module Simp::Rake::Build
|
|
292
296
|
|
293
297
|
check_dvd_env
|
294
298
|
|
295
|
-
Rake::Task['pkg:
|
299
|
+
Rake::Task['pkg:simp_cli'].invoke(args.chroot)
|
296
300
|
Rake::Task['pkg:aux'].invoke(args.chroot)
|
297
301
|
if "#{args.docs}" == 'true'
|
298
302
|
Rake::Task['pkg:doc'].invoke(args.chroot)
|
299
303
|
end
|
300
|
-
Rake::Task['pkg:
|
304
|
+
Rake::Task['pkg:modules'].invoke(args.chroot)
|
301
305
|
|
302
306
|
# The main SIMP RPM must be built last!
|
303
307
|
Rake::Task['pkg:simp'].invoke(args.chroot,args.snapshot_release)
|
@@ -326,8 +330,8 @@ module Simp::Rake::Build
|
|
326
330
|
out_dir = "#{output_dir}/SRPMS"
|
327
331
|
mkdir_p(out_dir, :verbose => _verbose) unless File.directory?(out_dir)
|
328
332
|
|
329
|
-
|
330
|
-
cp(srpm,out_dir, :verbose => _verbose)
|
333
|
+
unless uptodate?("#{out_dir}/#{File.basename(srpm)}",[srpm])
|
334
|
+
cp(srpm, out_dir, :verbose => _verbose)
|
331
335
|
end
|
332
336
|
end
|
333
337
|
|
@@ -335,8 +339,8 @@ module Simp::Rake::Build
|
|
335
339
|
out_dir = "#{output_dir}/RPMS/#{rpm.split('.')[-2]}"
|
336
340
|
mkdir_p(out_dir, :verbose => _verbose) unless File.directory?(out_dir)
|
337
341
|
|
338
|
-
|
339
|
-
cp(rpm,out_dir, :verbose => _verbose)
|
342
|
+
unless uptodate?("#{out_dir}/#{File.basename(rpm)}",[rpm])
|
343
|
+
cp(rpm, out_dir, :verbose => _verbose)
|
340
344
|
end
|
341
345
|
end
|
342
346
|
end
|
@@ -516,6 +520,7 @@ module Simp::Rake::Build
|
|
516
520
|
|
517
521
|
ENV vars:
|
518
522
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
523
|
+
- Set `SIMP_PKG_repoclose_pe=yes` to enable repoclosure on PE-related RPMs.
|
519
524
|
|
520
525
|
EOM
|
521
526
|
task :repoclosure,[:target_dir,:aux_dir] => [:prep] do |t,args|
|
@@ -528,6 +533,7 @@ module Simp::Rake::Build
|
|
528
533
|
end
|
529
534
|
|
530
535
|
_verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
|
536
|
+
_repoclose_pe = ENV.fetch('SIMP_PKG_repoclose_pe','no') == 'yes'
|
531
537
|
|
532
538
|
yum_conf_template = <<-EOF
|
533
539
|
[main]
|
@@ -537,6 +543,9 @@ obsoletes=1
|
|
537
543
|
gpgcheck=0
|
538
544
|
plugins=1
|
539
545
|
installonly_limit=5
|
546
|
+
<% unless #{_repoclose_pe} -%>
|
547
|
+
exclude=*-pe-*
|
548
|
+
<% end -%>
|
540
549
|
|
541
550
|
<% repo_files.each do |repo| -%>
|
542
551
|
include=file://<%= repo %>
|
@@ -641,76 +650,62 @@ protect=1
|
|
641
650
|
# Default package metadata for reference
|
642
651
|
default_metadata = YAML.load(File.read("#{@src_dir}/build/package_metadata_defaults.yaml"))
|
643
652
|
|
644
|
-
failures = {}
|
645
|
-
|
646
653
|
metadata = Parallel.map(
|
654
|
+
# Allow for shell globs
|
647
655
|
Array(dirs),
|
648
656
|
:in_processes => get_cpu_limit,
|
649
657
|
:progress => task.name
|
650
658
|
) do |dir|
|
651
659
|
result = []
|
652
660
|
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
661
|
+
fail("Could not find directory #{dir}") unless Dir.exist?(dir)
|
662
|
+
|
663
|
+
Dir.chdir(dir) do
|
664
|
+
if File.exist?('Rakefile')
|
665
|
+
|
666
|
+
unique_build = (get_cpu_limit != 1)
|
667
|
+
|
668
|
+
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
669
|
+
cmd = %{rake pkg:rpm[#{chroot},unique_build,#{snapshot_release}] #{rake_flags} 2>&1}
|
657
670
|
begin
|
671
|
+
if _verbose
|
672
|
+
$stderr.puts("Running 'rake pkg:rpm'")
|
673
|
+
end
|
658
674
|
|
659
|
-
|
660
|
-
|
661
|
-
Dir.chdir(dir) do
|
662
|
-
if File.exist?('Rakefile')
|
663
|
-
unique_build = (get_cpu_limit != 1)
|
664
|
-
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
665
|
-
output = %x{rake pkg:rpm[#{chroot},unique_build,#{snapshot_release}] #{rake_flags} 2>&1}
|
666
|
-
raise(output) unless $?.success?
|
667
|
-
|
668
|
-
# Glob all generated rpms, and add their metadata to a result array.
|
669
|
-
pkginfo = Hash.new
|
670
|
-
Dir.glob('dist/*.rpm') do |rpm|
|
671
|
-
if not rpm =~ /.*.src.rpm/ then
|
672
|
-
# get_info from each generated rpm, not the spec file, so macros in the
|
673
|
-
# metadata have already been resolved in the mock chroot.
|
674
|
-
result << Simp::RPM.get_info(rpm)
|
675
|
-
end
|
676
|
-
end
|
677
|
-
else
|
678
|
-
puts "Warning: Could not find Rakefile in '#{dir}'"
|
679
|
-
end
|
675
|
+
::Bundler.with_clean_env do
|
676
|
+
%x{#{cmd}}
|
680
677
|
end
|
681
|
-
rescue
|
682
|
-
if
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
else
|
690
|
-
build_attempt += 1
|
691
|
-
try_build = false
|
692
|
-
failures[dir] = e.to_s
|
693
|
-
if _verbose
|
694
|
-
stderr.puts(e.to_s)
|
695
|
-
else
|
696
|
-
stderr.puts("Error found in: #{File.basename(dir)}")
|
697
|
-
end
|
678
|
+
rescue
|
679
|
+
if _verbose
|
680
|
+
$stderr.puts("First 'rake pkg:rpm' attempt failed, running bundle and trying again.")
|
681
|
+
end
|
682
|
+
|
683
|
+
::Bundler.with_clean_env do
|
684
|
+
%x{bundle install}
|
685
|
+
%x{#{cmd}}
|
698
686
|
end
|
699
687
|
end
|
700
688
|
|
701
|
-
|
702
|
-
|
689
|
+
tarballs = Dir.glob('dist/*.tar.gz')
|
690
|
+
srpms = Dir.glob('dist/*.src.rpm')
|
691
|
+
rpms = (Dir.glob('dist/*.rpm') - srpms)
|
703
692
|
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
errmsg = ['Error: Failures found during module build']
|
708
|
-
failures.keys.each do |dir|
|
709
|
-
errmsg << ('* ' + dir)
|
710
|
-
errmsg << (failures[dir].lines.map{|ln| ln = " #{ln}}"})
|
693
|
+
# Not all items generate tarballs
|
694
|
+
tarballs.each do |pkg|
|
695
|
+
raise("Empty Tarball '#{pkg}' generated for #{dir}") if (File.stat(pkg).size == 0)
|
711
696
|
end
|
712
|
-
|
713
|
-
raise
|
697
|
+
raise("No SRPMs generated for #{dir}") if srpms.empty?
|
698
|
+
raise("No RPMs generated for #{dir}") if rpms.empty?
|
699
|
+
|
700
|
+
# Glob all generated rpms, and add their metadata to a result array.
|
701
|
+
pkginfo = Hash.new
|
702
|
+
rpms.each do |rpm|
|
703
|
+
# get_info from each generated rpm, not the spec file, so macros in the
|
704
|
+
# metadata have already been resolved in the mock chroot.
|
705
|
+
result << Simp::RPM.get_info(rpm)
|
706
|
+
end
|
707
|
+
else
|
708
|
+
puts "Warning: Could not find Rakefile in '#{dir}'"
|
714
709
|
end
|
715
710
|
end
|
716
711
|
end
|
@@ -719,7 +714,7 @@ protect=1
|
|
719
714
|
# Each module could generate multiple rpms, each with its own metadata.
|
720
715
|
# Iterate over them to add all built rpms to autorequires.
|
721
716
|
mod.each do |module_pkginfo|
|
722
|
-
next unless (module_pkginfo)
|
717
|
+
next unless (module_pkginfo && module_pkginfo.is_a?(Hash))
|
723
718
|
|
724
719
|
# Set up the autorequires
|
725
720
|
if add_to_autoreq
|
data/lib/simp/rake/build/tar.rb
CHANGED
@@ -25,6 +25,9 @@ module Simp::Rake::Build
|
|
25
25
|
fail("Could not find simp main RPM in output directory!") unless simp_rpm
|
26
26
|
simp_version = File.basename(simp_rpm).gsub(".noarch.rpm","").gsub("simp-","")
|
27
27
|
|
28
|
+
# For picking up the correct RPM template
|
29
|
+
ENV['SIMP_BUILD_version'] ||= simp_version
|
30
|
+
|
28
31
|
return simp_version
|
29
32
|
end
|
30
33
|
|
@@ -1,382 +1,20 @@
|
|
1
1
|
module Simp; end
|
2
2
|
module Simp::Rake; end
|
3
3
|
class Simp::Rake::Helpers
|
4
|
-
module Simp::Rake::Helpers::
|
5
|
-
|
4
|
+
module Simp::Rake::Helpers::RPMSpec
|
6
5
|
def self.template
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
--
|
11
|
-
-- When you build you must to pass this along so that we know how
|
12
|
-
-- to get the preliminary information.
|
13
|
-
-- This directory should hold the following items:
|
14
|
-
-- * 'build' directory
|
15
|
-
-- * 'CHANGELOG' <- The RPM formatted Changelog
|
16
|
-
-- * 'metadata.json'
|
17
|
-
--
|
18
|
-
-- Example:
|
19
|
-
-- rpmbuild -D 'pup_module_info_dir /home/user/project/puppet_module' -ba SPECS/specfile.spec
|
20
|
-
--
|
21
|
-
-- If this is not found, we will look in %{_sourcedir} for the files and fall
|
22
|
-
-- back to the current directory
|
23
|
-
--
|
24
|
-
|
25
|
-
src_dir = rpm.expand('%{pup_module_info_dir}')
|
26
|
-
|
27
|
-
if string.match(src_dir, '^%%') or (posix.stat(src_dir, 'type') ~= 'directory') then
|
28
|
-
src_dir = rpm.expand('%{_sourcedir}')
|
29
|
-
|
30
|
-
if (posix.stat((src_dir .. "/metadata.json"), 'type') ~= 'regular') then
|
31
|
-
src_dir = './'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
-- These UNKNOWN entries should break the build if something bad happens
|
36
|
-
|
37
|
-
package_name = "UNKNOWN"
|
38
|
-
package_version = "UNKNOWN"
|
39
|
-
module_license = "UNKNOWN"
|
40
|
-
|
41
|
-
--
|
42
|
-
-- Default to 2016
|
43
|
-
-- This was done due to the change in naming scheme across all of the modules.
|
44
|
-
--
|
45
|
-
|
46
|
-
package_release = '2016'
|
47
|
-
|
48
|
-
}
|
49
|
-
|
50
|
-
%{lua:
|
51
|
-
-- Pull the Relevant Metadata out of the Puppet module metadata.json.
|
52
|
-
|
53
|
-
metadata = ''
|
54
|
-
metadata_file = io.open(src_dir .. "/metadata.json","r")
|
55
|
-
if metadata_file then
|
56
|
-
metadata = metadata_file:read("*all")
|
57
|
-
|
58
|
-
-- Ignore the first curly brace
|
59
|
-
metadata = metadata:gsub("{}?", '|', 1)
|
60
|
-
|
61
|
-
-- Ignore all keys that are below the first level
|
62
|
-
metadata = metadata:gsub("{.-}", '')
|
63
|
-
metadata = metadata:gsub("%[.-%]", '')
|
64
|
-
end
|
65
|
-
|
66
|
-
-- This starts as an empty string so that we can build it later
|
67
|
-
module_requires = ''
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
%{lua:
|
72
|
-
|
73
|
-
-- Get the Module Name and put it in the correct format
|
74
|
-
|
75
|
-
local name_match = string.match(metadata, '"name":%s+"(.-)"%s*,')
|
76
|
-
|
77
|
-
module_author = ''
|
78
|
-
module_name = ''
|
79
|
-
|
80
|
-
if name_match then
|
81
|
-
package_name = ('pupmod-' .. name_match)
|
82
|
-
|
83
|
-
local i = 0
|
84
|
-
for str in string.gmatch(name_match,'[^-]+') do
|
85
|
-
if i == 0 then
|
86
|
-
module_author = str
|
87
|
-
else
|
88
|
-
if module_name == '' then
|
89
|
-
module_name = str
|
6
|
+
simp_version = ENV.fetch('SIMP_BUILD_version', @simp_version)
|
7
|
+
if simp_version
|
8
|
+
simp_main_version = simp_version.split('.').first
|
90
9
|
else
|
91
|
-
|
10
|
+
simp_main_version = 'default'
|
92
11
|
end
|
93
|
-
end
|
94
|
-
|
95
|
-
i = i+1
|
96
|
-
end
|
97
|
-
else
|
98
|
-
print("Error: Could not find valid package name in 'metadata.json'")
|
99
|
-
end
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
%{lua:
|
104
|
-
|
105
|
-
-- Get the Module Version
|
106
|
-
-- This will not be processed at all
|
107
|
-
|
108
|
-
local version_match = string.match(metadata, '"version":%s+"(.-)"%s*,')
|
109
|
-
|
110
|
-
if version_match then
|
111
|
-
package_version = version_match
|
112
|
-
end
|
113
|
-
|
114
|
-
}
|
115
|
-
|
116
|
-
%{lua:
|
117
|
-
|
118
|
-
-- Get the Module License
|
119
|
-
-- This will not be processed at all
|
120
|
-
|
121
|
-
local license_match = string.match(metadata, '"license":%s+"(.-)"%s*,')
|
122
|
-
|
123
|
-
if license_match then
|
124
|
-
module_license = license_match
|
125
|
-
end
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
%{lua:
|
130
|
-
|
131
|
-
-- Get the Module Summary
|
132
|
-
-- This will not be processed at all
|
133
|
-
|
134
|
-
local summary_match = string.match(metadata, '"summary":%s+"(.-)"%s*,')
|
135
|
-
|
136
|
-
if summary_match then
|
137
|
-
module_summary = summary_match
|
138
|
-
end
|
139
|
-
|
140
|
-
}
|
141
|
-
|
142
|
-
%{lua:
|
143
|
-
|
144
|
-
-- Get the Module Source line for the URL string
|
145
|
-
-- This will not be processed at all
|
146
|
-
|
147
|
-
local source_match = string.match(metadata, '"source":%s+"(.-)"%s*,')
|
148
|
-
|
149
|
-
if source_match then
|
150
|
-
module_source = source_match
|
151
|
-
end
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
%{lua:
|
156
|
-
|
157
|
-
-- Snag the RPM-specific items out of the 'build/rpm_metadata' directory
|
158
|
-
|
159
|
-
-- First, the Release Number
|
160
|
-
|
161
|
-
rel_file = io.open(src_dir .. "/build/rpm_metadata/release", "r")
|
162
|
-
|
163
|
-
if not rel_file then
|
164
|
-
-- Need this for the SRPM case
|
165
|
-
rel_file = io.open(src_dir .. "/release", "r")
|
166
|
-
end
|
167
12
|
|
168
|
-
|
169
|
-
for line in rel_file:lines() do
|
170
|
-
is_comment = string.match(line, "^%s*#")
|
171
|
-
is_blank = string.match(line, "^%s*$")
|
13
|
+
template_file = File.join(File.dirname(__FILE__), 'rpm_spec', 'assets', "simp#{simp_main_version}.spec")
|
172
14
|
|
173
|
-
|
174
|
-
package_release = line
|
175
|
-
break
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
}
|
181
|
-
|
182
|
-
%{lua:
|
183
|
-
|
184
|
-
-- Next, the Requirements
|
185
|
-
req_file = io.open(src_dir .. "/build/rpm_metadata/requires", "r")
|
186
|
-
|
187
|
-
if not req_file then
|
188
|
-
-- Need this for the SRPM case
|
189
|
-
req_file = io.open(src_dir .. "/requires", "r")
|
190
|
-
end
|
191
|
-
|
192
|
-
if req_file then
|
193
|
-
for line in req_file:lines() do
|
194
|
-
valid_line = (string.match(line, "^Requires: ") or string.match(line, "^Obsoletes: ") or string.match(line, "^Provides: "))
|
195
|
-
|
196
|
-
if valid_line then
|
197
|
-
module_requires = (module_requires .. "\\n" .. line)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
}
|
202
|
-
|
203
|
-
%define module_name %{lua: print(module_name)}
|
204
|
-
%define base_name %{lua: print(package_name)}
|
205
|
-
|
206
|
-
%{lua:
|
207
|
-
-- Determine which Variant we are going to build
|
208
|
-
|
209
|
-
local variant = rpm.expand("%{_variant}")
|
210
|
-
local variant_version = nil
|
211
|
-
|
212
|
-
local foo = ""
|
213
|
-
|
214
|
-
local i = 0
|
215
|
-
for str in string.gmatch(variant,'[^-]+') do
|
216
|
-
if i == 0 then
|
217
|
-
variant = str
|
218
|
-
elseif i == 1 then
|
219
|
-
variant_version = str
|
220
|
-
else
|
221
|
-
break
|
222
|
-
end
|
223
|
-
|
224
|
-
i = i+1
|
225
|
-
end
|
226
|
-
|
227
|
-
rpm.define("variant " .. variant)
|
228
|
-
|
229
|
-
if variant == "pe" then
|
230
|
-
rpm.define("puppet_user pe-puppet")
|
231
|
-
else
|
232
|
-
rpm.define("puppet_user puppet")
|
233
|
-
end
|
234
|
-
|
235
|
-
if variant == "pe" then
|
236
|
-
if variant_version and ( rpm.vercmp(variant_version,'4') >= 0 ) then
|
237
|
-
rpm.define("_sysconfdir /etc/puppetlabs/code")
|
238
|
-
else
|
239
|
-
rpm.define("_sysconfdir /etc/puppetlabs/puppet")
|
240
|
-
end
|
241
|
-
elseif variant == "p4" then
|
242
|
-
rpm.define("_sysconfdir /etc/puppetlabs/code")
|
243
|
-
else
|
244
|
-
rpm.define("_sysconfdir /etc/puppet")
|
245
|
-
end
|
246
|
-
}
|
247
|
-
|
248
|
-
Summary: %{module_name} Puppet Module
|
249
|
-
%if 0%{?_variant:1}
|
250
|
-
Name: %{base_name}-%{variant}
|
251
|
-
%else
|
252
|
-
Name: %{base_name}
|
253
|
-
%endif
|
254
|
-
|
255
|
-
Version: %{lua: print(package_version)}
|
256
|
-
Release: %{lua: print(package_release)}
|
257
|
-
License: %{lua: print(module_license)}
|
258
|
-
Group: Applications/System
|
259
|
-
Source0: %{base_name}-%{version}-%{release}.tar.gz
|
260
|
-
Source1: %{lua: print("metadata.json")}
|
261
|
-
%{lua:
|
262
|
-
-- Include our sources as appropriate
|
263
|
-
changelog = io.open(src_dir .. "/CHANGELOG","r")
|
264
|
-
if changelog then
|
265
|
-
print("Source2: " .. "CHANGELOG\\n")
|
266
|
-
end
|
15
|
+
raise "Error: Could not find template for SIMP version #{simp_version}" unless File.exist?(template_file)
|
267
16
|
|
268
|
-
|
269
|
-
print("Source3: " .. "release\\n")
|
270
|
-
end
|
271
|
-
if req_file then
|
272
|
-
print("Source4: " .. "requires\\n")
|
273
|
-
end
|
274
|
-
}
|
275
|
-
URL: %{lua: print(module_source)}
|
276
|
-
BuildRoot: %{_tmppath}/%{base_name}-%{version}-%{release}-buildroot
|
277
|
-
BuildArch: noarch
|
278
|
-
|
279
|
-
%if "%{variant}" == "pe"
|
280
|
-
Requires: pe-puppet >= 3.8.6
|
281
|
-
%else
|
282
|
-
Requires: puppet >= 3.8.6
|
283
|
-
%endif
|
284
|
-
|
285
|
-
%if ("%{base_name}" != "pupmod-simp-simplib") && ("%{base_name}" != "pupmod-puppetlabs-stdlib")
|
286
|
-
Requires: pupmod-simp-simplib >= 1.2.6
|
287
|
-
%endif
|
288
|
-
|
289
|
-
%if "%{base_name}" != "pupmod-puppetlabs-stdlib"
|
290
|
-
Requires: pupmod-puppetlabs-stdlib >= 4.9.0
|
291
|
-
Requires: pupmod-puppetlabs-stdlib < 6.0.0
|
292
|
-
%endif
|
293
|
-
|
294
|
-
%{lua: print(module_requires)}
|
295
|
-
|
296
|
-
Provides: pupmod-%{lua: print(module_name)} = %{lua: print(package_version .. "-" .. package_release)}
|
297
|
-
Obsoletes: pupmod-%{lua: print(module_name)} < %{lua: print(package_version .. "-" .. package_release)}
|
298
|
-
|
299
|
-
%{lua:
|
300
|
-
|
301
|
-
-- This is a workaround for the 'simp-rsync' real RPM conflict but is
|
302
|
-
-- required by some external modules.
|
303
|
-
-- This should be removed when SIMP 6 is stable
|
304
|
-
|
305
|
-
author_rpm_name = module_author .. "-" .. module_name
|
306
|
-
|
307
|
-
if author_rpm_name ~= 'simp-rsync' then
|
308
|
-
print("Provides: " .. author_rpm_name .. " = " .. package_version .. "-" .. package_release .. "\\n")
|
309
|
-
print("Obsoletes: " .. author_rpm_name .. " < " .. package_version .. "-" .. package_release .. "\\n")
|
310
|
-
end
|
311
|
-
}
|
312
|
-
|
313
|
-
Prefix: %{_sysconfdir}/environments/simp/modules
|
314
|
-
|
315
|
-
%description
|
316
|
-
%{lua: print(module_summary)}
|
317
|
-
|
318
|
-
%prep
|
319
|
-
%setup -q -n %{base_name}-%{version}
|
320
|
-
|
321
|
-
%build
|
322
|
-
|
323
|
-
%install
|
324
|
-
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
|
325
|
-
|
326
|
-
mkdir -p %{buildroot}/%{prefix}
|
327
|
-
|
328
|
-
rm -rf .git
|
329
|
-
rm -f *.lock
|
330
|
-
rm -rf spec/fixtures/modules
|
331
|
-
rm -rf dist
|
332
|
-
rm -rf junit
|
333
|
-
rm -rf log
|
334
|
-
|
335
|
-
curdir=`pwd`
|
336
|
-
dirname=`basename $curdir`
|
337
|
-
cp -r ../$dirname %{buildroot}/%{prefix}/%{module_name}
|
338
|
-
|
339
|
-
%clean
|
340
|
-
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
|
341
|
-
|
342
|
-
mkdir -p %{buildroot}/%{prefix}
|
343
|
-
|
344
|
-
%files
|
345
|
-
%defattr(0640,root,%{puppet_user},0750)
|
346
|
-
%{prefix}/%{module_name}
|
347
|
-
|
348
|
-
%changelog
|
349
|
-
%{lua:
|
350
|
-
-- Finally, the CHANGELOG
|
351
|
-
|
352
|
-
-- A default CHANGELOG in case we cannot find a real one
|
353
|
-
|
354
|
-
default_changelog = [===[
|
355
|
-
* $date Auto Changelog <auto@no.body> - $version-$release
|
356
|
-
- Latest release of $name
|
357
|
-
]===]
|
358
|
-
|
359
|
-
default_lookup_table = {
|
360
|
-
date = os.date("%a %b %d %Y"),
|
361
|
-
version = package_version,
|
362
|
-
release = package_release,
|
363
|
-
name = package_name
|
364
|
-
}
|
365
|
-
|
366
|
-
changelog = io.open(src_dir .. "/CHANGELOG","r")
|
367
|
-
if changelog then
|
368
|
-
first_line = changelog:read()
|
369
|
-
if string.match(first_line, "^*%s+%a%a%a%s+%a%a%a%s+%d%d?%s+%d%d%d%d%s+.+") then
|
370
|
-
changelog:seek("set",0)
|
371
|
-
print(changelog:read("*all"))
|
372
|
-
else
|
373
|
-
print((default_changelog:gsub('$(%w+)', default_lookup_table)))
|
374
|
-
end
|
375
|
-
else
|
376
|
-
print((default_changelog:gsub('$(%w+)', default_lookup_table)))
|
377
|
-
end
|
378
|
-
}
|
379
|
-
EOF
|
17
|
+
return File.read(template_file)
|
380
18
|
end
|
381
19
|
end
|
382
20
|
end
|