SHA256
1
0
forked from pool/ruby
ruby/rubygemsdeps.rb
Klaus Kämpf 9594841e44 Accepting request 220747 from openSUSE:Factory:Staging:H
- readd old macros - for now at least
- generate provides for embedded rubygems
- merged ruby-common
- new package split - only single Ruby version installable
  ruby - binary
  libruby2_1-2_0 - ruby runtime library
  ruby-stdlib - ruby standard library
  ruby-doc - ruby documentation
  ruby-devel - ruby development
- revert the ruby split (ruby - ruby21)
  rename ruby21 to ruby, integrate 'ruby' and 'ruby-common'
- remove part of rubygems1.5 patch that modify mkmf which is
  already fixed upstream
- fix rb_arch in spec: append -gnu
- fix native gem builds: create gem native extensions dir
- initial version for ruby 2.1.0 - changes to Ruby 2.0:
  VM (method cache)
  RGenGC (See ko1’s RubyKaigi presentation and RubyConf 2013 presentation)
  refinements #8481 #8571
  syntax changes
  Rational/Complex Literal #8430
  def’s return value #3753
  Bignum
  use GMP #8796
  String#scrub #8414
  Socket.getifaddrs #8368
  RDoc 4.1.0 and RubyGems 2.2.0
  “literal”.freeze is now optimized #9042
  add Exception#cause #8257
  update libraries like BigDecimal, JSON, NKF, Rake, RubyGems, and RDoc

OBS-URL: https://build.opensuse.org/request/show/220747
OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby?expand=0&rev=70
2014-02-03 20:16:17 +00:00

151 lines
5.2 KiB
Ruby

#!/usr/bin/ruby
# Copyright (c) 2012 Stephan Kulow
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'optparse'
require 'rubygems'
#require 'rubygems/format'
require 'rubygems/specification'
opts = OptionParser.new("Usage: #{$0}")
provides=false
opts.on("-P", "--provides", "Output the provides of the package") do |val|
provides=true
end
requires=false
opts.on("-R", "--requires", "Output the requires of the package") do |val|
requires=true
end
file_match=".*/gems/[^/]*/specifications/.*\.gemspec$"
opts.on("-m", "--file-match REGEX", String,
"Override the regex against which the input file names",
"matched with the supplied regex") do |val|
file_match=val
end
in_file=nil
opts.on("-g", "--gemspec FILE", String,
"Take gemspec from FILE, not filename in STDIN",
"Can be a .gem file or a .gemspec file") do |file|
in_file=file
end
rest = opts.permute(ARGV)
unless provides || requires
exit(0)
end
def fatal(msg)
$stderr.puts msg
exit 1
end
def register_gemspec_from_file(gemspecs, rubyabi, file)
fatal "Couldn't read '#{file}'" unless File.readable? file
case file
when /\.gem$/
gem = Gem::Format.from_file_by_path(file)
fatal "Failed to load gem from '#{file}'" unless gem
spec = gem.spec
when /\.gemspec$/
spec = Gem::Specification.load(file)
fatal "Failed to load gem spec from '#{file}'" unless spec
else
fatal "'#{file}' must be a .gem or .gemspec file"
end
gemspecs << [ rubyabi, spec ]
end
def rubyabi_from_path(path)
m = path.match(%r{.*/gems/([^/]*)/.*})
return m ? m[1] : RbConfig::CONFIG["ruby_version"]
end
gemspecs = Array.new
if in_file
# This mode will not be used during actual rpm builds, but only by
# gem packagers for debugging / diagnostics, so that they can
# predict in advance what the dependencies will look like.
rubyabi = rubyabi_from_path(in_file) || '$RUBYABI'
register_gemspec_from_file(gemspecs, rubyabi, in_file)
else
$stdin.each_line do |line|
line.chomp!
m = line.match(%r{#{file_match}$})
if m
register_gemspec_from_file(gemspecs, rubyabi_from_path(line), line)
end
end
end
gemspecs.each do |rubyabi, spec|
if provides
# old forms
puts "rubygem-#{spec.name} = #{spec.version}"
versions = spec.version.to_s.split('.')
puts "rubygem-#{spec.name}-#{versions[0]} = #{spec.version}" if versions.length > 0
puts "rubygem-#{spec.name}-#{versions[0]}_#{versions[1]} = #{spec.version}" if versions.length > 1
puts "rubygem-#{spec.name}-#{versions[0]}_#{versions[1]}_#{versions[2]} = #{spec.version}" if versions.length > 2
# version without ruby version - asking for trouble
puts "rubygem(#{spec.name}) = #{spec.version}"
if rubyabi
puts "rubygem(#{rubyabi}:#{spec.name}) = #{spec.version}"
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}) = #{spec.version}" if versions.length > 0
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}.#{versions[1]}) = #{spec.version}" if versions.length > 1
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}.#{versions[1]}.#{versions[2]}) = #{spec.version}" if versions.length > 2
end
end
if requires
puts "ruby(abi) = #{rubyabi}" if rubyabi
puts "rubygems" if rubyabi.to_f < 1.9
spec.runtime_dependencies.each do |dep|
dep.requirement.requirements.each do |r|
if r.first == '~>'
minversion = r.last.to_s.split('.')
versions = minversion[0,minversion.length-1]
# ~> 2 is pretty nonsense, so avoid being tricked
if versions.length > 0
if minversion[minversion.length-1] == '0'
# ~> 1.2.0 is the same as >= 1.2 for rpm and it avoids problems when 1.2 is followed by 1.2.1
minversion = versions
end
puts "rubygem(#{rubyabi}:#{dep.name}:#{versions.join('.')}) >= #{minversion.join('.')}"
else
puts "rubygem(#{rubyabi}:#{dep.name}) >= #{minversion.join('.')}"
end
elsif r.first == '!='
# this is purely guessing, but we can't generate conflicts here ;(
puts "rubygem(#{rubyabi}:#{dep.name}) > #{r.last}"
#puts "rubygem(#{rubyabi}:#{dep.name}) < #{r.last}"
else
puts "rubygem(#{rubyabi}:#{dep.name}) #{r.first} #{r.last}"
end
end
end
end
end