simp-rake-helpers 5.11.6 → 5.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +0 -3
  5. data/README.md +3 -38
  6. data/Rakefile +2 -3
  7. data/lib/simp/command_utils.rb +21 -0
  8. data/lib/simp/local_gpg_signing_key.rb +128 -79
  9. data/lib/simp/rake/build/auto.rb +4 -2
  10. data/lib/simp/rake/build/build.rb +5 -4
  11. data/lib/simp/rake/build/iso.rb +57 -31
  12. data/lib/simp/rake/build/pkg.rb +118 -56
  13. data/lib/simp/rake/build/spec.rb +1 -1
  14. data/lib/simp/rake/build/tar.rb +1 -1
  15. data/lib/simp/rake/build/unpack.rb +1 -1
  16. data/lib/simp/rake/build/upload.rb +1 -1
  17. data/lib/simp/rake/build/vermap.yaml +1 -1
  18. data/lib/simp/rake/helpers/assets/rpm_spec/simp6.spec +3 -3
  19. data/lib/simp/rake/helpers/assets/rpm_spec/simpdefault.spec +3 -3
  20. data/lib/simp/rake/helpers/version.rb +1 -1
  21. data/lib/simp/rake/helpers.rb +2 -2
  22. data/lib/simp/rake/pkg.rb +5 -1
  23. data/lib/simp/rake/pupmod/helpers.rb +2 -0
  24. data/lib/simp/rake/rubygem.rb +5 -1
  25. data/lib/simp/rake.rb +3 -17
  26. data/lib/simp/rpm.rb +10 -127
  27. data/lib/simp/rpm_signer.rb +321 -0
  28. data/spec/acceptance/nodesets/default.yml +0 -3
  29. data/spec/acceptance/{00_pkg_rpm_custom_scriptlets_spec.rb → suites/default/00_pkg_rpm_custom_scriptlets_spec.rb} +21 -22
  30. data/spec/acceptance/{10_pkg_rpm_spec.rb → suites/default/10_pkg_rpm_spec.rb} +50 -52
  31. data/spec/acceptance/{30_pkg_misc_spec.rb → suites/default/30_pkg_misc_spec.rb} +1 -1
  32. data/spec/acceptance/{50_local_gpg_signing_key_spec.rb → suites/default/50_local_gpg_signing_key_spec.rb} +7 -3
  33. data/spec/acceptance/suites/default/55_build_pkg_signing_spec.rb +391 -0
  34. data/spec/acceptance/{development → suites/default/development}/docker_env.sh +0 -0
  35. data/spec/acceptance/{development → suites/default/development}/rerun_acceptance_tests.sh +0 -0
  36. data/spec/acceptance/{development → suites/default/development}/vagrant_rsync.sh +0 -0
  37. data/spec/acceptance/{files → suites/default/files}/asset/Rakefile +0 -0
  38. data/spec/acceptance/{files → suites/default/files}/asset/build/asset.spec +0 -0
  39. data/spec/acceptance/{files → suites/default/files}/asset_with_misordered_entries/Rakefile +0 -0
  40. data/spec/acceptance/{files → suites/default/files}/asset_with_misordered_entries/build/asset_with_misordered_entries.spec +0 -0
  41. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/RPM-GPG-KEY-SIMP-Dev +0 -0
  42. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/gengpgkey +0 -0
  43. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/pubring.gpg +0 -0
  44. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/random_seed +0 -0
  45. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/run_gpg_agent +0 -0
  46. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/secring.gpg +0 -0
  47. data/spec/acceptance/{files → suites/default/files}/build/pkg/gpg-keydir.expired.2018-04-06/trustdb.gpg +0 -0
  48. data/spec/acceptance/{files → suites/default/files}/build/project_skeleton/Puppetfile.tracking +0 -0
  49. data/spec/acceptance/{files → suites/default/files}/build/project_skeleton/README.md +0 -0
  50. data/spec/acceptance/{files → suites/default/files}/build/project_skeleton/Rakefile +0 -0
  51. data/spec/acceptance/{files → suites/default/files}/build/project_skeleton/src/assets/simp/build/simp.spec +0 -0
  52. data/spec/acceptance/{files → suites/default/files}/module/CHANGELOG +0 -0
  53. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-new-package-2.1 → suites/default/files/module}/Rakefile +0 -0
  54. data/spec/acceptance/{files → suites/default/files}/module/metadata.json +0 -0
  55. data/spec/acceptance/{files → suites/default/files}/module_with_misordered_entries/CHANGELOG +0 -0
  56. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-new-package-3.0 → suites/default/files/module_with_misordered_entries}/Rakefile +0 -0
  57. data/spec/acceptance/{files → suites/default/files}/module_with_misordered_entries/metadata.json +0 -0
  58. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-new-package-2.1 → suites/default/files/simplib}/CHANGELOG +0 -0
  59. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-1.0 → suites/default/files/simplib}/Rakefile +0 -0
  60. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-1.0 → suites/default/files/simplib}/build/rpm_metadata/requires +0 -0
  61. data/spec/acceptance/{files → suites/default/files}/simplib/metadata.json +0 -0
  62. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-new-package-3.0 → suites/default/files/testpackage}/CHANGELOG +0 -0
  63. data/spec/acceptance/suites/default/files/testpackage/README +8 -0
  64. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-2.0 → suites/default/files/testpackage}/Rakefile +0 -0
  65. data/spec/acceptance/{files/package_upgrades/pupmod-simp-testpackage-1.0 → suites/default/files/testpackage}/build/rpm_metadata/requires +0 -0
  66. data/spec/acceptance/{files → suites/default/files}/testpackage/metadata.json +0 -0
  67. data/spec/acceptance/suites/default/files/testpackage/spec/classes/init_spec.rb +1 -0
  68. data/spec/acceptance/suites/default/files/testpackage/spec/files/mock_something.rb +3 -0
  69. data/spec/acceptance/suites/default/files/testpackage/utils/convert_v1_to_v2.rb +3 -0
  70. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-1.0 → suites/default/files/testpackage_custom_scriptlet}/CHANGELOG +0 -0
  71. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-2.2 → suites/default/files/testpackage_custom_scriptlet}/Rakefile +0 -0
  72. data/spec/acceptance/{files → suites/default/files}/testpackage_custom_scriptlet/build/rpm_metadata/custom/overrides +0 -0
  73. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-2.0 → suites/default/files/testpackage_custom_scriptlet}/build/rpm_metadata/requires +0 -0
  74. data/spec/acceptance/{files → suites/default/files}/testpackage_custom_scriptlet/metadata.json +0 -0
  75. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-2.0 → suites/default/files/testpackage_missing_license}/CHANGELOG +0 -0
  76. data/spec/acceptance/{files/module → suites/default/files/testpackage_missing_license}/Rakefile +0 -0
  77. data/spec/acceptance/{files/simplib → suites/default/files/testpackage_missing_license}/build/rpm_metadata/requires +0 -0
  78. data/spec/acceptance/{files → suites/default/files}/testpackage_missing_license/metadata.json +0 -0
  79. data/spec/acceptance/{files/custom_scriptlet_triggers/pupmod-old-package-2.2 → suites/default/files/testpackage_missing_metadata_file}/CHANGELOG +0 -0
  80. data/spec/acceptance/{files/module_with_misordered_entries → suites/default/files/testpackage_missing_metadata_file}/Rakefile +0 -0
  81. data/spec/acceptance/{files/testpackage_custom_scriptlet → suites/default/files/testpackage_missing_metadata_file}/build/rpm_metadata/requires +0 -0
  82. data/spec/acceptance/{files/simplib → suites/default/files/testpackage_missing_name}/CHANGELOG +0 -0
  83. data/spec/acceptance/{files/package_upgrades/pupmod-simp-testpackage-1.0 → suites/default/files/testpackage_missing_name}/Rakefile +0 -0
  84. data/spec/acceptance/{files/testpackage_missing_license → suites/default/files/testpackage_missing_name}/build/rpm_metadata/requires +0 -0
  85. data/spec/acceptance/{files → suites/default/files}/testpackage_missing_name/metadata.json +0 -0
  86. data/spec/acceptance/{files/testpackage → suites/default/files/testpackage_missing_source}/CHANGELOG +0 -0
  87. data/spec/acceptance/{files/package_upgrades/pupmod-simp-testpackage-2.0 → suites/default/files/testpackage_missing_source}/Rakefile +0 -0
  88. data/spec/acceptance/{files/testpackage_missing_metadata_file → suites/default/files/testpackage_missing_source}/build/rpm_metadata/requires +0 -0
  89. data/spec/acceptance/{files → suites/default/files}/testpackage_missing_source/metadata.json +0 -0
  90. data/spec/acceptance/{files/testpackage_custom_scriptlet → suites/default/files/testpackage_missing_summary}/CHANGELOG +0 -0
  91. data/spec/acceptance/{files/simplib → suites/default/files/testpackage_missing_summary}/Rakefile +0 -0
  92. data/spec/acceptance/{files/testpackage_missing_name → suites/default/files/testpackage_missing_summary}/build/rpm_metadata/requires +0 -0
  93. data/spec/acceptance/{files → suites/default/files}/testpackage_missing_summary/metadata.json +0 -0
  94. data/spec/acceptance/{files/testpackage_missing_license → suites/default/files/testpackage_missing_version}/CHANGELOG +0 -0
  95. data/spec/acceptance/{files/testpackage → suites/default/files/testpackage_missing_version}/Rakefile +0 -0
  96. data/spec/acceptance/{files/testpackage_missing_source → suites/default/files/testpackage_missing_version}/build/rpm_metadata/requires +0 -0
  97. data/spec/acceptance/{files → suites/default/files}/testpackage_missing_version/metadata.json +0 -0
  98. data/spec/acceptance/{files → suites/default/files}/testpackage_with_bad_changelog_date/CHANGELOG +0 -0
  99. data/spec/acceptance/{files/testpackage_custom_scriptlet → suites/default/files/testpackage_with_bad_changelog_date}/Rakefile +0 -0
  100. data/spec/acceptance/{files/testpackage_missing_summary → suites/default/files/testpackage_with_bad_changelog_date}/build/rpm_metadata/requires +0 -0
  101. data/spec/acceptance/{files → suites/default/files}/testpackage_with_bad_changelog_date/metadata.json +0 -0
  102. data/spec/acceptance/{files/testpackage_missing_metadata_file → suites/default/files/testpackage_with_release}/CHANGELOG +0 -0
  103. data/spec/acceptance/{files/testpackage_missing_license → suites/default/files/testpackage_with_release}/Rakefile +0 -0
  104. data/spec/acceptance/{files → suites/default/files}/testpackage_with_release/build/rpm_metadata/release +0 -0
  105. data/spec/acceptance/{files/testpackage_missing_version → suites/default/files/testpackage_with_release}/build/rpm_metadata/requires +0 -0
  106. data/spec/acceptance/{files → suites/default/files}/testpackage_with_release/metadata.json +0 -0
  107. data/spec/acceptance/{files/testpackage_missing_metadata_file → suites/default/files/testpackage_without_changelog}/Rakefile +0 -0
  108. data/spec/acceptance/{files/testpackage_with_bad_changelog_date → suites/default/files/testpackage_without_changelog}/build/rpm_metadata/requires +0 -0
  109. data/spec/acceptance/{files → suites/default/files}/testpackage_without_changelog/metadata.json +0 -0
  110. data/spec/acceptance/{support → suites/default/support}/build_project_helpers.rb +33 -9
  111. data/spec/acceptance/{support → suites/default/support}/build_user_helpers.rb +0 -0
  112. data/spec/acceptance/{support → suites/default/support}/pkg_rpm_helpers.rb +0 -0
  113. data/spec/lib/simp/command_utils_spec.rb +29 -0
  114. data/spec/lib/simp/local_gpg_signing_key_spec.rb.beaker-only +115 -18
  115. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/README.md +2 -2
  116. data/spec/lib/simp/rpm_signer_spec.rb +98 -0
  117. data/spec/lib/simp/rpm_spec.rb +0 -6
  118. data/spec/spec_helper_acceptance.rb +4 -0
  119. metadata +92 -149
  120. data/.travis.yml +0 -41
  121. data/lib/simp/rake/helpers/assets/rpm_spec/simp4.spec +0 -388
  122. data/lib/simp/rake/helpers/assets/rpm_spec/simp5.spec +0 -388
  123. data/spec/acceptance/20_pkg_rpm_upgrade_spec.rb +0 -236
  124. data/spec/acceptance/55_build_pkg_signing_spec.rb +0 -140
  125. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/build/rpm_metadata/custom/overrides +0 -14
  126. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/build/rpm_metadata/requires +0 -1
  127. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/metadata.json +0 -33
  128. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/build/rpm_metadata/custom/overrides +0 -14
  129. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/build/rpm_metadata/requires +0 -1
  130. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/metadata.json +0 -33
  131. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-1.0/metadata.json +0 -33
  132. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.0/metadata.json +0 -33
  133. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/build/rpm_metadata/custom/overrides +0 -14
  134. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/build/rpm_metadata/requires +0 -1
  135. data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/metadata.json +0 -33
  136. data/spec/acceptance/files/mock_packages/pupmod-puppetlabs-stdlib.spec +0 -32
  137. data/spec/acceptance/files/mock_packages/pupmod-simp-foo.spec +0 -32
  138. data/spec/acceptance/files/mock_packages/pupmod-simp-simplib.spec +0 -32
  139. data/spec/acceptance/files/mock_packages/rpmbuild.sh +0 -25
  140. data/spec/acceptance/files/mock_packages/simp-adapter/etc/simp/adapter_config.yaml +0 -3
  141. data/spec/acceptance/files/mock_packages/simp-adapter/usr/local/sbin/simp_rpm_helper +0 -495
  142. data/spec/acceptance/files/mock_packages/simp-adapter.spec +0 -43
  143. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/CHANGELOG +0 -2
  144. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/data/os/CentOS.yaml +0 -2
  145. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/data/os/RedHat.yaml +0 -2
  146. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/hiera.yaml +0 -14
  147. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/manifests/init.pp +0 -2
  148. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-1.0/metadata.json +0 -37
  149. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/CHANGELOG +0 -5
  150. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/build/rpm_metadata/requires +0 -2
  151. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/data/os/CentOS.yaml +0 -2
  152. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/data/os/RedHat.yaml +0 -2
  153. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/hiera.yaml +0 -14
  154. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/manifests/init.pp +0 -3
  155. data/spec/acceptance/files/package_upgrades/pupmod-simp-testpackage-2.0/metadata.json +0 -37
  156. data/spec/acceptance/files/testpackage/build/rpm_metadata/requires +0 -2
  157. data/spec/acceptance/files/testpackage_missing_name/CHANGELOG +0 -2
  158. data/spec/acceptance/files/testpackage_missing_name/Rakefile +0 -3
  159. data/spec/acceptance/files/testpackage_missing_source/CHANGELOG +0 -2
  160. data/spec/acceptance/files/testpackage_missing_source/Rakefile +0 -3
  161. data/spec/acceptance/files/testpackage_missing_summary/CHANGELOG +0 -2
  162. data/spec/acceptance/files/testpackage_missing_summary/Rakefile +0 -3
  163. data/spec/acceptance/files/testpackage_missing_version/CHANGELOG +0 -2
  164. data/spec/acceptance/files/testpackage_missing_version/Rakefile +0 -3
  165. data/spec/acceptance/files/testpackage_with_bad_changelog_date/Rakefile +0 -3
  166. data/spec/acceptance/files/testpackage_with_release/CHANGELOG +0 -2
  167. data/spec/acceptance/files/testpackage_with_release/Rakefile +0 -3
  168. data/spec/acceptance/files/testpackage_with_release/build/rpm_metadata/requires +0 -1
  169. data/spec/acceptance/files/testpackage_without_changelog/Rakefile +0 -3
  170. data/spec/acceptance/files/testpackage_without_changelog/build/rpm_metadata/requires +0 -1
  171. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/nodesets +0 -1
  172. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/nodesets +0 -1
  173. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/nodesets +0 -1
  174. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/nodesets +0 -1
  175. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/nodesets +0 -1
  176. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/nodesets +0 -1
  177. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/nodesets +0 -1
  178. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/nodesets +0 -1
  179. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/suites/default/nodesets +0 -1
  180. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/default.yml +0 -1
  181. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/suites/default/nodesets +0 -1
  182. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/nodesets +0 -1
  183. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/default.yml +0 -1
  184. data/spec/lib/simp/files/build/testpackage.spec +0 -1
  185. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/nodesets/default.yml +0 -1
  186. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/nodesets +0 -1
@@ -1,388 +0,0 @@
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 0
45
- --
46
-
47
- package_release = 0
48
-
49
- }
50
-
51
- %{lua:
52
- -- Pull the Relevant Metadata out of the Puppet module metadata.json.
53
-
54
- metadata = ''
55
- metadata_file = io.open(src_dir .. "/metadata.json","r")
56
- if metadata_file then
57
- metadata = metadata_file:read("*all")
58
-
59
- -- Ignore the first curly brace
60
- metadata = metadata:gsub("{}?", '|', 1)
61
-
62
- -- Ignore all keys that are below the first level
63
- metadata = metadata:gsub("{.-}", '')
64
- metadata = metadata:gsub("%[.-%]", '')
65
- else
66
- error("Could not open 'metadata.json'", 0)
67
- end
68
-
69
- -- This starts as an empty string so that we can build it later
70
- module_requires = ''
71
-
72
- }
73
-
74
- %{lua:
75
-
76
- -- Get the Module Name and put it in the correct format
77
-
78
- local name_match = string.match(metadata, '"name":%s+"(.-)"%s*,')
79
-
80
- module_author = ''
81
- module_name = ''
82
-
83
- if name_match then
84
- package_name = ('pupmod-' .. name_match)
85
-
86
- local i = 0
87
- for str in string.gmatch(name_match,'[^-]+') do
88
- if i == 0 then
89
- module_author = str
90
- else
91
- if module_name == '' then
92
- module_name = str
93
- else
94
- module_name = (module_name .. '-' .. str)
95
- end
96
- end
97
-
98
- i = i+1
99
- end
100
- else
101
- error("Could not find valid package name in 'metadata.json'", 0)
102
- end
103
-
104
- }
105
-
106
- %{lua:
107
-
108
- -- Get the Module Version
109
-
110
- local version_match = string.match(metadata, '"version":%s+"(.-)"%s*,')
111
-
112
- if version_match then
113
- package_version = version_match
114
- else
115
- error("Could not find valid package version in 'metadata.json'", 0)
116
- end
117
-
118
- }
119
-
120
- %{lua:
121
-
122
- -- Get the Module License
123
-
124
- local license_match = string.match(metadata, '"license":%s+"(.-)"%s*,')
125
-
126
- if license_match then
127
- module_license = license_match
128
- else
129
- error("Could not find valid package license in 'metadata.json'", 0)
130
- end
131
-
132
- }
133
-
134
- %{lua:
135
-
136
- -- Get the Module Summary
137
-
138
- local summary_match = string.match(metadata, '"summary":%s+"(.-)"%s*,')
139
-
140
- if summary_match then
141
- module_summary = summary_match
142
- else
143
- error("Could not find valid package summary in 'metadata.json'", 0)
144
- end
145
-
146
- }
147
-
148
- %{lua:
149
-
150
- -- Get the Module Source line for the URL string
151
-
152
- local source_match = string.match(metadata, '"source":%s+"(.-)"%s*,')
153
-
154
- if source_match then
155
- module_source = source_match
156
- else
157
- error("Could not find valid package source in 'metadata.json'", 0)
158
- end
159
-
160
- }
161
-
162
- %{lua:
163
-
164
- -- Snag the RPM-specific items out of the 'build/rpm_metadata' directory
165
-
166
- -- First, the Release Number
167
-
168
- rel_file = io.open(src_dir .. "/build/rpm_metadata/release", "r")
169
-
170
- if not rel_file then
171
- -- Need this for the SRPM case
172
- rel_file = io.open(src_dir .. "/release", "r")
173
- end
174
-
175
-
176
- if rel_file then
177
- for line in rel_file:lines() do
178
- is_comment = string.match(line, "^%s*#")
179
- is_blank = string.match(line, "^%s*$")
180
-
181
- if not (is_comment or is_blank) then
182
- package_release = line
183
- break
184
- end
185
- end
186
- end
187
-
188
- }
189
-
190
- %{lua:
191
-
192
- -- Next, the Requirements
193
- req_file = io.open(src_dir .. "/build/rpm_metadata/requires", "r")
194
-
195
- if not req_file then
196
- -- Need this for the SRPM case
197
- req_file = io.open(src_dir .. "/requires", "r")
198
- end
199
-
200
- if req_file then
201
- for line in req_file:lines() do
202
- valid_line = (string.match(line, "^Requires: ") or string.match(line, "^Obsoletes: ") or string.match(line, "^Provides: "))
203
-
204
- if valid_line then
205
- module_requires = (module_requires .. "\n" .. line)
206
- end
207
- end
208
- end
209
- }
210
-
211
- %define module_name %{lua: print(module_name)}
212
- %define base_name %{lua: print(package_name)}
213
-
214
- %{lua:
215
- -- Determine which Variant we are going to build
216
-
217
- local variant = rpm.expand("%{_variant}")
218
- local variant_version = nil
219
-
220
- local foo = ""
221
-
222
- local i = 0
223
- for str in string.gmatch(variant,'[^-]+') do
224
- if i == 0 then
225
- variant = str
226
- elseif i == 1 then
227
- variant_version = str
228
- else
229
- break
230
- end
231
-
232
- i = i+1
233
- end
234
-
235
- rpm.define("variant " .. variant)
236
-
237
- if variant == "pe" then
238
- rpm.define("puppet_user pe-puppet")
239
- else
240
- rpm.define("puppet_user puppet")
241
- end
242
-
243
- if variant == "pe" then
244
- if variant_version and ( rpm.vercmp(variant_version,'4') >= 0 ) then
245
- rpm.define("_sysconfdir /etc/puppetlabs/code")
246
- else
247
- rpm.define("_sysconfdir /etc/puppetlabs/puppet")
248
- end
249
- elseif variant == "p4" then
250
- rpm.define("_sysconfdir /etc/puppetlabs/code")
251
- else
252
- rpm.define("_sysconfdir /etc/puppet")
253
- end
254
- }
255
-
256
- Summary: %{module_name} Puppet Module
257
- %if 0%{?_variant:1}
258
- Name: %{base_name}-%{_variant}
259
- %else
260
- Name: %{base_name}
261
- %endif
262
-
263
- Version: %{lua: print(package_version)}
264
- Release: %{lua: print(package_release)}
265
- License: %{lua: print(module_license)}
266
- Group: Applications/System
267
- Source0: %{base_name}-%{version}-%{release}.tar.gz
268
- Source1: %{lua: print("metadata.json")}
269
- %{lua:
270
- -- Include our sources as appropriate
271
- changelog = io.open(src_dir .. "/CHANGELOG","r")
272
- if changelog then
273
- print("Source2: " .. "CHANGELOG\n")
274
- end
275
-
276
- if rel_file then
277
- print("Source3: " .. "release\n")
278
- end
279
- if req_file then
280
- print("Source4: " .. "requires\n")
281
- end
282
- }
283
- URL: %{lua: print(module_source)}
284
- BuildRoot: %{_tmppath}/%{base_name}-%{version}-%{release}-buildroot
285
- BuildArch: noarch
286
-
287
- %if "%{variant}" == "pe"
288
- Requires: pe-puppet >= 3.8.6
289
- %else
290
- Requires: puppet >= 3.8.6
291
- %endif
292
-
293
- %if ("%{base_name}" != "pupmod-simp-simplib") && ("%{base_name}" != "pupmod-puppetlabs-stdlib")
294
- Requires: pupmod-simp-simplib >= 1.2.6
295
- %endif
296
-
297
- %if "%{base_name}" != "pupmod-puppetlabs-stdlib"
298
- Requires: pupmod-puppetlabs-stdlib >= 4.9.0
299
- Requires: pupmod-puppetlabs-stdlib < 6.0.0
300
- %endif
301
-
302
- %{lua: print(module_requires)}
303
-
304
- Provides: pupmod-%{lua: print(module_name)} = %{lua: print(package_version .. "-" .. package_release)}
305
- Obsoletes: pupmod-%{lua: print(module_name)} < %{lua: print(package_version .. "-" .. package_release)}
306
-
307
- %{lua:
308
-
309
- -- This is a workaround for the 'simp-rsync' real RPM conflict but is
310
- -- required by some external modules.
311
- -- This should be removed when SIMP 6 is stable
312
-
313
- author_rpm_name = module_author .. "-" .. module_name
314
-
315
- if author_rpm_name ~= 'simp-rsync' then
316
- print("Provides: " .. author_rpm_name .. " = " .. package_version .. "-" .. package_release .. "\n")
317
- print("Obsoletes: " .. author_rpm_name .. " < " .. package_version .. "-" .. package_release .. "\n")
318
- end
319
- }
320
-
321
- Prefix: %{_sysconfdir}/environments/simp/modules
322
-
323
- %description
324
- %{lua: print(module_summary)}
325
-
326
- %prep
327
- %setup -q -n %{base_name}-%{version}
328
-
329
- %build
330
-
331
- %install
332
- [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
333
-
334
- mkdir -p %{buildroot}/%{prefix}
335
-
336
- curdir=`pwd`
337
- dirname=`basename $curdir`
338
- cp -r ../$dirname %{buildroot}/%{prefix}/%{module_name}
339
- cd %{buildroot}%{prefix}/%{module_name}
340
-
341
- # Remove unnecessary assets
342
- rm -rf %{buildroot}/%{prefix}/%{module_name}/.git
343
- rm -f %{buildroot}/%{prefix}/%{module_name}/*.lock
344
- rm -rf %{buildroot}/%{prefix}/%{module_name}/spec/fixtures/modules
345
- rm -rf %{buildroot}/%{prefix}/%{module_name}/dist
346
- rm -rf %{buildroot}/%{prefix}/%{module_name}/junit
347
- rm -rf %{buildroot}/%{prefix}/%{module_name}/log
348
-
349
- %clean
350
- [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
351
-
352
- mkdir -p %{buildroot}/%{prefix}
353
-
354
- %files
355
- %defattr(0640,root,%{puppet_user},0750)
356
- %{prefix}/%{module_name}
357
-
358
- %changelog
359
- %{lua:
360
- -- Finally, the CHANGELOG
361
-
362
- -- A default CHANGELOG in case we cannot find a real one
363
-
364
- default_changelog = [===[
365
- * $date Auto Changelog <auto@no.body> - $version-$release
366
- - Latest release of $name
367
- ]===]
368
-
369
- default_lookup_table = {
370
- date = os.date("%a %b %d %Y"),
371
- version = package_version,
372
- release = package_release,
373
- name = package_name
374
- }
375
-
376
- changelog = io.open(src_dir .. "/CHANGELOG","r")
377
- if changelog then
378
- first_line = changelog:read()
379
- if string.match(first_line, "^*%s+%a%a%a%s+%a%a%a%s+%d%d?%s+%d%d%d%d%s+.+") then
380
- changelog:seek("set",0)
381
- print(changelog:read("*all"))
382
- else
383
- print((default_changelog:gsub('$(%w+)', default_lookup_table)))
384
- end
385
- else
386
- print((default_changelog:gsub('$(%w+)', default_lookup_table)))
387
- end
388
- }
@@ -1,236 +0,0 @@
1
- require 'spec_helper_acceptance'
2
- require_relative 'support/pkg_rpm_helpers'
3
-
4
- require 'beaker/puppet_install_helper'
5
- require 'json'
6
-
7
- RSpec.configure do |c|
8
- c.include Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
9
- c.extend Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
10
- end
11
-
12
- # This tests RPM upgrade scenarios for components that use
13
- # simp-adapter's simp_rpm_helper to copy files from the RPM install
14
- # directory to a second destination directory
15
-
16
-
17
- shared_examples_for 'RPM generator' do
18
- it 'should create RPMs' do
19
- testpackages.each do |package|
20
- on host, %Q(#{run_cmd} "cd #{pkg_root_dir}/#{package}; ) +
21
- %Q(rvm use default; bundle update --local || bundle update")
22
- rpm_name = package.sub(/-[^-]+$/,'')
23
- # In case previous tests haven't been clean
24
- on host, "rpm -q #{rpm_name} && rpm -e #{rpm_name}; :"
25
-
26
- on host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; #{rake_cmd} pkg:rpm")
27
- end
28
- end
29
- end
30
-
31
- shared_examples_for 'an upgrade path that works safely with simp_rpm_helper' do |first_package_file, second_package_file|
32
- let( :rpm_regex ) do
33
- /^(?<name>pupmod-[a-z0-9_]+-[a-z0-9_]+)-(?<version>\d+\.\d+\.\d+)-(?<release>\d+)\..*\.rpm$/
34
- end
35
-
36
- let( :first_package_version ){ first_package_file.match(rpm_regex)['version'] }
37
- let( :first_package_name ){ first_package_file.match(rpm_regex)['name'] }
38
- let( :first_package_forge_name ){ first_package_name.sub(/^[^-]+-/,'') }
39
- let( :first_package_module_name ){ first_package_forge_name.sub(/^[^-]+-/,'') }
40
- let( :first_package_dir_name ){ first_package_name + '-' + first_package_version.sub(/\.\d+-\d+$/,'') }
41
-
42
- let( :second_package_name ){ second_package_file.match(rpm_regex)['name'] }
43
- let( :second_package_forge_name ){ second_package_name.sub(/^[^-]+-/,'') }
44
- let( :second_package_module_name ){ second_package_forge_name.sub(/^[^-]+-/,'') }
45
- let( :second_package_version ){ second_package_file.match(rpm_regex)['version'] }
46
- let( :second_package_dir_name ){ second_package_name + '-' + second_package_version.sub(/\.\d+-\d+$/,'') }
47
-
48
- context "When upgrading from #{first_package_file} to #{second_package_file}" do
49
- it "should clean out any old installs" do
50
- on host, "rpm -e #{first_package_name} &> /dev/null; " +
51
- "rpm -e #{second_package_name} &> /dev/null ",
52
- accept_all_exit_codes: true
53
- end
54
-
55
- it "should install #{first_package_file}" do
56
- on host, "cd #{pkg_root_dir}/#{first_package_dir_name.gsub(/\.\d+$/,'')}; "+
57
- "rpm -Uvh dist/#{first_package_file}"
58
- end
59
-
60
- it "should transfer contents of #{first_package_file} into the code directory" do
61
- result = on host, "cat /opt/test/puppet/code/#{first_package_module_name}/metadata.json"
62
- metadata = JSON.parse(result.stdout)
63
- expect(metadata['name']).to eq first_package_forge_name
64
- expect(metadata['version']).to eq first_package_version
65
-
66
- # This verifies all files/dirs from the first package are copied
67
- on host, "diff -r /usr/share/simp/modules/#{first_package_module_name} /opt/test/puppet/code/#{first_package_module_name}"
68
- end
69
-
70
- it "should upgrade to #{second_package_file}" do
71
- on host, "cd #{pkg_root_dir}/#{second_package_dir_name.gsub(/\.\d+$/,'')}; rpm -Uvh dist/#{second_package_file}"
72
- end
73
-
74
- it "should transfer contents of #{second_package_file} into the code directory" do
75
- result = on host, "cat /opt/test/puppet/code/#{second_package_module_name}/metadata.json"
76
- metadata = JSON.parse(result.stdout)
77
- expect(metadata['name']).to eq second_package_forge_name
78
- expect(metadata['version']).to eq second_package_version
79
-
80
- # This verifies all files/dirs from the second package are copied and
81
- # no files/dirs onyn in the old package remain
82
- on host, "diff -r /usr/share/simp/modules/#{second_package_module_name} /opt/test/puppet/code/#{second_package_module_name}"
83
- end
84
-
85
- end
86
- end
87
-
88
- describe 'rake pkg:rpm + component upgrade scenarios' do
89
-
90
- before :all do
91
- copy_host_files_into_build_user_homedir(hosts)
92
-
93
- comment 'ensure the Puppet AIO is installed'
94
- run_puppet_install_helper_on(hosts)
95
-
96
- comment 'configure puppet agent to look like a Puppet server for simp_rpm_helper'
97
- on hosts, '/opt/puppetlabs/bin/puppet config --section master set user root; ' +
98
- '/opt/puppetlabs/bin/puppet config --section master set group root; ' +
99
- '/opt/puppetlabs/bin/puppet config --section master set codedir /opt/test/puppet/code; ' +
100
- '/opt/puppetlabs/bin/puppet config --section master set confdir /opt/test/puppet/code'
101
-
102
-
103
- # TODO This mock simp-adapter has old functionality that corresponds to
104
- # SIMP < 6.4.0 (i.e, a version that rsync's modules to a directory).
105
- # Once SIMP 6.4.0 is released, we may want to update it to match that
106
- # of the newer simp-adapter (i.e., the version that creates and updates
107
- # local Git repositories). The tests that assume the copy behavior will
108
- # have to be updated as well.
109
- comment 'build and install mock RPMs'
110
- mock_pkg_dir = '/home/build_user/host_files/spec/acceptance/files/mock_packages'
111
- on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; rm -rf pkg"]
112
- on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh simp-adapter.spec"]
113
- on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-puppetlabs-stdlib.spec"]
114
- on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-simp-simplib.spec"]
115
- on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-simp-foo.spec"]
116
-
117
- on hosts, %Q[rpm -Uvh "#{mock_pkg_dir}/pkg/dist/*.noarch.rpm"], acceptable_exit_codes: [0,1]
118
- end
119
-
120
- hosts.each do |_host|
121
- context "on #{_host}" do
122
- let!(:host){ _host }
123
-
124
- # This tests standard upgrades, which should
125
- context 'with normal module RPM upgrades' do
126
- let(:pkg_root_dir) do
127
- '/home/build_user/host_files/spec/acceptance/files/package_upgrades'
128
- end
129
-
130
- let(:testpackages) do
131
- [
132
- 'pupmod-simp-testpackage-1.0',
133
- 'pupmod-simp-testpackage-2.0',
134
- ]
135
- end
136
-
137
- context 'RPM build' do
138
- it_should_behave_like('RPM generator')
139
- end
140
-
141
- context 'RPM upgrades' do
142
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
143
- 'pupmod-simp-testpackage-1.0.0-0.noarch.rpm',
144
- 'pupmod-simp-testpackage-2.0.0-0.noarch.rpm')
145
- end
146
-
147
- context 'RPM erase' do
148
- it 'should remove copied files on an erase' do
149
- on host, 'rpm -e pupmod-simp-testpackage'
150
- on host, 'ls /opt/test/puppet/code/testpackage', acceptable_exit_codes: [2]
151
- end
152
- end
153
-
154
- context 'RPM transaction state directory' do
155
- it 'should use /var/lib/rpm-state/simp-adapter for RPM state' do
156
- on host, 'test -d /var/lib/rpm-state/simp-adapter'
157
- end
158
-
159
- it 'should not use /%{_localstatedir}/lib/rpm-state/simp-adapter for RPM state' do
160
- on host, "test ! -d '/%{_localstatedir}/lib/rpm-state/simp-adapter'"
161
- end
162
- end
163
- end
164
-
165
- # These tests demonstrate custom RPM triggers that work around the obsolete
166
- # module RPM upgrate + simp_rpm_helper problem described in SIMP-3895:
167
- #
168
- # https://simp-project.atlassian.net/browse/SIMP-3988
169
- #
170
- # The expected outcome is that simp_rpm_helper always ensures the correct
171
- # content is installed after an upgrade, even during after a package has been
172
- # obsoleted. This is accomplished via %triggerpostun -- <name of old package>
173
- #
174
- # old 1.0 -> old 2.0 = no need for a trigger
175
- # old 1.0 -> new 2.0 = must re-run simp_rpm_helper
176
- # old 1.0 -> new 3.0 = must re-run simp_rpm_helper
177
- # old 2.0 -> new 2.0 = must re-run simp_rpm_helper
178
- # old 2.0 -> new 3.0 = must re-run simp_rpm_helper
179
- # new 2.0 -> new 3.0 = no need for a trigger
180
- #
181
- context 'with module RPMs that are susceptible to SIMP-3895' do
182
- let(:pkg_root_dir) do
183
- '/home/build_user/host_files/spec/acceptance/files/custom_scriptlet_triggers'
184
- end
185
-
186
- let(:testpackages) do
187
- [
188
- 'pupmod-old-package-1.0',
189
- 'pupmod-old-package-2.0',
190
- 'pupmod-old-package-2.2',
191
- 'pupmod-new-package-2.1',
192
- 'pupmod-new-package-3.0',
193
- ]
194
- end
195
-
196
- context 'RPM build' do
197
- it_should_behave_like('RPM generator')
198
- end
199
-
200
- context 'RPM upgrades' do
201
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
202
- 'pupmod-old-package-1.0.0-0.noarch.rpm',
203
- 'pupmod-old-package-2.0.0-0.noarch.rpm')
204
-
205
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
206
- 'pupmod-old-package-1.0.0-0.noarch.rpm',
207
- 'pupmod-new-package-2.1.0-0.noarch.rpm')
208
-
209
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
210
- 'pupmod-new-package-2.1.0-0.noarch.rpm',
211
- 'pupmod-old-package-2.2.0-0.noarch.rpm')
212
-
213
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
214
- 'pupmod-old-package-1.0.0-0.noarch.rpm',
215
- 'pupmod-new-package-3.0.0-0.noarch.rpm')
216
-
217
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
218
- 'pupmod-old-package-2.0.0-0.noarch.rpm',
219
- 'pupmod-new-package-2.1.0-0.noarch.rpm')
220
-
221
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
222
- 'pupmod-old-package-2.0.0-0.noarch.rpm',
223
- 'pupmod-new-package-3.0.0-0.noarch.rpm')
224
-
225
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
226
- 'pupmod-old-package-2.2.0-0.noarch.rpm',
227
- 'pupmod-new-package-3.0.0-0.noarch.rpm')
228
-
229
- it_should_behave_like('an upgrade path that works safely with simp_rpm_helper',
230
- 'pupmod-new-package-2.1.0-0.noarch.rpm',
231
- 'pupmod-new-package-3.0.0-0.noarch.rpm')
232
- end
233
- end
234
- end
235
- end
236
- end