chef 19.1.164 → 19.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7fc478657545da0cad78e0200726a50534157cbee77bd4f130b5c5252e8b9d
4
- data.tar.gz: 0c6a6791f5f5c13dd65f3ce6bd428f7447920408d6ca01f04860d1ca762a8839
3
+ metadata.gz: a348124039267c43844767273ea5e8727b35d92b641fc3e6690885947277b543
4
+ data.tar.gz: f85cdbe7468884cd9c80d2775a8e30ead5c2102b451bcd1d778e13b2090ceae0
5
5
  SHA512:
6
- metadata.gz: 64d827469a38015f1db81fb765617836b1524c6c9c1e70a13f3062815989e25ca1ef6b651fc607a69b382c8b4c4cae9f4d2f9fec408b5433d69db49be3ce38fe
7
- data.tar.gz: 61e13e48a1d7459635b076b346a5c37942da12e965ca4172679d0d7fee7da611c3c482c5b4d0414fef222cef79fc6eb4a21bb592fada320f8115b9c0311dfc44
6
+ metadata.gz: 523e235dfa63d0f7ba8de9aee74606e13e9795e04ce18893c11298a1b1c2d08d23c03f7e8f3c0c30e297330740abaab6a74fac58b1d0338dec1f8abacecebedd
7
+ data.tar.gz: f7eb3b68c618206e5ba488e7eeca347f316e2e5098338eeaebeb06e37b4a37291190a5b98170006daf000f48c21c17aa4ed3c961bd478c6910d9f2de3e73534f
data/Gemfile CHANGED
@@ -35,7 +35,7 @@ end
35
35
  group(:omnibus_package) do
36
36
  gem "appbundler"
37
37
  gem "rb-readline"
38
- gem "inspec-core-bin", "= 7.0.95" # need to provide the binaries for inspec
38
+ gem "inspec-core-bin", "= 7.0.107" # need to provide the binaries for inspec
39
39
  gem "chef-vault"
40
40
  end
41
41
 
data/Rakefile CHANGED
@@ -114,3 +114,13 @@ task :style do
114
114
  rescue LoadError
115
115
  puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
116
116
  end
117
+
118
+ # begin
119
+ # require "chefstyle"
120
+ # require "rubocop/rake_task"
121
+ # RuboCop::RakeTask.new(:style) do |task|
122
+ # task.options += ["--display-cop-names", "--no-color"]
123
+ # end
124
+ # rescue LoadError
125
+ # puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
126
+ # end
data/chef.gemspec CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.add_dependency "mixlib-shellout", "~> 3.3.8"
45
45
  s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
46
46
  s.add_dependency "ohai", "~> 19.0"
47
- s.add_dependency "inspec-core", "~> 7.0.95"
47
+ s.add_dependency "inspec-core", "~> 7.0.107"
48
48
 
49
49
  s.add_dependency "ffi", ">= 1.15.5", "< 1.18.0"
50
50
  s.add_dependency "ffi-yajl", "~> 2.2"
@@ -257,7 +257,8 @@ class Chef
257
257
  @choco_install_path ||= begin
258
258
  result = powershell_exec!(PATHFINDING_POWERSHELL_COMMAND).result
259
259
  result = "" if result.empty?
260
- result
260
+ # Ensure consistent Windows path separators
261
+ result.empty? ? result : result.tr("/", "\\")
261
262
  end
262
263
  end
263
264
 
@@ -459,8 +460,10 @@ class Chef
459
460
  def get_local_pkg_dirs(base_dir)
460
461
  return [] unless Dir.exist?(base_dir)
461
462
 
462
- Dir.entries(base_dir).select do |dir|
463
- ::File.directory?(::File.join(base_dir, dir)) && !dir.start_with?(".")
463
+ with_file_lock_retry("reading chocolatey package directories") do
464
+ Dir.entries(base_dir).select do |dir|
465
+ ::File.directory?(::File.join(base_dir, dir)) && !dir.start_with?(".")
466
+ end
464
467
  end
465
468
  end
466
469
 
@@ -496,6 +499,60 @@ class Chef
496
499
  args
497
500
  end
498
501
 
502
+ # Wait for chocolatey to release file locks after package operations
503
+ # @param names [Array<String>] package names that were just installed/upgraded
504
+ def wait_for_chocolatey_lock_release(names)
505
+ return if names.empty?
506
+
507
+ Chef::Log.debug("Waiting for chocolatey to release file locks for packages: #{names.join(", ")}")
508
+
509
+ # Check for .chocolateyPending files and wait for them to be released
510
+ names.each do |name|
511
+ pending_file = ::File.join(choco_lib_path, name.downcase, ".chocolateyPending")
512
+ if ::File.exist?(pending_file)
513
+ with_file_lock_retry("waiting for .chocolateyPending file release: #{pending_file}") do
514
+ # Try to open the file exclusively - this will fail if it's locked
515
+ ::File.open(pending_file, "r") do |f|
516
+ f.flock(::File::LOCK_EX | ::File::LOCK_NB) or raise Errno::EAGAIN
517
+ end
518
+ end
519
+ end
520
+ end
521
+ end
522
+
523
+ # Retry file operations that might encounter chocolatey process file locks
524
+ # @param operation_desc [String] description of the operation for logging
525
+ # @param max_retries [Integer] maximum number of retry attempts
526
+ # @param base_delay [Float] base delay between retries in seconds
527
+ def with_file_lock_retry(operation_desc, max_retries: 5, base_delay: 0.5)
528
+ retries = 0
529
+ begin
530
+ yield
531
+ rescue Errno::EACCES, Errno::EBUSY, Errno::EAGAIN, Errno::ENOENT => e
532
+ if retries < max_retries && file_lock_error?(e)
533
+ retries += 1
534
+ delay = base_delay * (2**(retries - 1)) # exponential backoff
535
+ Chef::Log.debug("Chocolatey file lock detected during #{operation_desc}, retrying in #{delay}s (attempt #{retries}/#{max_retries}): #{e.message}")
536
+ sleep(delay)
537
+ retry
538
+ else
539
+ Chef::Log.warn("Failed #{operation_desc} after #{retries} retries: #{e.message}")
540
+ raise e
541
+ end
542
+ end
543
+ end
544
+
545
+ # Check if the error is related to file locking by chocolatey processes
546
+ # @param error [Exception] the exception to check
547
+ # @return [Boolean] true if it's a chocolatey file lock related error
548
+ def file_lock_error?(error)
549
+ error.message&.include?("being used by another process") ||
550
+ error.message&.include?("chocolateyPending") ||
551
+ error.is_a?(Errno::EACCES) ||
552
+ error.is_a?(Errno::EBUSY) ||
553
+ error.is_a?(Errno::EAGAIN)
554
+ end
555
+
499
556
  # Fetch the local package versions from chocolatey
500
557
  def fetch_package_versions(base_dir, target_dirs, targets)
501
558
  pkg_versions = {}
@@ -511,25 +568,27 @@ class Chef
511
568
  # Grab the locally installed packages from the nupkg list
512
569
  # rather than shelling out to chocolatey
513
570
  def get_pkg_data(path)
514
- t = ::File.join(path, "*.nupkg").gsub("\\", "/")
515
- targets = Dir.glob(t)
516
-
517
- # Extract package version from the first nuspec file in this nupkg
518
- targets.each do |target|
519
- Zip::File.open(target) do |zip_file|
520
- zip_file.each do |entry|
521
- next unless entry.name.end_with?(".nuspec")
522
-
523
- f = entry.get_input_stream
524
- doc = REXML::Document.new(f.read.to_s)
525
- f.close
526
- id = doc.elements["package/metadata/id"]
527
- version = doc.elements["package/metadata/version"]
528
- return { id.text.to_s.downcase => version.text } if id && version
571
+ with_file_lock_retry("get package data for #{path}") do
572
+ t = ::File.join(path, "*.nupkg")
573
+ targets = Dir.glob(t)
574
+
575
+ # Extract package version from the first nuspec file in this nupkg
576
+ targets.each do |target|
577
+ Zip::File.open(target) do |zip_file|
578
+ zip_file.each do |entry|
579
+ next unless entry.name.end_with?(".nuspec")
580
+
581
+ f = entry.get_input_stream
582
+ doc = REXML::Document.new(f.read.to_s)
583
+ f.close
584
+ id = doc.elements["package/metadata/id"]
585
+ version = doc.elements["package/metadata/version"]
586
+ return { id.text.to_s.downcase => version.text } if id && version
587
+ end
529
588
  end
530
589
  end
590
+ {}
531
591
  end
532
- {}
533
592
  rescue StandardError => e
534
593
  Chef::Log.warn("Failed to get package info for #{path}: #{e}")
535
594
  {}
@@ -391,6 +391,8 @@ class Chef
391
391
  cmd = "#{@gem_binary_location} list #{gem_dependency.name} --remote --all #{source_args}"
392
392
  result = shell_out!(cmd)
393
393
 
394
+ target_platforms = nil
395
+
394
396
  versions = []
395
397
  result.stdout.each_line do |line|
396
398
  next unless line.start_with?("#{gem_dependency.name} (")
@@ -399,10 +401,31 @@ class Chef
399
401
  next unless version_string
400
402
 
401
403
  version_string.split(/,\s*/).each do |v|
402
- version = Gem::Version.new(v.strip)
404
+ # `gem list --remote --all` emits entries like "1.6.0 x86_64-linux".
405
+ # Accept platform-specific tokens only when the platform is compatible
406
+ # with the target gem environment; pure-Ruby tokens have no suffix and
407
+ # are always accepted.
408
+ version_token, *platform_tokens = v.strip.split(/\s+/)
409
+
410
+ if platform_tokens.any?
411
+ target_platforms ||= gem_platforms
412
+ # Each comma-separated entry from `gem list --remote --all` can list
413
+ # multiple platforms for one version: "1.5.9 ruby x86_64-linux aarch64-linux ...".
414
+ # Accept if any listed platform is "ruby" (pure-Ruby) or matches the target env.
415
+ compatible = platform_tokens.any? do |pt|
416
+ pt == "ruby" || target_platforms.any? do |p|
417
+ Gem::Platform.new(p) === Gem::Platform.new(pt)
418
+ rescue ArgumentError
419
+ false
420
+ end
421
+ end
422
+ next unless compatible
423
+ end
424
+
425
+ version = Gem::Version.new(version_token)
403
426
  versions << version if gem_dependency.requirement.satisfied_by?(version)
404
427
  rescue ArgumentError
405
- # Skip invalid versions
428
+ # Skip tokens with invalid version strings.
406
429
  end
407
430
  end
408
431
 
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "pathname"
17
+ require "pathname" unless defined?(Pathname)
18
18
  require "chef-utils/dist" unless defined?(ChefUtils::Dist)
19
19
 
20
20
  class Chef
@@ -35,7 +35,7 @@ class Chef
35
35
  ```ruby
36
36
  chocolatey_installer 'latest' do
37
37
  action :install
38
- download_url "c:\\foo\foo.nupkg"
38
+ download_url "c:\\foo\\foo.nupkg"
39
39
  chocolatey_version '2.12.24'
40
40
  end
41
41
  ```
@@ -23,9 +23,11 @@ class Chef
23
23
  bin = File.basename(path)
24
24
 
25
25
  # On Windows, temporarily use the c:\\hab\\bin\\*.bat binstubs
26
- bat_path = "C:\\hab\\bin\\#{bin}.bat"
26
+ bat_path = "C:\\hab\\bin\\#{ChefUtils::Dist::Infra::CLIENT}.bat"
27
27
  return bat_path if File.exist?(bat_path) && ChefUtils.windows?
28
- return path if bin == "#{ChefUtils::Dist::Infra::CLIENT}"
28
+
29
+ # return path for any bin/chef-* names
30
+ return path.sub(bin, ChefUtils::Dist::Infra::CLIENT) if bin =~ /^chef-[a-z-]+$/
29
31
 
30
32
  # Return empty string if no valid path is found
31
33
  ""
@@ -37,7 +39,7 @@ class Chef
37
39
  path = File.realpath($PROGRAM_NAME)
38
40
  bin = File.basename(path)
39
41
 
40
- return path if bin == "#{ChefUtils::Dist::Infra::CLIENT}"
42
+ return path.sub(bin, ChefUtils::Dist::Infra::CLIENT) if bin =~ /^chef-[a-z-]+$/
41
43
 
42
44
  # Return empty string if no valid path is found
43
45
  ""
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("19.1.164")
26
+ VERSION = Chef::VersionString.new("19.2.12")
27
27
  end
28
28
 
29
29
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.1.164
4
+ version: 19.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 19.1.164
18
+ version: 19.2.12
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 19.1.164
25
+ version: 19.2.12
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: chef-utils
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 19.1.164
32
+ version: 19.2.12
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 19.1.164
39
+ version: 19.2.12
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: train-core
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -219,14 +219,14 @@ dependencies:
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: 7.0.95
222
+ version: 7.0.107
223
223
  type: :runtime
224
224
  prerelease: false
225
225
  version_requirements: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: 7.0.95
229
+ version: 7.0.107
230
230
  - !ruby/object:Gem::Dependency
231
231
  name: ffi
232
232
  requirement: !ruby/object:Gem::Requirement