From fdf7e5ceb4c165babfb7486fe6640faa21ab5e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20R=C3=BCckert?= Date: Wed, 6 Jun 2018 16:15:39 +0200 Subject: [PATCH 28/32] add binary_map support --- gem2rpm.yml.documentation | 2 ++ templates/gem_packages.spec.erb | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gem2rpm.yml.documentation b/gem2rpm.yml.documentation index bb4893d..5b9e4e3 100644 --- a/gem2rpm.yml.documentation +++ b/gem2rpm.yml.documentation @@ -28,6 +28,8 @@ # :sources: # - foo.desktop # - bar.desktop +# :binary_map: +# annotate: annotate-rb # :gem_install_args: '....' # ## used by gem2rpm # :pre_install: |- diff --git a/templates/gem_packages.spec.erb b/templates/gem_packages.spec.erb index 6add6a7..4861bbd 100644 --- a/templates/gem_packages.spec.erb +++ b/templates/gem_packages.spec.erb @@ -30,6 +30,13 @@ weight=v1*10000+v2*100+v3 end + def self.map_executable(config, executable) + if not(config[:binary_map].nil? and 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 @@ -93,6 +100,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 -%> @@ -157,19 +165,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 -%> @@ -188,8 +196,8 @@ 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 -%> -- 2.20.1