pdk 3.2.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61c49c154cc69ce1e3c47ddfdd089b42c9c4c5e610bfb2e6caf3256939a16d5d
4
- data.tar.gz: 420c70b35bfaf64077b990f6853bfc92062659fc7ba36379cb053232b99313a5
3
+ metadata.gz: b8d097ab722c6b85e1a3f6bd87790a9d41c3a6de0efef08dbea9d9661ced6275
4
+ data.tar.gz: de41ce5f8860c34521f4001b4c882f4424b427fb6d85398332eba1b9ef8e324c
5
5
  SHA512:
6
- metadata.gz: 3e2e8f1e63a936c310459a67a14b632e00a4ac1694fa4cc77f2849b3d19bf09cc9a5e4a19d7ce3e3a0eb6493a31141c76a72bc98d30cbb4eb7ffd1f5d3da7ca0
7
- data.tar.gz: fe219a60e2cf9f7263e1b8fd8e721f143349aa3f03125649e551f9978ae3a9012c4b051f21b2707a266ed31a67772ad6c3cef026f1c5a1a0dadaf8257dc888dc
6
+ metadata.gz: 89b14fb73fb9122d4ce879f9260028ea8bc67a50f0e81c9b96a223c2087ed8493051eca0dde8d708ac37ffd984d88a0f19e950e1864395d6db0313364871df4d
7
+ data.tar.gz: 9d94174c163ebca1f7b16b0da7a51bb0767de7a2c5868cdb7d291f2c8f086dbc12a4ed7f90180c8ccd7c1f44f321119c78cf62e43155ee327d29508e70463b82
data/CHANGELOG.md CHANGED
@@ -5,7 +5,44 @@ All notable changes to this project will be documented in this file.
5
5
 
6
6
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
7
7
 
8
- ## [v3.2.0](https://github.com/puppetlabs/pdk/tree/v3.2.0) - 2024-05-02
8
+ ## [v3.4.0](https://github.com/puppetlabs/pdk/tree/v3.4.0) - 2024-11-25
9
+
10
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.3.0...v3.4.0)
11
+
12
+ ### Added
13
+
14
+ - (CAT-2141) Update `json-schema` dependency [#1412](https://github.com/puppetlabs/pdk/pull/1412) ([david22swan](https://github.com/david22swan))
15
+ - (CAT-643) Add forge gem upload functionality [#1403](https://github.com/puppetlabs/pdk/pull/1403) ([danadoherty639](https://github.com/danadoherty639))
16
+
17
+ ### Fixed
18
+
19
+ - (CAT-2162) Remove support for SLES 12 [#1418](https://github.com/puppetlabs/pdk/pull/1418) ([david22swan](https://github.com/david22swan))
20
+ - (CAT-2155) Remove metadata_syntax_validator parser swap to `JSON::Pure` [#1415](https://github.com/puppetlabs/pdk/pull/1415) ([david22swan](https://github.com/david22swan))
21
+ - (CAT-2128) Remove `json_pure` dependency [#1411](https://github.com/puppetlabs/pdk/pull/1411) ([david22swan](https://github.com/david22swan))
22
+ - (maint) Fix Gem::Platform.match() deprecation warning [#1408](https://github.com/puppetlabs/pdk/pull/1408) ([jhbuchanan45](https://github.com/jhbuchanan45))
23
+ - (CAT-2007) Update http setting cert to setting ca_file [#1398](https://github.com/puppetlabs/pdk/pull/1398) ([david22swan](https://github.com/david22swan))
24
+ - (CAT-2007) Use vendored cert files and VERIFY_PEER wth NET::HTTP on Windows [#1396](https://github.com/puppetlabs/pdk/pull/1396) ([david22swan](https://github.com/david22swan))
25
+ - (CAT-2040) pdk spinner inconsistent on windows [#1394](https://github.com/puppetlabs/pdk/pull/1394) ([alex501212](https://github.com/alex501212))
26
+
27
+ ## [v3.3.0](https://github.com/puppetlabs/pdk/tree/v3.3.0) - 2024-09-11
28
+
29
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.2.0...v3.3.0)
30
+
31
+ ### Added
32
+
33
+ - (CAT-1928) Update Supported OS on new module to match what is expected [#1381](https://github.com/puppetlabs/pdk/pull/1381) ([david22swan](https://github.com/david22swan))
34
+ - (CAT-1896) - Use puppet-modulebuilder for `PDK build` [#1374](https://github.com/puppetlabs/pdk/pull/1374) ([jordanbreen28](https://github.com/jordanbreen28))
35
+ - Skip 'name' validation when in a controlrepo context [#1352](https://github.com/puppetlabs/pdk/pull/1352) ([garrettrowell](https://github.com/garrettrowell))
36
+
37
+ ### Fixed
38
+
39
+ - (CAT-2026) Update how `pdk test unit --list` detects an error [#1388](https://github.com/puppetlabs/pdk/pull/1388) ([david22swan](https://github.com/david22swan))
40
+ - Support executable templates on filesystems mounted with `noexec` [#1383](https://github.com/puppetlabs/pdk/pull/1383) ([nabertrand](https://github.com/nabertrand))
41
+ - (CAT-1786) Remove Fedora 36 from the and add Fedora 40 to the PDK README [#1379](https://github.com/puppetlabs/pdk/pull/1379) ([LukasAud](https://github.com/LukasAud))
42
+ - (CAT-648) - Mark release*.rb files as non-executable [#1378](https://github.com/puppetlabs/pdk/pull/1378) ([jordanbreen28](https://github.com/jordanbreen28))
43
+ - (CAT-1643) Update childprocess and remove patch [#1356](https://github.com/puppetlabs/pdk/pull/1356) ([david22swan](https://github.com/david22swan))
44
+
45
+ ## [v3.2.0](https://github.com/puppetlabs/pdk/tree/v3.2.0) - 2024-05-08
9
46
 
10
47
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.1.0...v3.2.0)
11
48
 
@@ -43,6 +80,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
43
80
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.1...v3.0.0)
44
81
 
45
82
  ### Changed
83
+
46
84
  - (CONT-1134) Bump PDK Templates REF [#1264](https://github.com/puppetlabs/pdk/pull/1264) ([chelnak](https://github.com/chelnak))
47
85
  - (CONT-1154) Disable console command [#1263](https://github.com/puppetlabs/pdk/pull/1263) ([chelnak](https://github.com/chelnak))
48
86
  - (CONT-1130) Bump PDK gem version [#1260](https://github.com/puppetlabs/pdk/pull/1260) ([chelnak](https://github.com/chelnak))
data/lib/pdk/cli/build.rb CHANGED
@@ -12,7 +12,6 @@ module PDK
12
12
  option nil, 'force', 'Skips the prompts and builds the module package.'
13
13
 
14
14
  run do |opts, _args, _cmd|
15
- require 'pdk/module/build'
16
15
  require 'pdk/module/metadata'
17
16
  require 'pdk/cli/util'
18
17
 
@@ -37,7 +36,11 @@ module PDK
37
36
  end
38
37
  end
39
38
 
40
- builder = PDK::Module::Build.new(opts)
39
+ # build module
40
+ require 'puppet/modulebuilder'
41
+ module_dir = PDK::Util::Filesystem.expand_path(Dir.pwd)
42
+ target_dir = PDK::Util::Filesystem.expand_path(opts[:'target-dir'])
43
+ builder = Puppet::Modulebuilder::Builder.new(module_dir, target_dir, PDK.logger)
41
44
 
42
45
  unless opts[:force]
43
46
  if builder.package_already_exists?
@@ -49,7 +52,7 @@ module PDK
49
52
  end
50
53
  end
51
54
 
52
- unless builder.module_pdk_compatible?
55
+ unless PDK::Util.module_pdk_compatible?(module_dir)
53
56
  PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \
54
57
  'Unvalidated modules may have errors when uploading to the Forge. ' \
55
58
  'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.'
@@ -20,8 +20,6 @@ module PDK
20
20
 
21
21
  def initialize(*argv)
22
22
  require 'childprocess'
23
-
24
- require 'pdk/monkey_patches'
25
23
  require 'tempfile'
26
24
 
27
25
  @argv = argv
@@ -82,7 +80,7 @@ module PDK
82
80
 
83
81
  require 'pdk/cli/util/spinner'
84
82
 
85
- @spinner = TTY::Spinner.new("[:spinner] #{message}", opts.merge(PDK::CLI::Util.spinner_opts_for_platform))
83
+ @spinner = TTY::Spinner.new("[:spinner] #{message}")
86
84
  end
87
85
 
88
86
  def update_environment(additional_env)
@@ -3,7 +3,6 @@ require 'pdk/validate'
3
3
  require 'pdk/util/bundler'
4
4
  require 'pdk/cli/util/interview'
5
5
  require 'pdk/util/changelog_generator'
6
- require 'pdk/module/build'
7
6
 
8
7
  module PDK
9
8
  module CLI
data/lib/pdk/cli/util.rb CHANGED
@@ -28,18 +28,6 @@ module PDK
28
28
  end
29
29
  module_function :ensure_in_module!
30
30
 
31
- def spinner_opts_for_platform
32
- windows_opts = {
33
- success_mark: '*',
34
- error_mark: 'X'
35
- }
36
-
37
- return windows_opts if Gem.win_platform?
38
-
39
- {}
40
- end
41
- module_function :spinner_opts_for_platform
42
-
43
31
  def prompt_for_yes(question_text, opts = {})
44
32
  require 'tty/prompt'
45
33
 
@@ -163,7 +163,7 @@ module PDK
163
163
  when :manage
164
164
  if PDK::Util::Filesystem.exist?(absolute_file_path)
165
165
  update_manager.modify_file(absolute_file_path, file_content)
166
- update_manager.make_file_executable(absolute_file_path) if file_executable && !PDK::Util::Filesystem.executable?(absolute_file_path)
166
+ update_manager.make_file_executable(absolute_file_path) if file_executable && !PDK::Util::Filesystem.stat(absolute_file_path).executable?
167
167
  else
168
168
  update_manager.add_file(absolute_file_path, file_content)
169
169
  update_manager.make_file_executable(absolute_file_path) if file_executable
@@ -211,7 +211,7 @@ module PDK
211
211
  return if options[:noop]
212
212
 
213
213
  project_dir = File.basename(Dir.pwd)
214
- options[:module_name] = project_dir.split('-', 2).compact[-1]
214
+ options[:module_name] = PDK.context.is_a?(PDK::Context::ControlRepo) ? project_dir : project_dir.split('-', 2).compact[-1]
215
215
  options[:prompt] = false
216
216
  options[:'skip-interview'] = true if options[:force]
217
217
 
@@ -9,7 +9,7 @@ module PDK
9
9
  'RedHat based Linux' => [
10
10
  {
11
11
  'operatingsystem' => 'CentOS',
12
- 'operatingsystemrelease' => ['7']
12
+ 'operatingsystemrelease' => ['7', '8', '9']
13
13
  },
14
14
  {
15
15
  'operatingsystem' => 'OracleLinux',
@@ -17,30 +17,38 @@ module PDK
17
17
  },
18
18
  {
19
19
  'operatingsystem' => 'RedHat',
20
- 'operatingsystemrelease' => ['8']
20
+ 'operatingsystemrelease' => ['7', '8', '9']
21
21
  },
22
22
  {
23
23
  'operatingsystem' => 'Scientific',
24
24
  'operatingsystemrelease' => ['7']
25
+ },
26
+ {
27
+ 'operatingsystem' => 'Rocky',
28
+ 'operatingsystemrelease' => ['8']
29
+ },
30
+ {
31
+ 'operatingsystem' => 'AlmaLinux',
32
+ 'operatingsystemrelease' => ['8']
25
33
  }
26
34
  ],
27
35
  'Debian based Linux' => [
28
36
  {
29
37
  'operatingsystem' => 'Debian',
30
- 'operatingsystemrelease' => ['10']
38
+ 'operatingsystemrelease' => ['10', '11', '12']
31
39
  },
32
40
  {
33
41
  'operatingsystem' => 'Ubuntu',
34
- 'operatingsystemrelease' => ['18.04']
42
+ 'operatingsystemrelease' => ['18.04', '20.04', '22.04']
35
43
  }
36
44
  ],
37
45
  'Fedora' => {
38
46
  'operatingsystem' => 'Fedora',
39
- 'operatingsystemrelease' => ['29']
47
+ 'operatingsystemrelease' => ['40']
40
48
  },
41
49
  'OSX' => {
42
50
  'operatingsystem' => 'Darwin',
43
- 'operatingsystemrelease' => ['16']
51
+ 'operatingsystemrelease' => ['21', '22', '23']
44
52
  },
45
53
  'SLES' => {
46
54
  'operatingsystem' => 'SLES',
@@ -52,11 +60,11 @@ module PDK
52
60
  },
53
61
  'Windows' => {
54
62
  'operatingsystem' => 'windows',
55
- 'operatingsystemrelease' => ['2019', '10']
63
+ 'operatingsystemrelease' => ['2019', '2022', '10', '11']
56
64
  },
57
65
  'AIX' => {
58
66
  'operatingsystem' => 'AIX',
59
- 'operatingsystemrelease' => ['6.1', '7.1', '7.2']
67
+ 'operatingsystemrelease' => ['7.2', '7.3']
60
68
  }
61
69
  }.freeze
62
70
 
@@ -162,7 +170,7 @@ module PDK
162
170
 
163
171
  # Do basic validation and parsing of the name parameter.
164
172
  def process_name(data)
165
- validate_name(data['name'])
173
+ validate_name(data['name']) unless PDK.context.is_a?(PDK::Context::ControlRepo)
166
174
  author, modname = data['name'].split(%r{[-/]}, 2)
167
175
  data['name'] = [author, modname].join('-')
168
176
 
@@ -1,5 +1,6 @@
1
1
  require 'pdk'
2
2
  require 'uri'
3
+ require 'puppet/modulebuilder'
3
4
 
4
5
  module PDK
5
6
  module Module
@@ -77,7 +78,7 @@ module PDK
77
78
  # Use the default as a last resort
78
79
  package_file = default_package_filename if package_file.nil?
79
80
  else
80
- package_file = run_build(options)
81
+ package_file = run_build
81
82
  end
82
83
 
83
84
  run_publish(options.dup, package_file) unless skip_publish?
@@ -95,7 +96,7 @@ module PDK
95
96
  def default_package_filename
96
97
  return @default_tarball_filename unless @default_tarball_filename.nil?
97
98
 
98
- builder = PDK::Module::Build.new(module_dir: module_path)
99
+ builder = Puppet::Modulebuilder::Builder.new(module_path, nil, PDK.logger)
99
100
  @default_tarball_filename = builder.package_file
100
101
  end
101
102
 
@@ -135,36 +136,27 @@ module PDK
135
136
  end
136
137
 
137
138
  # @return [String] Path to the built tarball
138
- def run_build(opts)
139
- PDK::Module::Build.invoke(opts.dup)
139
+ def run_build
140
+ module_dir = PDK::Util::Filesystem.expand_path(module_path || Dir.pwd)
141
+ target_dir = File.join(module_dir, 'pkg')
142
+ builder = Puppet::Modulebuilder::Builder.new(module_dir, target_dir, PDK.logger)
143
+ builder.build
140
144
  end
141
145
 
142
146
  def run_publish(_opts, tarball_path)
143
147
  validate_publish_options!
144
148
  raise PDK::CLI::ExitWithError, format('Module tarball %{tarball_path} does not exist', tarball_path: tarball_path) unless PDK::Util::Filesystem.file?(tarball_path)
145
149
 
146
- # TODO: Replace this code when the upload functionality is added to the forge ruby gem
147
- require 'base64'
148
- file_data = Base64.encode64(PDK::Util::Filesystem.read_file(tarball_path, open_args: 'rb'))
149
-
150
150
  PDK.logger.info 'Uploading tarball to puppet forge...'
151
- uri = URI(forge_upload_url)
152
- require 'net/http'
153
- request = Net::HTTP::Post.new(uri.path)
154
- request['Authorization'] = "Bearer #{forge_token}"
155
- request['Content-Type'] = 'application/json'
156
- data = { file: file_data }
157
-
158
- request.body = data.to_json
159
-
160
- require 'openssl'
161
- use_ssl = uri.instance_of?(URI::HTTPS)
162
- response = Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http|
163
- http.request(request)
151
+ begin
152
+ require 'puppet_forge'
153
+ PuppetForge.host = forge_upload_url
154
+ PuppetForge::Connection.authorization = forge_token
155
+ PuppetForge::V3::Release.upload(tarball_path)
156
+ rescue StandardError => e
157
+ raise PDK::CLI::ExitWithError, format('Error uploading to Puppet Forge: %{result}', result: e.message)
164
158
  end
165
159
 
166
- raise PDK::CLI::ExitWithError, format('Error uploading to Puppet Forge: %{result}', result: response.body) unless response.is_a?(Net::HTTPSuccess)
167
-
168
160
  PDK.logger.info 'Publish to Forge was successful'
169
161
  end
170
162
 
@@ -238,8 +230,7 @@ module PDK
238
230
  def pdk_compatible?
239
231
  return @pdk_compatible unless @pdk_compatible.nil?
240
232
 
241
- builder = PDK::Module::Build.new(module_dir: module_path)
242
- @pdk_compatible = builder.module_pdk_compatible?
233
+ @pdk_compatible = PDK::Util.module_pdk_compatible?(module_path)
243
234
  end
244
235
  # :nocov:
245
236
 
@@ -95,7 +95,7 @@ module PDK
95
95
  end
96
96
  end
97
97
 
98
- dest_executable = config['manage_execute_permissions'] && PDK::Util::Filesystem.executable?(File.join(template_loc, template_file))
98
+ dest_executable = config['manage_execute_permissions'] && PDK::Util::Filesystem.stat(File.join(template_loc, template_file)).executable?
99
99
 
100
100
  yield dest_path, dest_content, dest_status, dest_executable
101
101
  end
@@ -246,10 +246,10 @@ module PDK
246
246
  raise PDK::CLI::FatalError, format('Failed to find valid JSON in output from rspec: %{output}', output: output[:stdout]) unless rspec_json
247
247
 
248
248
  if rspec_json['examples'].empty?
249
- rspec_message = rspec_json['messages'][0]
250
- return [] if rspec_message == 'No examples found.'
249
+ return [] if rspec_json['messages'][0] == 'No examples found.'
250
+ return [] if rspec_json['messages'].include?("\nAll examples were filtered out")
251
251
 
252
- raise PDK::CLI::FatalError, format('Unable to enumerate examples. rspec reported: %{message}', message: rspec_message)
252
+ raise PDK::CLI::FatalError, format('Unable to enumerate examples. rspec reported: %{message}', message: rspec_json['messages'])
253
253
  else
254
254
  examples = []
255
255
  rspec_json['examples'].each do |example|
@@ -182,7 +182,7 @@ module PDK
182
182
  @rubygems_puppet_versions ||= begin
183
183
  fetcher = Gem::SpecFetcher.fetcher
184
184
  puppet_tuples = fetcher.detect(:released) do |spec_tuple|
185
- spec_tuple.name == 'puppet' && Gem::Platform.match(spec_tuple.platform)
185
+ spec_tuple.name == 'puppet' && Gem::Platform.match_spec?(spec_tuple)
186
186
  end
187
187
  puppet_versions = puppet_tuples.map { |name, _| name.version }.uniq
188
188
  puppet_versions.sort.reverse
@@ -51,8 +51,10 @@ module PDK
51
51
  uri = URI.parse(url)
52
52
  http = Net::HTTP.new(uri.host, uri.port)
53
53
  http.use_ssl = true
54
- # TODO: Get rid of this
55
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE if Gem.win_platform?
54
+ if Gem.win_platform?
55
+ http.ca_file = 'C:/Program Files/Puppet Labs/DevelopmentKit/ssl/cert.pem'
56
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
57
+ end
56
58
  request = Net::HTTP::Get.new(uri.request_uri)
57
59
  response = http.request(request)
58
60
 
data/lib/pdk/util.rb CHANGED
@@ -32,6 +32,7 @@ module PDK
32
32
  def exit_process(exit_code)
33
33
  exit exit_code
34
34
  end
35
+ module_function :exit_process
35
36
  # :nocov:
36
37
 
37
38
  # Searches upwards from current working directory for the given target file.
@@ -161,9 +161,9 @@ module PDK
161
161
  if parent_validator.nil? || parent_validator.spinner.nil? || !parent_validator.spinner.is_a?(TTY::Spinner::Multi)
162
162
  c.add_spinner(spinner_text_for_targets(invokation_targets))
163
163
  else
164
- spinner = TTY::Spinner.new("[:spinner] #{spinner_text_for_targets(invokation_targets)}", PDK::CLI::Util.spinner_opts_for_platform)
164
+ spinner = TTY::Spinner.new("[:spinner] #{spinner_text_for_targets(invokation_targets)}")
165
165
  parent_validator.spinner.register(spinner)
166
- c.register_spinner(spinner, PDK::CLI::Util.spinner_opts_for_platform)
166
+ c.register_spinner(spinner)
167
167
  end
168
168
  end
169
169
  end
@@ -138,7 +138,7 @@ module PDK
138
138
 
139
139
  require 'pdk/cli/util/spinner'
140
140
 
141
- @spinner = TTY::Spinner.new("[:spinner] #{spinner_text}", PDK::CLI::Util.spinner_opts_for_platform)
141
+ @spinner = TTY::Spinner.new("[:spinner] #{spinner_text}")
142
142
  end
143
143
 
144
144
  # Process any targets that were skipped by the validator and add the events to the validation report
@@ -22,15 +22,6 @@ module PDK
22
22
  JSON.parser = JSON::Ext::Parser if defined?(JSON::Ext::Parser)
23
23
  end
24
24
 
25
- def before_validation
26
- # The pure ruby JSON parser gives much nicer parse error messages than
27
- # the C extension at the cost of slightly slower parsing. We require it
28
- # here and restore the C extension at the end of the method (if it was
29
- # being used).
30
- require 'json/pure'
31
- JSON.parser = JSON::Pure::Parser
32
- end
33
-
34
25
  def validate_target(report, target)
35
26
  unless PDK::Util::Filesystem.readable?(target)
36
27
  report.add_event(
@@ -56,9 +47,7 @@ module PDK
56
47
  rescue JSON::ParserError => e
57
48
  # Because the message contains a raw segment of the file, we use
58
49
  # String#dump here to unescape any escape characters like newlines.
59
- # We then strip out the surrounding quotes and the exclaimation
60
- # point that json_pure likes to put in exception messages.
61
- sane_message = e.message.dump[/\A"(.+?)!?"\Z/, 1]
50
+ sane_message = e.message.dump
62
51
 
63
52
  report.add_event(
64
53
  file: target,
@@ -42,7 +42,7 @@ module PDK
42
42
 
43
43
  require 'pdk/cli/util/spinner'
44
44
 
45
- @spinner = TTY::Spinner::Multi.new("[:spinner] #{spinner_text}", PDK::CLI::Util.spinner_opts_for_platform)
45
+ @spinner = TTY::Spinner::Multi.new("[:spinner] #{spinner_text}")
46
46
 
47
47
  # Register the child spinners
48
48
  validator_instances.each do |instance|
data/lib/pdk/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module PDK
2
- VERSION = '3.2.0'.freeze
3
- TEMPLATE_REF = '3.2.0'.freeze
2
+ VERSION = '3.4.0'.freeze
3
+ TEMPLATE_REF = '3.4.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-09 00:00:00.000000000 Z
11
+ date: 2024-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.0
19
+ version: 1.15.5
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 3.0.0
22
+ version: 2.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.0
29
+ version: 1.15.5
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 3.0.0
32
+ version: 2.0.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: childprocess
34
+ name: minitar
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 4.1.0
39
+ version: '0.8'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 4.1.0
46
+ version: '0.8'
47
47
  - !ruby/object:Gem::Dependency
48
- name: cri
48
+ name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 2.15.11
53
+ version: 2.1.0
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 3.0.0
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">="
59
62
  - !ruby/object:Gem::Version
60
- version: 2.15.11
63
+ version: 2.1.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 3.0.0
61
67
  - !ruby/object:Gem::Dependency
62
- name: diff-lcs
68
+ name: cri
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
- - - ">="
71
+ - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: 1.5.0
73
+ version: 2.15.11
68
74
  type: :runtime
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
- - - ">="
78
+ - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: 1.5.0
80
+ version: 2.15.11
75
81
  - !ruby/object:Gem::Dependency
76
- name: ffi
82
+ name: childprocess
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 1.15.5
82
- - - "<"
85
+ - - "~>"
83
86
  - !ruby/object:Gem::Version
84
- version: 2.0.0
87
+ version: '5.0'
85
88
  type: :runtime
86
89
  prerelease: false
87
90
  version_requirements: !ruby/object:Gem::Requirement
88
91
  requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: 1.15.5
92
- - - "<"
92
+ - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 2.0.0
94
+ version: '5.0'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: hitimes
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -107,117 +107,131 @@ dependencies:
107
107
  - !ruby/object:Gem::Version
108
108
  version: 2.0.0
109
109
  - !ruby/object:Gem::Dependency
110
- name: json_pure
110
+ name: tty-prompt
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 2.6.3
115
+ version: '0.23'
116
116
  type: :runtime
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: 2.6.3
122
+ version: '0.23'
123
123
  - !ruby/object:Gem::Dependency
124
- name: json-schema
124
+ name: tty-spinner
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '4.0'
129
+ version: '0.9'
130
130
  type: :runtime
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '4.0'
136
+ version: '0.9'
137
137
  - !ruby/object:Gem::Dependency
138
- name: minitar
138
+ name: tty-which
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '0.8'
143
+ version: '0.5'
144
144
  type: :runtime
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '0.8'
150
+ version: '0.5'
151
151
  - !ruby/object:Gem::Dependency
152
- name: pathspec
152
+ name: json-schema
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '1.1'
157
+ version: '5.0'
158
158
  type: :runtime
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: '1.1'
164
+ version: '5.0'
165
165
  - !ruby/object:Gem::Dependency
166
- name: tty-prompt
166
+ name: puppet-modulebuilder
167
167
  requirement: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: '0.23'
171
+ version: '1.0'
172
172
  type: :runtime
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - "~>"
177
177
  - !ruby/object:Gem::Version
178
- version: '0.23'
178
+ version: '1.0'
179
179
  - !ruby/object:Gem::Dependency
180
- name: tty-spinner
180
+ name: deep_merge
181
181
  requirement: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - "~>"
184
184
  - !ruby/object:Gem::Version
185
- version: '0.9'
185
+ version: 1.2.2
186
186
  type: :runtime
187
187
  prerelease: false
188
188
  version_requirements: !ruby/object:Gem::Requirement
189
189
  requirements:
190
190
  - - "~>"
191
191
  - !ruby/object:Gem::Version
192
- version: '0.9'
192
+ version: 1.2.2
193
193
  - !ruby/object:Gem::Dependency
194
- name: tty-which
194
+ name: diff-lcs
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: 1.5.0
200
+ type: :runtime
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: 1.5.0
207
+ - !ruby/object:Gem::Dependency
208
+ name: pathspec
195
209
  requirement: !ruby/object:Gem::Requirement
196
210
  requirements:
197
211
  - - "~>"
198
212
  - !ruby/object:Gem::Version
199
- version: '0.5'
213
+ version: '1.1'
200
214
  type: :runtime
201
215
  prerelease: false
202
216
  version_requirements: !ruby/object:Gem::Requirement
203
217
  requirements:
204
218
  - - "~>"
205
219
  - !ruby/object:Gem::Version
206
- version: '0.5'
220
+ version: '1.1'
207
221
  - !ruby/object:Gem::Dependency
208
- name: deep_merge
222
+ name: puppet_forge
209
223
  requirement: !ruby/object:Gem::Requirement
210
224
  requirements:
211
225
  - - "~>"
212
226
  - !ruby/object:Gem::Version
213
- version: 1.2.2
227
+ version: '5.0'
214
228
  type: :runtime
215
229
  prerelease: false
216
230
  version_requirements: !ruby/object:Gem::Requirement
217
231
  requirements:
218
232
  - - "~>"
219
233
  - !ruby/object:Gem::Version
220
- version: 1.2.2
234
+ version: '5.0'
221
235
  description: A CLI to facilitate easy, unified development workflows for Puppet modules.
222
236
  email:
223
237
  - pdk-maintainers@puppet.com
@@ -305,13 +319,11 @@ files:
305
319
  - lib/pdk/generate/transport.rb
306
320
  - lib/pdk/logger.rb
307
321
  - lib/pdk/module.rb
308
- - lib/pdk/module/build.rb
309
322
  - lib/pdk/module/convert.rb
310
323
  - lib/pdk/module/metadata.rb
311
324
  - lib/pdk/module/release.rb
312
325
  - lib/pdk/module/update.rb
313
326
  - lib/pdk/module/update_manager.rb
314
- - lib/pdk/monkey_patches.rb
315
327
  - lib/pdk/report.rb
316
328
  - lib/pdk/report/event.rb
317
329
  - lib/pdk/template.rb
@@ -1,302 +0,0 @@
1
- require 'pdk'
2
-
3
- module PDK
4
- module Module
5
- class Build
6
- def self.invoke(options = {})
7
- new(options).build
8
- end
9
-
10
- attr_reader :module_dir, :target_dir
11
-
12
- def initialize(options = {})
13
- @module_dir = PDK::Util::Filesystem.expand_path(options[:module_dir] || Dir.pwd)
14
- @target_dir = PDK::Util::Filesystem.expand_path(options[:'target-dir'] || File.join(module_dir, 'pkg'))
15
- end
16
-
17
- # Read and parse the values from metadata.json for the module that is
18
- # being built.
19
- #
20
- # @return [Hash{String => Object}] The hash of metadata values.
21
- def metadata
22
- require 'pdk/module/metadata'
23
-
24
- @metadata ||= PDK::Module::Metadata.from_file(File.join(module_dir, 'metadata.json')).data
25
- end
26
-
27
- # Return the path where the built package file will be written to.
28
- def package_file
29
- @package_file ||= File.join(target_dir, "#{release_name}.tar.gz")
30
- end
31
-
32
- # Build a module package from a module directory.
33
- #
34
- # @return [String] The path to the built package file.
35
- def build
36
- create_build_dir
37
-
38
- stage_module_in_build_dir
39
- build_package
40
-
41
- package_file
42
- ensure
43
- cleanup_build_dir
44
- end
45
-
46
- # Verify if there is an existing package in the target directory and prompts
47
- # the user if they want to overwrite it.
48
- def package_already_exists?
49
- PDK::Util::Filesystem.exist?(package_file)
50
- end
51
-
52
- # Check if the module is PDK Compatible. If not, then prompt the user if
53
- # they want to run PDK Convert.
54
- def module_pdk_compatible?
55
- ['pdk-version', 'template-url'].any? { |key| metadata.key?(key) }
56
- end
57
-
58
- # Return the path to the temporary build directory, which will be placed
59
- # inside the target directory and match the release name (see #release_name).
60
- def build_dir
61
- @build_dir ||= File.join(target_dir, release_name)
62
- end
63
-
64
- # Create a temporary build directory where the files to be included in
65
- # the package will be staged before building the tarball.
66
- #
67
- # If the directory already exists, remove it first.
68
- def create_build_dir
69
- cleanup_build_dir
70
-
71
- PDK::Util::Filesystem.mkdir_p(build_dir)
72
- end
73
-
74
- # Remove the temporary build directory and all its contents from disk.
75
- #
76
- # @return nil.
77
- def cleanup_build_dir
78
- PDK::Util::Filesystem.rm_rf(build_dir, secure: true)
79
- end
80
-
81
- # Combine the module name and version into a Forge-compatible dash
82
- # separated string.
83
- #
84
- # @return [String] The module name and version, joined by a dash.
85
- def release_name
86
- @release_name ||= [
87
- metadata['name'],
88
- metadata['version']
89
- ].join('-')
90
- end
91
-
92
- # Iterate through all the files and directories in the module and stage
93
- # them into the temporary build directory (unless ignored).
94
- #
95
- # @return nil
96
- def stage_module_in_build_dir
97
- require 'find'
98
-
99
- Find.find(module_dir) do |path|
100
- next if path == module_dir
101
-
102
- ignored_path?(path) ? Find.prune : stage_path(path)
103
- end
104
- end
105
-
106
- # Stage a file or directory from the module into the build directory.
107
- #
108
- # @param path [String] The path to the file or directory.
109
- #
110
- # @return nil.
111
- def stage_path(path)
112
- require 'pathname'
113
-
114
- relative_path = Pathname.new(path).relative_path_from(Pathname.new(module_dir))
115
- dest_path = File.join(build_dir, relative_path)
116
-
117
- validate_path_encoding!(relative_path.to_path)
118
-
119
- if PDK::Util::Filesystem.directory?(path)
120
- PDK::Util::Filesystem.mkdir_p(dest_path, mode: PDK::Util::Filesystem.stat(path).mode)
121
- elsif PDK::Util::Filesystem.symlink?(path)
122
- warn_symlink(path)
123
- else
124
- validate_ustar_path!(relative_path.to_path)
125
- PDK::Util::Filesystem.cp(path, dest_path, preserve: true)
126
- end
127
- rescue ArgumentError => e
128
- raise PDK::CLI::ExitWithError, format('%{message} Rename the file or exclude it from the package ' \
129
- 'by adding it to the .pdkignore file in your module.', message: e.message)
130
- end
131
-
132
- # Check if the given path matches one of the patterns listed in the
133
- # ignore file.
134
- #
135
- # @param path [String] The path to be checked.
136
- #
137
- # @return [Boolean] true if the path matches and should be ignored.
138
- def ignored_path?(path)
139
- path = "#{path}/" if PDK::Util::Filesystem.directory?(path)
140
-
141
- !ignored_files.match_paths([path], module_dir).empty?
142
- end
143
-
144
- # Warn the user about a symlink that would have been included in the
145
- # built package.
146
- #
147
- # @param path [String] The relative or absolute path to the symlink.
148
- #
149
- # @return nil.
150
- def warn_symlink(path)
151
- require 'pathname'
152
-
153
- symlink_path = Pathname.new(path)
154
- module_path = Pathname.new(module_dir)
155
-
156
- PDK.logger.warn format('Symlinks in modules are not supported and will not be included in the package. Please investigate symlink %{from} -> %{to}.',
157
- from: symlink_path.relative_path_from(module_path), to: symlink_path.realpath.relative_path_from(module_path))
158
- end
159
-
160
- # Checks if the path length will fit into the POSIX.1-1998 (ustar) tar
161
- # header format.
162
- #
163
- # POSIX.1-2001 (which allows paths of infinite length) was adopted by GNU
164
- # tar in 2004 and is supported by minitar 0.7 and above. Unfortunately
165
- # much of the Puppet ecosystem still uses minitar 0.6.1.
166
- #
167
- # POSIX.1-1998 tar format does not allow for paths greater than 256 bytes,
168
- # or paths that can't be split into a prefix of 155 bytes (max) and
169
- # a suffix of 100 bytes (max).
170
- #
171
- # This logic was pretty much copied from the private method
172
- # {Archive::Tar::Minitar::Writer#split_name}.
173
- #
174
- # @param path [String] the relative path to be added to the tar file.
175
- #
176
- # @raise [ArgumentError] if the path is too long or could not be split.
177
- #
178
- # @return [nil]
179
- def validate_ustar_path!(path)
180
- raise ArgumentError, format("The path '%{path}' is longer than 256 bytes.", path: path) if path.bytesize > 256
181
-
182
- if path.bytesize <= 100
183
- prefix = ''
184
- else
185
- parts = path.split(File::SEPARATOR)
186
- newpath = parts.pop
187
- nxt = ''
188
-
189
- loop do
190
- nxt = parts.pop || ''
191
- break if newpath.bytesize + 1 + nxt.bytesize >= 100
192
-
193
- newpath = File.join(nxt, newpath)
194
- end
195
-
196
- prefix = File.join(*parts, nxt)
197
- path = newpath
198
- end
199
-
200
- return unless path.bytesize > 100 || prefix.bytesize > 155
201
-
202
- raise ArgumentError,
203
- format("'%{path}' could not be split at a directory separator into two " \
204
- 'parts, the first having a maximum length of 155 bytes and the ' \
205
- 'second having a maximum length of 100 bytes.', path: path)
206
- end
207
-
208
- # Checks if the path contains any non-ASCII characters.
209
- #
210
- # Java will throw an error when it encounters a path containing
211
- # characters that are not supported by the hosts locale. In order to
212
- # maximise compatibility we limit the paths to contain only ASCII
213
- # characters, which should be part of any locale character set.
214
- #
215
- # @param path [String] the relative path to be added to the tar file.
216
- #
217
- # @raise [ArgumentError] if the path contains non-ASCII characters.
218
- #
219
- # @return [nil]
220
- def validate_path_encoding!(path)
221
- return unless /[^\x00-\x7F]/.match?(path)
222
-
223
- raise ArgumentError, format("'%{path}' can only include ASCII characters in its path or " \
224
- 'filename in order to be compatible with a wide range of hosts.', path: path)
225
- end
226
-
227
- # Creates a gzip compressed tarball of the build directory.
228
- #
229
- # If the destination package already exists, it will be removed before
230
- # creating the new tarball.
231
- #
232
- # @return nil.
233
- def build_package
234
- require 'zlib'
235
- require 'minitar'
236
- require 'find'
237
-
238
- PDK::Util::Filesystem.rm_f(package_file)
239
-
240
- Dir.chdir(target_dir) do
241
- gz = Zlib::GzipWriter.new(File.open(package_file, 'wb')) # rubocop:disable PDK/FileOpen
242
- tar = Minitar::Output.new(gz)
243
- Find.find(release_name) do |entry|
244
- entry_meta = {
245
- name: entry
246
- }
247
-
248
- orig_mode = PDK::Util::Filesystem.stat(entry).mode
249
- min_mode = Minitar.dir?(entry) ? 0o755 : 0o644
250
-
251
- entry_meta[:mode] = orig_mode | min_mode
252
-
253
- PDK.logger.debug(format('Updated permissions of packaged \'%{entry}\' to %{new_mode}', entry: entry, new_mode: (entry_meta[:mode] & 0o7777).to_s(8))) if entry_meta[:mode] != orig_mode
254
-
255
- Minitar.pack_file(entry_meta, tar)
256
- end
257
- ensure
258
- tar.close
259
- end
260
- end
261
-
262
- # Select the most appropriate ignore file in the module directory.
263
- #
264
- # In order of preference, we first try `.pdkignore`, then `.pmtignore`
265
- # and finally `.gitignore`.
266
- #
267
- # @return [String] The path to the file containing the patterns of file
268
- # paths to ignore.
269
- def ignore_file
270
- @ignore_file ||= [
271
- File.join(module_dir, '.pdkignore'),
272
- File.join(module_dir, '.pmtignore'),
273
- File.join(module_dir, '.gitignore')
274
- ].find { |file| PDK::Util::Filesystem.file?(file) && PDK::Util::Filesystem.readable?(file) }
275
- end
276
-
277
- # Instantiate a new PathSpec class and populate it with the pattern(s) of
278
- # files to be ignored.
279
- #
280
- # @return [PathSpec] The populated ignore path matcher.
281
- def ignored_files
282
- require 'pdk/module'
283
- require 'pathspec'
284
-
285
- @ignored_files ||=
286
- begin
287
- ignored = if ignore_file.nil?
288
- PathSpec.new
289
- else
290
- PathSpec.new(PDK::Util::Filesystem.read_file(ignore_file, open_args: 'rb:UTF-8'))
291
- end
292
-
293
- ignored = ignored.add("/#{File.basename(target_dir)}/") if File.realdirpath(target_dir).start_with?(File.realdirpath(module_dir))
294
-
295
- PDK::Module::DEFAULT_IGNORED.each { |r| ignored.add(r) }
296
-
297
- ignored
298
- end
299
- end
300
- end
301
- end
302
- end
@@ -1,268 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module OS
4
- # Os detection: Are we on Windows?
5
- def self.windows?
6
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
7
- end
8
- end
9
-
10
- # Patch childprocess so that it is Ruby 3 compliant.
11
- # This could be removed if the following PR is ever merged
12
- # and released:
13
- # https://github.com/enkessler/childprocess/pull/185
14
- module ChildProcess
15
- class << self
16
- def build(*args)
17
- case os
18
- when :macosx, :linux, :solaris, :bsd, :cygwin, :aix
19
- if posix_spawn?
20
- Unix::PosixSpawnProcess.new(*args)
21
- elsif jruby?
22
- JRuby::Process.new(*args)
23
- else
24
- Unix::ForkExecProcess.new(*args)
25
- end
26
- when :windows
27
- Windows::Process.new(*args)
28
- else
29
- raise Error, "unsupported platform #{platform_name.inspect}"
30
- end
31
- end
32
- end
33
-
34
- class AbstractProcess
35
- def initialize(*args)
36
- raise ArgumentError, "all arguments must be String: #{args.inspect}" unless args.all?(String)
37
-
38
- @args = args
39
- @started = false
40
- @exit_code = nil
41
- @io = nil
42
- @cwd = nil
43
- @detach = false
44
- @duplex = false
45
- @leader = false
46
- @environment = {}
47
- end
48
- end
49
-
50
- if OS.windows?
51
- module Windows
52
- module Lib
53
- extend FFI::Library
54
- def self.msvcrt_name
55
- RbConfig::CONFIG['RUBY_SO_NAME'][/msvc\w+/] || 'ucrtbase'
56
- end
57
-
58
- ffi_lib 'kernel32', msvcrt_name
59
- ffi_convention :stdcall
60
-
61
- # We have to redefine the function declarations so that they are available
62
- # with the patched ffi_lib.
63
- enum :wait_status, [
64
- :wait_object_0, 0, # rubocop:disable Naming/VariableNumber
65
- :wait_timeout, 0x102,
66
- :wait_abandoned, 0x80,
67
- :wait_failed, 0xFFFFFFFF
68
- ]
69
-
70
- #
71
- # BOOL WINAPI CreateProcess(
72
- # __in_opt LPCTSTR lpApplicationName,
73
- # __inout_opt LPTSTR lpCommandLine,
74
- # __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
75
- # __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
76
- # __in BOOL bInheritHandles,
77
- # __in DWORD dwCreationFlags,
78
- # __in_opt LPVOID lpEnvironment,
79
- # __in_opt LPCTSTR lpCurrentDirectory,
80
- # __in LPSTARTUPINFO lpStartupInfo,
81
- # __out LPPROCESS_INFORMATION lpProcessInformation
82
- # );
83
- #
84
-
85
- attach_function :create_process, :CreateProcessW, [
86
- :pointer,
87
- :buffer_inout,
88
- :pointer,
89
- :pointer,
90
- :bool,
91
- :ulong,
92
- :pointer,
93
- :pointer,
94
- :pointer,
95
- :pointer
96
- ], :bool
97
-
98
- #
99
- # DWORD WINAPI FormatMessage(
100
- # __in DWORD dwFlags,
101
- # __in_opt LPCVOID lpSource,
102
- # __in DWORD dwMessageId,
103
- # __in DWORD dwLanguageId,
104
- # __out LPTSTR lpBuffer,
105
- # __in DWORD nSize,
106
- # __in_opt va_list *Arguments
107
- # );
108
- #
109
-
110
- attach_function :format_message, :FormatMessageA, [
111
- :ulong,
112
- :pointer,
113
- :ulong,
114
- :ulong,
115
- :pointer,
116
- :ulong,
117
- :pointer
118
- ], :ulong
119
-
120
- attach_function :close_handle, :CloseHandle, [:pointer], :bool
121
-
122
- #
123
- # HANDLE WINAPI OpenProcess(
124
- # __in DWORD dwDesiredAccess,
125
- # __in BOOL bInheritHandle,
126
- # __in DWORD dwProcessId
127
- # );
128
- #
129
-
130
- attach_function :open_process, :OpenProcess, [:ulong, :bool, :ulong], :pointer
131
-
132
- #
133
- # HANDLE WINAPI CreateJobObject(
134
- # _In_opt_ LPSECURITY_ATTRIBUTES lpJobAttributes,
135
- # _In_opt_ LPCTSTR lpName
136
- # );
137
- #
138
-
139
- attach_function :create_job_object, :CreateJobObjectA, [:pointer, :pointer], :pointer
140
-
141
- #
142
- # BOOL WINAPI AssignProcessToJobObject(
143
- # _In_ HANDLE hJob,
144
- # _In_ HANDLE hProcess
145
- # );
146
-
147
- attach_function :assign_process_to_job_object, :AssignProcessToJobObject, [:pointer, :pointer], :bool
148
-
149
- #
150
- # BOOL WINAPI SetInformationJobObject(
151
- # _In_ HANDLE hJob,
152
- # _In_ JOBOBJECTINFOCLASS JobObjectInfoClass,
153
- # _In_ LPVOID lpJobObjectInfo,
154
- # _In_ DWORD cbJobObjectInfoLength
155
- # );
156
- #
157
-
158
- attach_function :set_information_job_object, :SetInformationJobObject, [:pointer, :int, :pointer, :ulong], :bool
159
-
160
- #
161
- #
162
- # DWORD WINAPI WaitForSingleObject(
163
- # __in HANDLE hHandle,
164
- # __in DWORD dwMilliseconds
165
- # );
166
- #
167
-
168
- attach_function :wait_for_single_object, :WaitForSingleObject, [:pointer, :ulong], :wait_status, blocking: true
169
-
170
- #
171
- # BOOL WINAPI GetExitCodeProcess(
172
- # __in HANDLE hProcess,
173
- # __out LPDWORD lpExitCode
174
- # );
175
- #
176
-
177
- attach_function :get_exit_code, :GetExitCodeProcess, [:pointer, :pointer], :bool
178
-
179
- #
180
- # BOOL WINAPI GenerateConsoleCtrlEvent(
181
- # __in DWORD dwCtrlEvent,
182
- # __in DWORD dwProcessGroupId
183
- # );
184
- #
185
-
186
- attach_function :generate_console_ctrl_event, :GenerateConsoleCtrlEvent, [:ulong, :ulong], :bool
187
-
188
- #
189
- # BOOL WINAPI TerminateProcess(
190
- # __in HANDLE hProcess,
191
- # __in UINT uExitCode
192
- # );
193
- #
194
-
195
- attach_function :terminate_process, :TerminateProcess, [:pointer, :uint], :bool
196
-
197
- #
198
- # intptr_t _get_osfhandle(
199
- # int fd
200
- # );
201
- #
202
-
203
- attach_function :get_osfhandle, :_get_osfhandle, [:int], :intptr_t
204
-
205
- #
206
- # int _open_osfhandle (
207
- # intptr_t osfhandle,
208
- # int flags
209
- # );
210
- #
211
-
212
- attach_function :open_osfhandle, :_open_osfhandle, [:pointer, :int], :int
213
-
214
- # BOOL WINAPI SetHandleInformation(
215
- # __in HANDLE hObject,
216
- # __in DWORD dwMask,
217
- # __in DWORD dwFlags
218
- # );
219
-
220
- attach_function :set_handle_information, :SetHandleInformation, [:pointer, :ulong, :ulong], :bool
221
-
222
- # BOOL WINAPI GetHandleInformation(
223
- # __in HANDLE hObject,
224
- # __out LPDWORD lpdwFlags
225
- # );
226
-
227
- attach_function :get_handle_information, :GetHandleInformation, [:pointer, :pointer], :bool
228
-
229
- # BOOL WINAPI CreatePipe(
230
- # __out PHANDLE hReadPipe,
231
- # __out PHANDLE hWritePipe,
232
- # __in_opt LPSECURITY_ATTRIBUTES lpPipeAttributes,
233
- # __in DWORD nSize
234
- # );
235
-
236
- attach_function :create_pipe, :CreatePipe, [:pointer, :pointer, :pointer, :ulong], :bool
237
-
238
- #
239
- # HANDLE WINAPI GetCurrentProcess(void);
240
- #
241
-
242
- attach_function :current_process, :GetCurrentProcess, [], :pointer
243
-
244
- #
245
- # BOOL WINAPI DuplicateHandle(
246
- # __in HANDLE hSourceProcessHandle,
247
- # __in HANDLE hSourceHandle,
248
- # __in HANDLE hTargetProcessHandle,
249
- # __out LPHANDLE lpTargetHandle,
250
- # __in DWORD dwDesiredAccess,
251
- # __in BOOL bInheritHandle,
252
- # __in DWORD dwOptions
253
- # );
254
- #
255
-
256
- attach_function :_duplicate_handle, :DuplicateHandle, [
257
- :pointer,
258
- :pointer,
259
- :pointer,
260
- :pointer,
261
- :ulong,
262
- :bool,
263
- :ulong
264
- ], :bool
265
- end
266
- end
267
- end
268
- end