[packages/rpm] add rubygems.rb as source instead of patching it with 5 patches

glen glen at pld-linux.org
Sun Jun 1 21:14:52 CEST 2014


commit e2489d8e67d1f7067516cd5a20acd59962e76dad
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sat May 31 22:06:51 2014 +0300

    add rubygems.rb as source instead of patching it with 5 patches

 rpm-5.4.5-rubygems-add-missing-newline.patch       |  16 ---
 ...5.4.7-fix-generation-of-ruby-abi-provides.patch |  29 -----
 rpm-5.4.9-ruby1.9-fixes.patch                      |  52 ---------
 rpm.spec                                           |   9 +-
 rubygems.rb                                        | 122 +++++++++++++++++++++
 rubyprov-abi-versioned.patch                       |  12 --
 rubyprov-archdirs.patch                            |  19 ----
 7 files changed, 124 insertions(+), 135 deletions(-)
---
diff --git a/rpm.spec b/rpm.spec
index 635b46a..b8a7b67 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -88,6 +88,7 @@ Source26:	%{name}db_checkversion.c
 Source27:	macros.lang
 Source28:	%{name}db_reset.c
 Source29:	dbupgrade.sh
+Source30:	rubygems.rb
 Patch0:		%{name}-branch.patch
 Patch1:		%{name}-man_pl.patch
 Patch2:		%{name}-popt-aliases.patch
@@ -154,8 +155,6 @@ Patch64:	%{name}-fix-compress-doc.patch
 Patch65:	%{name}-parseSpec-skip-empty-tags.patch
 Patch66:	%{name}-payload-use-hashed-inode.patch
 Patch67:	%{name}-repackage-dont-force-max-compression.patch
-Patch68:	rubyprov-archdirs.patch
-Patch69:	rubyprov-abi-versioned.patch
 Patch70:	python-%{name}sense-missingok.patch
 Patch71:	%{name}-changelog-encoding.patch
 Patch72:	%{name}-preserve-tag-type.patch
@@ -213,8 +212,6 @@ Patch1015:	%{name}-5.4.9-keep-loading-script-macros.patch
 Patch1016:	%{name}-5.4.9-update-rpmfc-when-removing-dependencies-on-self.patch
 # status: idem
 Patch1017:	%{name}-5.4.9-rpmfc-extract-dependencies-for-all-files.patch
-# status: ready for merge
-Patch1018:	%{name}-5.4.5-rubygems-add-missing-newline.patch
 # status: probably okay to merge
 Patch1019:	%{name}-5.4.5-python-export-spec-macros.patch
 # status: idem
@@ -941,7 +938,6 @@ Dokumentacja API RPM-a oraz przewodniki w formacie HTML generowane ze
 %patch1015 -p1
 %patch1016 -p1
 %patch1017 -p1
-%patch1018 -p1
 %patch1019 -p1
 %patch1020 -p1
 %patch1021 -p1
@@ -968,13 +964,12 @@ Dokumentacja API RPM-a oraz przewodniki w formacie HTML generowane ze
 %patch1045 -p1
 %patch1046 -p1
 %patch1047 -p1
-%patch68 -p1
-%patch69 -p1
 
 install %{SOURCE2} macros/pld.in
 install %{SOURCE8} scripts/php.prov.in
 install %{SOURCE9} scripts/php.req.in
 install %{SOURCE11} scripts/perl.prov.in
+cp -p %{SOURCE30} scripts/rubygems.rb
 
 %{__mv} -f scripts/perl.req{,.in}
 
diff --git a/rpm-5.4.5-rubygems-add-missing-newline.patch b/rpm-5.4.5-rubygems-add-missing-newline.patch
deleted file mode 100644
index 706e38a..0000000
--- a/rpm-5.4.5-rubygems-add-missing-newline.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- rpm-5.4.5/scripts/rubygems.rb.rb_newline~	2012-02-29 17:25:34.815069060 +0100
-+++ rpm-5.4.5/scripts/rubygems.rb	2012-02-29 18:45:41.587464927 +0100
-@@ -61,10 +61,11 @@ for path in $stdin.readlines
- end
- 
- if requires or abi_provide
--  print "ruby(abi)"
-+  abidep = "ruby(abi)"
-   if ruby_versioned
--    print " = %s\n" % RbConfig::CONFIG["ruby_version"]
-+    abidep += " = %s" % RbConfig::CONFIG["ruby_version"]
-   end
-+  print abidep + "\n"
- end
- 
- if gems.length > 0
diff --git a/rpm-5.4.7-fix-generation-of-ruby-abi-provides.patch b/rpm-5.4.7-fix-generation-of-ruby-abi-provides.patch
index b75fd38..59b8409 100644
--- a/rpm-5.4.7-fix-generation-of-ruby-abi-provides.patch
+++ b/rpm-5.4.7-fix-generation-of-ruby-abi-provides.patch
@@ -17,32 +17,3 @@
  		}
  		/* XXX: lacking better, more generic classifier... */
  		else if (!strncmp(fn, "/gstreamer", sizeof("/gstreamer")-1) &&
---- rpm-5.4.7/scripts/rubygems.rb.rubyabi_prov~	2012-03-10 21:50:15.637085059 +0100
-+++ rpm-5.4.7/scripts/rubygems.rb	2012-03-10 21:50:23.928092180 +0100
-@@ -36,7 +36,12 @@ ruby_versioned = false
- abi_provide = false
- 
- for path in $stdin.readlines
--  if path.match(specpatt)
-+  # way 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(RbConfig::CONFIG["archdir"] + "/rbconfig.rb")
-+     abi_provide = 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
-@@ -46,12 +51,6 @@ for path in $stdin.readlines
-   elsif not ruby_versioned
-     if path.match(RbConfig::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(RbConfig::CONFIG["rubylibdir"] + "/Env.rb")
--	abi_provide = true
--      end
-     elsif path.match(RbConfig::CONFIG["sitelibdir"])
-       ruby_versioned = true
-     elsif path.match(RbConfig::CONFIG["vendorlibdir"])
diff --git a/rpm-5.4.9-ruby1.9-fixes.patch b/rpm-5.4.9-ruby1.9-fixes.patch
index 2c0ae90..b6e24af 100644
--- a/rpm-5.4.9-ruby1.9-fixes.patch
+++ b/rpm-5.4.9-ruby1.9-fixes.patch
@@ -60,55 +60,3 @@ diff -urN rpm-5.4.9/scripts/gem_helper.rb rpm-5.4.9-patched/scripts/gem_helper.r
  
    require 'rubygems'
    spec = Gem::Specification.from_yaml(YAML.dump(header))
-diff -urN rpm-5.4.9/scripts/rubygems.rb rpm-5.4.9-patched/scripts/rubygems.rb
---- rpm-5.4.9/scripts/rubygems.rb	2011-04-01 18:30:28.000000000 +1100
-+++ rpm-5.4.9-patched/scripts/rubygems.rb	2012-08-30 18:09:09.771009037 +1100
-@@ -30,7 +30,7 @@
-   exit(1)
- end
- 
--specpatt = Config::CONFIG["rubylibdir"].sub(Config::CONFIG["ruby_version"], ".*/specifications/.*\.gemspec$")
-+specpatt = RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], ".*/specifications/.*\.gemspec$")
- gems = []
- ruby_versioned = false
- abi_provide = false
-@@ -44,17 +44,17 @@
-   # package is dependent on this specific version.
-   # FIXME: only supports current ruby version
-   elsif not ruby_versioned
--    if path.match(Config::CONFIG["rubylibdir"])
-+    if path.match(RbConfig::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")
-+      if provides and path.match(RbConfig::CONFIG["rubylibdir"] + "/Env.rb")
- 	abi_provide = true
-       end
--    elsif path.match(Config::CONFIG["sitelibdir"])
-+    elsif path.match(RbConfig::CONFIG["sitelibdir"])
-       ruby_versioned = true
--    elsif path.match(Config::CONFIG["vendorlibdir"])
-+    elsif path.match(RbConfig::CONFIG["vendorlibdir"])
-       ruby_versioned = true
-     end
-   end
-@@ -63,7 +63,7 @@
- if requires or abi_provide
-   print "ruby(abi)"
-   if ruby_versioned
--    print " = %s\n" % Config::CONFIG["ruby_version"]
-+    print " = %s\n" % RbConfig::CONFIG["ruby_version"]
-   end
- end
- 
-@@ -105,7 +105,7 @@
-     end
-     if requires
-       for d in spec.dependencies
--        print d.requirement.to_rpm(d.name) unless d.type != :runtime
-+        print d.requirement.to_rpm(d.name)[0] unless d.type != :runtime
-       end
-       for d in spec.required_rubygems_version.to_rpm("rubygems")
-         print d.gsub(/(rubygem\()|(\))/, "")
diff --git a/rubygems.rb b/rubygems.rb
new file mode 100755
index 0000000..f048488
--- /dev/null
+++ b/rubygems.rb
@@ -0,0 +1,122 @@
+#!/usr/bin/env ruby
+#--
+# Copyright 2010 Per Øyvind Karlsen <peroyvind at 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 'rbconfig'
+
+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
+
+specpatt = RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], ".*/specifications/.*\.gemspec$")
+gems = []
+ruby_versioned = false
+abi_provide = false
+
+for path in $stdin.readlines
+  # way 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(RbConfig::CONFIG["archdir"] + "/rbconfig.rb")
+     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
+  # package is dependent on this specific version.
+  # FIXME: only supports current ruby version
+  elsif not ruby_versioned
+    if path.match(RbConfig::CONFIG["rubylibdir"])
+      ruby_versioned = true
+    elsif path.match(RbConfig::CONFIG["archdir"])
+      ruby_versioned = true
+    elsif path.match(RbConfig::CONFIG["sitelibdir"])
+      ruby_versioned = true
+    elsif path.match(RbConfig::CONFIG["sitearchdir"])
+      ruby_versioned = true
+    elsif path.match(RbConfig::CONFIG["vendorlibdir"])
+      ruby_versioned = true
+    elsif path.match(RbConfig::CONFIG["vendorarchdir"])
+      ruby_versioned = true
+    end
+  end
+end
+
+if requires or abi_provide
+  abidep = "ruby(abi)"
+  if ruby_versioned
+    abidep += " = %s" % RbConfig::CONFIG["ruby_version"]
+  end
+  print abidep + "\n"
+end
+
+if gems.length > 0
+  require 'rubygems'
+
+  if requires
+
+    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
+  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.requirement.to_rpm(d.name)[0] unless d.type != :runtime
+      end
+      for d in spec.required_rubygems_version.to_rpm("rubygems")
+        print d.gsub(/(rubygem\()|(\))/, "")
+      end
+    end
+  end
+end
diff --git a/rubyprov-abi-versioned.patch b/rubyprov-abi-versioned.patch
deleted file mode 100644
index e446f74..0000000
--- a/rubyprov-abi-versioned.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- rpm-5.4.10/scripts/rubygems.rb~	2013-04-26 00:58:58.622064212 +0300
-+++ rpm-5.4.10/scripts/rubygems.rb	2013-04-26 11:42:07.842839682 +0300
-@@ -39,8 +39,9 @@
-   # way 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(RbConfig::CONFIG["archdir"] + "/rbconfig.rb")
-      abi_provide = true
-+     ruby_versioned = true
-   elsif path.match(specpatt)
-     ruby_versioned = true
-     gems.push(path.chomp)
diff --git a/rubyprov-archdirs.patch b/rubyprov-archdirs.patch
deleted file mode 100644
index 1e0036b..0000000
--- a/rubyprov-archdirs.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- rpm-5.4.10/scripts/rubygems.rb~	2013-04-26 00:28:59.955288629 +0300
-+++ rpm-5.4.10/scripts/rubygems.rb	2013-04-26 00:43:35.122569376 +0300
-@@ -51,10 +51,16 @@
-   elsif not ruby_versioned
-     if path.match(RbConfig::CONFIG["rubylibdir"])
-       ruby_versioned = true
-+    elsif path.match(RbConfig::CONFIG["archdir"])
-+      ruby_versioned = true
-     elsif path.match(RbConfig::CONFIG["sitelibdir"])
-       ruby_versioned = true
-+    elsif path.match(RbConfig::CONFIG["sitearchdir"])
-+      ruby_versioned = true
-     elsif path.match(RbConfig::CONFIG["vendorlibdir"])
-       ruby_versioned = true
-+    elsif path.match(RbConfig::CONFIG["vendorarchdir"])
-+      ruby_versioned = true
-     end
-   end
- end
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm.git/commitdiff/73eb048b2f020161bf036d5096c3e7d9b74c62f5



More information about the pld-cvs-commit mailing list