diff options
author | Vít Ondruch <vondruch@redhat.com> | 2014-11-26 11:58:44 +0100 |
---|---|---|
committer | Vít Ondruch <vondruch@redhat.com> | 2015-01-21 12:53:03 +0100 |
commit | c11853ff6f2fc97032b14f9df78588a0fa9eee41 (patch) | |
tree | e74eee887da95ab6f61bad263bbc970148d2973c | |
parent | 7aee8d4f2e330e09ecf7c2ae9b9035d79f5cf937 (diff) | |
download | fedora-vagrant-c11853ff6f2fc97032b14f9df78588a0fa9eee41.tar.gz fedora-vagrant-c11853ff6f2fc97032b14f9df78588a0fa9eee41.tar.xz fedora-vagrant-c11853ff6f2fc97032b14f9df78588a0fa9eee41.zip |
Include monkey-patching for RubyGems and Bundler for now.
-rw-r--r-- | patches.rb | 114 | ||||
-rw-r--r-- | vagrant.spec | 14 |
2 files changed, 127 insertions, 1 deletions
diff --git a/patches.rb b/patches.rb new file mode 100644 index 0000000..7fd8972 --- /dev/null +++ b/patches.rb @@ -0,0 +1,114 @@ +# Monkey-patching for RubyGems and Bundler to play nicely with Vagrant + +# Don't touch the binary when not needed. +# https://github.com/rubygems/rubygems/pull/1057 +class Gem::Installer + def generate_bin # :nodoc: + return if spec.executables.nil? or spec.executables.empty? + + Dir.mkdir @bin_dir unless File.exist? @bin_dir + raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir + + spec.executables.each do |filename| + filename.untaint + bin_path = File.join gem_dir, spec.bindir, filename + + unless File.exist? bin_path then + # TODO change this to a more useful warning + warn "#{bin_path} maybe `gem pristine #{spec.name}` will fix it?" + next + end + + mode = File.stat(bin_path).mode + FileUtils.chmod mode | 0111, bin_path unless (mode | 0111) == mode + + check_executable_overwrite filename + + if @wrappers then + generate_bin_script filename, @bin_dir + else + generate_bin_symlink filename, @bin_dir + end + + end + end +end + +# Fix rubygems 2.2 compatibility +# https://github.com/bundler/bundler/pull/3237 +module Bundler + module SharedHelpers + private + def clean_load_path + # handle 1.9 where system gems are always on the load path + if defined?(::Gem) + me = File.expand_path("../../", __FILE__) + + # RubyGems 2.2+ can put binary extension into dedicated folders, + # therefore use RubyGems facilities to obtain their load paths. + if Gem::Specification.method_defined? :full_require_paths + loaded_gem_paths = Gem.loaded_specs.map do |n, s| + s.full_require_paths.none? {|path| File.expand_path(path) =~ /^#{Regexp.escape(me)}/} ? s.full_require_paths : [] + end + loaded_gem_paths.flatten! + + $LOAD_PATH.reject! {|p| loaded_gem_paths.delete(p) } + else + $LOAD_PATH.reject! do |p| + next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/ + p != File.dirname(__FILE__) && + Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ } + end + end + $LOAD_PATH.uniq! + end + end + end +end + +# Remove useless gem build step. +# https://github.com/bundler/bundler/pull/3238 +module Bundler + class Source + + class Path < Source + + private + def generate_bin(spec, disable_extensions = false) + gem_dir = Pathname.new(spec.full_gem_path) + + # Some gem authors put absolute paths in their gemspec + # and we have to save them from themselves + spec.files = spec.files.map do |p| + next if File.directory?(p) + begin + Pathname.new(p).relative_path_from(gem_dir).to_s + rescue ArgumentError + p + end + end.compact + + SharedHelpers.chdir(gem_dir) do + installer = Path::Installer.new(spec, :env_shebang => false) + run_hooks(:pre_install, installer) + installer.build_extensions unless disable_extensions + run_hooks(:post_build, installer) + installer.generate_bin + run_hooks(:post_install, installer) + end + rescue Gem::InvalidSpecificationException => e + Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \ + "This prevents bundler from installing bins or native extensions, but " \ + "that may not affect its functionality." + + if !spec.extensions.empty? && !spec.email.empty? + Bundler.ui.warn "If you need to use this package without installing it from a gem " \ + "repository, please contact #{spec.email} and ask them " \ + "to modify their .gemspec so it can work with `gem build`." + end + + Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}" + end + end + end +end diff --git a/vagrant.spec b/vagrant.spec index 7c233a5..9480802 100644 --- a/vagrant.spec +++ b/vagrant.spec @@ -6,7 +6,7 @@ Name: vagrant Version: 1.6.5 -Release: 11%{?dist} +Release: 12%{?dist} Summary: Build and distribute virtualized development environments Group: Development/Languages License: MIT @@ -20,6 +20,10 @@ Source1: binstub # dependency, it should be fine to include the source right here. Source2: https://github.com/mitchellh/%{name}-spec/archive/%{vagrant_spec_commit}/%{name}-spec-%{vagrant_spec_commit}.tar.gz +# Monkey-patching needed for Vagrant to work until the respective patches +# for RubyGems and Bundler are in place +Source3: patches.rb + Patch0: vagrant-1.6.5-fix-dependencies.patch Requires: ruby(release) @@ -108,6 +112,11 @@ install -D -m 0644 %{buildroot}%{vagrant_dir}/contrib/bash/completion.sh \ # create the global home dir install -d -m 755 %{buildroot}%{vagrant_plugin_dir} +# Install the monkey-patch file and load it from Vagrant after loading RubyGems +cp %{SOURCE3} %{buildroot}%{vagrant_dir}/lib/vagrant +sed -i -e "11irequire 'vagrant/patches'" %{buildroot}%{vagrant_dir}/lib/vagrant.rb + + %check # Unpack the vagran-spec and adjust the directory name. tar xvzf %{S:2} -C .. @@ -161,6 +170,9 @@ getent group vagrant >/dev/null || groupadd -r vagrant %changelog +* Mon Nov 24 2014 Josef Stribny <jstribny@redhat.com> - 1.6.5-12 +- Include monkey-patching for RubyGems and Bundler for now + * Wed Oct 22 2014 Vít Ondruch <vondruch@redhat.com> - 1.6.5-11 - Make vagrant non-rubygem package. |