]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rubygems.rb
- cleanup upgrade path from rpm5
[packages/rpm.git] / rubygems.rb
index f048488a810702d513db5725f82812ac5467b501..a3f63aaf3f112b303544b22ba2ec3984078d1b01 100755 (executable)
@@ -30,10 +30,14 @@ if rest.size != 0 or (!provides and !requires) or (provides and requires)
   exit(1)
 end
 
-specpatt = RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], ".*/specifications/.*\.gemspec$")
+require 'rubygems'
+gem_dir = Gem.respond_to?(:default_dirs) ? Gem.default_dirs[:system][:gem_dir] : Gem.path.first
+specpatt = "#{gem_dir}/specifications/.*\.gemspec$"
 gems = []
 ruby_versioned = false
 abi_provide = false
+# as ruby_version may be empty, take version from basename of archdir
+ruby_version = RbConfig::CONFIG["ruby_version"].empty? ? File.basename(RbConfig::CONFIG["archdir"]) : RbConfig::CONFIG["ruby_version"]
 
 for path in $stdin.readlines
   # way fugly, but we make the assumption that if the package has
@@ -43,7 +47,6 @@ for path in $stdin.readlines
      abi_provide = true
      ruby_versioned = true
   elsif 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
@@ -55,11 +58,11 @@ for path in $stdin.readlines
     elsif path.match(RbConfig::CONFIG["archdir"])
       ruby_versioned = true
     elsif path.match(RbConfig::CONFIG["sitelibdir"])
-      ruby_versioned = true
+      ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty?
     elsif path.match(RbConfig::CONFIG["sitearchdir"])
       ruby_versioned = true
     elsif path.match(RbConfig::CONFIG["vendorlibdir"])
-      ruby_versioned = true
+      ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty?
     elsif path.match(RbConfig::CONFIG["vendorarchdir"])
       ruby_versioned = true
     end
@@ -69,7 +72,7 @@ end
 if requires or abi_provide
   abidep = "ruby(abi)"
   if ruby_versioned
-    abidep += " = %s" % RbConfig::CONFIG["ruby_version"]
+    abidep += " = %s" % ruby_version
   end
   print abidep + "\n"
 end
@@ -90,7 +93,10 @@ if gems.length > 0
               pessimistic = "rubygem(%s) < %s\n" % [name, Gem::Version.create(version[3..-1]).bump]
               version = version.gsub(/\~>/, '=>')
             end
-            version = version.gsub(/^/, ' ')
+            if version[0..1] == "!="
+              version = version.gsub(/\!=/, '>')
+            end
+            version = version.sub(/^/, ' ')
           end
           version = "rubygem(%s)%s\n%s" % [name, version, pessimistic]
         end
This page took 0.028161 seconds and 4 git commands to generate.