ruby/rubygemsdeps.rb
Stephan Kulow 53dbe04f09 Accepting request 128957 from openSUSE:Tools:Unstable
- map the != operator to > - which might be wrong in 50% of all cases

- require a patched rpm in case rpm does not have magic hooks

- move the option parsing to a shell script that is able to do it
  rightly (rpm macros are just *BAD*)

- make the rubygemdeps a ruby script much more clever about gemspecs

- Another take on %gem_install, the version w/o passing parameters
  seemed to be wrong

- avoid *.gemspec, we get problems if we there are two

- remove too relaxing permissions from unpacked archive

- add a provides for ruby-macros

- Fix %gem_unpack:
  Fetch Gemspec from gem metadata for gems that don't package Gemspecs
  but generate them programatically

OBS-URL: https://build.opensuse.org/request/show/128957
OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby?expand=0&rev=42
2012-07-26 07:25:42 +00:00

67 lines
2.0 KiB
Ruby

#!/usr/bin/ruby
require 'optparse'
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
rest = opts.permute(ARGV)
unless provides || requires
exit(0)
end
gemspecs=Array.new
$stdin.each_line do |line|
line.match(%r{.*/specifications/.*\.gemspec$}) do |m|
gemspecs << [m[0], Gem::Specification.load(m[0])]
end
end
gemspecs.each do |file, spec|
rubyabi=nil
file.match(%r{.*/gems/([^/]*)/.*}) do |m|
rubyabi=m[1]
end
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}"
puts "rubygem(#{rubyabi}:#{spec.name}) = #{spec.version}" if rubyabi
end
if requires
puts "ruby(abi) = #{rubyabi}" if rubyabi
spec.runtime_dependencies.each do |dep|
dep.requirement.requirements.each do |r|
if r.first == '~>'
next_version = Gem::Version.create(r.last).bump
puts "rubygem(#{rubyabi}:#{dep.name}) >= #{r.last}"
puts "rubygem(#{rubyabi}:#{dep.name}) < #{next_version}"
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