From 329ba54c7ec5c5332f861d582fa6534db98c16d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 3 Feb 2015 13:33:29 +0100 Subject: [PATCH] Make operating_system.rb more robust. This avoids issues with incomplete rbconfig.rb such as: https://bugs.ruby-lang.org/issues/10822 --- operating_system.rb | 24 +++++++++++++++++------- ruby.spec | 5 ++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/operating_system.rb b/operating_system.rb index 3a21b0b..29f223e 100644 --- a/operating_system.rb +++ b/operating_system.rb @@ -6,6 +6,8 @@ module Gem # E.g. for '/usr/share/ruby', 'ruby', it returns '/usr' def previous_but_one_dir_to(path, dir) + return unless path + split_path = path.split(File::SEPARATOR) File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2]) end @@ -44,13 +46,21 @@ module Gem RbConfig::CONFIG['libdir'] end - @default_dirs ||= Hash[default_locations.collect do |destination, path| - [destination, { - :bin_dir => File.join(path, RbConfig::CONFIG['bindir'].split(File::SEPARATOR).last), - :gem_dir => File.join(path, RbConfig::CONFIG['datadir'].split(File::SEPARATOR).last, 'gems'), - :ext_dir => File.join(path, @libdir.split(File::SEPARATOR).last, 'gems') - }] - end] + @default_dirs ||= Hash.new do |hash, key| + hash[key] = if path = default_locations[key] + { + :bin_dir => File.join(path, RbConfig::CONFIG['bindir'].split(File::SEPARATOR).last), + :gem_dir => File.join(path, RbConfig::CONFIG['datadir'].split(File::SEPARATOR).last, 'gems'), + :ext_dir => File.join(path, @libdir.split(File::SEPARATOR).last, 'gems') + } + else + { + :bin_dir => '', + :gem_dir => '', + :ext_dir => '' + } + end + end end ## diff --git a/ruby.spec b/ruby.spec index 2783914..371d645 100644 --- a/ruby.spec +++ b/ruby.spec @@ -21,7 +21,7 @@ %endif -%global release 4 +%global release 5 %{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} %global rubygems_version 2.4.5 @@ -881,6 +881,9 @@ make check TESTS="-v $DISABLE_TESTS" %{ruby_libdir}/tkextlib %changelog +* Tue Feb 03 2015 Vít Ondruch - 2.2.0-5 +- Make operating_system.rb more robust. + * Thu Jan 29 2015 Vít Ondruch - 2.2.0-4 - Add missing rubygem-test-unit dependency on rubygem-power_assert.