Accepting request 574040 from devel:languages:ruby

OBS-URL: https://build.opensuse.org/request/show/574040
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ruby-common?expand=0&rev=12
This commit is contained in:
Dominique Leuenberger 2018-02-12 09:08:32 +00:00 committed by Git OBS Bridge
commit 8e47fe5b94
4 changed files with 43 additions and 9 deletions

View File

@ -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

View File

@ -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

3
rubygems_bundled.attr Normal file
View File

@ -0,0 +1,3 @@
%__rubygems_bundled_provides %{_rpmconfigdir}/rubygemsdeps.rb --provides --bundled
%__rubygems_bundled_path .*/vendor/bundle/.*/specifications/.*\.gemspec$

View File

@ -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