From 025213f0270fce3112e9227f7a0de176d79635eb1a107c1a6518496038a3918c Mon Sep 17 00:00:00 2001 From: Marcus Rueckert Date: Tue, 8 Oct 2024 00:30:04 +0000 Subject: [PATCH] - 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 --- rubygem-gem2rpm.changes | 5 +++ suse.patch | 97 ++++++++++++++++++++++++++++++++--------- 2 files changed, 81 insertions(+), 21 deletions(-) diff --git a/rubygem-gem2rpm.changes b/rubygem-gem2rpm.changes index e1e092b..8b1ac7b 100644 --- a/rubygem-gem2rpm.changes +++ b/rubygem-gem2rpm.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Oct 8 00:26:29 UTC 2024 - Marcus Rueckert + +- update suse.patch and sync in ruby-common/gem_packages.spec.erb + ------------------------------------------------------------------- Mon Oct 7 23:08:35 UTC 2024 - Marcus Rueckert diff --git a/suse.patch b/suse.patch index c60c27b..3957761 100644 --- a/suse.patch +++ b/suse.patch @@ -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 = /(?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 = /^(?\s*\S+\s*:\s+rubygem\()(?[^\)]+)(?\).*)?$/.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] %>