- update gem_packages.spec.erb by syncing with gem2rpm

- drop group tag
  - only emit manual comments if we actually put out content
  - mark docs explicitely with the %doc tag
  - stop using deprecated PreReq for update-alternatives

- update suse.patch and sync in ruby-common/gem_packages.spec.erb

OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/rubygem-gem2rpm?expand=0&rev=61
This commit is contained in:
Marcus Rückert 2024-10-08 00:30:04 +00:00 committed by Git OBS Bridge
parent 5cfa1a3148
commit 025213f027
2 changed files with 81 additions and 21 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Oct 8 00:26:29 UTC 2024 - Marcus Rueckert <mrueckert@suse.de>
- update suse.patch and sync in ruby-common/gem_packages.spec.erb
-------------------------------------------------------------------
Mon Oct 7 23:08:35 UTC 2024 - Marcus Rueckert <mrueckert@suse.de>

View File

@ -248,10 +248,10 @@ index 9a8d5a1..2e4f7b2 100644
super.map {|d| Gem2Rpm::Dependency.new d}
diff --git a/templates/gem_packages.spec.erb b/templates/gem_packages.spec.erb
new file mode 100644
index 0000000..74da961
index 0000000..10b1d70
--- /dev/null
+++ b/templates/gem_packages.spec.erb
@@ -0,0 +1,264 @@
@@ -0,0 +1,319 @@
+<%
+
+ begin
@ -267,6 +267,34 @@ index 0000000..74da961
+ path
+ end
+
+
+ def self.rpm_suffix_for_feature(feature)
+ rpm_prefix = nil
+
+ package_name = RbConfig::CONFIG['RUBY_SO_NAME']
+
+ IO.popen("rpm -q --provides #{package_name}") {|rpm_io|
+ rpm_provides = rpm_io.read
+ mo = /(?<rpm_prefix>with(out)?-#{feature})/.match(rpm_provides)
+
+ if mo
+ rpm_prefix = mo[:rpm_prefix]
+ end
+ }
+
+ rpm_prefix
+ end
+
+ def self.requires_for_feature(feature)
+ found_rpm_prefix = rpm_suffix_for_feature(feature)
+
+ if found_rpm_prefix
+ return "Requires: #{RbConfig::CONFIG['RUBY_SO_NAME']}-#{found_rpm_prefix} >= #{RbConfig::CONFIG['RUBY_PROGRAM_VERSION']}"
+ end
+ #
+ return ""
+ end
+
+ def self.get_extension_doc_dir(gem_spec)
+ return nil unless Gem.ruby_engine == 'ruby' && Gem::Requirement.new("~> 2.1.0").satisfied_by?(Gem.ruby_version)
+ if gem_spec.respond_to?(:extensions_dir)
@ -293,7 +321,7 @@ index 0000000..74da961
+ end
+
+ def self.filecontent_or_value(path)
+ (path and File.exist?(path)) ? File.read(path) : path
+ (path and File.exists?(path)) ? File.read(path) : path
+ end
+
+ def self.parse_custom_pkgs(env_value)
@ -315,9 +343,23 @@ index 0000000..74da961
+ custom_pkgs
+ end
+
+ def self.fix_up_rubygem_requires_with_rb_api(rb_api, preamble_text)
+ STDERR.puts(preamble_text)
+ preamble_text.lines.map do |line|
+ if mo = /^(?<pre_text>\s*\S+\s*:\s+rubygem\()(?<pkg_info>[^\)]+)(?<post_text>\).*)?$/.match(line)
+ if not(mo[:pkg_info] =~ /^ruby:\d\.\d\.\d/)
+ line = "#{mo[:pre_text]}#{rb_api}:#{mo[:pkg_info]}#{mo[:post_text]}"
+ end
+ end
+ line
+ end.join("\n")
+ end
+
+ rb_api = "#{RUBY_ENGINE}:#{RbConfig::CONFIG['ruby_version']}"
+
+ rb_pkg_abi = "#{rb_api}:#{spec.name}"
+
+ rb_suffix = RbConfig::CONFIG['ruby_install_name'].gsub(/^ruby/, '')
+ # TODO: "ruby" hardcoded here is wrong. it should support jruby/rubinius or so
+ rb_abi = "ruby:#{RbConfig::CONFIG['ruby_version']}"
+ rb_pkgname = RbConfig::CONFIG['ruby_install_name'].gsub(/^ruby\./, '')
+ if rb_suffix =~ /\A\d+\.\d+\z/
+ rb_suffix = '.ruby' + rb_suffix
@ -346,29 +388,42 @@ index 0000000..74da961
+ gem_extension_dir = gem_spec.respond_to?(:extension_dir) ? patch_libdir(patch_mod_full_name(gem_spec.extension_dir, mod_full_name)) : nil
+ gem_extension_doc = patch_libdir(get_extension_doc_dir(gem_spec))
+ #/ruby2.1
+ gem_plugins_dir = Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.2.0") ? File.join(gem_spec.base_dir, 'plugins') : nil
+ gem_plugins_dir = Gem.respond_to?(:plugindir) ? Gem.plugindir : nil
+ has_plugins = gem_plugins_dir && not( spec.files.select {|filename| filename =~ /rubygems_plugin#{Gem.suffix_regexp}\z/ }.empty? )
+ if config[:disable_docs].nil?
+ config[:disable_docs] ||= true
+ end
+ if config[:include_testsuite].nil?
+ config[:include_testsuite] ||= false
+ end
+%>
+%package -n <%= pkg_basename %><%= config[:version_suffix] %>
+# MANUAL
+<% if config[:main] && config[:main][:preamble] -%>
+<%= config[:main][:preamble] %>
+<%= fix_up_rubygem_requires_with_rb_api(rb_api, config[:main][:preamble]) %>
+<% end -%>
+# /MANUAL
+<% unless spec.extensions.empty? -%>
+<%= requires_for_feature('jemalloc') %>
+<%= requires_for_feature('yjit') %>
+<% end -%>
+Summary: <%= config[:summary] or spec.summary %>
+Group: Development/Languages/Ruby
+<% unless spec.executables.empty? -%>
+Requires(preun): update-alternatives
+Requires(post): update-alternatives
+<% end -%>
+<% if has_plugins -%>
+Conflicts: rubygem(<%= rb_pkg_abi %>)
+<% end -%>
+Enhances: <%= rb_pkgname %>
+
+%description -n <%= pkg_basename %><%= config[:version_suffix] %>
+<%= config[:description] or spec.description -%>
+
+<% if spec.has_rdoc && !(config[:disable_docs]) -%>
+<% if spec.has_rdoc? && !(config[:disable_docs]) -%>
+%package -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
+Summary: RDoc documentation for <%= spec.name %>
+Group: Development/Languages/Ruby
+Requires: rubygem(<%= rb_abi %>:<%= spec.name %>) = <%= spec.version %>
+Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
+
+%description -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
+Documentation generated at gem installation time.
@ -412,8 +467,7 @@ index 0000000..74da961
+<% unless test_frameworks.empty? -%>
+%package -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
+Summary: Test suite for <%= spec.name %>
+Group: Development/Languages/Ruby
+Requires: rubygem(<%= rb_abi %>:<%= spec.name %>) = <%= spec.version %>
+Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
+
+%description -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
+Test::Unit or RSpec files, useful for developers.
@ -443,13 +497,13 @@ index 0000000..74da961
+
+%files -n <%= pkg_basename %><%= config[:version_suffix] %>
+%defattr(-,root,root,-)
+# MANUAL
+<% if config[:main] && config[:main][:filelist] -%>
+<%= config[:main][:filelist] -%>
+<% end -%>
+# MANUAL
+<%= config[:main][:filelist] %>
+# /MANUAL
+<% end -%>
+<% unless docdirfiles.empty? -%>
+<%= docdir %>/<%= pkg_basename %><%= config[:version_suffix] %>
+%doc <%= docdir %>/<%= pkg_basename %><%= config[:version_suffix] %>
+<% end -%>
+<% spec.executables.each do |executable| -%>
+<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
@ -463,7 +517,9 @@ index 0000000..74da961
+# cache file
+<%= gem_cache_dir %>/<%= mod_full_name %>.gem
+<%= gem_gem_dir %>
+<% if has_plugins -%>
+<%= gem_plugins_dir %>
+<% end -%>
+<%= gem_build_info_dir %>
+<% unless spec.extensions.empty? or gem_extension_dir.nil? -%>
+<%= gem_extension_dir %>
@ -473,7 +529,7 @@ index 0000000..74da961
+<% end -%>
+<%= gem_spec_dir %>/<%= mod_full_name -%>.gemspec
+
+<% if spec.has_rdoc && !(config[:disable_docs]) -%>
+<% if spec.has_rdoc? && !(config[:disable_docs]) -%>
+%files -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
+%defattr(-,root,root,-)
+%doc <%= gem_doc_dir %>
@ -482,7 +538,7 @@ index 0000000..74da961
+<% end -%>
+<% end -%>
+
+<% unless test_frameworks.empty? -%>
+<% if config[:include_testsuite] and !test_frameworks.empty? -%>
+%files -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
+%defattr(-,root,root,-)
+<% test_frameworks.each do |framework| -%>
@ -498,9 +554,8 @@ index 0000000..74da961
+<%= data[:preamble] %>
+<% else %>
+Summary: <%= custom_pkg_name %> sub package for <%= spec.name %>
+Group: Development/Languages/Ruby
+<% end %>
+Requires: rubygem(<%= rb_abi %>:<%= spec.name %>) = <%= spec.version %>
+Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
+%description -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %>
+<% if data[:description] and data[:description] != '' -%>
+<%= data[:description] %>