Skip to content

Commit e49408c

Browse files
Tim Hinderliterdanielsdeleo
authored andcommitted
fixed broken regex on cookbook manifest generation; expand paths from relative- to absolute- in manifest generation
1 parent 40e7eb9 commit e49408c

3 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎chef-server-api/app/controllers/sandboxes.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ChefServerApi::Sandboxes < ChefServerApi::Application
2525

2626
before :authenticate_every
2727

28-
include Chef::Mixin::ChecksumHelper
28+
include Chef::Mixin::Checksum
2929
include Merb::ChefServerApi::TarballHelper
3030

3131
def index

‎chef/lib/chef/cookbook.rb‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,28 +364,28 @@ def generate_manifest(&url_generation)
364364
}
365365

366366
[ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates ].each do |segment|
367-
segment_files(segment).each do |sf|
368-
next if File.directory?(sf)
367+
segment_files(segment).each do |segment_file|
368+
next if File.directory?(segment_file)
369369

370370
file_name = nil
371371
file_url = nil
372372
file_specificity = nil
373373
url_options = nil
374-
374+
375375
if segment == :templates || segment == :files
376-
mo = sf.match("cookbooks/#{name}/#{segment}/(.+?)/(.+)")
377-
unless mo
378-
Chef::Log.debug("Skipping file #{sf}, as it doesn't have a proper segment.")
376+
matcher = segment_file.match("/#{name}/#{segment}/(.+?)/(.+)")
377+
unless matcher
378+
Chef::Log.debug("Skipping file #{segment_file}, as it doesn't have a proper segment.")
379379
next
380380
end
381-
specificity = mo[1]
382-
file_name = mo[2]
381+
specificity = matcher[1]
382+
file_name = matcher[2]
383383
url_options = { :cookbook_id => name.to_s, :segment => segment, :id => file_name, :cookbook_version => version }
384384
set_specificity_arguments(specificity, url_options)
385385
file_specificity = specificity
386386
else
387-
mo = sf.match("cookbooks/#{name}/#{segment}/(.+)")
388-
file_name = mo[1]
387+
matcher = segment_file.match("/#{name}/#{segment}/(.+)")
388+
file_name = matcher[1]
389389
url_options = { :cookbook_id => name.to_s, :segment => segment, :id => file_name }
390390
end
391391

@@ -398,9 +398,9 @@ def generate_manifest(&url_generation)
398398
rs = {
399399
:name => file_name,
400400
:uri => file_url,
401-
:path => sf.match("cookbooks/#{name}/(#{segment}/.+)")[1],
402-
:on_disk_path => sf,
403-
:checksum => checksum(sf)
401+
:path => segment_file.match("/#{name}/(#{segment}/.+)")[1],
402+
:on_disk_path => segment_file,
403+
:checksum => checksum(segment_file)
404404
}
405405
rs[:specificity] = file_specificity if file_specificity
406406

‎chef/lib/chef/cookbook_loader.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def initialize()
3939
def load_cookbooks
4040
cookbook_settings = Hash.new
4141
[Chef::Config.cookbook_path].flatten.each do |cb_path|
42+
cb_path = File.expand_path(cb_path)
4243
Dir[File.join(cb_path, "*")].each do |cookbook|
4344
next unless File.directory?(cookbook)
4445
cookbook_name = File.basename(cookbook).to_sym

0 commit comments

Comments
 (0)