aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rwxr-xr-xfind-provides.in6
-rwxr-xr-xfind-requires.in6
-rwxr-xr-xrubygems.rb84
4 files changed, 98 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 4ea55e1..f89860d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,8 @@ pkg_scripts = \
perl.req-from-meta \
php.prov \
php.req \
- pkgconfigdeps.sh
+ pkgconfigdeps.sh \
+ rubygems.rb
pkg_gscripts = \
find-provides \
diff --git a/find-provides.in b/find-provides.in
index 23c9296..90d7d7e 100755
--- a/find-provides.in
+++ b/find-provides.in
@@ -9,6 +9,7 @@ solist=$(echo "$filelist" | egrep -v "^/lib/ld\.so|/usr/lib(64)?/gcj/" | egrep '
xargs file -L 2>/dev/null | grep "ELF.*shared object" | cut -d: -f1)
pythonlist=
tcllist=
+rubygemlist=$(echo "$filelist"| egrep "\.gemspec$")
#
# --- Alpha does not mark 64bit dependencies
@@ -82,6 +83,11 @@ if [ -n "$LIBTOOLDEP" ]; then
fi
#
+# --- Ruby gems
+#[ -x @RPMVENDORDIR@/rubygems.rb -a -n "$rubygemlist" ] &&
+# echo $rubygemlist | tr '[:blank:]' \\n | @RPMVENDORDIR@/rubygems.rb --provides | sort -u
+
+#
# --- .so files.
for i in `echo $filelist | tr '[:blank:]' "\n" | egrep '(/usr(/X11R6)?)?/lib(|64)(/gcc(-lib)?/.+)?/[^/]+\.so$'`; do
objd=`objdump -p ${i} | grep SONAME`
diff --git a/find-requires.in b/find-requires.in
index 9d5e841..dbadb0b 100755
--- a/find-requires.in
+++ b/find-requires.in
@@ -52,6 +52,7 @@ interplist=
perllist=
pythonlist=
tcllist=
+rubygemlist=`echo "$filelist"| egrep "\.gemspec$"`
uniqdeplist=
@@ -234,6 +235,11 @@ if [ -n "$LIBTOOLDEP" ]; then
fi
#
+# --- Ruby gems
+#[ -x @RPMVENDORDIR@/rubygems.rb -a -n "$rubygemlist" ] &&
+# echo $rubygemlist | tr '[:blank:]' \\n | @RPMVENDORDIR@/rubygems.rb --requires | sort -u
+
+#
# --- .so files.
for i in `echo $filelist | tr '[:blank:]' "\n" | egrep "(/usr(/X11R6)?)?/lib(|64)/[^/]+\.so$"`; do
objd=`objdump -p ${i} | grep SONAME`
diff --git a/rubygems.rb b/rubygems.rb
new file mode 100755
index 0000000..51044b3
--- /dev/null
+++ b/rubygems.rb
@@ -0,0 +1,84 @@
+#!/usr/bin/env ruby
+#--
+# Copyright 2010 Per Øyvind Karlsen <peroyvind@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).
+#++
+
+require 'optparse'
+require 'rubygems'
+
+provides = false
+requires = false
+
+opts = OptionParser.new("#{$0} <--provides|--requires>")
+opts.on("-P", "--provides", "Print provides") do |val|
+ provides = true
+end
+opts.on("-R", "--requires", "Print requires") do |val|
+ 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)
+end
+
+specpath = "%s/specifications/.*\.gemspec$" % Gem::dir
+gems = []
+for gemspec in $stdin.readlines
+ if gemspec.match(specpath)
+ gems.push(gemspec.chomp)
+ end
+end
+if gems.length > 0
+ if requires
+ require 'rbconfig'
+
+ module Gem
+ class Requirement
+ def rpm_dependency_transform(name, version)
+ pessimistic = ""
+ if version == "> 0.0.0" or version == ">= 0"
+ version = ""
+ else
+ if version[0..1] == "~>"
+ pessimistic = "rubygem(%s) < %s\n" % [name, Gem::Version.create(version[3..-1]).bump]
+ version = version.gsub(/\~>/, '=>')
+ end
+ version = version.gsub(/^/, ' ')
+ end
+ version = "rubygem(%s)%s\n%s" % [name, version, pessimistic]
+ end
+
+ def to_rpm(name)
+ result = as_list
+ return result.map { |version| rpm_dependency_transform(name, version) }
+ end
+
+ end
+ end
+ # TODO: Should we add a strict dependency on ruby version here?
+ #print "ruby < %s%s\n" % [Config::CONFIG["ruby_version"][0..-2], Config::CONFIG["ruby_version"][-1..-1].to_i + 1]
+ print "ruby >= %s\n" % Config::CONFIG["ruby_version"]
+ end
+
+ for gem in gems
+ data = File.read(gem)
+ spec = eval(data)
+ if provides
+ print "rubygem(%s) = %s\n" % [spec.name, spec.version]
+ end
+ if requires
+ for d in spec.dependencies
+ print d.version_requirements.to_rpm(d.name)
+ end
+ for d in spec.required_rubygems_version.to_rpm("rubygems")
+ print d.gsub(/(rubygem\()|(\))/, "")
+ end
+ end
+ end
+end