summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-09-29 14:57:51 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-29 15:01:47 -0700
commited3f76c6f0c2a9e925af32ffb8c28878f34eea9e (patch)
tree87ef4319f02a25f1b2d78148df4469bdffce17d6
parent4098cf801f8d991ab163f5ce21b81c7807dde6ff (diff)
downloadchef-ed3f76c6f0c2a9e925af32ffb8c28878f34eea9e.tar.gz
Fixing cookbook loading for windows
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb12
-rw-r--r--lib/chef/cookbook_version.rb2
-rw-r--r--lib/chef/util/path_helper.rb4
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index 5c9de6b8ca..5481ba7ddc 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -214,23 +214,29 @@ class Chef
def load_root_files
Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(cookbook_path), '*'), File::FNM_DOTMATCH).each do |file|
+ file = Chef::Util::PathHelper.cleanpath(file)
next if File.directory?(file)
next if File.basename(file) == UPLOADED_COOKBOOK_VERSION_FILE
- cookbook_settings[:root_filenames][file[@relative_path, 1]] = file
+ name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file)
+ cookbook_settings[:root_filenames][name] = file
end
end
def load_recursively_as(category, category_dir, glob)
file_spec = File.join(Chef::Util::PathHelper.escape_glob(cookbook_path, category_dir), '**', glob)
Dir.glob(file_spec, File::FNM_DOTMATCH).each do |file|
+ file = Chef::Util::PathHelper.cleanpath(file)
next if File.directory?(file)
- cookbook_settings[category][file[@relative_path, 1]] = file
+ name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file)
+ cookbook_settings[category][name] = file
end
end
def load_as(category, *path_glob)
Dir[File.join(Chef::Util::PathHelper.escape_glob(cookbook_path), *path_glob)].each do |file|
- cookbook_settings[category][file[@relative_path, 1]] = file
+ file = Chef::Util::PathHelper.cleanpath(file)
+ name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file)
+ cookbook_settings[category][name] = file
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 76e6d152b2..1503add33a 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -660,7 +660,7 @@ class Chef
def parse_segment_file_from_root_paths(segment, segment_file)
root_paths.each do |root_path|
- pathname = Pathname.new(segment_file).relative_path_from(Pathname.new(root_path))
+ pathname = Chef::Util::PathHelper.relative_path_from(root_path, segment_file)
parts = pathname.each_filename.take(2)
# Check if path is actually under root_path
diff --git a/lib/chef/util/path_helper.rb b/lib/chef/util/path_helper.rb
index 8ca8279593..26c9c76fe5 100644
--- a/lib/chef/util/path_helper.rb
+++ b/lib/chef/util/path_helper.rb
@@ -141,6 +141,10 @@ class Chef
path = cleanpath(join(*parts))
path.gsub(/[\\\{\}\[\]\*\?]/) { |x| "\\"+x }
end
+
+ def self.relative_path_from(from, to)
+ pathname = Pathname.new(Chef::Util::PathHelper.cleanpath(to)).relative_path_from(Pathname.new(Chef::Util::PathHelper.cleanpath(from)))
+ end
end
end
end