From ea19926d07d5f67163f98418ee2b229b33f04392970d0da4b7ebcb244664d2c1 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 8 Feb 2018 06:32:02 +0000 Subject: [PATCH] Accepting request 569569 from home:lnussel:branches:devel:languages:ruby - generate bundled(rubygem($name)) = $version provides for bundled gems in the vendor directory. OBS-URL: https://build.opensuse.org/request/show/569569 OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby-common?expand=0&rev=97 --- ruby-common.changes | 6 ++++++ ruby-common.spec | 5 ++++- rubygems_bundled.attr | 3 +++ rubygemsdeps.rb | 38 ++++++++++++++++++++++++++++++-------- 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 rubygems_bundled.attr diff --git a/ruby-common.changes b/ruby-common.changes index b08db0e..aed6cab 100644 --- a/ruby-common.changes +++ b/ruby-common.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Jan 24 16:13:42 UTC 2018 - lnussel@suse.de + +- generate bundled(rubygem($name)) = $version provides for bundled + gems in the vendor directory. + ------------------------------------------------------------------- Tue Dec 12 13:30:27 UTC 2017 - mrueckert@suse.de diff --git a/ruby-common.spec b/ruby-common.spec index 56a7726..ec57d35 100644 --- a/ruby-common.spec +++ b/ruby-common.spec @@ -1,7 +1,7 @@ # # spec file for package ruby-common # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -42,6 +42,7 @@ Source13: gemfile.attr Source14: gemfile.rb Source15: rails.macros Source16: g2r +Source17: rubygems_bundled.attr Summary: Collection of scripts and macros for ruby packaging License: MIT Group: Development/Languages/Ruby @@ -100,6 +101,7 @@ install -D -m 0644 %{S:13} %{buildroot}/usr/lib/rpm/fileattrs/gemfile.attr install -D -m 0755 %{S:14} %{buildroot}/usr/lib/rpm/gemfile.rb install -D -m 0644 %{S:15} %{buildroot}/etc/rpm/macros.rails install -D -m 0755 %{S:16} %{buildroot}%{_bindir}/g2r +install -D -m 0644 %{S:17} %{buildroot}/usr/lib/rpm/fileattrs/rubygems_bundled.attr %files %defattr(-,root,root) @@ -109,6 +111,7 @@ install -D -m 0755 %{S:16} %{buildroot}%{_bindir}/g2r %config /etc/rpm/macros.*ruby* %dir /usr/lib/rpm/fileattrs /usr/lib/rpm/fileattrs/rubygems.attr +/usr/lib/rpm/fileattrs/rubygems_bundled.attr /usr/lib/rpm/rubygemsdeps.rb /usr/lib/rpm/gem_install.sh /usr/lib/rpm/gem_build_cleanup.sh diff --git a/rubygems_bundled.attr b/rubygems_bundled.attr new file mode 100644 index 0000000..e20a244 --- /dev/null +++ b/rubygems_bundled.attr @@ -0,0 +1,3 @@ +%__rubygems_bundled_provides %{_rpmconfigdir}/rubygemsdeps.rb --provides --bundled +%__rubygems_bundled_path .*/vendor/bundle/.*/specifications/.*\.gemspec$ + diff --git a/rubygemsdeps.rb b/rubygemsdeps.rb index 8f961af..99ab6d6 100644 --- a/rubygemsdeps.rb +++ b/rubygemsdeps.rb @@ -47,7 +47,12 @@ requires=false opts.on("-R", "--requires", "Output the requires of the package") do |val| requires=true end -file_match=".*/gems/[^/]*/specifications/.*\.gemspec$" +bundled=false +opts.on("-b", "--bundled", "Output provides as bundled ones") do |val| + bundled=true +end + +file_match=nil opts.on("-m", "--file-match REGEX", String, "Override the regex against which the input file names", "matched with the supplied regex") do |val| @@ -65,6 +70,19 @@ unless provides || requires exit(0) end +if file_match.nil? + if bundled + file_match = ".*/vendor/bundle/[^/]*/[^/]*/specifications/.*\.gemspec$" + else + file_match = ".*/gems/[^/]*/specifications/.*\.gemspec$" + end +end + +$rubyapi_re = %r{.*/([^/]*)/gems/([^/]*)/.*} +if bundled + $rubyapi_re = %r{.*/vendor/bundle/([^/]*)/([^/]*)/.*} +end + def fatal(msg) $stderr.puts msg exit 1 @@ -89,7 +107,7 @@ def register_gemspec_from_file(gemspecs, rubyabi, file) end def rubyabi_from_path(path) - m = path.match(%r{.*/([^/]*)/gems/([^/]*)/.*}) + m = path.match($rubyapi_re) # return m ? m[1] : RbConfig::CONFIG["ruby_version"] return { :interpreter => m[1], :version => m[2], :abi => "#{m[1]}:#{m[2]}", :requires => "#{m[1]}(abi) = #{m[2]}" } end @@ -124,12 +142,16 @@ gemspecs.each do |rubyabi_hash, spec| # 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 + if bundled + puts "bundled(rubygem(#{spec.name})) = #{spec.version}" + else + 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 end