From cd4b13663635b197f0e4eba054c5effb2e659a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 8 Jan 2013 16:23:30 +0100 Subject: [PATCH] Move rubygems native extension from gems/exts into gems/%{name}. This allows to provide native extensions for alternative implementations. --- operating_system.rb | 22 +++++++++++----------- ruby.spec | 42 +++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/operating_system.rb b/operating_system.rb index b81425f..7b3930e 100644 --- a/operating_system.rb +++ b/operating_system.rb @@ -2,15 +2,14 @@ module Gem class << self ## - # Returns a string representing that part or the directory tree that is - # common to all specified directories. + # Returns full path of previous but one directory of dir in path + # E.g. for '/usr/share/ruby', 'ruby', it returns '/usr' - def common_path(dirs) - paths = dirs.collect {|dir| dir.split(File::SEPARATOR)} - uncommon_idx = paths.transpose.each_with_index.find {|dirnames, idx| dirnames.uniq.length > 1}.last - paths[0][0 ... uncommon_idx].join(File::SEPARATOR) + def previous_but_one_dir_to(path, dir) + split_path = path.split(File::SEPARATOR) + File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2]) end - private :common_path + private :previous_but_one_dir_to ## # Default gems locations allowed on FHS system (/usr, /usr/share). @@ -19,8 +18,8 @@ module Gem def default_locations @default_locations ||= { - :system => common_path([ConfigMap[:vendorlibdir], ConfigMap[:vendorarchdir]]), - :local => common_path([ConfigMap[:sitelibdir], ConfigMap[:sitearchdir]]) + :system => previous_but_one_dir_to(ConfigMap[:vendordir], ConfigMap[:RUBY_INSTALL_NAME]), + :local => previous_but_one_dir_to(ConfigMap[:sitedir], ConfigMap[:RUBY_INSTALL_NAME]) } end @@ -29,11 +28,12 @@ module Gem # platform independent (:gem_dir) and dependent (:ext_dir) files. def default_dirs + @libdir ||= ConfigMap[:sitelibdir] == ConfigMap[:sitearchdir] ? ConfigMap[:datadir] : ConfigMap[:libdir] @default_dirs ||= Hash[default_locations.collect do |destination, path| [destination, { :bin_dir => File.join(path, ConfigMap[:bindir].split(File::SEPARATOR).last), :gem_dir => File.join(path, ConfigMap[:datadir].split(File::SEPARATOR).last, 'gems'), - :ext_dir => File.join(path, ConfigMap[:libdir].split(File::SEPARATOR).last, 'gems') + :ext_dir => File.join(path, @libdir.split(File::SEPARATOR).last, 'gems') }] end] end @@ -64,7 +64,7 @@ module Gem def default_ext_dir_for base_dir dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir} - dirs && File.join(dirs.last[:ext_dir], 'exts') + dirs && File.join(dirs.last[:ext_dir], RbConfig::CONFIG['RUBY_INSTALL_NAME']) end end end diff --git a/ruby.spec b/ruby.spec index 9b67911..699d5b6 100644 --- a/ruby.spec +++ b/ruby.spec @@ -453,7 +453,7 @@ cat >> %{buildroot}%{_sysconfdir}/rpm/macros.rubygems << \EOF # Common gem locations and files. %%gem_instdir %%{gem_dir}/gems/%%{gem_name}-%%{version} -%%gem_extdir %%{_libdir}/gems/exts/%%{gem_name}-%%{version} +%%gem_extdir %%{_libdir}/gems/%{name}/%%{gem_name}-%%{version} %%gem_libdir %%{gem_instdir}/lib %%gem_cache %%{gem_dir}/cache/%%{gem_name}-%%{version}.gem %%gem_spec %%{gem_dir}/specifications/%%{gem_name}-%%{version}.gemspec @@ -468,7 +468,7 @@ cp %{SOURCE1} %{buildroot}%{rubygems_dir}/rubygems/defaults mv %{buildroot}%{ruby_libdir}/gems/2.0.0 %{buildroot}%{gem_dir} # Create folders for gem binary extensions. -mkdir -p %{buildroot}%{gem_extdir}/exts +mkdir -p %{buildroot}%{gem_extdir}/%{name} # Move bundled rubygems to %%gem_dir and %%gem_extdir # make symlinks for io-console and bigdecimal, which are considered to be part of stdlib by other Gems @@ -481,25 +481,25 @@ mv %{buildroot}%{ruby_libdir}/rdoc* %{buildroot}%{gem_dir}/gems/rdoc-%{rdoc_vers mv %{buildroot}%{gem_dir}/specifications/default/rdoc-%{rdoc_version}.gemspec %{buildroot}%{gem_dir}/specifications mkdir -p %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}/lib +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version}/lib mv %{buildroot}%{ruby_libdir}/bigdecimal %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib -mv %{buildroot}%{ruby_libarchdir}/bigdecimal.so %{buildroot}%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}/lib +mv %{buildroot}%{ruby_libarchdir}/bigdecimal.so %{buildroot}%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version}/lib mv %{buildroot}%{gem_dir}/specifications/default/bigdecimal-%{bigdecimal_version}.gemspec %{buildroot}%{gem_dir}/specifications ln -s %{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib/bigdecimal %{buildroot}%{ruby_libdir}/bigdecimal -ln -s %{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}/lib/bigdecimal.so %{buildroot}%{ruby_libarchdir}/bigdecimal.so +ln -s %{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version}/lib/bigdecimal.so %{buildroot}%{ruby_libarchdir}/bigdecimal.so mkdir -p %{buildroot}%{gem_dir}/gems/io-console-%{io_console_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/exts/io-console-%{io_console_version}/lib/io +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/io-console-%{io_console_version}/lib/io mv %{buildroot}%{ruby_libdir}/io %{buildroot}%{gem_dir}/gems/io-console-%{io_console_version}/lib -mv %{buildroot}%{ruby_libarchdir}/io/console.so %{buildroot}%{_libdir}/gems/exts/io-console-%{io_console_version}/lib/io +mv %{buildroot}%{ruby_libarchdir}/io/console.so %{buildroot}%{_libdir}/gems/%{name}/io-console-%{io_console_version}/lib/io mv %{buildroot}%{gem_dir}/specifications/default/io-console-%{io_console_version}.gemspec %{buildroot}%{gem_dir}/specifications ln -s %{gem_dir}/gems/io-console-%{io_console_version}/lib/io %{buildroot}%{ruby_libdir}/io -ln -s %{_libdir}/gems/exts/io-console-%{io_console_version}/lib/io/console.so %{buildroot}%{ruby_libarchdir}/io/console.so +ln -s %{_libdir}/gems/%{name}/io-console-%{io_console_version}/lib/io/console.so %{buildroot}%{ruby_libarchdir}/io/console.so mkdir -p %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/exts/json-%{json_version}/lib +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/json-%{json_version}/lib mv %{buildroot}%{ruby_libdir}/json* %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib -mv %{buildroot}%{ruby_libarchdir}/json/ %{buildroot}%{_libdir}/gems/exts/json-%{json_version}/lib/ +mv %{buildroot}%{ruby_libarchdir}/json/ %{buildroot}%{_libdir}/gems/%{name}/json-%{json_version}/lib/ mv %{buildroot}%{gem_dir}/specifications/default/json-%{json_version}.gemspec %{buildroot}%{gem_dir}/specifications mkdir -p %{buildroot}%{gem_dir}/gems/minitest-%{minitest_version}/lib @@ -507,9 +507,9 @@ mv %{buildroot}%{ruby_libdir}/minitest %{buildroot}%{gem_dir}/gems/minitest-%{mi mv %{buildroot}%{gem_dir}/specifications/default/minitest-%{minitest_version}.gemspec %{buildroot}%{gem_dir}/specifications mkdir -p %{buildroot}%{gem_dir}/gems/psych-%{psych_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/exts/psych-%{psych_version}/lib +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/psych-%{psych_version}/lib mv %{buildroot}%{ruby_libdir}/psych* %{buildroot}%{gem_dir}/gems/psych-%{psych_version}/lib -mv %{buildroot}%{ruby_libarchdir}/psych.so %{buildroot}%{_libdir}/gems/exts/psych-%{psych_version}/lib/ +mv %{buildroot}%{ruby_libarchdir}/psych.so %{buildroot}%{_libdir}/gems/%{name}/psych-%{psych_version}/lib/ mv %{buildroot}%{gem_dir}/specifications/default/psych-%{psych_version}.gemspec %{buildroot}%{gem_dir}/specifications # Adjust the gemspec files so that the gems will load properly @@ -537,7 +537,7 @@ sed -i '/^end$/ i\ # Install a tapset and fix up the path to the library. mkdir -p %{buildroot}%{tapset_dir} sed -e "s|@LIBRARY_PATH@|%{tapset_libdir}/libruby.so.%{ruby_version}|" \ - %{SOURCE2} > %{buildroot}%{tapset_dir}/libruby.so.%{ruby_version}.stp + %{SOURCE2} > %{buildroot}%{tapset_dir}/libruby.so.%{ruby_version}.stp # Escape '*/' in comment. sed -r "s|( \*.*\*)\/(.*)|\1\\\/\2|" %{buildroot}%{tapset_dir}/libruby.so.%{ruby_version}.stp @@ -753,10 +753,10 @@ make check TESTS="-v $DISABLE_TESTS" %{gem_dir} %exclude %{gem_dir}/gems/* %{_exec_prefix}/lib*/gems -%exclude %{_exec_prefix}/lib*/gems/exts/bigdecimal-%{bigdecimal_version} -%exclude %{_exec_prefix}/lib*/gems/exts/io-console-%{io_console_version} -%exclude %{_exec_prefix}/lib*/gems/exts/json-%{json_version} -%exclude %{_exec_prefix}/lib*/gems/exts/psych-%{psych_version} +%exclude %{_exec_prefix}/lib*/gems/%{name}/bigdecimal-%{bigdecimal_version} +%exclude %{_exec_prefix}/lib*/gems/%{name}/io-console-%{io_console_version} +%exclude %{_exec_prefix}/lib*/gems/%{name}/json-%{json_version} +%exclude %{_exec_prefix}/lib*/gems/%{name}/psych-%{psych_version} %exclude %{gem_dir}/gems/rake-%{rake_version} %exclude %{gem_dir}/gems/rdoc-%{rdoc_version} %exclude %{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec @@ -800,19 +800,19 @@ make check TESTS="-v $DISABLE_TESTS" %files -n rubygem-bigdecimal %{ruby_libdir}/bigdecimal %{ruby_libarchdir}/bigdecimal.so -%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version} +%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version} %{gem_dir}/gems/bigdecimal-%{bigdecimal_version} %{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec %files -n rubygem-io-console %{ruby_libdir}/io %{ruby_libarchdir}/io/console.so -%{_libdir}/gems/exts/io-console-%{io_console_version} +%{_libdir}/gems/%{name}/io-console-%{io_console_version} %{gem_dir}/gems/io-console-%{io_console_version} %{gem_dir}/specifications/io-console-%{io_console_version}.gemspec %files -n rubygem-json -%{_libdir}/gems/exts/json-%{json_version} +%{_libdir}/gems/%{name}/json-%{json_version} %{gem_dir}/gems/json-%{json_version} %{gem_dir}/specifications/json-%{json_version}.gemspec @@ -821,7 +821,7 @@ make check TESTS="-v $DISABLE_TESTS" %{gem_dir}/specifications/minitest-%{minitest_version}.gemspec %files -n rubygem-psych -%{_libdir}/gems/exts/psych-%{psych_version} +%{_libdir}/gems/%{name}/psych-%{psych_version} %{gem_dir}/gems/psych-%{psych_version} %{gem_dir}/specifications/psych-%{psych_version}.gemspec