RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Per Øyvind Karlsen
  Root:   /v/rpm/cvs                       Email:  pkarl...@rpm5.org
  Module: rpm                              Date:   01-Apr-2011 09:29:51
  Branch: HEAD                             Handle: 2011040107295100

  Modified files:
    rpm                     CHANGES
    rpm/scripts             rubygems.rb

  Log:
    rubygems.rb: add/provide ruby(abi) dependencies for non-gems. (not my
    proudest work.. ;)

  Summary:
    Revision    Changes     Path
    1.3592      +1  -0      rpm/CHANGES
    1.8         +45 -12     rpm/scripts/rubygems.rb
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3591 -r1.3592 CHANGES
  --- rpm/CHANGES       1 Apr 2011 05:08:11 -0000       1.3591
  +++ rpm/CHANGES       1 Apr 2011 07:29:51 -0000       1.3592
  @@ -1,4 +1,5 @@
   5.4.0 -> 5.4.1:
  +    - proyvind: rubygems.rb: add/provide ruby(abi) dependencies for non-gems.
       - proyvind: rpmfc: add classifiers for gstreamer plugins & dep generator.
       - proyvind: use pythoneggs.py for python deps generated by internal 
generator.
       - proyvind: rpmfc: enable ruby file classifier & internal dep generator.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/scripts/rubygems.rb
  ============================================================================
  $ cvs diff -u -r1.7 -r1.8 rubygems.rb
  --- rpm/scripts/rubygems.rb   13 Mar 2011 20:08:58 -0000      1.7
  +++ rpm/scripts/rubygems.rb   1 Apr 2011 07:29:51 -0000       1.8
  @@ -3,40 +3,74 @@
   # Copyright 2010 Per Øyvind Karlsen <peroyv...@mandriva.org>
   # This program is free software. It may be redistributed and/or modified 
under
   # the terms of the LGPL version 2.1 (or later).
  +#
  +# FIXME: Someone with actual ruby skills should really clean up and sanitize
  +#     this! fugliness obvious...
   #++
   
   require 'optparse'
  -require 'rubygems'
  +require 'rbconfig'
   
   provides = false
   requires = false
   
   opts = OptionParser.new("#{$0} <--provides|--requires>")
   opts.on("-P", "--provides", "Print provides") do |val|
  -    provides = true
  +  provides = true
   end
   opts.on("-R", "--requires", "Print requires") do |val|
  -    requires= true
  +  requires= true
   end
   
   rest = opts.permute(ARGV)
   
   if rest.size != 0 or (!provides and !requires) or (provides and requires)
  -    $stderr.puts "Use either --provides OR --requires"
  -    $stderr.puts opts
  -    exit(1)
  +  $stderr.puts "Use either --provides OR --requires"
  +  $stderr.puts opts
  +  exit(1)
   end
   
  -specpath = "%s/specifications/.*\.gemspec$" % Gem::dir
  +specpatt = Config::CONFIG["rubylibdir"].sub(Config::CONFIG["ruby_version"], 
".*/specifications/.*\.gemspec$")
   gems = []
  -for gemspec in $stdin.readlines
  -  if gemspec.match(specpath)
  -    gems.push(gemspec.chomp)
  +ruby_versioned = false
  +abi_provide = false
  +
  +for path in $stdin.readlines
  +  if path.match(specpatt)
  +    ruby_versioned = true
  +    gems.push(path.chomp)
  +  # this is quite ugly and lame, but the assumption made is that if any files
  +  # found in any of these directories specific to this ruby version, the
  +  # package is dependent on this specific version.
  +  # FIXME: only supports current ruby version
  +  elsif not ruby_versioned
  +    if path.match(Config::CONFIG["rubylibdir"])
  +      ruby_versioned = true
  +      # even more fugly, but we make the assumption that if the package has
  +      # this file, the package is the current ruby version, and should
  +      # therefore provide ruby(abi) = version
  +      if provides and path.match(Config::CONFIG["rubylibdir"] + "/Env.rb")
  +     abi_provide = true
  +      end
  +    elsif path.match(Config::CONFIG["sitelibdir"])
  +      ruby_versioned = true
  +    elsif path.match(Config::CONFIG["vendorlibdir"])
  +      ruby_versioned = true
  +    end
  +  end
  +end
  +
  +if requires or abi_provide
  +  print "ruby(abi)"
  +  if ruby_versioned
  +    print " = %s\n" % Config::CONFIG["ruby_version"]
     end
   end
  +
   if gems.length > 0
  +  require 'rubygems'
  +
     if requires
  -    require 'rbconfig'
   
       module Gem
         class Requirement
  @@ -61,7 +95,6 @@
   
         end
       end
  -    print "ruby(abi) = %s\n" % Config::CONFIG["ruby_version"]
     end
   
     for gem in gems
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to