Permalink
Browse files

Allow for having multiple patchfiles for the same target.

  • Loading branch information...
1 parent 98258f7 commit cb7df9f1b1c97e0da6615217fe54399c2b8485d9 @VictorLowther VictorLowther committed May 21, 2012
Showing with 91 additions and 15 deletions.
  1. +12 −11 extra/patches/patch.sh
  2. +75 −0 extra/patches/rubygems.rb.2.patch
  3. +4 −4 extra/patches/rubygems.rb.patch
View
@@ -3,6 +3,7 @@
# function the way we expect.
patches=(
'ohai/mixin/command.rb' # OHAI-330
+ 'chef/mixin/command/unix.rb' # CHEF-2916
'chef-server-ap*/app/controllers/data_item.rb' # CHEF-2005
'chef/run_list.rb' # Always return run_lists sanely.
'ohai-0.6.6/lib/ohai/plugins/linux/platform.rb'
@@ -15,15 +16,15 @@ for p in "${patches[@]}"; do
echo "Cannot find file to patch for $p, will skip."
continue
}
- patch="$PWD/${f##*/}.patch"
- [[ -f $patch ]] || {
- echo "No patch file for $f, will skip."
- continue
- }
- [[ -f $f.crowbar-backup ]] && continue
- cp "$f" "$f.crowbar-backup"
- (cd "${f%/*}"; patch <"$patch") && continue
- echo "Patch $patch did not cleanly apply to $f"
- echo "Assuming things went horribly wrong."
- exit 1
+ for patch in "$PWD/${f##*/}"*".patch"; do
+ [[ -f $patch ]] || {
+ echo "No patch file for $f, will skip."
+ continue 2
+ }
+ [[ -f $f.crowbar-backup ]] && continue 2
+ cp "$f" "$f.crowbar-backup"
+ (cd "${f%/*}"; patch <"$patch") && continue 2
+ mv "$f.crowbar-backup" "$f"
+ echo "Patch $patch did not cleanly apply to $f, skipping it."
+ done
done
@@ -0,0 +1,75 @@
+--- /usr/lib/ruby/vendor_ruby/chef/provider/package/rubygems.rb 2012-01-17 16:19:36.000000000 -0600
++++ rubygems.rb 2012-03-17 01:32:16.000000000 -0500
+@@ -332,13 +332,13 @@
+
+ def initialize(new_resource, run_context=nil)
+ super
+- if new_resource.gem_binary
++ if new_resource.gem_binary or Gem.configuration["gem"]
+ if new_resource.options && new_resource.options.kind_of?(Hash)
+ msg = "options cannot be given as a hash when using an explicit gem_binary\n"
+ msg << "in #{new_resource} from #{new_resource.source_line}"
+ raise ArgumentError, msg
+ end
+- @gem_env = AlternateGemEnvironment.new(new_resource.gem_binary)
++ @gem_env = AlternateGemEnvironment.new(new_resource.gem_binary || "gem")
+ Chef::Log.debug("#{@new_resource} using gem '#{new_resource.gem_binary}'")
+ elsif is_omnibus? && (!@new_resource.instance_of? Chef::Resource::ChefGem)
+ # Opscode Omnibus - The ruby that ships inside omnibus is only used for Chef
+@@ -396,22 +396,19 @@
+ # 2. shell out to `gem install` when a String of options is given
+ # 3. use gems API with options if a hash of options is given
+ def install_package(name, version)
+- if source_is_remote? && @new_resource.gem_binary.nil?
+- if @new_resource.options.nil?
+- @gem_env.install(gem_dependency, :sources => gem_sources)
+- elsif @new_resource.options.kind_of?(Hash)
+- options = @new_resource.options
+- options[:sources] = gem_sources
+- @gem_env.install(gem_dependency, options)
+- else
+- install_via_gem_command(name, version)
+- end
+- elsif @new_resource.gem_binary.nil?
+- @gem_env.install(@new_resource.source)
+- else
++ case
++ when Gem.configuration["gem"] || @new_resource.gem_binary || @new_resource.options.kind_of?(String)
+ install_via_gem_command(name,version)
++ when source_is_remote? && @new_resource.options.kind_of?(Hash)
++ options = @new_resource.options
++ options[:sources] = gem_sources
++ @gem_env.install(gem_dependency, options)
++ when source_is_remote?
++ @gem_env.install(gem_dependency, :sources => gem_sources)
++ else
++ @gem_env.install(@new_resource.source)
+ end
+- true
++ true
+ end
+
+ def gem_binary_path
+@@ -428,16 +425,13 @@
+ end
+
+ def remove_package(name, version)
+- if @new_resource.gem_binary.nil?
+- if @new_resource.options.nil?
+- @gem_env.uninstall(name, version)
+- elsif @new_resource.options.kind_of?(Hash)
+- @gem_env.uninstall(name, version, @new_resource.options)
+- else
+- uninstall_via_gem_command(name, version)
+- end
+- else
++ case
++ when Gem.configuration["gem"] || @new_resource.gem_binary || @new_resource.options.kind_of?(String)
+ uninstall_via_gem_command(name, version)
++ when @new_resource.options.kind_of?(Hash)
++ @gem_env.uninstall(name, version, @new_resource.options)
++ else
++ @gem_env.uninstall(name, version)
+ end
+ end
+
@@ -1,6 +1,6 @@
--- /usr/lib/ruby/vendor_ruby/chef/provider/package/rubygems.rb 2012-01-17 16:19:36.000000000 -0600
+++ rubygems.rb 2012-03-17 01:32:16.000000000 -0500
-@@ -332,13 +332,13 @@
+@@ -304,13 +304,13 @@
def initialize(new_resource, run_context=nil)
super
@@ -13,9 +13,9 @@
end
- @gem_env = AlternateGemEnvironment.new(new_resource.gem_binary)
+ @gem_env = AlternateGemEnvironment.new(new_resource.gem_binary || "gem")
- Chef::Log.debug("#{@new_resource} using gem '#{new_resource.gem_binary}'")
- elsif is_omnibus? && (!@new_resource.instance_of? Chef::Resource::ChefGem)
- # Opscode Omnibus - The ruby that ships inside omnibus is only used for Chef
+ else
+ @gem_env = CurrentGemEnvironment.new
+ end
@@ -396,22 +396,19 @@
# 2. shell out to `gem install` when a String of options is given
# 3. use gems API with options if a hash of options is given

0 comments on commit cb7df9f

Please sign in to comment.