Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:ruby
rubygem-gem2rpm
suse.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File suse.patch of Package rubygem-gem2rpm
diff --git a/bin/gem2rpm b/bin/gem2rpm index 736a645..a794436 100755 --- a/bin/gem2rpm +++ b/bin/gem2rpm @@ -8,6 +8,7 @@ require 'optparse' require 'fileutils' require 'open-uri' require 'uri' +require 'yaml' opts = OptionParser.new("Usage: #{$0} [OPTIONS] GEM") opts.separator(" Convert ruby Gems to source RPMs and specfiles") @@ -23,6 +24,8 @@ deps = false nongem = false doc_subpackage = true fetch = false +config_file = nil +config = {} opts.separator("") opts.separator(" Options:") @@ -58,6 +61,9 @@ end opts.on("--fetch", "Fetch the gem from rubygems.org") do |val| fetch = true end +opts.on("--config FILE", "Path to gem2rpm.yaml") do |val| + config_file = val +end opts.separator("") opts.separator(" Arguments:") opts.separator(" GEM the path to locally stored gem package file or the name") @@ -67,11 +73,25 @@ opts.separator("") rest = opts.permute(ARGV) template = nil +if template_file.nil? + f = open("/etc/os-release", "r") if File.exist?("/etc/os-release") + if f + f.read.split('\n').each do |line| + line.match(%r{^ID=(.*)$}) { |m| template_file=m[1] } + end + f.close + f = nil + end + if template_file.match? '^"opensuse' + $stderr.puts 'Using template opensuse on openSUSE variant' + template_file = 'opensuse' + end +end if template_file.nil? template = Gem2Rpm::TEMPLATE else begin - f = open(template_file, "r") if File.exists?(template_file) + f = open(template_file, "r") if File.exist?(template_file) f = open(File.join(Gem2Rpm.template_dir, template_file + '.spec.erb'), "r") unless f rescue Errno::ENOENT $stderr.puts "Could not open template #{template_file}. Aborting" @@ -95,7 +115,7 @@ gemfile = rest[0] if fetch gem_uri = '' - open("http://rubygems.org/api/v1/gems/#{gemfile}.json") do |f| + open("https://rubygems.org/api/v1/gems/#{gemfile}.json") do |f| gem_uri = f.read.match(/"gem_uri":\s*"(.*?)",/m)[1] gemfile = URI.parse(gem_uri).path.split('/').last open(gemfile, 'w') do |gf| @@ -117,13 +137,33 @@ if srpm end end +if config_file + begin + config = YAML.load_file(config_file) + config[:sources] ||= [] + config[:sources] << File.basename(config_file) + rescue Exception => ex + $stderr.puts "Failed to load config file '#{config_file}': #{ex}" + exit 1 + end +end + # Produce a specfile +oldlicense = nil if output_file.nil? - Gem2Rpm::convert(gemfile, template, $stdout, nongem, local, doc_subpackage) unless deps + Gem2Rpm::convert(gemfile, template, $stdout, nongem, local, doc_subpackage, oldlicense, config) unless deps else begin + if File.exist?(output_file) + File.open(output_file, 'r') do |oldfile| + oldfile.each_line do |line| + m = line.match(%r{^License:\s*(\w.*)$}) + oldlicense = m[1] if m + end + end + end out = open(output_file, "w") - Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage) + Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage, oldlicense, config) ensure out.close() end diff --git a/gem2rpm.yml.documentation b/gem2rpm.yml.documentation new file mode 100644 index 0000000..2d4adf0 --- /dev/null +++ b/gem2rpm.yml.documentation @@ -0,0 +1,76 @@ +# --- +# ## used by gem2rpm +# :summary: this is a custom summary +# ## used by gem2rpm +# :description: |- +# this is a custom description +# +# it can be multiline +# ## used by gem2rpm +# :license: MIT or Ruby +# :additional_copyrights: +# - 2006-2024 darix was here +# ## used by gem2rpm and gem_packages +# :version_suffix: '-x.y' +# ## used by gem2rpm and gem_packages +# :disable_docs: true +# ## used by gem2rpm +# :disable_automatic_rdoc_dep: true +# ## used by gem2rpm +# :preamble: |- +# BuildRequires: foobar +# Requires: foobar +# ## used by gem2rpm +# :patches: +# foo.patch: -p1 +# bar.patch: +# :post_patch: +# if you need to fiddle with the source dir before rebuilding the gem +# ## used by gem2rpm +# :sources: +# - foo.desktop +# - bar.desktop +# :binary_map: +# annotate: annotate-rb +# :gem_install_args: '....' +# ## used by gem2rpm +# :pre_install: |- +# %if 0%{?use_system_libev} +# export USE_VENDORED_LIBEV="no" +# %endif +# ## used by gem2rpm +# :post_install: |- +# # delete custom files here or do other fancy stuff +# install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse +# ## used by gem2rpm +# :testsuite_command: |- +# (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test) +# ## used by gem2rpm +# :filelist: |- +# /usr/bin/gem2rpm-opensuse +# ## used by gem2rpm +# :scripts: +# :post: |- +# /bin/echo foo +# ## used by gem_packages +# :main: +# :preamble: |- +# Requires: util-linux +# Recommends: pwgen +# :filelist: |- +# /usr/bin/gem2rpm-opensuse +# ## used by gem_packages +# :custom_pkgs: +# apache: +# :preamble: |- +# Requires: ..... +# :filelist: |- +# /etc/apache2/conf.d/passenger.conf +# :summary: Custom summary is optional +# :description: |- +# Custom description is optional +# +# bar +# :post: |- +# /bin/echo foo +# diff --git a/lib/gem2rpm.rb b/lib/gem2rpm.rb index 017ecd1..3db6853 100644 --- a/lib/gem2rpm.rb +++ b/lib/gem2rpm.rb @@ -31,12 +31,15 @@ module Gem2Rpm end def Gem2Rpm.convert(fname, template=TEMPLATE, out=$stdout, - nongem=true, local=false, doc_subpackage = true) + nongem=true, local=false, doc_subpackage = true, oldlicense=nil, config={}) package = Gem2Rpm::Package.new(fname) # Deprecate, kept just for backward compatibility. format = Gem2Rpm::Format.new(package) spec = Gem2Rpm::Specification.new(package.spec) - spec.description ||= spec.summary + if spec.licenses.empty? && oldlicense + spec.licenses = oldlicense.split(' and ') + end + config ||= {} download_path = "" unless local begin @@ -46,8 +49,12 @@ module Gem2Rpm $stderr.puts e.inspect end end - template = ERB.new(template, 0, '-') - out.puts template.result(binding) + erb_instance = if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') + ERB.new(str=template, trim_mode: '-') + else + ERB.new(str=template, safe_mode=0, trim_mode='-') + end + out.puts erb_instance.result(binding) rescue Gem::Exception => e puts e end diff --git a/lib/gem2rpm/specification.rb b/lib/gem2rpm/specification.rb index 9a8d5a1..2e4f7b2 100644 --- a/lib/gem2rpm/specification.rb +++ b/lib/gem2rpm/specification.rb @@ -7,6 +7,9 @@ module Gem2Rpm # A long description of gem wrapped to 78 characters. def description d = super.to_s.chomp + if d.nil? or d.empty? + d=self.__getobj__().summary + end d.gsub!(/([^.])\Z/, "\\1.") Helpers::word_wrap(d, 78) + "\n" end @@ -17,6 +20,17 @@ module Gem2Rpm super.map {|d| Gem2Rpm::Dependency.new d} end + # a short summary trimmed to 70 characters + def summary + text = super + if text.length >= 70 + text = text[0,70].split(/\s/) + text = text[0, text.length-1].join(" ") + end + text = text[0, text.length-1] if text[-1] == '.' + text + end + # List of dependencies that are used for development. def development_dependencies 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..10b1d70 --- /dev/null +++ b/templates/gem_packages.spec.erb @@ -0,0 +1,319 @@ +<% + + begin + require 'rbconfigpackagingsupport' + rescue LoadError => ex + end + def self.patch_mod_full_name(path, mod_full_name) + path.gsub(/\/-/, "/#{mod_full_name}") + end + + def self.patch_libdir(path) + # path ? path.gsub(/\/usr\/lib(64)?/, '%{_libdir}') : path + 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) + rp = gem_spec.extensions_dir.rpartition(gem_spec.base_dir) + return File.join(rp[1], 'doc', rp[2]) + end + return nil + end + + def self.get_mod_weight(spec) + versions=spec.version.to_s.split('.') + begin v1=Integer(versions[0]) rescue v1=1 end + begin v2=Integer(versions[1]) rescue v2=0 end + begin v3=Integer(versions[2]) rescue v3=0 end + weight=v1*10000+v2*100+v3 + end + + def self.map_executable(config, executable) + if not(config[:binary_map].nil? or + config[:binary_map][executable].nil?) + executable=config[:binary_map][executable] + end + executable + end + + def self.filecontent_or_value(path) + (path and File.exists?(path)) ? File.read(path) : path + end + + def self.parse_custom_pkgs(env_value) + custom_pkgs = {} + if env_value + list = env_value.split(/\s+/) + list.each do |element| + pkg_name,filelist_path, preamble, description = element.split(/\|/, 4) + filelist = filecontent_or_value(filelist_path) + preamble = filecontent_or_value(preamble) + description = filecontent_or_value(description) + custom_pkgs[pkg_name] = { + "filelist" => filelist, + "preamble" => preamble, + "description" => description, + } + end + end + 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/, '') + rb_pkgname = RbConfig::CONFIG['ruby_install_name'].gsub(/^ruby\./, '') + if rb_suffix =~ /\A\d+\.\d+\z/ + rb_suffix = '.ruby' + rb_suffix + end + pkg_basename = rb_pkgname + '-rubygem-' + spec.name + + mod_full_name = "#{spec.name}-#{spec.version}" + mod_weight = get_mod_weight(spec) + + gem_platform = Gem::Platform.new(RbConfig::CONFIG["arch"]).to_s + rb_bindir = RbConfig::CONFIG['bindir'] + rb_sysconfdir = RbConfig::CONFIG['sysconfdir'] + docdir = '/usr/share/doc/packages' + gem_spec = Gem::Specification.new + gem_base_dir = patch_libdir(gem_spec.base_dir) + gem_cache_dir = patch_libdir(gem_spec.cache_dir) + gem_build_info_dir = patch_libdir(gem_spec.build_info_dir) + gem_gems_dir = patch_libdir(gem_spec.gems_dir) + gem_spec_dir = patch_libdir(gem_spec.spec_dir) + gem_bin_dir = patch_libdir(patch_mod_full_name(gem_spec.bin_dir , mod_full_name )) + gem_doc_dir = patch_libdir(patch_mod_full_name(gem_spec.doc_dir, mod_full_name )) + gem_gem_dir = patch_libdir(patch_mod_full_name(gem_spec.gem_dir, mod_full_name )) + gem_ri_dir = patch_libdir(patch_mod_full_name(gem_spec.ri_dir, mod_full_name )) + #ruby2.1 + gem_extensions_dir = gem_spec.respond_to?(:extensions_dir) ? patch_libdir(gem_spec.extensions_dir) : nil + 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.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] -%> +<%= 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 %> +<% 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]) -%> +%package -n <%= pkg_basename %>-doc<%= config[:version_suffix] %> +Summary: RDoc documentation for <%= spec.name %> +Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %> + +%description -n <%= pkg_basename %>-doc<%= config[:version_suffix] %> +Documentation generated at gem installation time. +Usually in RDoc and RI formats. + +<% end -%> +<% test_frameworks = Hash.new + docdirfiles = [] + format.file_entries.each do |entry| + # new rubygems version has it different + if entry.kind_of?(Array) + path=entry[0]['path'] + else + path=entry + end + path.gsub!(%r{^\./}, '') + %w(test spec).each { |framework| + test_frameworks[framework] = 1 if path.index(framework + "/") == 0 + } + %w(changes + copying + history + legal + licence + license + license-mit + mit-license + changelog + news + release_notes + readme + ).each { |file| + bpath = path.downcase.gsub(%r{\.rdoc$}, '').gsub(%r{\.txt$}, '').gsub(%r{\.md$}, '').gsub(%r{\.markdown$}, '') + #$stderr.puts "PATH #{path} #{bpath} #{file}" + docdirfiles << path if bpath == file + } + end + + test_frameworks = test_frameworks.keys.sort +-%> +<% unless test_frameworks.empty? -%> +%package -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %> +Summary: Test suite for <%= spec.name %> +Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %> + +%description -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %> +Test::Unit or RSpec files, useful for developers. + +<% end -%> + +<% unless spec.executables.empty? -%> +%post -n <%= pkg_basename %><%= config[:version_suffix] %> +<% spec.executables.each do |executable| -%> +/usr/sbin/update-alternatives --install \ + <%= rb_bindir %>/<%= map_executable(config, executable) %> <%= map_executable(config, executable) %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %> +/usr/sbin/update-alternatives --install \ + <%= rb_bindir %>/<%= "#{executable}-#{spec.version}" %> <%= "#{executable}-#{spec.version}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %> +/usr/sbin/update-alternatives --install \ + <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}" %> <%= "#{executable}#{rb_suffix}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %> +<% end -%> + +%preun -n <%= pkg_basename %><%= config[:version_suffix] %> +if [ "$1" = 0 ] ; then +<% spec.executables.each do |executable| -%> + /usr/sbin/update-alternatives --remove <%= map_executable(config, executable) %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> + /usr/sbin/update-alternatives --remove <%= "#{executable}-#{spec.version}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> + /usr/sbin/update-alternatives --remove <%= "#{executable}#{rb_suffix}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> +<% end -%> +fi +<% end -%> + +%files -n <%= pkg_basename %><%= config[:version_suffix] %> +%defattr(-,root,root,-) +<% if config[:main] && config[:main][:filelist] -%> +# MANUAL +<%= config[:main][:filelist] %> +# /MANUAL +<% end -%> +<% unless docdirfiles.empty? -%> +%doc <%= docdir %>/<%= pkg_basename %><%= config[:version_suffix] %> +<% end -%> +<% spec.executables.each do |executable| -%> +<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> +<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}" %> +<%= rb_bindir %>/<%= "#{executable}-#{spec.version}" %> +<%= rb_bindir %>/<%= map_executable(config, executable) %> +%ghost <%= rb_sysconfdir %>/alternatives/<%= map_executable(config, executable) %> +%ghost <%= rb_sysconfdir %>/alternatives/<%= "#{executable}#{rb_suffix}" %> +%ghost <%= rb_sysconfdir %>/alternatives/<%= "#{executable}-#{spec.version}" %> +<% end -%> +# 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 %> +<% end -%> +<% test_frameworks.each do |framework| -%> +%exclude <%= File.join gem_gem_dir, framework %> +<% end -%> +<%= gem_spec_dir %>/<%= mod_full_name -%>.gemspec + +<% if spec.has_rdoc? && !(config[:disable_docs]) -%> +%files -n <%= pkg_basename %>-doc<%= config[:version_suffix] %> +%defattr(-,root,root,-) +%doc <%= gem_doc_dir %> +<% unless spec.extensions.empty? or gem_extension_doc.nil? -%> +%doc <%= gem_extension_doc %> +<% end -%> +<% end -%> + +<% if config[:include_testsuite] and !test_frameworks.empty? -%> +%files -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %> +%defattr(-,root,root,-) +<% test_frameworks.each do |framework| -%> +<%= File.join gem_gem_dir, framework %> +<% end -%> +<% end -%> +<% + if config[:custom_pkgs_ruby_versioned] + config[:custom_pkgs_ruby_versioned].each do |custom_pkg_name, data| +-%> +%package -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %> +<% if data[:preamble] and data[:preamble] != '' -%> +<%= data[:preamble] %> +<% else %> +Summary: <%= custom_pkg_name %> sub package for <%= spec.name %> +<% end %> +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] %> +<% else %> +<%= spec.description -%> + +This package holds the <%= custom_pkg_name %> sub package for <%= spec.name -%> +<% end %> +%files -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %> +%defattr(-,root,root,-) +<%= data['filelist'] -%> +<% + end + end +-%> diff --git a/templates/opensuse.spec.erb b/templates/opensuse.spec.erb index 37de592..eb7e84c 100644 --- a/templates/opensuse.spec.erb +++ b/templates/opensuse.spec.erb @@ -1,7 +1,12 @@ # -# spec file for package rubygem-<%= spec.name %> (Version <%= spec.version %>) +# spec file for package rubygem-<%= spec.name %><%= config[:version_suffix] %> # -# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) <%= Time.now.year %> SUSE LLC +<% if config[:additional_copyrights] -%> +<% for copyright in config[:additional_copyrights] -%> +# Copyright (c) <%= copyright %> +<% end -%> +<% end -%> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,61 +17,236 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # +<% if config && not(config.empty?) -%> + + +# +# This file was generated with a gem2rpm.yml and not just plain gem2rpm. +# All sections marked as MANUAL, license headers, summaries and descriptions +# can be maintained in that file. Please consult this file before editing any +# of those fields +# +<% end -%> -# norootforbuild -Name: rubygem-<%= spec.name %> +Name: <%= config[:name] ? config[:name] : "rubygem-#{spec.name}#{config[:version_suffix]}" %> Version: <%= spec.version %> Release: 0 %define mod_name <%= spec.name %> -# -Group: Development/Languages/Ruby -License: GPLv2+ or Ruby -# -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: rubygems_with_buildroot_patch -Requires: rubygems >= <%= Gem::RubyGemsVersion %> -<% -# no need to add a requires ruby >= 0 here. will be pulled in via rubygems already - unless spec.required_ruby_version == [''] --%> -Requires: ruby <%= spec.required_ruby_version %> -BuildRequires: ruby-devel <%= spec.required_ruby_version %> +%define mod_full_name %{mod_name}-%{version} +<% if config[:version_suffix] -%> +%define mod_version_suffix <%= config[:version_suffix] %> <% end -%> -<% for d in spec.dependencies -%> +<% if config[:preamble] -%> +# MANUAL +<%= config[:preamble] %> +# /MANUAL +<% end -%> +BuildRequires: ruby-macros >= 5 +<% for req in spec.required_ruby_version -%> +<% unless req.empty? -%> +<% if spec.extensions.empty? -%> +BuildRequires: %{ruby <%= req %>} +<% else -%> +BuildRequires: %{rubydevel <%= req %>} +<% end -%> +<% else -%> +<% if spec.extensions.empty? -%> +BuildRequires: %{ruby} +<% else -%> +BuildRequires: %{rubydevel} +<% end -%> +<% end -%> +<% end -%> +<% for d in spec.runtime_dependencies -%> +<% if ['rdoc'].include? d.name.to_s -%> +# <%= d.name %> <%= d.__getobj__().requirement %> <% for req in d.requirement -%> -BuildRequires: rubygem-<%= d.name %> <%= req %> -Requires: rubygem-<%= d.name %> <%= req %> +BuildRequires: %{rubygem <%= d.name %> <%= req %>} <% end -%> <% end -%> -# -Url: <%= spec.homepage %> -Source: %{mod_name}-%{version}.gem -# -Summary: <%= spec.summary.gsub(/\.$/, "") %> +<% end -%> +BuildRequires: %{rubygem gem2rpm} +<% unless spec.rdoc_options.empty? || config[:disable_automatic_rdoc_dep] -%> +BuildRequires: %{rubygem rdoc > 3.10} +<% end -%> +<% unless spec.executables.empty? -%> +BuildRequires: update-alternatives +<% end -%> +<% unless spec.homepage.nil? || spec.homepage.empty? -%> +URL: <%= spec.homepage %> +<% end -%> +<% if config[:sourceurl] -%> +Source: <%= config[:sourceurl] %> +<% else -%> +Source: https://rubygems.org/gems/%{mod_full_name}.gem +<% end -%> +<% if config[:sources] + config[:sources].each_with_index do |src, i| -%> +Source<%= i+1 %>: <%= src %> +<% end + end -%> +<% if config[:patches] -%> +# MANUAL +<% config[:patches].each_with_index do |patch,i| -%> +Patch<%= i %>: <%= patch[0] %> +<% end -%> +# /MANUAL +<% end -%> +Summary: <%= config[:summary] or spec.summary %> +License: <%= config[:license] or (spec.licenses and spec.licenses.join(" and ")) or 'CHECK(Ruby)' %> + %description -<%= spec.description %> +<%= config[:description] or spec.description -%> + +<% # TODO move into gem2rpm as gem_packages.sh also need this and we only leave it here for getting the docfiles list + test_frameworks = Hash.new + docdirfiles = [] + format.file_entries.each do |entry| + # new rubygems version has it different + if entry.kind_of?(Array) + path=entry[0]['path'] + else + path=entry + end + path.gsub!(%r{^\./}, '') + %w(test spec).each { |framework| + test_frameworks[framework] = 1 if path.index(framework + "/") == 0 + } + %w(changes + copying + history + legal + licence + license + license-mit + mit-license + apache-license-2.0 + license-apache-2.0 + changelog + news + release_notes + readme + ).each { |file| + bpath = path.downcase.gsub(%r{\.rdoc$}, '').gsub(%r{\.txt$}, '').gsub(%r{\.md$}, '').gsub(%r{\.markdown$}, '') + #$stderr.puts "PATH #{path} #{bpath} #{file}" + docdirfiles << path if bpath == file + } + end + test_frameworks = test_frameworks.keys.sort +-%> %prep +<% unless config[:patches].nil? or config[:patches].empty? -%> +%gem_unpack +<% config[:patches].each_with_index do |patch, i| -%> +%patch -P <%= i %> <%= patch[1] if patch[1] %> +<% end -%> +<% if config[:post_patch] -%> +# MANUAL +<%= config[:post_patch] %> +# /MANUAL +<% end -%> +find -type f -print0 | xargs -0 touch -r %{S:0} +%gem_build +<% end -%> + %build + %install -%gem_install %{S:0} -<% unless spec.extensions.empty? %> +<% if config[:pre_install] -%> +# MANUAL +<%= config[:pre_install] %> +# /MANUAL +<% end -%> +%gem_install \ +<% if config[:gem_install_args] -%> +<%= config[:gem_install_args] %> \ +<% end -%> +<% if config[:disable_docs] -%> + --no-rdoc --no-ri \ +<% end -%> +<% unless spec.executables.empty? -%> + --symlink-binaries \ +<% end -%> +<% unless docdirfiles.empty? -%> + --doc-files="<%= docdirfiles.join(' ') %>" \ +<% end -%> + -f +<% unless spec.extensions.empty? -%> %gem_cleanup -<% end %> +<% end -%> +<% if config[:post_install] -%> +# MANUAL +<%= config[:post_install] %> +# /MANUAL + +<% end -%> -%clean -%{__rm} -rf %{buildroot} +<% if config[:testsuite_command] -%> +# MANUAL +%check +<%= config[:testsuite_command] %> +#/ MANUAL +<% end -%> +<% if config[:filelist] -%> %files %defattr(-,root,root,-) -<% spec.executables.each do |executable| %> -%{_bindir}/<%= executable %> +<%= config[:filelist] %> + +<% end -%> +<% if config[:scripts] + if config[:scripts].is_a? Hash + config[:scripts].each do |section, content| -%> +%<%= section %> +<%= content %> + +<% end + else -%> +<%= config[:scripts] %> + +<% end + end +-%> +<% if config[:custom_pkgs] + config[:custom_pkgs].each do |custom_pkg_name, data| +-%> +%package <%= custom_pkg_name %><%= config[:version_suffix] %> +<% if data[:preamble] and data[:preamble] != '' -%> +<%= data[:preamble] %> +<% else %> +Summary: <%= custom_pkg_name %> sub package for <%= spec.name %> +Group: Development/Languages/Ruby +<% end %> +# Requires: rubygem-<%= spec.name %><%= config[:version_suffix] %> = <%= spec.version %> +%description <%= custom_pkg_name %><%= config[:version_suffix] %> +<% if data[:description] and data[:description] != '' -%> +<%= data[:description] %> +<% else %> +<%= spec.description -%> + +This package holds the <%= custom_pkg_name %> sub package for <%= spec.name -%> <% end %> -%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_name}-%{version}.gem -%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_name}-%{version}/ -%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_name}-%{version}.gemspec -%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_name}-%{version}/ +%files <%= custom_pkg_name %><%= config[:version_suffix] %> +%defattr(-,root,root,-) +<%= data[:filelist] %> + +<% if data[:scripts] + if data[:scripts].is_a? Hash + data[:scripts].each do |section, content| -%> +%<%=section %> <%=custom_pkg_name %> +<%= content %> + +<% end + end + end +-%> + +<% end + end +-%> +%gem_packages %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor