Accepting request 620969 from devel:languages:ruby

Automatic submission by obs-autosubmit

OBS-URL: https://build.opensuse.org/request/show/620969
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ruby-common?expand=0&rev=13
This commit is contained in:
Dominique Leuenberger 2018-07-13 08:13:27 +00:00 committed by Git OBS Bridge
commit 46bd6f10d7
4 changed files with 57 additions and 17 deletions

View File

@ -22,6 +22,7 @@ require 'tempfile'
require 'logger'
require 'rubygems'
require 'rubygems/package'
require 'yaml'
begin
require 'rubygems/format'
rescue LoadError => ex
@ -48,6 +49,7 @@ options.symlinkbinaries=false
options.verbose = false
options.rpmsourcedir = ENV['RPM_SOURCE_DIR'] || '/home/abuild/rpmbuild/SOURCES'
options.rpmbuildroot = ENV['RPM_BUILD_ROOT'] || '/home/abuild/rpmbuild/BUILDROOT/just-testing'
options.parsed_config = nil
GILogger = Logger.new(STDERR)
GILogger.level=Logger::DEBUG
@ -75,6 +77,20 @@ def patchfile(fname, needle, replace)
end
end
def map_executable(options, executable)
if not(options.parsed_config.nil? or
options.parsed_config[:binary_map].nil? or
options.parsed_config[:binary_map][executable].nil?)
executable=options.parsed_config[:binary_map][executable]
end
executable
end
def initialized_gem2rpm_config(options, name)
options.config = name
options.parsed_config = YAML.load_file(name)
end
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: gem_install.rb [options]"
@ -82,7 +98,7 @@ opt_parser = OptionParser.new do |opts|
opts.separator "Specific options:"
opts.on('--config [FILENAME]', 'path to gem2rpm.yml') do |name|
options.config = name
initialized_gem2rpm_config(options, name)
end
opts.on('--default-gem [FILENAME]', 'Which filename to use when we dont find another gem file.') do |fname|
@ -152,6 +168,13 @@ if options.gemfile.nil?
GILogger.info "Found gem #{options.gemfile}"
end
if options.config.nil?
name = File.join(options.rpmsourcedir, 'gem2rpm.yml')
if File.exist?(name)
initialized_gem2rpm_config(options, name)
end
end
package = Gem::Package.new(options.gemfile) rescue Gem::Format.from_file_by_path(options.gemfile)
spec = package.spec
gemdir = File.join(Gem.dir, 'gems', "#{options.gemname}-#{options.gemversion}")
@ -212,6 +235,7 @@ if options.symlinkbinaries && File.exists?(bindir)
full_versioned = "#{unversioned}#{options.rubysuffix}-#{spec.version}"
ruby_versioned = "#{unversioned}#{options.rubysuffix}"
gem_versioned = "#{unversioned}-#{spec.version}"
unversioned = map_executable(options, unversioned)
File.rename(default_path, full_versioned)
patchfile(full_versioned, />= 0(\.a)?/, "= #{options.gemversion}")
# unversioned

View File

@ -30,6 +30,14 @@
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
@ -54,8 +62,6 @@
end
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
@ -72,7 +78,6 @@
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 ))
@ -96,6 +101,7 @@ Group: Development/Languages/Ruby
<% unless spec.executables.empty? -%>
PreReq: update-alternatives
<% end -%>
Enhances: <%= rb_pkgname %>
%description -n <%= pkg_basename %><%= config[:version_suffix] %>
<%= config[:description] or spec.description -%>
@ -104,7 +110,7 @@ PreReq: update-alternatives
%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.
@ -149,7 +155,7 @@ Usually in RDoc and RI formats.
%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.
@ -160,19 +166,19 @@ Test::Unit or RSpec files, useful for developers.
%post -n <%= pkg_basename %><%= config[:version_suffix] %>
<% spec.executables.each do |executable| -%>
/usr/sbin/update-alternatives --install \
<%= rb_bindir %>/<%= executable %> <%= executable %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %>
<%= 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 %>
<%= 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 %>
<%= 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 <%= 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}" %>
/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 -%>
@ -191,15 +197,14 @@ fi
<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}" %>
<%= rb_bindir %>/<%= "#{executable}-#{spec.version}" %>
<%= rb_bindir %>/<%= executable %>
%ghost <%= rb_sysconfdir %>/alternatives/<%= executable %>
<%= 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 %>
<%= gem_build_info_dir %>
<% unless spec.extensions.empty? or gem_extension_dir.nil? -%>
<%= gem_extension_dir %>
<% end -%>
@ -235,7 +240,7 @@ fi
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] %>

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Jun 6 15:11:27 UTC 2018 - mrueckert@suse.de
- rename the gem_packages template from opensuse.spec.erb to
gem_packages.spec.erb
- add support for binary_map flag in gem2rpm.yml
- This can be used to rename the _unversioned_ symlink of the
binaries in /usr/bin/ to avoid conflicts with other packages
- gem_packages.spec.erb: sync with file in gem2rpm
-------------------------------------------------------------------
Wed Jan 24 16:13:42 UTC 2018 - lnussel@suse.de

View File

@ -36,7 +36,7 @@ Source7: generate_buildrequires.sh
Source8: ruby-common.macros
Source9: ruby.rpm-macros
Source10: gem_packages.sh
Source11: opensuse.spec.erb
Source11: gem_packages.spec.erb
Source12: ruby-find-versioned
Source13: gemfile.attr
Source14: gemfile.rb