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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +3 -1
  4. data/lib/simp/rake/build/iso.rb +11 -2
  5. data/lib/simp/rake/build/pkg.rb +60 -65
  6. data/lib/simp/rake/build/tar.rb +3 -0
  7. data/lib/simp/rake/build/vermap.yaml +1 -0
  8. data/lib/simp/rake/helpers/rpm_spec.rb +8 -370
  9. data/lib/simp/rake/helpers/rpm_spec/assets/simp4.spec +387 -0
  10. data/lib/simp/rake/helpers/rpm_spec/assets/simp5.spec +387 -0
  11. data/lib/simp/rake/helpers/rpm_spec/assets/simpdefault.spec +356 -0
  12. data/lib/simp/rake/helpers/version.rb +1 -1
  13. data/lib/simp/rake/pkg.rb +63 -60
  14. data/lib/simp/rpm.rb +52 -25
  15. data/spec/acceptance/files/simplib/CHANGELOG +2 -0
  16. data/spec/acceptance/files/simplib/Rakefile +3 -0
  17. data/spec/acceptance/files/simplib/build/rpm_metadata/requires +1 -0
  18. data/spec/acceptance/files/simplib/metadata.json +33 -0
  19. data/spec/acceptance/files/testpackage_missing_license/CHANGELOG +2 -0
  20. data/spec/acceptance/files/testpackage_missing_license/Rakefile +3 -0
  21. data/spec/acceptance/files/testpackage_missing_license/build/rpm_metadata/requires +1 -0
  22. data/spec/acceptance/files/testpackage_missing_license/metadata.json +32 -0
  23. data/spec/acceptance/files/testpackage_missing_metadata_file/CHANGELOG +2 -0
  24. data/spec/acceptance/files/testpackage_missing_metadata_file/Rakefile +3 -0
  25. data/spec/acceptance/files/testpackage_missing_metadata_file/build/rpm_metadata/requires +1 -0
  26. data/spec/acceptance/files/testpackage_missing_name/CHANGELOG +2 -0
  27. data/spec/acceptance/files/testpackage_missing_name/Rakefile +3 -0
  28. data/spec/acceptance/files/testpackage_missing_name/build/rpm_metadata/requires +1 -0
  29. data/spec/acceptance/files/testpackage_missing_name/metadata.json +32 -0
  30. data/spec/acceptance/files/testpackage_missing_source/CHANGELOG +2 -0
  31. data/spec/acceptance/files/testpackage_missing_source/Rakefile +3 -0
  32. data/spec/acceptance/files/testpackage_missing_source/build/rpm_metadata/requires +1 -0
  33. data/spec/acceptance/files/testpackage_missing_source/metadata.json +32 -0
  34. data/spec/acceptance/files/testpackage_missing_summary/CHANGELOG +2 -0
  35. data/spec/acceptance/files/testpackage_missing_summary/Rakefile +3 -0
  36. data/spec/acceptance/files/testpackage_missing_summary/build/rpm_metadata/requires +1 -0
  37. data/spec/acceptance/files/testpackage_missing_summary/metadata.json +32 -0
  38. data/spec/acceptance/files/testpackage_missing_version/CHANGELOG +2 -0
  39. data/spec/acceptance/files/testpackage_missing_version/Rakefile +3 -0
  40. data/spec/acceptance/files/testpackage_missing_version/build/rpm_metadata/requires +1 -0
  41. data/spec/acceptance/files/testpackage_missing_version/metadata.json +32 -0
  42. data/spec/acceptance/files/testpackage_with_bad_changelog_date/CHANGELOG +2 -0
  43. data/spec/acceptance/files/testpackage_with_bad_changelog_date/Rakefile +3 -0
  44. data/spec/acceptance/files/testpackage_with_bad_changelog_date/build/rpm_metadata/requires +1 -0
  45. data/spec/acceptance/files/testpackage_with_bad_changelog_date/metadata.json +33 -0
  46. data/spec/acceptance/files/testpackage_with_release/CHANGELOG +2 -0
  47. data/spec/acceptance/files/testpackage_with_release/Rakefile +3 -0
  48. data/spec/acceptance/files/testpackage_with_release/build/rpm_metadata/release +1 -0
  49. data/spec/acceptance/files/testpackage_with_release/build/rpm_metadata/requires +1 -0
  50. data/spec/acceptance/files/testpackage_with_release/metadata.json +33 -0
  51. data/spec/acceptance/files/testpackage_without_changelog/Rakefile +3 -0
  52. data/spec/acceptance/files/testpackage_without_changelog/build/rpm_metadata/requires +1 -0
  53. data/spec/acceptance/files/testpackage_without_changelog/metadata.json +33 -0
  54. data/spec/acceptance/pkg_rpm_spec.rb +215 -41
  55. metadata +44 -2
data/lib/simp/rpm.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module Simp
2
4
  # Simp::RPM represents a single package that is built and packaged by the Simp team.
3
5
  class Simp::RPM
@@ -33,6 +35,7 @@ module Simp
33
35
  @full_version = info[:full_version]
34
36
  @name = "#{@basename}-#{@full_version}"
35
37
  @sources = Array.new
38
+ @verbose = false
36
39
  end
37
40
 
38
41
  # Copies specific content from one directory to another.
@@ -51,6 +54,30 @@ module Simp
51
54
  end
52
55
  end
53
56
 
57
+ # Executes a command and returns a hash with the exit status,
58
+ # stdout output and stderr output.
59
+ # cmd:: command to be executed
60
+ def self.execute(cmd)
61
+ #puts "Executing: [#{cmd}]"
62
+ outfile = File.join('/tmp', "#{ENV['USER']}_#{SecureRandom.hex}")
63
+ errfile = File.join('/tmp', "#{ENV['USER']}_#{SecureRandom.hex}")
64
+ pid = spawn(cmd, :out=>outfile, :err=>errfile)
65
+
66
+ begin
67
+ pid,status = Process.wait2(pid)
68
+ rescue Errno::ECHILD
69
+ # process exited before status could be determined
70
+ end
71
+
72
+ exit_status = status.nil? ? nil : status.exitstatus
73
+ stdout = IO.read(outfile)
74
+ stderr = IO.read(errfile)
75
+
76
+ { :exit_status => exit_status, :stdout => stdout, :stderr => stderr }
77
+ ensure
78
+ FileUtils.rm_f([outfile, errfile])
79
+ end
80
+
54
81
  # Parses information, such as the version, from the given specfile or RPM
55
82
  # into a hash.
56
83
  #
@@ -65,40 +92,36 @@ module Simp
65
92
  rpm_cmd = "rpm -q --queryformat '%{NAME} %{VERSION} %{RELEASE}\n'"
66
93
 
67
94
  if mock_hash
68
- rpm_cmd = mock_hash[:command] + ' ' + '"' + rpm_cmd + ' ' + mock_hash[:rpm_extras] + ' 2>/dev/null "'
95
+ # Suppression of error messages is a hack for the following
96
+ # scenario:
97
+ # * The RPM spec file has an invalid date in its %changelog.
98
+ # * The 'bogus date' warning message from rpmbuild
99
+ # is sent to stderr, while RPM name, version, and release
100
+ # info is sent to stdout.
101
+ # * mock combines stdout and stderr in the command run.
102
+ # * The 'bogus date' warning message is parsed to generate
103
+ # the RPM info, instead of the RPM info message.
104
+ rpm_cmd = mock_hash[:command] + ' ' + '"' + rpm_cmd + ' ' + mock_hash[:rpm_extras] + ' 2>/dev/null"'
69
105
  end
70
106
 
71
107
  if File.readable?(rpm_source)
72
108
  if rpm_source.split('.').last == 'rpm'
73
- rpm_info = %x(#{rpm_cmd} -p #{rpm_source} 2>/dev/null).strip
74
-
75
- if rpm_info.empty?
76
- raise <<-EOE
77
- Error getting RPM info.
78
- Run '#{rpm_cmd.gsub("\n",'\\n')} -p #{rpm_source}' to debug the issue.
79
- EOE
80
- end
109
+ results = execute("#{rpm_cmd} -p #{rpm_source}")
81
110
  elsif mock_hash
82
- rpm_info = %x(#{rpm_cmd}).strip
83
-
84
- if rpm_info.empty?
85
- raise <<-EOE
86
- Error getting RPM info.
87
- Run '#{rpm_cmd.gsub("\n",'\\n')}' to debug the issue.
88
- EOE
89
- end
111
+ results = execute("#{rpm_cmd}")
90
112
  else
91
- rpm_info = %x(#{rpm_cmd} --specfile #{rpm_source} 2>/dev/null).strip
113
+ results = execute("#{rpm_cmd} --specfile #{rpm_source}")
114
+ end
92
115
 
93
- if rpm_info.empty?
94
- raise <<-EOE
95
- Error getting RPM info.
96
- Run '#{rpm_cmd.gsub("\n",'\\n')} --specfile #{rpm_source}' to debug the issue.
97
- EOE
98
- end
116
+ if results[:exit_status] != 0
117
+ raise <<-EOE
118
+ #{indent('Error getting RPM info:', 2)}
119
+ #{indent(results[:stderr].strip, 5)}
120
+ #{indent("Run '#{rpm_cmd.gsub("\n",'\\n')} --specfile #{rpm_source}' to recreate the issue.", 2)}
121
+ EOE
99
122
  end
100
123
 
101
- info[:name],info[:version],info[:release] = rpm_info.split("\n").first.split(' ')
124
+ info[:name],info[:version],info[:release] = results[:stdout].strip.split("\n").first.split(' ')
102
125
  else
103
126
  raise "Error: unable to read '#{rpm_source}'"
104
127
  end
@@ -108,6 +131,10 @@ module Simp
108
131
  return info
109
132
  end
110
133
 
134
+ def self.indent(message, indent_length)
135
+ message.split("\n").map {|line| ' '*indent_length + line }.join("\n")
136
+ end
137
+
111
138
  # Loads metadata for a GPG key. The GPG key is to be used to sign RPMs. The
112
139
  # value of gpg_key should be the full path of the directory where the key
113
140
  # resides. If the metadata cannot be found, then the user will be prompted
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "simp-simplib",
3
+ "version": "1.2.3",
4
+ "author": "simp",
5
+ "summary": "A fake SIMP simplib for Testing Test Things",
6
+ "license": "Apache-2.0",
7
+ "source": "https://github.com/simp/pupmod-imatest",
8
+ "project_page": "https://github.com/simp/pupmod-imatest",
9
+ "issues_url": "https://simp/project.atlassian.net",
10
+ "tags": [ "simp", "test"],
11
+ "dependencies": [
12
+ {
13
+ "name": "simp/compliance_markup",
14
+ "version_requirement": ">= 1.0.0"
15
+ }
16
+ ],
17
+ "operatingsystem_support": [
18
+ {
19
+ "operatingsystem": "CentOS",
20
+ "operatingsystemrelease": [
21
+ "6",
22
+ "7"
23
+ ]
24
+ },
25
+ {
26
+ "operatingsystem": "RedHat",
27
+ "operatingsystemrelease": [
28
+ "6",
29
+ "7"
30
+ ]
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "simp-testpackage",
3
+ "version": "0.0.1",
4
+ "author": "simp",
5
+ "summary": "A SIMP Test Package for Testing Test Things",
6
+ "source": "https://github.com/simp/pupmod-imatest",
7
+ "project_page": "https://github.com/simp/pupmod-imatest",
8
+ "issues_url": "https://simp/project.atlassian.net",
9
+ "tags": [ "simp", "test"],
10
+ "dependencies": [
11
+ {
12
+ "name": "simp/simplib",
13
+ "version_requirement": ">= 1.1.0"
14
+ }
15
+ ],
16
+ "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "CentOS",
19
+ "operatingsystemrelease": [
20
+ "6",
21
+ "7"
22
+ ]
23
+ },
24
+ {
25
+ "operatingsystem": "RedHat",
26
+ "operatingsystemrelease": [
27
+ "6",
28
+ "7"
29
+ ]
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,32 @@
1
+ {
2
+ "version": "0.0.1",
3
+ "author": "simp",
4
+ "summary": "A SIMP Test Package for Testing Test Things",
5
+ "license": "Apache-2.0",
6
+ "source": "https://github.com/simp/pupmod-imatest",
7
+ "project_page": "https://github.com/simp/pupmod-imatest",
8
+ "issues_url": "https://simp/project.atlassian.net",
9
+ "tags": [ "simp", "test"],
10
+ "dependencies": [
11
+ {
12
+ "name": "simp/simplib",
13
+ "version_requirement": ">= 1.1.0"
14
+ }
15
+ ],
16
+ "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "CentOS",
19
+ "operatingsystemrelease": [
20
+ "6",
21
+ "7"
22
+ ]
23
+ },
24
+ {
25
+ "operatingsystem": "RedHat",
26
+ "operatingsystemrelease": [
27
+ "6",
28
+ "7"
29
+ ]
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "simp-testpackage",
3
+ "version": "0.0.1",
4
+ "author": "simp",
5
+ "summary": "A SIMP Test Package for Testing Test Things",
6
+ "license": "Apache-2.0",
7
+ "project_page": "https://github.com/simp/pupmod-imatest",
8
+ "issues_url": "https://simp/project.atlassian.net",
9
+ "tags": [ "simp", "test"],
10
+ "dependencies": [
11
+ {
12
+ "name": "simp/simplib",
13
+ "version_requirement": ">= 1.1.0"
14
+ }
15
+ ],
16
+ "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "CentOS",
19
+ "operatingsystemrelease": [
20
+ "6",
21
+ "7"
22
+ ]
23
+ },
24
+ {
25
+ "operatingsystem": "RedHat",
26
+ "operatingsystemrelease": [
27
+ "6",
28
+ "7"
29
+ ]
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "simp-testpackage",
3
+ "version": "0.0.1",
4
+ "author": "simp",
5
+ "license": "Apache-2.0",
6
+ "source": "https://github.com/simp/pupmod-imatest",
7
+ "project_page": "https://github.com/simp/pupmod-imatest",
8
+ "issues_url": "https://simp/project.atlassian.net",
9
+ "tags": [ "simp", "test"],
10
+ "dependencies": [
11
+ {
12
+ "name": "simp/simplib",
13
+ "version_requirement": ">= 1.1.0"
14
+ }
15
+ ],
16
+ "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "CentOS",
19
+ "operatingsystemrelease": [
20
+ "6",
21
+ "7"
22
+ ]
23
+ },
24
+ {
25
+ "operatingsystem": "RedHat",
26
+ "operatingsystemrelease": [
27
+ "6",
28
+ "7"
29
+ ]
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ * Sat Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "simp-testpackage",
3
+ "author": "simp",
4
+ "summary": "A SIMP Test Package for Testing Test Things",
5
+ "license": "Apache-2.0",
6
+ "source": "https://github.com/simp/pupmod-imatest",
7
+ "project_page": "https://github.com/simp/pupmod-imatest",
8
+ "issues_url": "https://simp/project.atlassian.net",
9
+ "tags": [ "simp", "test"],
10
+ "dependencies": [
11
+ {
12
+ "name": "simp/simplib",
13
+ "version_requirement": ">= 1.1.0"
14
+ }
15
+ ],
16
+ "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "CentOS",
19
+ "operatingsystemrelease": [
20
+ "6",
21
+ "7"
22
+ ]
23
+ },
24
+ {
25
+ "operatingsystem": "RedHat",
26
+ "operatingsystemrelease": [
27
+ "6",
28
+ "7"
29
+ ]
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ * Wed Dec 13 2014 Richard Stallman <rms@gnu.org> - 0.0.1-0
2
+ - Behold, there was a brave GNU world....
@@ -0,0 +1,3 @@
1
+ require 'simp/rake/pkg'
2
+
3
+ Simp::Rake::Pkg.new( File.dirname( __FILE__ ) )
@@ -0,0 +1 @@
1
+ Requires: pupmod-simp-foo >= 1.2.3
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "simp-testpackage",
3
+ "version": "0.0.1",
4
+ "author": "simp",
5
+ "summary": "A SIMP Test Package for Testing Test Things",
6
+ "license": "Apache-2.0",
7
+ "source": "https://github.com/simp/pupmod-imatest",
8
+ "project_page": "https://github.com/simp/pupmod-imatest",
9
+ "issues_url": "https://simp/project.atlassian.net",
10
+ "tags": [ "simp", "test"],
11
+ "dependencies": [
12
+ {
13
+ "name": "simp/simplib",
14
+ "version_requirement": ">= 1.1.0"
15
+ }
16
+ ],
17
+ "operatingsystem_support": [
18
+ {
19
+ "operatingsystem": "CentOS",
20
+ "operatingsystemrelease": [
21
+ "6",
22
+ "7"
23
+ ]
24
+ },
25
+ {
26
+ "operatingsystem": "RedHat",
27
+ "operatingsystemrelease": [
28
+ "6",
29
+ "7"
30
+ ]
31
+ }
32
+ ]
33
+ }