Created
February 27, 2011 07:12
-
-
Save takeru/845977 to your computer and use it in GitHub Desktop.
appengine-jruby-bundler-1.0-patch.diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -r -u gems/appengine-tools-0.0.17/lib/appengine-tools/gem_bundler.rb ../ruby-1.8.7-p334@default/gems/appengine-tools-0.0.17/lib/appengine-tools/gem_bundler.rb | |
| --- gems/appengine-tools-0.0.17/lib/appengine-tools/gem_bundler.rb 2011-04-14 01:06:51.000000000 +0900 | |
| +++ ../ruby-1.8.7-p334@default/gems/appengine-tools-0.0.17/lib/appengine-tools/gem_bundler.rb 2011-02-27 15:54:16.000000000 +0900 | |
| @@ -26,7 +26,7 @@ | |
| module Admin | |
| TARGET_VERSION = '1.8' | |
| TARGET_ENGINE = 'jruby' | |
| - GEM_PLATFORM = Gem::Platform.new("universal-java-1.6") | |
| + #GEM_PLATFORM = Gem::Platform.new("universal-java-1.6") | |
| class GemBundler | |
| @@ -56,25 +56,23 @@ | |
| def gem_bundle(args) | |
| return unless args.include?('--update') || gems_out_of_date | |
| - Gem.platforms = [Gem::Platform::RUBY, GEM_PLATFORM] | |
| - Gem.configuration = Gem::ConfigFile.new(args.unshift('bundle')) | |
| - ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : nil | |
| - # Override RUBY_ENGINE (we bundle from MRI for JRuby) | |
| - Object.const_set('RUBY_ENGINE', TARGET_ENGINE) | |
| puts "=> Bundling gems" | |
| + | |
| + bundler_dir = "#{app.gems_dir}/bundler_gems" | |
| begin | |
| Dir.chdir(@root) do | |
| - Gem::CommandManager.instance.run(Gem.configuration.args) | |
| + system("bundle install --path #{bundler_dir}") | |
| end | |
| rescue Gem::SystemExitException => e | |
| exit e.exit_code unless e.exit_code == 0 | |
| end | |
| - # Restore RUBY_ENGINE (limit the scope of this hack) | |
| - Object.const_set('RUBY_ENGINE', ruby_engine) unless ruby_engine.nil? | |
| - bundler_dir = "#{app.gems_dir}/bundler_gems" | |
| + | |
| + source_pair = find_source_pair(bundler_dir) | |
| + File.open("#{bundler_dir}/#{source_pair}/environment.rb",'w') {|f| f << gems_loader("#{bundler_dir}/#{source_pair}") } | |
| target_pair = "#{TARGET_ENGINE}/#{TARGET_VERSION}" | |
| gem_patch = "require 'bundler_gems/#{target_pair}/environment'" | |
| File.open("#{bundler_dir}/environment.rb",'w') {|f| f << gem_patch } | |
| + | |
| FileUtils.rm app.gems_jar, :force => true # blow away the old jar | |
| # cleanup old extension jars | |
| if File.exists? app.bundled_jars | |
| @@ -87,12 +85,13 @@ | |
| appengine-jruby-0.0.8.pre.jar jruby-rack-0.9.6.jar).each do |j| | |
| FileUtils.rm File.join(app.webinf_lib, j), :force => true | |
| end | |
| - jars = [] | |
| + | |
| puts "=> Packaging gems" | |
| - gem_files = Dir["#{bundler_dir}/#{target_pair}/dirs/**/**"] + | |
| - Dir["#{bundler_dir}/#{target_pair}/gems/**/**"] + | |
| - Dir["#{bundler_dir}/#{target_pair}/environment.rb"] + | |
| + gem_files = Dir["#{bundler_dir}/#{source_pair}/dirs/**/**"] + | |
| + Dir["#{bundler_dir}/#{source_pair}/gems/**/**"] + | |
| + Dir["#{bundler_dir}/#{source_pair}/environment.rb"] + | |
| Dir["#{bundler_dir}/environment.rb"] | |
| + jars = [] | |
| Zip::ZipFile.open(app.gems_jar, 'w') do |jar| | |
| gem_files.reject {|f| f == app.gems_jar}.each do |file| | |
| if file[-4..-1].eql? '.jar' | |
| @@ -100,7 +99,9 @@ | |
| FileUtils.cp file, app.webinf_lib | |
| jars << File.basename(file) | |
| else | |
| - jar.add(file.sub("#{app.gems_dir}/",''), file) | |
| + fn = file.sub("#{app.gems_dir}/",'').sub(source_pair,target_pair) | |
| + # puts fn | |
| + jar.add(fn, file) | |
| end | |
| end | |
| end | |
| @@ -112,16 +113,169 @@ | |
| puts "=> Generating gemfile" | |
| # TODO: include the latest versions from updatecheck here? | |
| stock_gemfile = <<EOF | |
| -# Critical default settings: | |
| -disable_system_gems | |
| -disable_rubygems | |
| -bundle_path ".gems/bundler_gems" | |
| - | |
| # List gems to bundle here: | |
| +source :rubygems | |
| gem 'appengine-rack' | |
| +gem 'jruby-rack', '1.0.5' # need to avoid jruby-rack 1.0.6. http://groups.google.com/group/appengine-jruby/browse_thread/thread/c915691c8bbba9b | |
| EOF | |
| File.open(app.gemfile,'w') {|f| f.write(stock_gemfile) } | |
| end | |
| + | |
| + def find_source_pair(bundler_dir) | |
| + "ruby/1.8" # todo!! | |
| + end | |
| + | |
| + def gems_loader(source_dir) | |
| + old_Gem_Specification = Gem::Specification | |
| + new_Gem_Specification = Class.new do | |
| + def initialize | |
| + yield(self) | |
| + end | |
| + attr_accessor :name, :version, :require_paths | |
| + def method_missing(method, *args) | |
| + # p method, args | |
| + end | |
| + end | |
| + Gem.instance_eval{ remove_const(:Specification) } | |
| + Gem.const_set(:Specification, new_Gem_Specification) | |
| + load_paths = [] | |
| + Dir["#{source_dir}/specifications/*.gemspec"].each do |f| | |
| + spec = eval(File.read(f)) | |
| + spec.require_paths.each do |require_path| | |
| + load_paths << "gems/#{spec.name}-#{spec.version}/#{require_path}" | |
| + end | |
| + end | |
| + Gem.instance_eval{ remove_const(:Specification) } | |
| + Gem.const_set(:Specification, old_Gem_Specification) | |
| + | |
| + code = "" | |
| + code << <<'END' | |
| +# DO NOT MODIFY THIS FILE | |
| +module Bundler | |
| + file = File.expand_path(__FILE__) | |
| + dir = File.dirname(file) | |
| + | |
| + ENV["GEM_HOME"] = dir | |
| + ENV["GEM_PATH"] = dir | |
| + | |
| + # handle 1.9 where system gems are always on the load path | |
| + if defined?(::Gem) | |
| + $LOAD_PATH.reject! do |p| | |
| + p != File.dirname(__FILE__) && | |
| + Gem.path.any? { |gp| p.include?(gp) } | |
| + end | |
| + end | |
| + | |
| + ENV["PATH"] = "#{dir}/../../../../bin:#{ENV["PATH"]}" | |
| + ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}" | |
| +END | |
| + | |
| + load_paths.each do |load_path| | |
| + # gems/jruby-jars-1.5.5/lib | |
| + code << '$LOAD_PATH.unshift File.expand_path("#{dir}/' + load_path + '")' + "\n" | |
| + end | |
| + # $LOAD_PATH.unshift File.expand_path("#{dir}/gems/jruby-jars-1.5.5/lib") | |
| + # $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.2.1/bin") | |
| + # $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.2.1/lib") | |
| + # $LOAD_PATH.unshift File.expand_path("#{dir}/gems/jruby-rack-1.0.3/lib") | |
| + # $LOAD_PATH.unshift File.expand_path("#{dir}/gems/appengine-rack-0.0.11/lib") | |
| + | |
| + code << <<'END' | |
| + @gemfile = "#{dir}/../../../../Gemfile" | |
| + | |
| + | |
| + def self.require_env(env = nil) | |
| + context = Class.new do | |
| + def initialize(env) @env = env && env.to_s ; end | |
| + def method_missing(*) ; yield if block_given? ; end | |
| + def only(*env) | |
| + old, @only = @only, _combine_only(env.flatten) | |
| + yield | |
| + @only = old | |
| + end | |
| + def except(*env) | |
| + old, @except = @except, _combine_except(env.flatten) | |
| + yield | |
| + @except = old | |
| + end | |
| + def gem(name, *args) | |
| + opt = args.last.is_a?(Hash) ? args.pop : {} | |
| + only = _combine_only(opt[:only] || opt["only"]) | |
| + except = _combine_except(opt[:except] || opt["except"]) | |
| + files = opt[:require_as] || opt["require_as"] || name | |
| + files = [files] unless files.respond_to?(:each) | |
| + | |
| + return unless !only || only.any? {|e| e == @env } | |
| + return if except && except.any? {|e| e == @env } | |
| + | |
| + if files = opt[:require_as] || opt["require_as"] | |
| + files = Array(files) | |
| + files.each { |f| require f } | |
| + else | |
| + begin | |
| + require name | |
| + rescue LoadError | |
| + # Do nothing | |
| + end | |
| + end | |
| + yield if block_given? | |
| + true | |
| + end | |
| + private | |
| + def _combine_only(only) | |
| + return @only unless only | |
| + only = [only].flatten.compact.uniq.map { |o| o.to_s } | |
| + only &= @only if @only | |
| + only | |
| + end | |
| + def _combine_except(except) | |
| + return @except unless except | |
| + except = [except].flatten.compact.uniq.map { |o| o.to_s } | |
| + except |= @except if @except | |
| + except | |
| + end | |
| + end | |
| + context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1) | |
| + end | |
| +end | |
| + | |
| +$" << "rubygems.rb" | |
| + | |
| +module Kernel | |
| + def gem(*) | |
| + # Silently ignore calls to gem, since, in theory, everything | |
| + # is activated correctly already. | |
| + end | |
| +end | |
| + | |
| +# Define all the Gem errors for gems that reference them. | |
| +module Gem | |
| + def self.ruby ; "/Users/takeru/.rvm/rubies/ruby-1.8.7-p302/bin/ruby" ; end | |
| + def self.dir ; @dir ||= File.dirname(File.expand_path(__FILE__)) ; end | |
| + class << self ; alias default_dir dir; alias path dir ; end | |
| + class LoadError < ::LoadError; end | |
| + class Exception < RuntimeError; end | |
| + class CommandLineError < Exception; end | |
| + class DependencyError < Exception; end | |
| + class DependencyRemovalException < Exception; end | |
| + class GemNotInHomeException < Exception ; end | |
| + class DocumentError < Exception; end | |
| + class EndOfYAMLException < Exception; end | |
| + class FilePermissionError < Exception; end | |
| + class FormatException < Exception; end | |
| + class GemNotFoundException < Exception; end | |
| + class InstallError < Exception; end | |
| + class InvalidSpecificationException < Exception; end | |
| + class OperationNotSupportedError < Exception; end | |
| + class RemoteError < Exception; end | |
| + class RemoteInstallationCancelled < Exception; end | |
| + class RemoteInstallationSkipped < Exception; end | |
| + class RemoteSourceException < Exception; end | |
| + class VerificationError < Exception; end | |
| + class SystemExitException < SystemExit; end | |
| +end | |
| +END | |
| + end | |
| end | |
| end | |
| end | |
| diff -r -u specifications/appengine-tools-0.0.17.gemspec ../ruby-1.8.7-p334@default/specifications/appengine-tools-0.0.17.gemspec | |
| --- specifications/appengine-tools-0.0.17.gemspec 2011-04-14 01:06:51.000000000 +0900 | |
| +++ ../ruby-1.8.7-p334@default/specifications/appengine-tools-0.0.17.gemspec 2011-02-27 11:35:54.000000000 +0900 | |
| @@ -25,18 +25,18 @@ | |
| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then | |
| s.add_runtime_dependency(%q<appengine-rack>, [">= 0"]) | |
| s.add_runtime_dependency(%q<appengine-sdk>, [">= 0"]) | |
| - s.add_runtime_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| +# s.add_runtime_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| s.add_runtime_dependency(%q<rubyzip>, [">= 0"]) | |
| else | |
| s.add_dependency(%q<appengine-rack>, [">= 0"]) | |
| s.add_dependency(%q<appengine-sdk>, [">= 0"]) | |
| - s.add_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| +# s.add_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| s.add_dependency(%q<rubyzip>, [">= 0"]) | |
| end | |
| else | |
| s.add_dependency(%q<appengine-rack>, [">= 0"]) | |
| s.add_dependency(%q<appengine-sdk>, [">= 0"]) | |
| - s.add_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| +# s.add_dependency(%q<bundler08>, ["~> 0.8.4"]) | |
| s.add_dependency(%q<rubyzip>, [">= 0"]) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tkrmb2:~/proj/drawchat% gem uninstall bundler08 | |
| You have requested to uninstall the gem: | |
| bundler08-0.8.5 | |
| appengine-tools-0.0.17 depends on [bundler08 (~> 0.8.4)] | |
| If you remove this gems, one or more dependencies will not be met. | |
| Continue with Uninstall? [Yn] | |
| Successfully uninstalled bundler08-0.8.5 | |
| tkrmb2:~/proj/drawchat% gem install bundler | |
| Fetching: bundler-1.0.12.gem (100%) | |
| Successfully installed bundler-1.0.12 | |
| 1 gem installed | |
| Installing ri documentation for bundler-1.0.12... | |
| Installing RDoc documentation for bundler-1.0.12... | |
| tkrmb2:~/proj/drawchat% gem list | |
| *** LOCAL GEMS *** | |
| appengine-apis (0.0.23) | |
| appengine-rack (0.0.12) | |
| appengine-sdk (1.4.2) | |
| appengine-tools (0.0.17) | |
| bundler (1.0.12) | |
| google-appengine (0.0.20) | |
| jruby-jars (1.6.1) | |
| jruby-rack (1.0.8) | |
| rack (1.2.2) | |
| rubyzip (0.9.4) | |
| tkrmb2:~/.rvm/gems/ruby-1.8.7-p334@gae142% patch -p0 < appengine-tools-0.0.17-bundler1.diff | |
| patching file gems/appengine-tools-0.0.17/lib/appengine-tools/gem_bundler.rb | |
| patching file specifications/appengine-tools-0.0.17.gemspec | |
| tkrmb2:~/proj/drawchat% appcfg.rb generate_app . | |
| => Generating gemfile | |
| => Bundling gems | |
| Fetching source index for http://rubygems.org/ | |
| Installing jruby-jars (1.6.1) | |
| Installing jruby-rack (1.0.5) | |
| Installing rack (1.2.2) | |
| Installing appengine-rack (0.0.12) | |
| Using bundler (1.0.12) | |
| Your bundle is complete! It was installed into ././.gems/bundler_gems | |
| => Packaging gems | |
| => Installing appengine-rack.jar | |
| => Installing jruby-core-1.6.1.jar | |
| => Installing jruby-stdlib-1.6.1.jar | |
| => Installing jruby-rack-1.0.5.jar | |
| => Generating rackup | |
| => Generating app.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment