diff --git a/.gitignore b/.gitignore index 4681722..3523d77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -*~ -*.swp -*.rpm -*.xz -*.tgz -*.gem /*/ +/ruby-2.*.tar.bz2 +/ruby-2.*.tar.xz +/*.rpm diff --git a/config.h b/config.h deleted file mode 100644 index b44f715..0000000 --- a/config.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This config.h is a wrapper include file for the original ruby/config.h, - * which has been renamed to ruby/config-.h. There are conflicts for the - * original ruby/config.h on multilib systems, which result from arch-specific - * configuration options. Please do not use the arch-specific file directly. - */ - -/* - * This wrapped is addpated from SDL's one: - * http://pkgs.fedoraproject.org/cgit/SDL.git/tree/SDL_config.h - */ - -#ifdef ruby_config_wrapper_h -#error "ruby_config_wrapper_h should not be defined!" -#endif -#define ruby_config_wrapper_h - -#if defined(__i386__) -#include "ruby/config-i386.h" -#elif defined(__ia64__) -#include "ruby/config-ia64.h" -#elif defined(__powerpc64__) -#include -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#include "ruby/config-ppc64.h" -#else -#include "ruby/config-ppc64le.h" -#endif -#elif defined(__powerpc__) -#include "ruby/config-ppc.h" -#elif defined(__s390x__) -#include "ruby/config-s390x.h" -#elif defined(__s390__) -#include "ruby/config-s390.h" -#elif defined(__x86_64__) -#include "ruby/config-x86_64.h" -#elif defined(__arm__) -#include "ruby/config-arm.h" -#elif defined(__alpha__) -#include "ruby/config-alpha.h" -#elif defined(__sparc__) && defined (__arch64__) -#include "ruby/config-sparc64.h" -#elif defined(__sparc__) -#include "ruby/config-sparc.h" -#elif defined(__aarch64__) -#include "ruby/config-aarch64.h" -#elif defined(__mips64) && defined(__MIPSEL__) -#include "ruby/config-mips64el.h" -#elif defined(__mips64) -#include "ruby/config-mips64.h" -#elif defined(__mips) && defined(__MIPSEL__) -#include "ruby/config-mipsel.h" -#elif defined(__mips) -#include "ruby/config-mips.h" -#elif defined(__riscv64) -#include "ruby/config-riscv64.h" -#else -#error "The ruby-devel package is not usable with the architecture." -#endif - -#undef ruby_config_wrapper_h diff --git a/load.inc b/load.inc deleted file mode 100644 index bf9c07e..0000000 --- a/load.inc +++ /dev/null @@ -1,30 +0,0 @@ -%{lua: - -function source_macros(file) - local macro = nil - - for line in io.lines(file) do - if not macro and line:match("^%%") then - macro = line:match("^%%(.*)$") - line = nil - end - - if macro then - if line and macro:match("^.-%s*\\%s*$") then - macro = macro .. '\n' .. line - end - - if not macro:match("^.-%s*\\%s*$") then - rpm.define(macro) - macro = nil - end - end - end -end - -} - -# Include the constants defined in macros files. Could be dropped as soon as -# RPM supports the %%load macro (RPM 4.12+ probably). -# http://lists.rpm.org/pipermail/rpm-maint/2014-February/003659.html -%define load() %{lua:source_macros(rpm.expand("%1"))} diff --git a/macros.ruby b/macros.ruby index ce3b6e4..36f4077 100644 --- a/macros.ruby +++ b/macros.ruby @@ -1,10 +1,10 @@ -%ruby_libdir %{_datadir}/%{pkg_name} -%ruby_libarchdir %{_libdir}/%{pkg_name} +%ruby_libdir %{_datadir}/%{name} +%ruby_libarchdir %{_libdir}/%{name} # This is the local lib/arch and should not be used for packaging. %ruby_sitedir site_ruby -%ruby_sitelibdir %{_prefix}/local/share/%{pkg_name}/%{ruby_sitedir} -%ruby_sitearchdir %{_prefix}/local/%{_lib}/%{pkg_name}/%{ruby_sitedir} +%ruby_sitelibdir %{_prefix}/local/share/%{name}/%{ruby_sitedir} +%ruby_sitearchdir %{_prefix}/local/%{_lib}/%{name}/%{ruby_sitedir} # This is the general location for libs/archs compatible with all # or most of the Ruby versions available in the Fedora repositories. diff --git a/macros.rubygems b/macros.rubygems index 1550c9c..0652ec6 100644 --- a/macros.rubygems +++ b/macros.rubygems @@ -4,7 +4,7 @@ # Common gem locations and files. %gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}%{?prerelease} -%gem_extdir_mri %{gem_archdir}/ruby/%{gem_name}-%{version}%{?prerelease} +%gem_extdir_mri %{gem_archdir}/%{name}/%{gem_name}-%{version}%{?prerelease} %gem_libdir %{gem_instdir}/lib %gem_cache %{gem_dir}/cache/%{gem_name}-%{version}%{?prerelease}.gem %gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}%{?prerelease}.gemspec diff --git a/operating_system.rb b/operating_system.rb index b1166de..0d4b1f0 100644 --- a/operating_system.rb +++ b/operating_system.rb @@ -38,53 +38,6 @@ module Gem end private :rpmbuild? - ## - # Get enabled SCLs in order of (most) dependent SCL to base SCL - - def x_scls - @x_scls ||= if ENV['X_SCLS'].kind_of?(String) - ENV['X_SCLS'].split(' ').reverse! - else - [] - end - end - private :x_scls - - ## - # Additional default locations for enabled software collections - # Dependent scls needs to add themselves on $GEM_PATH - - def default_locations_added_for_scls - if ENV['GEM_PATH'] - gem_paths = ENV['GEM_PATH'].split(':') - - x_scls.each do |scl| - next if scl == '@SCL@' - - regexp = /#{scl}\/root\/usr\/share\/gems/ - scl_gem_path = gem_paths.grep(regexp)[0] - if scl_gem_path - prefix = scl_gem_path.gsub(/\A(.*)#{regexp}\z/, "\\1") - @default_locations["#{scl}_system".to_sym] = "#{prefix}#{scl}/root/usr" - @default_locations["#{scl}_local".to_sym] = "#{prefix}#{scl}/root/usr/local" - end - end - end - - @default_locations - end - private :default_locations_added_for_scls - - ## - # SCL prefix genereatd from first detected SCL except own SCL. - - def scl_prefix - prefix = x_scls.detect {|c| c != '@SCL@'} - prefix = prefix ? prefix + '_': nil - prefix - end - private :scl_prefix - ## # Default gems locations allowed on FHS system (/usr, /usr/share). # The locations are derived from directories specified during build @@ -95,8 +48,6 @@ module Gem :system => previous_but_one_dir_to(RbConfig::CONFIG['vendordir'], RbConfig::CONFIG['RUBY_INSTALL_NAME']), :local => previous_but_one_dir_to(RbConfig::CONFIG['sitedir'], RbConfig::CONFIG['RUBY_INSTALL_NAME']) } - - default_locations_added_for_scls end ## @@ -162,12 +113,7 @@ module Gem # RubyGems default overrides. def default_dir - prefix = scl_prefix - if Gem.default_dirs.key?(:"#{prefix}system") - Gem.default_dirs[:"#{prefix}system"][:gem_dir] - else - Gem.default_dirs[:"system"][:gem_dir] - end + Gem.default_dirs[:system][:gem_dir] end def default_path @@ -177,10 +123,9 @@ module Gem def default_ext_dir_for base_dir dir = if rpmbuild? - prefix = scl_prefix - build_dir = base_dir.chomp Gem.default_dirs[:"#{prefix}system"][:gem_dir] + build_dir = base_dir.chomp Gem.default_dirs[:system][:gem_dir] if build_dir != base_dir - File.join build_dir, Gem.default_dirs[:"#{prefix}system"][:ext_dir] + File.join build_dir, Gem.default_dirs[:system][:ext_dir] end else dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir} diff --git a/ruby-2.6.0-library-options-to-MAINLIBS.patch b/ruby-2.6.0-library-options-to-MAINLIBS.patch new file mode 100644 index 0000000..7cc644f --- /dev/null +++ b/ruby-2.6.0-library-options-to-MAINLIBS.patch @@ -0,0 +1,177 @@ +From bb3db69e2a0c210cc3a63940622db96a97eb7947 Mon Sep 17 00:00:00 2001 +From: nobu +Date: Fri, 2 Mar 2018 01:37:53 +0000 +Subject: [PATCH] configure.ac: library options to MAINLIBS + +* configure.ac (MAINLIBS): moved library options for main program + and static libruby, and append MAINLIBS to LIBRUBYARG_STATIC, as + these libraries are not needed for linking to shared libruby. + [ruby-core:85882] [Bug #14422] + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + configure.ac | 33 +++++++++++++++------------------ + template/ruby.pc.in | 1 + + win32/Makefile.sub | 6 ++++-- + 3 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/configure.ac b/configure.ac +index aebbae1969a5..733a0c992fd7 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -10,6 +10,7 @@ AC_DISABLE_OPTION_CHECKING + AC_ARG_VAR([cflags], [additional CFLAGS]) + AC_ARG_VAR([cppflags], [additional CPPFLAGS]) + AC_ARG_VAR([cxxflags], [additional CXXFLAGS]) ++ORIG_LIBS=$LIBS + + AC_DEFUN([RUBY_RM_RECURSIVE], [ + m4_version_prereq([2.70], [-1], [ +@@ -2937,13 +2938,11 @@ AS_IF([test x"$enable_pthread" = xyes], [ + AC_DEFINE(_THREAD_SAFE) + AC_DEFINE(HAVE_LIBPTHREAD) + AC_CHECK_HEADERS(pthread_np.h, [], [], [@%:@include ]) +- AS_CASE([$pthread_lib], +- [c], [], +- [root], [], +- [c_r], [MAINLIBS="-pthread $MAINLIBS"], +- [AS_CASE(["$target_os"], +- [openbsd*|mirbsd*], [LIBS="-pthread $LIBS"], +- [LIBS="-l$pthread_lib $LIBS"])]) ++ AS_CASE(["$pthread_lib:$target_os"], ++ [c:*], [], ++ [root:*], [], ++ [c_r:*|*:openbsd*|*:mirbsd*], [LIBS="-pthread $LIBS"], ++ [LIBS="-l$pthread_lib $LIBS"]) + ], [ + AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled") + ]) +@@ -3622,7 +3621,7 @@ LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a' + LIBRUBY='$(LIBRUBY_A)' + LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static' + LIBRUBYARG='$(LIBRUBYARG_STATIC)' +-SOLIBS= ++SOLIBS='$(MAINLIBS)' + + AS_CASE(["$target_os"], + [cygwin*|mingw*|haiku*|darwin*], [ +@@ -3688,9 +3687,6 @@ AS_CASE("$enable_shared", [yes], [ + LIBRUBY_RELATIVE=no + test -z "$CCDLFLAGS" || CFLAGS="$CFLAGS $CCDLFLAGS" + ENABLE_SHARED=yes +- AS_IF([test "$rb_cv_binary_elf" = yes], [ +- SOLIBS='$(LIBS)' +- ]) + + # libdir can be overridden in config.site file (on OpenSUSE at least). + libdir_basename=lib +@@ -3725,7 +3721,6 @@ AS_CASE("$enable_shared", [yes], [ + ]) + ], + [freebsd*|dragonfly*], [ +- SOLIBS='$(LIBS)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)' + LIBRUBY_SONAME='$(LIBRUBY_SO)' + AS_IF([test "$rb_cv_binary_elf" != "yes" ], [ +@@ -3734,7 +3729,6 @@ AS_CASE("$enable_shared", [yes], [ + ]) + ], + [netbsd*], [ +- SOLIBS='$(LIBS)' + LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)' + LIBRUBY_SO="${LIBRUBY_SONAME}"'.$(TEENY)' + RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"]) +@@ -3745,11 +3739,9 @@ AS_CASE("$enable_shared", [yes], [ + ]) + ], + [openbsd*|mirbsd*], [ +- SOLIBS='$(LIBS)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}` + ], + [solaris*], [ +- SOLIBS='$(LIBS)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)' + LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(RUBY_PROGRAM_VERSION)' + LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)' +@@ -3767,7 +3759,7 @@ AS_CASE("$enable_shared", [yes], [ + [aix*], [ + RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-bnoentry" "$XLDFLAGS" "$LDFLAGS_OPTDIR"]) + LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}' +- SOLIBS='-lm -lc' ++ LIBS="$LIBS -lm -lc" + ], + [darwin*], [ + LIBRUBY_LDSHARED='$(CC) -dynamiclib' +@@ -3787,7 +3779,6 @@ AS_CASE("$enable_shared", [yes], [ + LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT)' + LIBRUBY_SONAME='lib$(RUBY_BASE_NAME).$(RUBY_API_VERSION).$(SOEXT)' + LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_INSTALL_NAME).$(SOEXT)' +- SOLIBS='$(LIBS)' + ], + [interix*], [ + LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)' +@@ -4030,7 +4021,6 @@ AS_CASE(["$target_os"], + ]) + LIBRUBY_ALIASES='' + FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in +- SOLIBS='$(LIBS)' + AS_IF([test x"$enable_shared" = xyes], [ + LIBRUBY='lib$(RUBY_SO_NAME).dll.a' + ], [ +@@ -4130,6 +4120,13 @@ AS_IF([test "${universal_binary-no}" = yes ], [ + [rb_cv_architecture_available=yes], [rb_cv_architecture_available=no])) + ]) + ++MAINLIBS="$LIBS" ++LIBS=$ORIG_LIBS ++AS_IF([test -n "${LIBS}"], [ ++ libspat=`echo "${LIBS}" | sed 's/[[][|.*$^]]/\\&/g;s/^ */ /;s/^ *$/ /'` ++ MAINFLAGS=`echo " $MAINLIBS " | sed "s|$libspat"'||;s/^ *//;s/ *$//'` ++]) ++LIBRUBYARG_STATIC="${LIBRUBYARG_STATIC} \$(MAINLIBS)" + CPPFLAGS="$CPPFLAGS "'$(DEFS)' + test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}' + AS_IF([test -n "${cflags+set}"], [ +diff --git a/template/ruby.pc.in b/template/ruby.pc.in +index d874f92c3b20..7ce4461c05df 100644 +--- a/template/ruby.pc.in ++++ b/template/ruby.pc.in +@@ -39,6 +39,7 @@ sitehdrdir=@sitehdrdir@ + rubyarchhdrdir=@rubyarchhdrdir@ + vendorarchhdrdir=@vendorarchhdrdir@ + sitearchhdrdir=@sitearchhdrdir@ ++MAINLIBS=@MAINLIBS@ + SOEXT=@SOEXT@ + LIBPATH=@LIBPATH@ + LIBRUBY_A=@LIBRUBY_A@ +diff --git a/win32/Makefile.sub b/win32/Makefile.sub +index 8673c121641e..f8316cccb68e 100644 +--- a/win32/Makefile.sub ++++ b/win32/Makefile.sub +@@ -279,6 +279,7 @@ MJIT_DEBUGFLAGS = $(DEBUGFLAGS) + CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS) + + DLDFLAGS = $(LDFLAGS) -dll ++MAINLIBS = $(LIBS) + SOLIBS = + RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc + !ifndef RCFLAGS +@@ -821,7 +822,8 @@ s,@CPPFLAGS@,$(CPPFLAGS),;t t + s,@CXXFLAGS@,$(CXXFLAGS),;t t + s,@FFLAGS@,$(FFLAGS),;t t + s,@LDFLAGS@,$(LDFLAGS),;t t +-s,@LIBS@,$(LIBS),;t t ++s,@LIBS@,,;t t ++s,@MAINLIBS@,$(MAINLIBS),;t t + s,@exec_prefix@,$${prefix},;t t + s,@prefix@,$(prefix),;t t + s,@program_transform_name@,s,.*,$(PROGRAM_PREFIX)&$(PROGRAM_SUFFIX),,;t t +@@ -909,7 +911,7 @@ s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t + s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t + s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t + s,@LIBRUBYARG@,$$(LIBRUBYARG_SHARED),;t t +-s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A),;t t ++s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A) $$(MAINLIBS),;t t + s,@LIBRUBYARG_SHARED@,$$(LIBRUBY),;t t + s,@SOLIBS@,$(SOLIBS),;t t + s,@DLDLIBS@,$(DLDLIBS),;t t diff --git a/ruby.spec b/ruby.spec index 70f4934..67eb27c 100644 --- a/ruby.spec +++ b/ruby.spec @@ -1,6 +1,3 @@ -%{!?scl:%global pkg_name %{name}} -%{?scl:%scl_package ruby} - %global major_version 2 %global minor_version 5 %global teeny_version 0 @@ -15,7 +12,7 @@ # Keep the revision enabled for pre-releases from SVN. #%%global revision 61414 -%global ruby_archive %{pkg_name}-%{ruby_version} +%global ruby_archive %{name}-%{ruby_version} # If revision and milestone are removed/commented out, the official release build is expected. %if 0%{?milestone:1}%{?revision:1} != 0 @@ -24,7 +21,7 @@ %endif -%global release 5 +%global release 91 %{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} # The RubyGems library has to stay out of Ruby directory three, since the @@ -32,7 +29,7 @@ %global rubygems_dir %{_datadir}/rubygems # Bundled libraries versions -%global rubygems_version 2.7.3 +%global rubygems_version 2.7.6 %global molinillo_version 0.5.7 # TODO: The IRB has strange versioning. Keep the Ruby's versioning ATM. @@ -68,13 +65,14 @@ %bcond_without systemtap %bcond_without git %bcond_without cmake +%bcond_without gmp %if 0%{?fedora} %bcond_without hardening_test %endif Summary: An interpreter of object-oriented scripting language -Name: %{?scl_prefix}ruby +Name: ruby Version: %{ruby_version} Release: %{release_string} Group: Development/Languages @@ -84,7 +82,7 @@ Group: Development/Languages # UCD: some of enc/trans/**/*.src License: (Ruby or BSD) and Public Domain and MIT and CC0 and zlib and UCD URL: http://ruby-lang.org/ -Source0: ftp://ftp.ruby-lang.org/pub/%{pkg_name}/%{major_minor_version}/%{ruby_archive}.tar.xz +Source0: ftp://ftp.ruby-lang.org/pub/%{name}/%{major_minor_version}/%{ruby_archive}.tar.xz Source1: operating_system.rb # TODO: Try to push SystemTap support upstream. Source2: libruby.stp @@ -92,27 +90,20 @@ Source3: ruby-exercise.stp Source4: macros.ruby Source5: macros.rubygems Source6: abrt_prelude.rb -# This wrapper fixes https://bugzilla.redhat.com/show_bug.cgi?id=977941 -# It was fixed by multilib-rpm-config on Fedora. -# But multilib-rpm-config is not available on RHEL7. -# https://fedorahosted.org/fpc/ticket/312 -# https://bugzilla.redhat.com/show_bug.cgi?id=977941 -Source7: config.h -# We do not provide RPM dependency generators on SCL that is on Fedora. +# RPM dependency generators. +Source8: rubygems.attr +Source9: rubygems.req +Source10: rubygems.prov +Source11: rubygems.con # ABRT hoook test case. -Source12: test_abrt.rb +Source13: test_abrt.rb # SystemTap tests. -Source13: test_systemtap.rb -# To test Ruby software collection -Source14: test_dependent_scls.rb +Source14: test_systemtap.rb -# %%load function should be supported in RPM 4.12+. -# http://lists.rpm.org/pipermail/rpm-maint/2014-February/003659.html -Source100: load.inc -%include %{SOURCE100} - -%{load %{SOURCE4}} -%{load %{SOURCE5}} +# The load directive is supported since RPM 4.12, i.e. F21+. The build process +# fails on older Fedoras. +%{?load:%{SOURCE4}} +%{?load:%{SOURCE5}} # Fix ruby_version abuse. # https://bugs.ruby-lang.org/issues/11002 @@ -154,53 +145,38 @@ Patch12: ruby-2.5.0-Disable-Tokyo-TZ-tests.patch # Fix thread_safe tests suite segfaults. # https://bugs.ruby-lang.org/issues/14357 Patch13: ruby-2.5.0-st.c-retry-operations-if-rebuilt.patch +# Fix: Multiple vulnerabilities in RubyGems +# https://bugzilla.redhat.com/show_bug.cgi?id=1547431 +# https://www.ruby-lang.org/en/news/2018/02/17/multiple-vulnerabilities-in-rubygems/ +Patch14: rubygems-2.5.0-multiple-vulnerabilities.patch +# Don't force libraries used to build Ruby to its dependencies. +# https://bugs.ruby-lang.org/issues/14422 +Patch15: ruby-2.6.0-library-options-to-MAINLIBS.patch + +Requires: %{name}-libs%{?_isa} = %{version}-%{release} +Suggests: rubypick +Recommends: ruby(rubygems) >= %{rubygems_version} +Recommends: rubygem(bigdecimal) >= %{bigdecimal_version} +Recommends: rubygem(did_you_mean) >= %{did_you_mean_version} +Recommends: rubygem(openssl) >= %{openssl_version} -Requires: %{?scl_prefix}%{pkg_name}-libs%{?_isa} = %{version}-%{release} -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -# We keep default installed gems that is sub pacakge as Requires. -# Make the bigdecimal gem a runtime dependency of Ruby to avoid problems -# with user-installed gems, that don't require it in gemspec/Gemfile -# See https://bugzilla.redhat.com/show_bug.cgi?id=829209 -# and http://bugs.ruby-lang.org/issues/6123 -# TODO: other gems required? -Requires: %{?scl_prefix}rubygem(bigdecimal) >= %{bigdecimal_version} -Requires: %{?scl_prefix}rubygem(did_you_mean) >= %{did_you_mean_version} -# Requires: %%{?scl_prefix}rubygem(bundler) >= %%{bundler_version} -# Requires: %%{?scl_prefix}rubygem(cmath) >= %%{cmath_version} -# Requires: %%{?scl_prefix}rubygem(csv) >= %%{csv_version} -# Requires: %%{?scl_prefix}rubygem(date) >= %%{date_version} -# Requires: %%{?scl_prefix}rubygem(dbm) >= %%{dbm_version} -# Requires: %%{?scl_prefix}rubygem(digest) >= %%{digest_version} -# Requires: %%{?scl_prefix}rubygem(etc) >= %%{etc_version} -# Requires: %%{?scl_prefix}rubygem(fcntl) >= %%{fcntl_version} -# Requires: %%{?scl_prefix}rubygem(fileutils) >= %%{fileutils_version} -# Requires: %%{?scl_prefix}rubygem(gdbm) >= %%{gdbm_version} -Requires: %{?scl_prefix}rubygem(io-console) >= %{io_console_version} -# Requires: %%{?scl_prefix}rubygem(ipaddr) >= %%{ipaddr_version} -Requires: %{?scl_prefix}rubygem(json) >= %{json_version} -Requires: %{?scl_prefix}rubygem(openssl) >= %{openssl_version} -Requires: %{?scl_prefix}rubygem(psych) >= %{psych_version} -Requires: %{?scl_prefix}rubygem(rdoc) >= %{rdoc_version} -# Requires: %%{?scl_prefix}rubygem(scanf) >= %%{scanf_version} -# Requires: %%{?scl_prefix}rubygem(sdbm) >= %%{sdbm_version} -# Requires: %%{?scl_prefix}rubygem(stringio) >= %%{stringio_version} -# Requires: %%{?scl_prefix}rubygem(strscan) >= %%{strscan_version} -# Requires: %%{?scl_prefix}rubygem(webrick) >= %%{webrick_version} -# Requires: %%{?scl_prefix}rubygem(zlib) >= %%{zlib_version} BuildRequires: autoconf BuildRequires: gdbm-devel +%{?with_gmp:BuildRequires: gmp-devel} BuildRequires: libffi-devel BuildRequires: openssl-devel BuildRequires: libyaml-devel BuildRequires: readline-devel # Needed to pass test_set_program_name(TestRubyOptions) BuildRequires: procps -%{?with_systemtap:BuildRequires: %{?_root_bindir}%{!?_root_bindir:%{_bindir}}/dtrace} +%{?with_systemtap:BuildRequires: %{_bindir}/dtrace} # RubyGems test suite optional dependencies. -%{?with_git:BuildRequires: %{?_root_bindir}%{!?_root_bindir:%{_bindir}}/git} -%{?with_cmake:BuildRequires: %{?_root_bindir}%{!?_root_bindir:%{_bindir}}/cmake} +%{?with_git:BuildRequires: git} +%{?with_cmake:BuildRequires: %{_bindir}/cmake} # Required to test hardening. -%{?with_hardening_test:BuildRequires: %{?_root_bindir}%{!?_root_bindir:%{_bindir}}/checksec} +%{?with_hardening_test:BuildRequires: %{_bindir}/checksec} +BuildRequires: multilib-rpm-config +BuildRequires: gcc # This package provides %%{_bindir}/ruby-mri therefore it is marked by this # virtual provide. It can be installed as dependency of rubypick. @@ -216,10 +192,10 @@ straight-forward, and extensible. %package devel Summary: A Ruby development environment Group: Development/Languages -Requires: %{?scl_prefix}%{pkg_name}%{?_isa} = %{version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} # This would not be needed if ~50 packages depending on -devel used # --disable-gems -Requires: %{?scl_prefix}rubygems +Requires: rubygems %description devel Header files and libraries for building an extension library for the @@ -229,7 +205,7 @@ Ruby or an application embedding Ruby. Summary: Libraries necessary to run Ruby Group: Development/Libraries License: Ruby or BSD -Provides: %{?scl_prefix}ruby(release) = %{ruby_release} +Provides: ruby(release) = %{ruby_release} # Virtual provides for CCAN copylibs. # https://fedorahosted.org/fpc/ticket/364 @@ -238,59 +214,66 @@ Provides: bundled(ccan-check_type) Provides: bundled(ccan-container_of) Provides: bundled(ccan-list) +# Tcl/Tk support was removed from stdlib in Ruby 2.4, i.e. F27 timeframe +# so lets obsolete it. This is not the best place, but we don't have +# better, unless https://fedorahosted.org/fpc/ticket/645 provides some +# generic solution. +Obsoletes: ruby-tcltk < 2.4.0 + + %description libs This package includes the libruby, necessary to run Ruby. # TODO: Rename or not rename to ruby-rubygems? -%package -n %{?scl_prefix}rubygems +%package -n rubygems Summary: The Ruby standard for packaging ruby libraries Version: %{rubygems_version} Group: Development/Libraries License: Ruby or MIT -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}rubygem(rdoc) >= %{rdoc_version} -Requires: %{?scl_prefix}rubygem(io-console) >= %{io_console_version} -Requires: %{?scl_prefix}rubygem(openssl) >= %{openssl_version} -Requires: %{?scl_prefix}rubygem(psych) >= %{psych_version} -Provides: %{?scl_prefix}gem = %{version}-%{release} -Provides: %{?scl_prefix}ruby(rubygems) = %{version}-%{release} +Requires: ruby(release) +Recommends: rubygem(rdoc) >= %{rdoc_version} +Recommends: rubygem(io-console) >= %{io_console_version} +Requires: rubygem(openssl) >= %{openssl_version} +Requires: rubygem(psych) >= %{psych_version} +Provides: gem = %{version}-%{release} +Provides: ruby(rubygems) = %{version}-%{release} # https://github.com/rubygems/rubygems/pull/1189#issuecomment-121600910 Provides: bundled(rubygem-molinillo) = %{molinillo_version} BuildArch: noarch -%description -n %{?scl_prefix}rubygems +%description -n rubygems RubyGems is the Ruby standard for publishing and managing third party libraries. -%package -n %{?scl_prefix}rubygems-devel +%package -n rubygems-devel Summary: Macros and development tools for packaging RubyGems Version: %{rubygems_version} Group: Development/Libraries License: Ruby or MIT -Requires: %{?scl_prefix}ruby(rubygems) = %{version}-%{release} +Requires: ruby(rubygems) = %{version}-%{release} # Needed for RDoc documentation format generation. -Requires: %{?scl_prefix}rubygem(json) >= %{json_version} -Requires: %{?scl_prefix}rubygem(rdoc) >= %{rdoc_version} +Requires: rubygem(json) >= %{json_version} +Requires: rubygem(rdoc) >= %{rdoc_version} BuildArch: noarch -%description -n %{?scl_prefix}rubygems-devel +%description -n rubygems-devel Macros and development tools for packaging RubyGems. -%package -n %{?scl_prefix}rubygem-rake +%package -n rubygem-rake Summary: Ruby based make-like utility Version: %{rake_version} Group: Development/Libraries License: MIT -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rake = %{version}-%{release} -Provides: %{?scl_prefix}rubygem(rake) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rake = %{version}-%{release} +Provides: rubygem(rake) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-rake +%description -n rubygem-rake Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax. @@ -299,9 +282,9 @@ specified in standard Ruby syntax. Summary: The Interactive Ruby Version: %{irb_version} Group: Development/Libraries -Requires: %{?scl_prefix}%{pkg_name}-libs = %{ruby_version} -Provides: %{?scl_prefix}irb = %{version}-%{release} -Provides: %{?scl_prefix}ruby(irb) = %{version}-%{release} +Requires: %{name}-libs = %{ruby_version} +Provides: irb = %{version}-%{release} +Provides: ruby(irb) = %{version}-%{release} BuildArch: noarch %description irb @@ -309,50 +292,50 @@ The irb is acronym for Interactive Ruby. It evaluates ruby expression from the terminal. -%package -n %{?scl_prefix}rubygem-rdoc +%package -n rubygem-rdoc Summary: A tool to generate HTML and command-line documentation for Ruby projects Version: %{rdoc_version} Group: Development/Libraries # SIL: lib/rdoc/generator/template/darkfish/css/fonts.css License: GPLv2 and Ruby and MIT and OFL -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Requires: %{?scl_prefix}ruby(irb) = %{irb_version} -Requires: %{?scl_prefix}rubygem(io-console) >= %{io_console_version} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Requires: ruby(irb) = %{irb_version} +Requires: rubygem(io-console) >= %{io_console_version} # Hardcode the dependency to keep it compatible with dependencies of the # official rubygem-rdoc gem. -Requires: %{?scl_prefix}rubygem(json) >= %{json_version} -Provides: %{?scl_prefix}rdoc = %{version}-%{release} -Provides: %{?scl_prefix}ri = %{version}-%{release} -Provides: %{?scl_prefix}rubygem(rdoc) = %{version}-%{release} +Requires: rubygem(json) >= %{json_version} +Provides: rdoc = %{version}-%{release} +Provides: ri = %{version}-%{release} +Provides: rubygem(rdoc) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-rdoc +%description -n rubygem-rdoc RDoc produces HTML and command-line documentation for Ruby projects. RDoc includes the 'rdoc' and 'ri' tools for generating and displaying online documentation. %package doc -Summary: Documentation for %{pkg_name} +Summary: Documentation for %{name} Group: Documentation Requires: %{_bindir}/ri BuildArch: noarch %description doc -This package contains documentation for %{pkg_name}. +This package contains documentation for %{name}. -%package -n %{?scl_prefix}rubygem-bigdecimal +%package -n rubygem-bigdecimal Summary: BigDecimal provides arbitrary-precision floating point decimal arithmetic Version: %{bigdecimal_version} Group: Development/Libraries License: Ruby or BSD -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(bigdecimal) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(bigdecimal) = %{version}-%{release} -%description -n %{?scl_prefix}rubygem-bigdecimal +%description -n rubygem-bigdecimal Ruby provides built-in support for arbitrary precision integer arithmetic. For example: @@ -365,62 +348,62 @@ floating point arithmetic often introduces subtle errors because of the conversion between base 10 and base 2. -%package -n %{?scl_prefix}rubygem-did_you_mean +%package -n rubygem-did_you_mean Summary: "Did you mean?" experience in Ruby Version: %{did_you_mean_version} Group: Development/Libraries License: MIT -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(did_you_mean) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(did_you_mean) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-did_you_mean +%description -n rubygem-did_you_mean "did you mean?" experience in Ruby: the error message will tell you the right one when you misspelled something. -%package -n %{?scl_prefix}rubygem-io-console +%package -n rubygem-io-console Summary: IO/Console is a simple console utilizing library Version: %{io_console_version} Group: Development/Libraries -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(io-console) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(io-console) = %{version}-%{release} -%description -n %{?scl_prefix}rubygem-io-console +%description -n rubygem-io-console IO/Console provides very simple and portable access to console. It doesn't provide higher layer features, such like curses and readline. -%package -n %{?scl_prefix}rubygem-json +%package -n rubygem-json Summary: This is a JSON implementation as a Ruby extension in C Version: %{json_version} Group: Development/Libraries # UCD: ext/json/generator/generator.c License: (Ruby or GPLv2) and UCD -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(json) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(json) = %{version}-%{release} -%description -n %{?scl_prefix}rubygem-json +%description -n rubygem-json This is a implementation of the JSON specification according to RFC 4627. You can think of it as a low fat alternative to XML, if you want to store data to disk or transmit it over a network rather than use a verbose markup language. -%package -n %{?scl_prefix}rubygem-minitest +%package -n rubygem-minitest Summary: Minitest provides a complete suite of testing facilities Version: %{minitest_version} Group: Development/Libraries License: MIT -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(minitest) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(minitest) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-minitest +%description -n rubygem-minitest minitest/unit is a small and incredibly fast unit testing framework. minitest/spec is a functionally complete spec engine. @@ -435,62 +418,62 @@ minitest/pride shows pride in testing and adds coloring to your test output. -%package -n %{?scl_prefix}rubygem-openssl +%package -n rubygem-openssl Summary: OpenSSL provides SSL, TLS and general purpose cryptography Version: %{openssl_version} Group: Development/Libraries License: Ruby or BSD -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(openssl) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(openssl) = %{version}-%{release} -%description -n %{?scl_prefix}rubygem-openssl +%description -n rubygem-openssl OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the OpenSSL library. -%package -n %{?scl_prefix}rubygem-power_assert +%package -n rubygem-power_assert Summary: Power Assert for Ruby Version: %{power_assert_version} Group: Development/Libraries License: Ruby or BSD -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(power_assert) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(power_assert) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-power_assert +%description -n rubygem-power_assert Power Assert shows each value of variables and method calls in the expression. It is useful for testing, providing which value wasn't correct when the condition is not satisfied. -%package -n %{?scl_prefix}rubygem-psych +%package -n rubygem-psych Summary: A libyaml wrapper for Ruby Version: %{psych_version} Group: Development/Libraries License: MIT -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(psych) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(psych) = %{version}-%{release} -%description -n %{?scl_prefix}rubygem-psych +%description -n rubygem-psych Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML] for its YAML parsing and emitting capabilities. In addition to wrapping libyaml, Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format. -%package -n %{?scl_prefix}rubygem-net-telnet +%package -n rubygem-net-telnet Summary: Provides telnet client functionality Version: %{net_telnet_version} Group: Development/Libraries -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(net-telnet) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(net-telnet) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-net-telnet +%description -n rubygem-net-telnet Provides telnet client functionality. This class also has, through delegation, all the methods of a socket object @@ -501,37 +484,37 @@ you do use sysread() directly when in telnet mode, you should probably pass the output through preprocess() to extract telnet command sequences. -%package -n %{?scl_prefix}rubygem-test-unit +%package -n rubygem-test-unit Summary: An xUnit family unit testing framework for Ruby Version: %{test_unit_version} Group: Development/Libraries # lib/test/unit/diff.rb is a double license of the Ruby license and PSF license. # lib/test-unit.rb is a dual license of the Ruby license and LGPLv2.1 or later. License: (Ruby or BSD) and (Ruby or BSD or Python) and (Ruby or BSD or LGPLv2+) -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Requires: %{?scl_prefix}rubygem(power_assert) -Provides: %{?scl_prefix}rubygem(test-unit) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Requires: rubygem(power_assert) +Provides: rubygem(test-unit) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-test-unit +%description -n rubygem-test-unit Test::Unit (test-unit) is unit testing framework for Ruby, based on xUnit principles. These were originally designed by Kent Beck, creator of extreme programming software development methodology, for Smalltalk's SUnit. It allows writing tests, checking results and automated testing in Ruby. -%package -n %{?scl_prefix}rubygem-xmlrpc +%package -n rubygem-xmlrpc Summary: XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP Version: %{xmlrpc_version} Group: Development/Libraries License: Ruby or BSD -Requires: %{?scl_prefix}ruby(release) -Requires: %{?scl_prefix}ruby(rubygems) >= %{rubygems_version} -Provides: %{?scl_prefix}rubygem(xmlrpc) = %{version}-%{release} +Requires: ruby(release) +Requires: ruby(rubygems) >= %{rubygems_version} +Provides: rubygem(xmlrpc) = %{version}-%{release} BuildArch: noarch -%description -n %{?scl_prefix}rubygem-xmlrpc +%description -n rubygem-xmlrpc XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP. @@ -556,6 +539,8 @@ rm -rf ext/fiddle/libffi* %patch11 -p1 %patch12 -p1 %patch13 -p1 +%patch14 -p0 +%patch15 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -581,13 +566,16 @@ autoconf --with-sitearchhdrdir='$(sitehdrdir)/$(arch)' \ --with-vendorarchhdrdir='$(vendorhdrdir)/$(arch)' \ --with-rubygemsdir='%{rubygems_dir}' \ - --with-ruby-pc='%{pkg_name}.pc' \ + --with-ruby-pc='%{name}.pc' \ --with-compress-debug-sections=no \ --disable-rpath \ --enable-shared \ --with-ruby-version='' \ --enable-multiarch \ --with-prelude=./abrt_prelude.rb \ +%ifarch aarch64 + --with-setjmp-type=setjmp \ +%endif # Q= makes the build output more verbose and allows to check Fedora # compiler options. @@ -599,15 +587,14 @@ make install DESTDIR=%{buildroot} # Rename ruby/config.h to ruby/config-.h to avoid file conflicts on # multilib systems and install config.h wrapper -mv %{buildroot}%{_includedir}/%{pkg_name}/config.h %{buildroot}%{_includedir}/%{pkg_name}/config-%{_arch}.h -install -m644 %{SOURCE7} %{buildroot}%{_includedir}/%{pkg_name}/config.h +%multilib_fix_c_header --file %{_includedir}/%{name}/config.h # Rename the ruby executable. It is replaced by RubyPick. -%{?with_rubypick:mv %{buildroot}%{_bindir}/%{pkg_name}{,-mri}} +%{?with_rubypick:mv %{buildroot}%{_bindir}/%{name}{,-mri}} # Version is empty if --with-ruby-version is specified. # http://bugs.ruby-lang.org/issues/7807 -sed -i 's/Version: \${ruby_version}/Version: %{ruby_version}/' %{buildroot}%{_libdir}/pkgconfig/%{pkg_name}.pc +sed -i 's/Version: \${ruby_version}/Version: %{ruby_version}/' %{buildroot}%{_libdir}/pkgconfig/%{name}.pc # Kill bundled certificates, as they should be part of ca-certificates. for cert in \ @@ -621,17 +608,24 @@ done # Ensure there is not forgotten any certificate. test ! "$(ls -A %{buildroot}%{rubygems_dir}/rubygems/ssl_certs/ 2>/dev/null)" -# Move macros file into proper place and replace the %%{pkg_name} macro, since it +# Move macros file into proper place and replace the %%{name} macro, since it # would be wrongly evaluated during build of other packages. -mkdir -p %{buildroot}%{_root_sysconfdir}/rpm -install -m 644 %{SOURCE4} %{buildroot}%{_root_sysconfdir}/rpm/macros.ruby%{?scl:.%{scl}} -sed -i "s/%%{pkg_name}/%{pkg_name}/" %{buildroot}%{_root_sysconfdir}/rpm/macros.ruby%{?scl:.%{scl}} -install -m 644 %{SOURCE5} %{buildroot}%{_root_sysconfdir}/rpm/macros.rubygems%{?scl:.%{scl}} -sed -i "s/%%{pkg_name}/%{pkg_name}/" %{buildroot}%{_root_sysconfdir}/rpm/macros.rubygems%{?scl:.%{scl}} +mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d +install -m 644 %{SOURCE4} %{buildroot}%{_rpmconfigdir}/macros.d/macros.ruby +sed -i "s/%%{name}/%{name}/" %{buildroot}%{_rpmconfigdir}/macros.d/macros.ruby +install -m 644 %{SOURCE5} %{buildroot}%{_rpmconfigdir}/macros.d/macros.rubygems +sed -i "s/%%{name}/%{name}/" %{buildroot}%{_rpmconfigdir}/macros.d/macros.rubygems + +# Install dependency generators. +mkdir -p %{buildroot}%{_rpmconfigdir}/fileattrs +install -m 644 %{SOURCE8} %{buildroot}%{_rpmconfigdir}/fileattrs +install -m 755 %{SOURCE9} %{buildroot}%{_rpmconfigdir} +install -m 755 %{SOURCE10} %{buildroot}%{_rpmconfigdir} +install -m 755 %{SOURCE11} %{buildroot}%{_rpmconfigdir} # Install custom operating_system.rb. mkdir -p %{buildroot}%{rubygems_dir}/rubygems/defaults -sed 's/@SCL@/%{scl}/' %{SOURCE1} > %{buildroot}%{rubygems_dir}/rubygems/defaults/%{basename:%{SOURCE1}} +cp %{SOURCE1} %{buildroot}%{rubygems_dir}/rubygems/defaults # Move gems root into common direcotry, out of Ruby directory structure. mv %{buildroot}%{ruby_libdir}/gems %{buildroot}%{gem_dir} @@ -640,48 +634,43 @@ mv %{buildroot}%{ruby_libdir}/gems %{buildroot}%{gem_dir} # TODO: These folders should go into rubygem-filesystem but how to achieve it, # since noarch package cannot provide arch dependent subpackages? # http://rpm.org/ticket/78 -mkdir -p %{buildroot}%{_exec_prefix}/lib{,64}/gems/%{pkg_name} +mkdir -p %{buildroot}%{_exec_prefix}/lib{,64}/gems/%{name} # Move bundled rubygems to %%gem_dir and %%gem_extdir_mri # make symlinks for io-console and bigdecimal, which are considered to be part of stdlib by other Gems mkdir -p %{buildroot}%{gem_dir}/gems/rdoc-%{rdoc_version}/lib mv %{buildroot}%{ruby_libdir}/rdoc* %{buildroot}%{gem_dir}/gems/rdoc-%{rdoc_version}/lib mv %{buildroot}%{gem_dir}/specifications/default/rdoc-%{rdoc_version}.gemspec %{buildroot}%{gem_dir}/specifications -# Below rdoc symbolic links' change is only on SCL. Not on Fedora. -# http://pkgs.devel.redhat.com/cgit/rpms/ruby/commit/?id=369e65c -# https://src.fedoraproject.org/rpms/ruby/pull-request/9 -ln -s %{gem_dir}/gems/rdoc-%{rdoc_version}/lib/rdoc.rb %{buildroot}%{ruby_libdir}/rdoc.rb -ln -s %{gem_dir}/gems/rdoc-%{rdoc_version}/lib/rdoc %{buildroot}%{ruby_libdir}/rdoc mkdir -p %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/%{pkg_name}/bigdecimal-%{bigdecimal_version} +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version} mv %{buildroot}%{ruby_libdir}/bigdecimal %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib -mv %{buildroot}%{ruby_libarchdir}/bigdecimal.so %{buildroot}%{_libdir}/gems/%{pkg_name}/bigdecimal-%{bigdecimal_version} +mv %{buildroot}%{ruby_libarchdir}/bigdecimal.so %{buildroot}%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version} 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/%{pkg_name}/bigdecimal-%{bigdecimal_version}/bigdecimal.so %{buildroot}%{ruby_libarchdir}/bigdecimal.so +ln -s %{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version}/bigdecimal.so %{buildroot}%{ruby_libarchdir}/bigdecimal.so mkdir -p %{buildroot}%{gem_dir}/gems/io-console-%{io_console_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/%{pkg_name}/io-console-%{io_console_version}/io +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/io-console-%{io_console_version}/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/%{pkg_name}/io-console-%{io_console_version}/io +mv %{buildroot}%{ruby_libarchdir}/io/console.so %{buildroot}%{_libdir}/gems/%{name}/io-console-%{io_console_version}/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/%{pkg_name}/io-console-%{io_console_version}/io/console.so %{buildroot}%{ruby_libarchdir}/io/console.so +ln -s %{_libdir}/gems/%{name}/io-console-%{io_console_version}/io/console.so %{buildroot}%{ruby_libarchdir}/io/console.so mkdir -p %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/%{pkg_name}/json-%{json_version} +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/json-%{json_version} mv %{buildroot}%{ruby_libdir}/json* %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib -mv %{buildroot}%{ruby_libarchdir}/json/ %{buildroot}%{_libdir}/gems/%{pkg_name}/json-%{json_version}/ +mv %{buildroot}%{ruby_libarchdir}/json/ %{buildroot}%{_libdir}/gems/%{name}/json-%{json_version}/ mv %{buildroot}%{gem_dir}/specifications/default/json-%{json_version}.gemspec %{buildroot}%{gem_dir}/specifications ln -s %{gem_dir}/gems/json-%{json_version}/lib/json.rb %{buildroot}%{ruby_libdir}/json.rb ln -s %{gem_dir}/gems/json-%{json_version}/lib/json %{buildroot}%{ruby_libdir}/json -ln -s %{_libdir}/gems/%{pkg_name}/json-%{json_version}/json/ %{buildroot}%{ruby_libarchdir}/json +ln -s %{_libdir}/gems/%{name}/json-%{json_version}/json/ %{buildroot}%{ruby_libarchdir}/json mkdir -p %{buildroot}%{gem_dir}/gems/openssl-%{openssl_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/%{pkg_name}/openssl-%{openssl_version} +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/openssl-%{openssl_version} mv %{buildroot}%{ruby_libdir}/openssl* %{buildroot}%{gem_dir}/gems/openssl-%{openssl_version}/lib -mv %{buildroot}%{ruby_libarchdir}/openssl.so %{buildroot}%{_libdir}/gems/%{pkg_name}/openssl-%{openssl_version}/ +mv %{buildroot}%{ruby_libarchdir}/openssl.so %{buildroot}%{_libdir}/gems/%{name}/openssl-%{openssl_version}/ mv %{buildroot}%{gem_dir}/specifications/default/openssl-%{openssl_version}.gemspec %{buildroot}%{gem_dir}/specifications # This used to be directory when OpenSSL was integral part of StdLib => Keep # it as directory and link everything in it to prevent directory => symlink @@ -690,16 +679,16 @@ mkdir -p %{buildroot}%{ruby_libdir}/openssl find %{buildroot}%{gem_dir}/gems/openssl-%{openssl_version}/lib/openssl -maxdepth 1 -type f -exec \ sh -c 'ln -s %{gem_dir}/gems/openssl-%{openssl_version}/lib/openssl/`basename {}` %{buildroot}%{ruby_libdir}/openssl' \; ln -s %{gem_dir}/gems/openssl-%{openssl_version}/lib/openssl.rb %{buildroot}%{ruby_libdir}/openssl.rb -ln -s %{_libdir}/gems/%{pkg_name}/openssl-%{openssl_version}/openssl.so %{buildroot}%{ruby_libarchdir}/openssl.so +ln -s %{_libdir}/gems/%{name}/openssl-%{openssl_version}/openssl.so %{buildroot}%{ruby_libarchdir}/openssl.so mkdir -p %{buildroot}%{gem_dir}/gems/psych-%{psych_version}/lib -mkdir -p %{buildroot}%{_libdir}/gems/%{pkg_name}/psych-%{psych_version} +mkdir -p %{buildroot}%{_libdir}/gems/%{name}/psych-%{psych_version} mv %{buildroot}%{ruby_libdir}/psych* %{buildroot}%{gem_dir}/gems/psych-%{psych_version}/lib -mv %{buildroot}%{ruby_libarchdir}/psych.so %{buildroot}%{_libdir}/gems/%{pkg_name}/psych-%{psych_version}/ +mv %{buildroot}%{ruby_libarchdir}/psych.so %{buildroot}%{_libdir}/gems/%{name}/psych-%{psych_version}/ mv %{buildroot}%{gem_dir}/specifications/default/psych-%{psych_version}.gemspec %{buildroot}%{gem_dir}/specifications ln -s %{gem_dir}/gems/psych-%{psych_version}/lib/psych %{buildroot}%{ruby_libdir}/psych ln -s %{gem_dir}/gems/psych-%{psych_version}/lib/psych.rb %{buildroot}%{ruby_libdir}/psych.rb -ln -s %{_libdir}/gems/%{pkg_name}/psych-%{psych_version}/psych.so %{buildroot}%{ruby_libarchdir}/psych.so +ln -s %{_libdir}/gems/%{name}/psych-%{psych_version}/psych.so %{buildroot}%{ruby_libarchdir}/psych.so # Move the binary extensions into proper place (if no gem has binary extension, # the extensions directory might be empty). @@ -734,16 +723,6 @@ sed -i 's/^/%doc /' .ruby-doc.* sed -i 's/^/%lang(ja) /' .ruby-doc.ja %check -# Ruby software collection tests -%{?scl:scl enable %scl - << \EOF -set -ex -mkdir -p ./lib/rubygems/defaults -cp %{SOURCE1} ./lib/rubygems/defaults -sed 's/@SCL@/%{scl}/' %{SOURCE14} > ./%{basename:%{SOURCE14}} -make test-all TESTS="%{basename:%{SOURCE14}}" -rm -rf ./lib/rubygems/defaults ./%{basename:%{SOURCE14}} -EOF} - %if 0%{?with_hardening_test} # Check Ruby hardening. checksec -f libruby.so.%{ruby_version} | \ @@ -770,10 +749,10 @@ touch abrt.rb # Check if abrt hook is required (RubyGems are disabled by default when using # runruby, so re-enable them). -make runruby TESTRUN_SCRIPT="--enable-gems %{SOURCE12}" +make runruby TESTRUN_SCRIPT="--enable-gems %{SOURCE13}" # Check if systemtap is supported. -%{?with_systemtap:make runruby TESTRUN_SCRIPT=%{SOURCE13}} +%{?with_systemtap:make runruby TESTRUN_SCRIPT=%{SOURCE14}} DISABLE_TESTS="" @@ -781,6 +760,12 @@ DISABLE_TESTS="" # Once seen: http://koji.fedoraproject.org/koji/taskinfo?taskID=12556650 DISABLE_TESTS="$DISABLE_TESTS -x test_fork.rb" +# SIGSEV handler does not provide correct output on AArch64. +# https://bugs.ruby-lang.org/issues/13758 +%ifarch aarch64 +DISABLE_TESTS="$DISABLE_TESTS -n !/test_segv_\(setproctitle\|test\|loaded_features\)/" +%endif + # Disable failing TestResolvMDNS#test_mdns_each_address test, # which fails on Koji. # https://bugs.ruby-lang.org/issues/14175 @@ -788,10 +773,6 @@ sed -i '/def test_mdns_each_address$/,/^ end$/ s/^/#/' test/resolv/test_mdns.rb make check TESTS="-v $DISABLE_TESTS" -%post libs -p /sbin/ldconfig - -%postun libs -p /sbin/ldconfig - %files %license BSDL %license COPYING @@ -799,7 +780,7 @@ make check TESTS="-v $DISABLE_TESTS" %license GPL %license LEGAL %{_bindir}/erb -%{_bindir}/%{pkg_name}%{?with_rubypick:-mri} +%{_bindir}/%{name}%{?with_rubypick:-mri} %{_mandir}/man1/erb* %{_mandir}/man1/ruby* @@ -810,11 +791,11 @@ make check TESTS="-v $DISABLE_TESTS" %license GPL %license LEGAL -%config(noreplace) %{_root_sysconfdir}/rpm/macros.ruby%{?scl:.%{scl}} +%{_rpmconfigdir}/macros.d/macros.ruby %{_includedir}/* %{_libdir}/libruby.so -%{_libdir}/pkgconfig/%{pkg_name}.pc +%{_libdir}/pkgconfig/%{name}.pc %files libs %license COPYING @@ -838,7 +819,6 @@ make check TESTS="-v $DISABLE_TESTS" %exclude %{ruby_libdir}/json.rb %exclude %{ruby_libdir}/openssl.rb %exclude %{ruby_libdir}/psych.rb -%exclude %{ruby_libdir}/rdoc.rb %{ruby_libdir}/cgi %{ruby_libdir}/digest %{ruby_libdir}/drb @@ -965,7 +945,7 @@ make check TESTS="-v $DISABLE_TESTS" %{tapset_root} -%files -n %{?scl_prefix}rubygems +%files -n rubygems %{_bindir}/gem %dir %{rubygems_dir} %{rubygems_dir}/rubygems @@ -1004,10 +984,14 @@ make check TESTS="-v $DISABLE_TESTS" %{gem_dir}/specifications/default/webrick-1.4.2.gemspec %{gem_dir}/specifications/default/zlib-1.0.0.gemspec -%files -n %{?scl_prefix}rubygems-devel -%config(noreplace) %{_root_sysconfdir}/rpm/macros.rubygems%{?scl:.%{scl}} +%files -n rubygems-devel +%{_rpmconfigdir}/macros.d/macros.rubygems +%{_rpmconfigdir}/fileattrs/rubygems.attr +%{_rpmconfigdir}/rubygems.req +%{_rpmconfigdir}/rubygems.prov +%{_rpmconfigdir}/rubygems.con -%files -n %{?scl_prefix}rubygem-rake +%files -n rubygem-rake %{_bindir}/rake %{gem_dir}/gems/rake-%{rake_version} %{gem_dir}/specifications/rake-%{rake_version}.gemspec @@ -1019,8 +1003,7 @@ make check TESTS="-v $DISABLE_TESTS" %{ruby_libdir}/irb %{_mandir}/man1/irb.1* -%files -n %{?scl_prefix}rubygem-rdoc -%{ruby_libdir}/rdoc* +%files -n rubygem-rdoc %{_bindir}/rdoc %{_bindir}/ri %{gem_dir}/gems/rdoc-%{rdoc_version} @@ -1033,68 +1016,68 @@ make check TESTS="-v $DISABLE_TESTS" %doc ruby-exercise.stp %{_datadir}/ri -%files -n %{?scl_prefix}rubygem-bigdecimal +%files -n rubygem-bigdecimal %{ruby_libdir}/bigdecimal %{ruby_libarchdir}/bigdecimal.so -%{_libdir}/gems/%{pkg_name}/bigdecimal-%{bigdecimal_version} +%{_libdir}/gems/%{name}/bigdecimal-%{bigdecimal_version} %{gem_dir}/gems/bigdecimal-%{bigdecimal_version} %{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec -%files -n %{?scl_prefix}rubygem-did_you_mean +%files -n rubygem-did_you_mean %{gem_dir}/gems/did_you_mean-%{did_you_mean_version} %exclude %{gem_dir}/gems/did_you_mean-%{did_you_mean_version}/.* %{gem_dir}/specifications/did_you_mean-%{did_you_mean_version}.gemspec -%files -n %{?scl_prefix}rubygem-io-console +%files -n rubygem-io-console %{ruby_libdir}/io %{ruby_libarchdir}/io/console.so -%{_libdir}/gems/%{pkg_name}/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 %{?scl_prefix}rubygem-json +%files -n rubygem-json %{ruby_libdir}/json* %{ruby_libarchdir}/json* -%{_libdir}/gems/%{pkg_name}/json-%{json_version} +%{_libdir}/gems/%{name}/json-%{json_version} %{gem_dir}/gems/json-%{json_version} %{gem_dir}/specifications/json-%{json_version}.gemspec -%files -n %{?scl_prefix}rubygem-minitest +%files -n rubygem-minitest %{gem_dir}/gems/minitest-%{minitest_version} %exclude %{gem_dir}/gems/minitest-%{minitest_version}/.* %{gem_dir}/specifications/minitest-%{minitest_version}.gemspec -%files -n %{?scl_prefix}rubygem-openssl +%files -n rubygem-openssl %{ruby_libdir}/openssl %{ruby_libdir}/openssl.rb %{ruby_libarchdir}/openssl.so -%{_libdir}/gems/%{pkg_name}/openssl-%{openssl_version} +%{_libdir}/gems/%{name}/openssl-%{openssl_version} %{gem_dir}/gems/openssl-%{openssl_version} %{gem_dir}/specifications/openssl-%{openssl_version}.gemspec -%files -n %{?scl_prefix}rubygem-power_assert +%files -n rubygem-power_assert %{gem_dir}/gems/power_assert-%{power_assert_version} %exclude %{gem_dir}/gems/power_assert-%{power_assert_version}/.* %{gem_dir}/specifications/power_assert-%{power_assert_version}.gemspec -%files -n %{?scl_prefix}rubygem-psych +%files -n rubygem-psych %{ruby_libdir}/psych %{ruby_libdir}/psych.rb %{ruby_libarchdir}/psych.so -%{_libdir}/gems/%{pkg_name}/psych-%{psych_version} +%{_libdir}/gems/%{name}/psych-%{psych_version} %{gem_dir}/gems/psych-%{psych_version} %{gem_dir}/specifications/psych-%{psych_version}.gemspec -%files -n %{?scl_prefix}rubygem-net-telnet +%files -n rubygem-net-telnet %{gem_dir}/gems/net-telnet-%{net_telnet_version} %exclude %{gem_dir}/gems/net-telnet-%{net_telnet_version}/.* %{gem_dir}/specifications/net-telnet-%{net_telnet_version}.gemspec -%files -n %{?scl_prefix}rubygem-test-unit +%files -n rubygem-test-unit %{gem_dir}/gems/test-unit-%{test_unit_version} %{gem_dir}/specifications/test-unit-%{test_unit_version}.gemspec -%files -n %{?scl_prefix}rubygem-xmlrpc +%files -n rubygem-xmlrpc %license %{gem_dir}/gems/xmlrpc-%{xmlrpc_version}/LICENSE.txt %dir %{gem_dir}/gems/xmlrpc-%{xmlrpc_version} %exclude %{gem_dir}/gems/xmlrpc-%{xmlrpc_version}/.* @@ -1107,101 +1090,127 @@ make check TESTS="-v $DISABLE_TESTS" %{gem_dir}/specifications/xmlrpc-%{xmlrpc_version}.gemspec %changelog -* Wed Feb 21 2018 Jun Aruga - 2.5.0-5 -- They are broken by recen tzdata update. +* Mon Mar 05 2018 Vít Ondruch - 2.5.0-91 +- Don't force libraries used to build Ruby to its dependencies. +- Re-enable GMP dependency. + +* Thu Mar 01 2018 Vít Ondruch - 2.5.0-90 +- Drop GMP dependency. + +* Sat Feb 24 2018 Florian Weimer - 2.5.0-89 +- Rebuild with new LDFLAGS from redhat-rpm-config +- Use --with-setjmp-type=setjmp on aarch64 to work around gcc issue (#1545239) + +* Wed Feb 21 2018 Pavel Valena - 2.5.0-89 +- Fix: Multiple vulnerabilities in RubyGems + https://bugzilla.redhat.com/show_bug.cgi?id=1547431 + https://www.ruby-lang.org/en/news/2018/02/17/multiple-vulnerabilities-in-rubygems/ + +* Tue Feb 13 2018 Vít Ondruch - 2.5.0-89 +- Drop obsolete ldconfig scriptlets. +- Add GMP dependency. +- Use 'with' operator in RPM dependency generator. +- Add conflicts RPM generator. - Fix thread_safe test suite segfaults. - Fix invalid licenses. -* Mon Jan 15 2018 Jun Aruga - 2.5.0-4 +* Fri Feb 09 2018 Fedora Release Engineering - 2.5.0-89 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Sat Jan 20 2018 Björn Esser - 2.5.0-88 +- Rebuilt for switch to libxcrypt + +* Tue Jan 09 2018 Vít Ondruch - 2.5.0-87 - Fix segfaults during generating of documentation. - Resolves: rhbz#1532585 -* Mon Jan 15 2018 Jun Aruga - 2.5.0-3 -- Update for did_you_mean required by ruby - Resolves: rhbz#1533920 - -* Tue Jan 02 2018 Jun Aruga - 2.5.0-2 +* Tue Jan 02 2018 Vít Ondruch - 2.5.0-86 - Upgrade to Ruby 2.5.0. -* Mon Oct 30 2017 Vít Ondruch - 2.4.2-86 -- Upgrade to Ruby 2.4.2. - * Remove Patch10: ruby-2.4.0-vm_insnhelper.c-block-argument-at-tailcall.patch; - subsumed - Resolves: rhbz#1506785 -- Fix unsafe object deserialization in RubyGems (CVE-2017-0903). - * ruby-2.4.3-CVE-2017-0903-Fix-unsafe-object-deserialization - -vulnerability.patch - Resolves: CVE-2017-0903 +* Fri Oct 27 2017 Jun Aruga - 2.4.2-86 +- Add macro to remove rubypick dependency. +- Improve "with" conditional statement as inline. + +* Thu Oct 19 2017 Jun Aruga - 2.4.2-85 +- Add macros to remove systemtap, git and cmake dependencies. + +* Mon Sep 18 2017 Pavel Valena - 2.4.2-84 +- Update to Ruby 2.4.2. + +* Fri Sep 08 2017 Vít Ondruch - 2.4.1-84 +- Drop ruby-devel dependency on rubypick, which is pulled in transtitively. + +* Fri Aug 11 2017 Vít Ondruch - 2.4.1-83 +- Fix "IOError: stream closed" errors affecting Puma. +- Temporary disable checksec on PPC64LE (rhbz#1479302). + +* Thu Aug 03 2017 Fedora Release Engineering - 2.4.1-82 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 2.4.1-81 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Thu Jul 20 2017 Vít Ondruch - 2.4.1-80 +- OpenSSL 1.1.0f-3 disables some weak ciphers. Adjust the package to pass + the tests suite. + +* Mon Apr 03 2017 Vít Ondruch - 2.4.1-79 +- Update to Ruby 2.4.1. + +* Thu Feb 23 2017 Vít Ondruch - 2.4.0-78 +- Fix OpenSSL symlinks. + +* Sat Feb 11 2017 Fedora Release Engineering - 2.4.0-77 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Fri Feb 03 2017 Vít Ondruch - 2.4.0-76 +- Fix GCC 7.x compatibility (rhbz#1417590). +- Use standardized multilib solution (rhbz#1412274). * Tue Jan 17 2017 Vít Ondruch - 2.4.0-75 - Apply patch fixing rubygem-mongo build failures. -* Mon Jan 09 2017 Vít Ondruch - 2.4.0-73 -- Reshuffle the %%license macro to avoid %%postun scriptlet issues. - Resolves: rhbz#1411233 +* Fri Jan 13 2017 Mamoru TASAKA - 2.4.0-74 +- Rebuild again for f26-ruby24 sidetag -* Mon Jan 09 2017 Vít Ondruch - 2.4.0-72 +* Thu Jan 12 2017 Igor Gnatenko - 2.4.0-73 +- Rebuild for readline 7.x + +* Wed Jan 11 2017 Vít Ondruch - 2.4.0-72 +- Link files into directory to avoid dir => symlink isues. + +* Mon Jan 09 2017 Vít Ondruch - 2.4.0-71 - Add rubygem-io-console dependency for rubygem-rdoc. -* Mon Jan 02 2017 Vít Ondruch - 2.4.0-71 -- ruby-libs should not own links to unbundled gems. - * Mon Jan 02 2017 Vít Ondruch - 2.4.0-70 - Upgrade to Ruby 2.4.0. -- Workaround "an invalid stdio handle" error on PPC (rhbz#1361037). -- Add gemspec_add_dep and gemspec_remove_dep macros. - Move gemified xmlrpc into subpackage. - Move gemified openssl into subpackage. -- Make symlinks for json gem. - Tk is removed from stdlib. -- Harden package. - Extend 'gem_' macros for pre-release version support. -* Wed Oct 26 2016 Pavel Valena - 2.3.1-64 -- Fix: do not fail in operating_system.rb when X_SCLS is empty - Resolves: rhbz#1387139 +* Tue Nov 22 2016 Vít Ondruch - 2.3.3-61 +- Update to Ruby 2.3.3. +- Exclude json.rb from ruby-libs (rhbz#1397370). -* Mon Oct 17 2016 Pavel Valena - 2.3.1-63 -- Support in no_proxy for domain names with whitespaces and leading dots - Resolves: rhbz#1384810 +* Fri Nov 18 2016 Vít Ondruch - 2.3.2-60 +- Update to Ruby 2.3.2. -* Fri Aug 12 2016 Pavel Valena - 2.3.1-62 -- Fix support for dependent^2 SCLs -- Update to Ruby 2.3.1 - * Remove Patch8: - ruby-2.3.0-undef-BUILTIN_CHOOSE_EXPR_CONSTANT_P.patch; subsumed - * Remove Patch10: - ruby-2.3.1-remove-tests-depending-on-europe-moscow.patch; subsumed - also removed "UTC=TZ " tests prefix +* Fri Oct 21 2016 Vít Ondruch - 2.3.1-59 +- Continue to use OpenSSL 1.0 for the moment. +- Add gemspec_add_dep and gemspec_remove_dep macros. +- Harden package. -* Mon Jul 25 2016 Pavel Valena - 2.3.0-61 -- Add %%{scl}-runtime to Requires in libs subpackage +* Wed Aug 10 2016 Vít Ondruch - 2.3.1-58 +- Workaround "an invalid stdio handle" error on PPC (rhbz#1361037). -* Tue Jul 19 2016 Pavel Valena - 2.3.0-60 -- Fix and enhance systemtap tests -- Remove tests depending on Europe/Moscow to avoid failures due to tzdata change +* Tue Jul 12 2016 Vít Ondruch - 2.3.1-57 +- Make symlinks for json gem. -* Wed Apr 13 2016 Pavel Valena - 2.3.0-60 -- Fix ruby lib path in macros.ruby.rh-ruby23 - - Resolves: rhbz#1255753 -- Manually set UTC timezone for tests +* Mon May 23 2016 Vít Ondruch - 2.3.1-56 +- Requires rubygem(json) for rubygem-rdoc (rhbz#1325022). -* Mon Feb 22 2016 Vít Ondruch - 2.3.0-59 -- Don't prefix bundling provides. -- Don't enable collections for build. -- Optimize operating_system.rb a bit. - -* Fri Feb 19 2016 Pavel Valena - 2.3.0-58 -- Fix default_dir and default_bindir - -* Fri Feb 19 2016 Pavel Valena - 2.3.0-57 -- Fix dependent scls's paths - -* Thu Feb 18 2016 Pavel Valena - 2.3.0-56 -- Fix macros.ruby and macros.rubygems - -* Wed Feb 17 2016 Pavel Valena - 2.3.0-55 -- Add scl macros +* Fri Apr 29 2016 Vít Ondruch - 2.3.1-55 +- Update to Ruby 2.3.1. * Wed Feb 3 2016 Peter Robinson 2.3.0-54 - Add rubypick and rubygems requires to ruby-devel to deal with BuildRequires diff --git a/rubygems-2.5.0-multiple-vulnerabilities.patch b/rubygems-2.5.0-multiple-vulnerabilities.patch new file mode 100644 index 0000000..e32926a --- /dev/null +++ b/rubygems-2.5.0-multiple-vulnerabilities.patch @@ -0,0 +1,2349 @@ +diff --git lib/rubygems.rb lib/rubygems.rb +index 0475ced164..2762bfcb88 100644 +--- lib/rubygems.rb ++++ lib/rubygems.rb +@@ -10,7 +10,7 @@ + require 'thread' + + module Gem +- VERSION = "2.7.3" ++ VERSION = "2.7.6" + end + + # Must be first since it unloads the prelude from 1.9.2 +@@ -161,7 +161,7 @@ module Gem + # these are defined in Ruby 1.8.7, hence the need for this convoluted setup. + + READ_BINARY_ERRORS = begin +- read_binary_errors = [Errno::EACCES, Errno::EROFS] ++ read_binary_errors = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS] + read_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP) + read_binary_errors + end.freeze +@@ -171,7 +171,7 @@ module Gem + # these are defined in Ruby 1.8.7. + + WRITE_BINARY_ERRORS = begin +- write_binary_errors = [] ++ write_binary_errors = [Errno::ENOSYS] + write_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP) + write_binary_errors + end.freeze +@@ -871,19 +871,19 @@ def self.refresh + # Safely read a file in binary mode on all platforms. + + def self.read_binary(path) +- open path, 'rb+' do |f| ++ File.open path, 'rb+' do |f| + f.flock(File::LOCK_EX) + f.read + end + rescue *READ_BINARY_ERRORS +- open path, 'rb' do |f| ++ File.open path, 'rb' do |f| + f.read + end + rescue Errno::ENOLCK # NFS + if Thread.main != Thread.current + raise + else +- open path, 'rb' do |f| ++ File.open path, 'rb' do |f| + f.read + end + end +diff --git lib/rubygems/commands/generate_index_command.rb lib/rubygems/commands/generate_index_command.rb +index 01f1f88405..0b677b73a9 100644 +--- lib/rubygems/commands/generate_index_command.rb ++++ lib/rubygems/commands/generate_index_command.rb +@@ -68,7 +68,7 @@ def execute + + if not File.exist?(options[:directory]) or + not File.directory?(options[:directory]) then +- alert_error "unknown directory name #{directory}." ++ alert_error "unknown directory name #{options[:directory]}." + terminate_interaction 1 + else + indexer = Gem::Indexer.new options.delete(:directory), options +diff --git lib/rubygems/commands/owner_command.rb lib/rubygems/commands/owner_command.rb +index 8e2271657a..637b5bdc4d 100644 +--- lib/rubygems/commands/owner_command.rb ++++ lib/rubygems/commands/owner_command.rb +@@ -64,7 +64,7 @@ def show_owners name + end + + with_response response do |resp| +- owners = YAML.load resp.body ++ owners = Gem::SafeYAML.load resp.body + + say "Owners for gem: #{name}" + owners.each do |owner| +diff --git lib/rubygems/commands/setup_command.rb lib/rubygems/commands/setup_command.rb +index 5d1414d102..6966cde01a 100644 +--- lib/rubygems/commands/setup_command.rb ++++ lib/rubygems/commands/setup_command.rb +@@ -350,7 +350,9 @@ def fake_spec.full_gem_path + def install_default_bundler_gem + return unless Gem::USE_BUNDLER_FOR_GEMDEPS + +- mkdir_p Gem::Specification.default_specifications_dir ++ specs_dir = Gem::Specification.default_specifications_dir ++ File.join(options[:destdir], specs_dir) unless Gem.win_platform? ++ mkdir_p specs_dir + + # Workaround for non-git environment. + gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") } +@@ -359,23 +361,36 @@ def install_default_bundler_gem + bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") + bundler_spec.files = Dir.chdir("bundler") { Dir["{*.md,{lib,exe,man}/**/*}"] } + bundler_spec.executables -= %w[bundler bundle_ruby] +- Dir.entries(Gem::Specification.default_specifications_dir). ++ ++ # Remove bundler-*.gemspec in default specification directory. ++ Dir.entries(specs_dir). + select {|gs| gs.start_with?("bundler-") }. +- each {|gs| File.delete(File.join(Gem::Specification.default_specifications_dir, gs)) } ++ each {|gs| File.delete(File.join(specs_dir, gs)) } + +- default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") ++ default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec") + Gem.write_binary(default_spec_path, bundler_spec.to_ruby) + + bundler_spec = Gem::Specification.load(default_spec_path) + ++ # Remove gemspec that was same version of vendored bundler. ++ normal_gemspec = File.join(Gem.default_dir, "specifications", "bundler-#{bundler_spec.version}.gemspec") ++ if File.file? normal_gemspec ++ File.delete normal_gemspec ++ end ++ ++ # Remove gem files that were same version of vendored bundler. + if File.directory? bundler_spec.gems_dir + Dir.entries(bundler_spec.gems_dir). +- select {|default_gem| File.basename(default_gem).match(/^bundler-#{Gem::Version::VERSION_PATTERN}$/) }. ++ select {|default_gem| File.basename(default_gem) == "bundler-#{bundler_spec.version}" }. + each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } + end + +- mkdir_p bundler_spec.bin_dir +- bundler_spec.executables.each {|e| cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_spec.bin_dir, e) } ++ bundler_bin_dir = File.join(Gem.default_dir, 'gems', bundler_spec.full_name, bundler_spec.bindir) ++ File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform? ++ mkdir_p bundler_bin_dir ++ bundler_spec.executables.each do |e| ++ cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e) ++ end + + if Gem.win_platform? + require 'rubygems/installer' +diff --git lib/rubygems/commands/unpack_command.rb lib/rubygems/commands/unpack_command.rb +index eb7f550673..b873f20d28 100644 +--- lib/rubygems/commands/unpack_command.rb ++++ lib/rubygems/commands/unpack_command.rb +@@ -94,7 +94,7 @@ def execute + + spec_file = File.basename spec.spec_file + +- open spec_file, 'w' do |io| ++ File.open spec_file, 'w' do |io| + io.write metadata + end + else +@@ -176,7 +176,7 @@ def get_metadata path, security_policy = nil + + metadata = nil + +- open path, Gem.binary_mode do |io| ++ File.open path, Gem.binary_mode do |io| + tar = Gem::Package::TarReader.new io + tar.each_entry do |entry| + case entry.full_name +diff --git lib/rubygems/config_file.rb lib/rubygems/config_file.rb +index a4efed0f5a..c0d19dbfc2 100644 +--- lib/rubygems/config_file.rb ++++ lib/rubygems/config_file.rb +@@ -458,7 +458,7 @@ def to_yaml # :nodoc: + + # Writes out this config file, replacing its source. + def write +- open config_file_name, 'w' do |io| ++ File.open config_file_name, 'w' do |io| + io.write to_yaml + end + end +diff --git lib/rubygems/ext/builder.rb lib/rubygems/ext/builder.rb +index a1619c97d7..eb9db199d5 100644 +--- lib/rubygems/ext/builder.rb ++++ lib/rubygems/ext/builder.rb +@@ -212,7 +212,7 @@ def write_gem_make_out output # :nodoc: + + FileUtils.mkdir_p @spec.extension_dir + +- open destination, 'wb' do |io| io.puts output end ++ File.open destination, 'wb' do |io| io.puts output end + + destination + end +diff --git lib/rubygems/indexer.rb lib/rubygems/indexer.rb +index 871cc09d8d..3ea994414b 100644 +--- lib/rubygems/indexer.rb ++++ lib/rubygems/indexer.rb +@@ -2,6 +2,7 @@ + require 'rubygems' + require 'rubygems/package' + require 'time' ++require 'tmpdir' + + begin + gem 'builder' +@@ -64,7 +65,7 @@ def initialize(directory, options = {}) + @build_modern = options[:build_modern] + + @dest_directory = directory +- @directory = File.join(Dir.tmpdir, "gem_generate_index_#{$$}") ++ @directory = Dir.mktmpdir 'gem_generate_index' + + marshal_name = "Marshal.#{Gem.marshal_version}" + +@@ -123,7 +124,7 @@ def build_marshal_gemspecs specs + marshal_name = File.join @quick_marshal_dir, spec_file_name + + marshal_zipped = Gem.deflate Marshal.dump(spec) +- open marshal_name, 'wb' do |io| io.write marshal_zipped end ++ File.open marshal_name, 'wb' do |io| io.write marshal_zipped end + + files << marshal_name + +@@ -261,7 +262,7 @@ def compress(filename, extension) + + zipped = Gem.deflate data + +- open "#{filename}.#{extension}", 'wb' do |io| ++ File.open "#{filename}.#{extension}", 'wb' do |io| + io.write zipped + end + end +@@ -427,7 +428,7 @@ def update_specs_index(index, source, dest) + + specs_index = compact_specs specs_index.uniq.sort + +- open dest, 'wb' do |io| ++ File.open dest, 'wb' do |io| + Marshal.dump specs_index, io + end + end +diff --git lib/rubygems/installer.rb lib/rubygems/installer.rb +index 0cbca0791b..ee5fedeb64 100644 +--- lib/rubygems/installer.rb ++++ lib/rubygems/installer.rb +@@ -206,7 +206,7 @@ def check_executable_overwrite filename # :nodoc: + ruby_executable = false + existing = nil + +- open generated_bin, 'rb' do |io| ++ File.open generated_bin, 'rb' do |io| + next unless io.gets =~ /^#!/ # shebang + io.gets # blankline + +@@ -427,7 +427,7 @@ def default_spec_file + # specifications directory. + + def write_spec +- open spec_file, 'w' do |file| ++ File.open spec_file, 'w' do |file| + spec.installed_by_version = Gem.rubygems_version + + file.puts spec.to_ruby_for_cache +@@ -464,7 +464,12 @@ def generate_windows_script(filename, bindir) + def generate_bin # :nodoc: + return if spec.executables.nil? or spec.executables.empty? + +- Dir.mkdir @bin_dir unless File.exist? @bin_dir ++ begin ++ Dir.mkdir @bin_dir ++ rescue SystemCallError ++ raise unless File.directory? @bin_dir ++ end ++ + raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir + + spec.executables.each do |filename| +@@ -863,7 +868,7 @@ def write_build_info_file + + build_info_file = File.join build_info_dir, "#{spec.full_name}.info" + +- open build_info_file, 'w' do |io| ++ File.open build_info_file, 'w' do |io| + @build_args.each do |arg| + io.puts arg + end +diff --git lib/rubygems/package.rb lib/rubygems/package.rb +index 77811ed5ec..b924122827 100644 +--- lib/rubygems/package.rb ++++ lib/rubygems/package.rb +@@ -219,7 +219,7 @@ def add_files tar # :nodoc: + next unless stat.file? + + tar.add_file_simple file, stat.mode, stat.size do |dst_io| +- open file, 'rb' do |src_io| ++ File.open file, 'rb' do |src_io| + dst_io.write src_io.read 16384 until src_io.eof? + end + end +@@ -378,9 +378,9 @@ def extract_tar_gz io, destination_dir, pattern = "*" # :nodoc: + File.dirname destination + end + +- FileUtils.mkdir_p mkdir, mkdir_options ++ mkdir_p_safe mkdir, mkdir_options, destination_dir, entry.full_name + +- open destination, 'wb' do |out| ++ File.open destination, 'wb' do |out| + out.write entry.read + FileUtils.chmod entry.header.mode, destination + end if entry.file? +@@ -416,20 +416,35 @@ def install_location filename, destination_dir # :nodoc: + raise Gem::Package::PathError.new(filename, destination_dir) if + filename.start_with? '/' + +- destination_dir = File.realpath destination_dir if +- File.respond_to? :realpath ++ destination_dir = realpath destination_dir + destination_dir = File.expand_path destination_dir + + destination = File.join destination_dir, filename + destination = File.expand_path destination + + raise Gem::Package::PathError.new(destination, destination_dir) unless +- destination.start_with? destination_dir ++ destination.start_with? destination_dir + '/' + + destination.untaint + destination + end + ++ def mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name ++ destination_dir = realpath File.expand_path(destination_dir) ++ parts = mkdir.split(File::SEPARATOR) ++ parts.reduce do |path, basename| ++ path = realpath path unless path == "" ++ path = File.expand_path(path + File::SEPARATOR + basename) ++ lstat = File.lstat path rescue nil ++ if !lstat || !lstat.directory? ++ unless path.start_with? destination_dir and (FileUtils.mkdir path, mkdir_options rescue false) ++ raise Gem::Package::PathError.new(file_name, destination_dir) ++ end ++ end ++ path ++ end ++ end ++ + ## + # Loads a Gem::Specification from the TarEntry +entry+ + +@@ -603,6 +618,10 @@ def verify_files gem + raise Gem::Package::FormatError.new \ + 'package content (data.tar.gz) is missing', @gem + end ++ ++ if duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first) and duplicates.any? ++ raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(', ')})" ++ end + end + + ## +@@ -616,6 +635,16 @@ def verify_gz entry # :nodoc: + raise Gem::Package::FormatError.new(e.message, entry.full_name) + end + ++ if File.respond_to? :realpath ++ def realpath file ++ File.realpath file ++ end ++ else ++ def realpath file ++ file ++ end ++ end ++ + end + + require 'rubygems/package/digest_io' +diff --git lib/rubygems/package/file_source.rb lib/rubygems/package/file_source.rb +index 1a4dc4c824..ecc3a68677 100644 +--- lib/rubygems/package/file_source.rb ++++ lib/rubygems/package/file_source.rb +@@ -23,11 +23,11 @@ def present? + end + + def with_write_io &block +- open path, 'wb', &block ++ File.open path, 'wb', &block + end + + def with_read_io &block +- open path, 'rb', &block ++ File.open path, 'rb', &block + end + + end +diff --git lib/rubygems/package/old.rb lib/rubygems/package/old.rb +index f6e6e67c38..322d682ca8 100644 +--- lib/rubygems/package/old.rb ++++ lib/rubygems/package/old.rb +@@ -80,7 +80,7 @@ def extract_files destination_dir + + FileUtils.mkdir_p File.dirname destination + +- open destination, 'wb', entry['mode'] do |out| ++ File.open destination, 'wb', entry['mode'] do |out| + out.write file_data + end + +diff --git lib/rubygems/package/tar_header.rb lib/rubygems/package/tar_header.rb +index c54bd14d57..d557357114 100644 +--- lib/rubygems/package/tar_header.rb ++++ lib/rubygems/package/tar_header.rb +@@ -104,25 +104,30 @@ def self.from(stream) + fields = header.unpack UNPACK_FORMAT + + new :name => fields.shift, +- :mode => fields.shift.oct, +- :uid => fields.shift.oct, +- :gid => fields.shift.oct, +- :size => fields.shift.oct, +- :mtime => fields.shift.oct, +- :checksum => fields.shift.oct, ++ :mode => strict_oct(fields.shift), ++ :uid => strict_oct(fields.shift), ++ :gid => strict_oct(fields.shift), ++ :size => strict_oct(fields.shift), ++ :mtime => strict_oct(fields.shift), ++ :checksum => strict_oct(fields.shift), + :typeflag => fields.shift, + :linkname => fields.shift, + :magic => fields.shift, +- :version => fields.shift.oct, ++ :version => strict_oct(fields.shift), + :uname => fields.shift, + :gname => fields.shift, +- :devmajor => fields.shift.oct, +- :devminor => fields.shift.oct, ++ :devmajor => strict_oct(fields.shift), ++ :devminor => strict_oct(fields.shift), + :prefix => fields.shift, + + :empty => empty + end + ++ def self.strict_oct(str) ++ return str.oct if str =~ /\A[0-7]*\z/ ++ raise ArgumentError, "#{str.inspect} is not an octal string" ++ end ++ + ## + # Creates a new TarHeader using +vals+ + +diff --git lib/rubygems/package/tar_writer.rb lib/rubygems/package/tar_writer.rb +index f68b8d4c5e..390f7851a3 100644 +--- lib/rubygems/package/tar_writer.rb ++++ lib/rubygems/package/tar_writer.rb +@@ -196,6 +196,8 @@ def add_file_signed name, mode, signer + digest_name == signer.digest_name + end + ++ raise "no #{signer.digest_name} in #{digests.values.compact}" unless signature_digest ++ + if signer.key then + signature = signer.sign signature_digest.digest + +diff --git lib/rubygems/request_set/lockfile.rb lib/rubygems/request_set/lockfile.rb +index 7f6eadb939..76ad17d486 100644 +--- lib/rubygems/request_set/lockfile.rb ++++ lib/rubygems/request_set/lockfile.rb +@@ -223,7 +223,7 @@ def to_s + def write + content = to_s + +- open "#{@gem_deps_file}.lock", 'w' do |io| ++ File.open "#{@gem_deps_file}.lock", 'w' do |io| + io.write content + end + end +diff --git lib/rubygems/security.rb lib/rubygems/security.rb +index 4690dd9230..236577c5a3 100644 +--- lib/rubygems/security.rb ++++ lib/rubygems/security.rb +@@ -578,7 +578,7 @@ def self.trusted_certificates &block + def self.write pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER + path = File.expand_path path + +- open path, 'wb', permissions do |io| ++ File.open path, 'wb', permissions do |io| + if passphrase and cipher + io.write pemmable.to_pem cipher, passphrase + else +diff --git lib/rubygems/security/trust_dir.rb lib/rubygems/security/trust_dir.rb +index bf44975cc6..849cf3cd3e 100644 +--- lib/rubygems/security/trust_dir.rb ++++ lib/rubygems/security/trust_dir.rb +@@ -93,7 +93,7 @@ def trust_cert certificate + + destination = cert_path certificate + +- open destination, 'wb', @permissions[:trusted_cert] do |io| ++ File.open destination, 'wb', @permissions[:trusted_cert] do |io| + io.write certificate.to_pem + end + end +diff --git lib/rubygems/server.rb lib/rubygems/server.rb +index 93b3af36f8..62c3dfe9cf 100644 +--- lib/rubygems/server.rb ++++ lib/rubygems/server.rb +@@ -623,6 +623,18 @@ def root(req, res) + executables = nil if executables.empty? + executables.last["is_last"] = true if executables + ++ # Pre-process spec homepage for safety reasons ++ begin ++ homepage_uri = URI.parse(spec.homepage) ++ if [URI::HTTP, URI::HTTPS].member? homepage_uri.class ++ homepage_uri = spec.homepage ++ else ++ homepage_uri = "." ++ end ++ rescue URI::InvalidURIError ++ homepage_uri = "." ++ end ++ + specs << { + "authors" => spec.authors.sort.join(", "), + "date" => spec.date.to_s, +@@ -632,7 +644,7 @@ def root(req, res) + "only_one_executable" => (executables && executables.size == 1), + "full_name" => spec.full_name, + "has_deps" => !deps.empty?, +- "homepage" => spec.homepage, ++ "homepage" => homepage_uri, + "name" => spec.name, + "rdoc_installed" => Gem::RDoc.new(spec).rdoc_installed?, + "ri_installed" => Gem::RDoc.new(spec).ri_installed?, +diff --git lib/rubygems/source.rb lib/rubygems/source.rb +index bd84c217a7..b28b850660 100644 +--- lib/rubygems/source.rb ++++ lib/rubygems/source.rb +@@ -160,7 +160,7 @@ def fetch_spec name_tuple + if update_cache? then + FileUtils.mkdir_p cache_dir + +- open local_spec, 'wb' do |io| ++ File.open local_spec, 'wb' do |io| + io.write spec + end + end +diff --git lib/rubygems/specification.rb lib/rubygems/specification.rb +index efc08c4738..2560324b7a 100644 +--- lib/rubygems/specification.rb ++++ lib/rubygems/specification.rb +@@ -15,6 +15,7 @@ + require 'rubygems/stub_specification' + require 'rubygems/util/list' + require 'stringio' ++require 'uri' + + ## + # The Specification class contains the information for a Gem. Typically +@@ -2822,10 +2823,16 @@ def validate packaging = true + raise Gem::InvalidSpecificationException, "#{lazy} is not a summary" + end + +- if homepage and not homepage.empty? and +- homepage !~ /\A[a-z][a-z\d+.-]*:/i then +- raise Gem::InvalidSpecificationException, +- "\"#{homepage}\" is not a URI" ++ # Make sure a homepage is valid HTTP/HTTPS URI ++ if homepage and not homepage.empty? ++ begin ++ homepage_uri = URI.parse(homepage) ++ unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class ++ raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI" ++ end ++ rescue URI::InvalidURIError ++ raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI" ++ end + end + + # Warnings +diff --git lib/rubygems/stub_specification.rb lib/rubygems/stub_specification.rb +index 8337375ab4..ae2effbc84 100644 +--- lib/rubygems/stub_specification.rb ++++ lib/rubygems/stub_specification.rb +@@ -113,6 +113,8 @@ def data + unless @data + begin + saved_lineno = $. ++ ++ # TODO It should be use `File.open`, but bundler-1.16.1 example expects Kernel#open. + open loaded_from, OPEN_MODE do |file| + begin + file.readline # discard encoding line +diff --git lib/rubygems/test_case.rb lib/rubygems/test_case.rb +index f7f216e5e3..39aa4fc9a7 100644 +--- lib/rubygems/test_case.rb ++++ lib/rubygems/test_case.rb +@@ -488,7 +488,7 @@ def git_gem name = 'a', version = 1 + + gemspec = "#{name}.gemspec" + +- open File.join(directory, gemspec), 'w' do |io| ++ File.open File.join(directory, gemspec), 'w' do |io| + io.write git_spec.to_ruby + end + +@@ -592,7 +592,7 @@ def mu_pp(obj) + # Reads a Marshal file at +path+ + + def read_cache(path) +- open path.dup.untaint, 'rb' do |io| ++ File.open path.dup.untaint, 'rb' do |io| + Marshal.load io.read + end + end +@@ -612,7 +612,7 @@ def write_file(path) + dir = File.dirname path + FileUtils.mkdir_p dir unless File.directory? dir + +- open path, 'wb' do |io| ++ File.open path, 'wb' do |io| + yield io if block_given? + end + +@@ -727,7 +727,7 @@ def install_default_gems(*specs) + install_default_specs(*specs) + + specs.each do |spec| +- open spec.loaded_from, 'w' do |io| ++ File.open spec.loaded_from, 'w' do |io| + io.write spec.to_ruby_for_cache + end + end +@@ -1363,7 +1363,7 @@ def save_gemspec name = 'a', version = 1, directory = '.' + yield specification if block_given? + end + +- open File.join(directory, "#{name}.gemspec"), 'w' do |io| ++ File.open File.join(directory, "#{name}.gemspec"), 'w' do |io| + io.write vendor_spec.to_ruby + end + +diff --git lib/rubygems/test_utilities.rb lib/rubygems/test_utilities.rb +index 686916ea02..83c9d2d0fe 100644 +--- lib/rubygems/test_utilities.rb ++++ lib/rubygems/test_utilities.rb +@@ -346,7 +346,7 @@ def spec name, version, dependencies = nil, &block + end + + def write_spec spec # :nodoc: +- open spec.spec_file, 'w' do |io| ++ File.open spec.spec_file, 'w' do |io| + io.write spec.to_ruby_for_cache + end + end +diff --git lib/rubygems/util.rb lib/rubygems/util.rb +index 2de45c900b..6c75910004 100644 +--- lib/rubygems/util.rb ++++ lib/rubygems/util.rb +@@ -114,7 +114,8 @@ def self.traverse_parents directory, &block + + here = File.expand_path directory + loop do +- Dir.chdir here, &block ++ Dir.chdir here, &block rescue Errno::EACCES ++ + new_here = File.expand_path('..', here) + return if new_here == here # toplevel + here = new_here +diff --git lib/rubygems/validator.rb lib/rubygems/validator.rb +index 83448229bb..6842e4fa9c 100644 +--- lib/rubygems/validator.rb ++++ lib/rubygems/validator.rb +@@ -34,7 +34,7 @@ def verify_gem(gem_data) + # gem_path:: [String] Path to gem file + + def verify_gem_file(gem_path) +- open gem_path, Gem.binary_mode do |file| ++ File.open gem_path, Gem.binary_mode do |file| + gem_data = file.read + verify_gem gem_data + end +@@ -109,7 +109,7 @@ def alien(gems=[]) + + good, gone, unreadable = nil, nil, nil, nil + +- open gem_path, Gem.binary_mode do |file| ++ File.open gem_path, Gem.binary_mode do |file| + package = Gem::Package.new gem_path + + good, gone = package.contents.partition { |file_name| +@@ -134,7 +134,7 @@ def alien(gems=[]) + + source = File.join gem_directory, entry['path'] + +- open source, Gem.binary_mode do |f| ++ File.open source, Gem.binary_mode do |f| + unless f.read == data then + errors[gem_name][entry['path']] = "Modified from original" + end +diff --git test/rubygems/test_gem.rb test/rubygems/test_gem.rb +index 8a11cc2ecf..183771f0f3 100644 +--- test/rubygems/test_gem.rb ++++ test/rubygems/test_gem.rb +@@ -7,7 +7,7 @@ + require 'tmpdir' + + # TODO: push this up to test_case.rb once battle tested +-$SAFE=1 ++ + $LOAD_PATH.map! do |path| + path.dup.untaint + end +@@ -463,7 +463,7 @@ def test_self_ensure_gem_directories_missing_parents + assert File.directory?(util_cache_dir) + end + +- unless win_platform? then # only for FS that support write protection ++ unless win_platform? || Process.uid.zero? then # only for FS that support write protection + def test_self_ensure_gem_directories_write_protected + gemdir = File.join @tempdir, "egd" + FileUtils.rm_r gemdir rescue nil +@@ -775,7 +775,7 @@ def test_self_prefix_sitelibdir + end + + def test_self_read_binary +- open 'test', 'w' do |io| ++ File.open 'test', 'w' do |io| + io.write "\xCF\x80" + end + +@@ -1643,7 +1643,7 @@ def test_use_gemdeps + spec = Gem::Specification.find { |s| s == spec } + refute spec.activated? + +- open gem_deps_file, 'w' do |io| ++ File.open gem_deps_file, 'w' do |io| + io.write 'gem "a"' + end + +@@ -1662,7 +1662,7 @@ def test_use_gemdeps_ENV + + refute spec.activated? + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.write 'gem "a"' + end + +@@ -1706,7 +1706,7 @@ def test_use_gemdeps_automatic + + refute spec.activated? + +- open 'Gemfile', 'w' do |io| ++ File.open 'Gemfile', 'w' do |io| + io.write 'gem "a"' + end + +@@ -1735,7 +1735,7 @@ def test_use_gemdeps_disabled + + refute spec.activated? + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.write 'gem "a"' + end + +@@ -1750,7 +1750,7 @@ def test_use_gemdeps_missing_gem + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" + rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' + +- open 'x', 'w' do |io| ++ File.open 'x', 'w' do |io| + io.write 'gem "a"' + end + +@@ -1791,7 +1791,7 @@ def test_use_gemdeps_specific + spec = Gem::Specification.find { |s| s == spec } + refute spec.activated? + +- open 'x', 'w' do |io| ++ File.open 'x', 'w' do |io| + io.write 'gem "a"' + end + +diff --git test/rubygems/test_gem_commands_cleanup_command.rb test/rubygems/test_gem_commands_cleanup_command.rb +index c55e195975..60d208fcc0 100644 +--- test/rubygems/test_gem_commands_cleanup_command.rb ++++ test/rubygems/test_gem_commands_cleanup_command.rb +@@ -158,7 +158,7 @@ def test_execute_all_user_no_sudo + assert_path_exists @a_1_1.gem_dir + ensure + FileUtils.chmod 0755, @gemhome +- end unless win_platform? ++ end unless win_platform? || Process.uid.zero? + + def test_execute_dry_run + @cmd.options[:args] = %w[a] +diff --git test/rubygems/test_gem_commands_install_command.rb test/rubygems/test_gem_commands_install_command.rb +index dd86a85038..822d40e3f3 100644 +--- test/rubygems/test_gem_commands_install_command.rb ++++ test/rubygems/test_gem_commands_install_command.rb +@@ -131,6 +131,7 @@ def test_execute_local_transitive_prerelease + + def test_execute_no_user_install + skip 'skipped on MS Windows (chmod has no effect)' if win_platform? ++ skip 'skipped in root privilege' if Process.uid.zero? + + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 +diff --git test/rubygems/test_gem_commands_owner_command.rb test/rubygems/test_gem_commands_owner_command.rb +index 44652c1093..53cac4ce87 100644 +--- test/rubygems/test_gem_commands_owner_command.rb ++++ test/rubygems/test_gem_commands_owner_command.rb +@@ -43,6 +43,31 @@ def test_show_owners + assert_match %r{- 4}, @ui.output + end + ++ def test_show_owners_dont_load_objects ++ skip "testing a psych-only API" unless defined?(::Psych::DisallowedClass) ++ ++ response = < 0 +- assert Gem::Specification.find_all_by_name('x').length == 0 ++ assert Gem::Specification.find_all_by_name('x').length.zero? + end + + def test_execute_all +diff --git test/rubygems/test_gem_dependency_installer.rb test/rubygems/test_gem_dependency_installer.rb +index e55cc75682..3d76291668 100644 +--- test/rubygems/test_gem_dependency_installer.rb ++++ test/rubygems/test_gem_dependency_installer.rb +@@ -424,7 +424,7 @@ def test_install_dependency_existing_extension + extconf_rb = File.join @gemhome, 'gems', 'e-1', 'extconf.rb' + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |io| ++ File.open extconf_rb, 'w' do |io| + io.write <<-EXTCONF_RB + require 'mkmf' + create_makefile 'e' +diff --git test/rubygems/test_gem_doctor.rb test/rubygems/test_gem_doctor.rb +index 39b8a11692..8db65d70ce 100644 +--- test/rubygems/test_gem_doctor.rb ++++ test/rubygems/test_gem_doctor.rb +@@ -24,7 +24,7 @@ def test_doctor + + FileUtils.rm b.spec_file + +- open c.spec_file, 'w' do |io| ++ File.open c.spec_file, 'w' do |io| + io.write 'this will raise an exception when evaluated.' + end + +@@ -77,7 +77,7 @@ def test_doctor_dry_run + + FileUtils.rm b.spec_file + +- open c.spec_file, 'w' do |io| ++ File.open c.spec_file, 'w' do |io| + io.write 'this will raise an exception when evaluated.' + end + +diff --git test/rubygems/test_gem_ext_builder.rb test/rubygems/test_gem_ext_builder.rb +index d142ef28da..3dabd3e350 100644 +--- test/rubygems/test_gem_ext_builder.rb ++++ test/rubygems/test_gem_ext_builder.rb +@@ -32,7 +32,7 @@ def test_class_make + results = [] + + Dir.chdir @ext do +- open 'Makefile', 'w' do |io| ++ File.open 'Makefile', 'w' do |io| + io.puts <<-MAKEFILE + all: + \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}" +@@ -72,7 +72,7 @@ def test_class_make_no_clean + results = [] + + Dir.chdir @ext do +- open 'Makefile', 'w' do |io| ++ File.open 'Makefile', 'w' do |io| + io.puts <<-MAKEFILE + all: + \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}" +@@ -107,7 +107,7 @@ def test_build_extensions + + extconf_rb = File.join ext_dir, 'extconf.rb' + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' + require 'mkmf' + +@@ -168,7 +168,7 @@ def Gem.install_extension_in_lib + + extconf_rb = File.join ext_dir, 'extconf.rb' + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' + require 'mkmf' + +@@ -290,7 +290,7 @@ def test_build_extensions_with_build_args + + FileUtils.mkdir_p @spec.gem_dir + +- open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f| ++ File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f| + f.write <<-'RUBY' + puts "IN EXTCONF" + extconf_args = File.join File.dirname(__FILE__), 'extconf_args' +@@ -323,7 +323,7 @@ def test_initialize + + build_info_file = File.join build_info_dir, "#{@spec.full_name}.info" + +- open build_info_file, 'w' do |io| ++ File.open build_info_file, 'w' do |io| + io.puts '--with-foo-dir=/nonexistent' + end + +diff --git test/rubygems/test_gem_gem_runner.rb test/rubygems/test_gem_gem_runner.rb +index 0a1faa404a..d68ac4da81 100644 +--- test/rubygems/test_gem_gem_runner.rb ++++ test/rubygems/test_gem_gem_runner.rb +@@ -1,38 +1,6 @@ + # frozen_string_literal: true + require 'rubygems/test_case' +-begin +- gem_home_files = lambda{ +- if Dir.exist?(ENV["GEM_HOME"]) +- require "find" +- ary = Find.find(ENV["GEM_HOME"]).to_a +- else +- [] +- end +- } +- prev_gem_home = ENV["GEM_HOME"] +- prev_gem_home_files = gem_home_files.call +- prev_threads = Thread.list.map{|e| e.inspect} +- +- require 'rubygems/gem_runner' +-ensure +- if $! +- msg = < 'KEY' } + FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path + +- open Gem.configuration.credentials_path, 'w' do |f| ++ File.open Gem.configuration.credentials_path, 'w' do |f| + f.write keys.to_yaml + end + +@@ -59,7 +59,7 @@ def test_api_key_override + keys = { :rubygems_api_key => 'KEY', :other => 'OTHER' } + FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path + +- open Gem.configuration.credentials_path, 'w' do |f| ++ File.open Gem.configuration.credentials_path, 'w' do |f| + f.write keys.to_yaml + end + +@@ -163,7 +163,7 @@ def test_sign_in_with_other_credentials_doesnt_overwrite_other_keys + other_api_key = 'f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf' + + FileUtils.mkdir_p File.dirname(Gem.configuration.credentials_path) +- open Gem.configuration.credentials_path, 'w' do |f| ++ File.open Gem.configuration.credentials_path, 'w' do |f| + f.write Hash[:other_api_key, other_api_key].to_yaml + end + util_sign_in [api_key, 200, 'OK'] +diff --git test/rubygems/test_gem_indexer.rb test/rubygems/test_gem_indexer.rb +index a4a966e8de..5a9075e676 100644 +--- test/rubygems/test_gem_indexer.rb ++++ test/rubygems/test_gem_indexer.rb +@@ -39,8 +39,7 @@ def setup + + def test_initialize + assert_equal @tempdir, @indexer.dest_directory +- assert_equal File.join(Dir.tmpdir, "gem_generate_index_#{$$}"), +- @indexer.directory ++ assert_match %r{#{Dir.mktmpdir('gem_generate_index').match(/.*-/)}}, @indexer.directory + + indexer = Gem::Indexer.new @tempdir + assert indexer.build_modern +diff --git test/rubygems/test_gem_install_update_options.rb test/rubygems/test_gem_install_update_options.rb +index e2d546307d..371e408d27 100644 +--- test/rubygems/test_gem_install_update_options.rb ++++ test/rubygems/test_gem_install_update_options.rb +@@ -141,6 +141,8 @@ def test_user_install_enabled + def test_user_install_disabled_read_only + if win_platform? + skip('test_user_install_disabled_read_only test skipped on MS Windows') ++ elsif Process.uid.zero? ++ skip('test_user_install_disabled_read_only test skipped in root privilege') + else + @cmd.handle_options %w[--no-user-install] + +diff --git test/rubygems/test_gem_installer.rb test/rubygems/test_gem_installer.rb +index 39095c7dee..93b0482407 100644 +--- test/rubygems/test_gem_installer.rb ++++ test/rubygems/test_gem_installer.rb +@@ -140,7 +140,7 @@ def test_check_executable_overwrite_format_executable + s.require_path = 'lib' + end + +- open File.join(util_inst_bindir, 'executable'), 'w' do |io| ++ File.open File.join(util_inst_bindir, 'executable'), 'w' do |io| + io.write <<-EXEC + #!/usr/local/bin/ruby + # +@@ -437,6 +437,8 @@ def test_generate_bin_script_no_perms + + if win_platform? + skip('test_generate_bin_script_no_perms skipped on MS Windows') ++ elsif Process.uid.zero? ++ skip('test_generate_bin_script_no_perms skipped in root privilege') + else + FileUtils.chmod 0000, util_inst_bindir + +@@ -529,6 +531,8 @@ def test_generate_bin_symlink_no_perms + + if win_platform? + skip('test_generate_bin_symlink_no_perms skipped on MS Windows') ++ elsif Process.uid.zero? ++ skip('test_user_install_disabled_read_only test skipped in root privilege') + else + FileUtils.chmod 0000, util_inst_bindir + +diff --git test/rubygems/test_gem_package.rb test/rubygems/test_gem_package.rb +index cec1981c4c..d1664cf285 100644 +--- test/rubygems/test_gem_package.rb ++++ test/rubygems/test_gem_package.rb +@@ -24,7 +24,7 @@ def setup + end + + def test_class_new_old_format +- open 'old_format.gem', 'wb' do |io| ++ File.open 'old_format.gem', 'wb' do |io| + io.write SIMPLE_GEM + end + +@@ -45,7 +45,7 @@ def test_add_checksums + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -110,8 +110,8 @@ def test_add_files + + FileUtils.mkdir_p 'lib/empty' + +- open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end +- open 'lib/extra.rb', 'w' do |io| io.write '# lib/extra.rb' end ++ File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end ++ File.open 'lib/extra.rb', 'w' do |io| io.write '# lib/extra.rb' end + + package = Gem::Package.new 'bogus.gem' + package.spec = spec +@@ -140,7 +140,7 @@ def test_add_files_symlink + spec.files = %w[lib/code.rb lib/code_sym.rb] + + FileUtils.mkdir_p 'lib' +- open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end ++ File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end + + # NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb + File.symlink('code.rb', 'lib/code_sym.rb') +@@ -179,7 +179,7 @@ def test_build + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -218,7 +218,7 @@ def test_build_auto_signed + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -261,7 +261,7 @@ def test_build_auto_signed_encrypted_key + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -311,7 +311,7 @@ def test_build_signed + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -348,7 +348,7 @@ def test_build_signed_encrypted_key + + FileUtils.mkdir 'lib' + +- open 'lib/code.rb', 'w' do |io| ++ File.open 'lib/code.rb', 'w' do |io| + io.write '# lib/code.rb' + end + +@@ -408,7 +408,7 @@ def test_extract_files_empty + end + end + +- open 'empty.gem', 'wb' do |io| ++ File.open 'empty.gem', 'wb' do |io| + io.write gem.string + end + +@@ -455,6 +455,31 @@ def test_extract_tar_gz_symlink_relative_path + File.read(extracted) + end + ++ def test_extract_symlink_parent ++ skip 'symlink not supported' if Gem.win_platform? ++ ++ package = Gem::Package.new @gem ++ ++ tgz_io = util_tar_gz do |tar| ++ tar.mkdir 'lib', 0755 ++ tar.add_symlink 'lib/link', '../..', 0644 ++ tar.add_file 'lib/link/outside.txt', 0644 do |io| io.write 'hi' end ++ end ++ ++ # Extract into a subdirectory of @destination; if this test fails it writes ++ # a file outside destination_subdir, but we want the file to remain inside ++ # @destination so it will be cleaned up. ++ destination_subdir = File.join @destination, 'subdir' ++ FileUtils.mkdir_p destination_subdir ++ ++ e = assert_raises Gem::Package::PathError do ++ package.extract_tar_gz tgz_io, destination_subdir ++ end ++ ++ assert_equal("installing into parent path lib/link/outside.txt of " + ++ "#{destination_subdir} is not allowed", e.message) ++ end ++ + def test_extract_tar_gz_directory + package = Gem::Package.new @gem + +@@ -566,6 +591,21 @@ def test_install_location_relative + "#{@destination} is not allowed", e.message) + end + ++ def test_install_location_suffix ++ package = Gem::Package.new @gem ++ ++ filename = "../#{File.basename(@destination)}suffix.rb" ++ ++ e = assert_raises Gem::Package::PathError do ++ package.install_location filename, @destination ++ end ++ ++ parent = File.expand_path File.join @destination, filename ++ ++ assert_equal("installing into parent path #{parent} of " + ++ "#{@destination} is not allowed", e.message) ++ end ++ + def test_load_spec + entry = StringIO.new Gem.gzip @spec.to_yaml + def entry.full_name() 'metadata.gz' end +@@ -620,7 +660,7 @@ def test_verify_checksum_bad + end + end + +- open 'mismatch.gem', 'wb' do |io| ++ File.open 'mismatch.gem', 'wb' do |io| + io.write gem.string + end + +@@ -670,7 +710,7 @@ def test_verify_checksum_missing + end + end + +- open 'data_checksum_missing.gem', 'wb' do |io| ++ File.open 'data_checksum_missing.gem', 'wb' do |io| + io.write gem.string + end + +@@ -723,6 +763,32 @@ def test_verify_nonexistent + assert_match %r%nonexistent.gem$%, e.message + end + ++ def test_verify_duplicate_file ++ FileUtils.mkdir_p 'lib' ++ FileUtils.touch 'lib/code.rb' ++ ++ build = Gem::Package.new @gem ++ build.spec = @spec ++ build.setup_signer ++ open @gem, 'wb' do |gem_io| ++ Gem::Package::TarWriter.new gem_io do |gem| ++ build.add_metadata gem ++ build.add_contents gem ++ ++ gem.add_file_simple 'a.sig', 0444, 0 ++ gem.add_file_simple 'a.sig', 0444, 0 ++ end ++ end ++ ++ package = Gem::Package.new @gem ++ ++ e = assert_raises Gem::Security::Exception do ++ package.verify ++ end ++ ++ assert_equal 'duplicate files in the package: ("a.sig")', e.message ++ end ++ + def test_verify_security_policy + skip 'openssl is missing' unless defined?(OpenSSL::SSL) + +@@ -773,14 +839,20 @@ def test_verify_security_policy_checksum_missing + FileUtils.mkdir 'lib' + FileUtils.touch 'lib/code.rb' + +- open @gem, 'wb' do |gem_io| ++ File.open @gem, 'wb' do |gem_io| + Gem::Package::TarWriter.new gem_io do |gem| + build.add_metadata gem + build.add_contents gem + + # write bogus data.tar.gz to foil signature + bogus_data = Gem.gzip 'hello' +- gem.add_file_simple 'data.tar.gz', 0444, bogus_data.length do |io| ++ fake_signer = Class.new do ++ def digest_name; 'SHA512'; end ++ def digest_algorithm; Digest(:SHA512); end ++ def key; 'key'; end ++ def sign(*); 'fake_sig'; end ++ end ++ gem.add_file_signed 'data2.tar.gz', 0444, fake_signer.new do |io| + io.write bogus_data + end + +@@ -804,7 +876,7 @@ def test_verify_security_policy_checksum_missing + end + + def test_verify_truncate +- open 'bad.gem', 'wb' do |io| ++ File.open 'bad.gem', 'wb' do |io| + io.write File.read(@gem, 1024) # don't care about newlines + end + +diff --git test/rubygems/test_gem_package_old.rb test/rubygems/test_gem_package_old.rb +index c15475b0c7..604981b3c1 100644 +--- test/rubygems/test_gem_package_old.rb ++++ test/rubygems/test_gem_package_old.rb +@@ -7,7 +7,7 @@ class TestGemPackageOld < Gem::TestCase + def setup + super + +- open 'old_format.gem', 'wb' do |io| ++ File.open 'old_format.gem', 'wb' do |io| + io.write SIMPLE_GEM + end + +diff --git test/rubygems/test_gem_package_tar_header.rb test/rubygems/test_gem_package_tar_header.rb +index d33877057d..43f508df45 100644 +--- test/rubygems/test_gem_package_tar_header.rb ++++ test/rubygems/test_gem_package_tar_header.rb +@@ -143,5 +143,26 @@ def test_update_checksum + assert_equal '012467', @tar_header.checksum + end + ++ def test_from_bad_octal ++ test_cases = [ ++ "00000006,44\000", # bogus character ++ "00000006789\000", # non-octal digit ++ "+0000001234\000", # positive sign ++ "-0000001000\000", # negative sign ++ "0x000123abc\000", # radix prefix ++ ] ++ ++ test_cases.each do |val| ++ header_s = @tar_header.to_s ++ # overwrite the size field ++ header_s[124, 12] = val ++ io = TempIO.new header_s ++ assert_raises ArgumentError do ++ new_header = Gem::Package::TarHeader.from io ++ end ++ io.close! if io.respond_to? :close! ++ end ++ end ++ + end + +diff --git test/rubygems/test_gem_rdoc.rb test/rubygems/test_gem_rdoc.rb +index 76ca8c45a9..0355883cb3 100644 +--- test/rubygems/test_gem_rdoc.rb ++++ test/rubygems/test_gem_rdoc.rb +@@ -223,6 +223,7 @@ def test_remove + + def test_remove_unwritable + skip 'chmod not supported' if Gem.win_platform? ++ skip 'skipped in root privilege' if Process.uid.zero? + FileUtils.mkdir_p @a.base_dir + FileUtils.chmod 0, @a.base_dir + +@@ -251,6 +252,7 @@ def test_setup + + def test_setup_unwritable + skip 'chmod not supported' if Gem.win_platform? ++ skip 'skipped in root privilege' if Process.uid.zero? + FileUtils.mkdir_p @a.doc_dir + FileUtils.chmod 0, @a.doc_dir + +diff --git test/rubygems/test_gem_remote_fetcher.rb test/rubygems/test_gem_remote_fetcher.rb +index ee5ac77717..20e34e84e1 100644 +--- test/rubygems/test_gem_remote_fetcher.rb ++++ test/rubygems/test_gem_remote_fetcher.rb +@@ -431,7 +431,7 @@ def test_download_install_dir + assert File.exist?(a1_cache_gem) + end + +- unless win_platform? # File.chmod doesn't work ++ unless win_platform? || Process.uid.zero? # File.chmod doesn't work + def test_download_local_read_only + FileUtils.mv @a1_gem, @tempdir + local_path = File.join @tempdir, @a1.file_name +diff --git test/rubygems/test_gem_request_set.rb test/rubygems/test_gem_request_set.rb +index 3a48827481..5dc6c1518d 100644 +--- test/rubygems/test_gem_request_set.rb ++++ test/rubygems/test_gem_request_set.rb +@@ -52,7 +52,7 @@ def test_install_from_gemdeps + rs = Gem::RequestSet.new + installed = [] + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + io.flush + +@@ -78,7 +78,7 @@ def test_install_from_gemdeps_explain + + rs = Gem::RequestSet.new + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + io.flush + +@@ -104,7 +104,7 @@ def test_install_from_gemdeps_install_dir + rs = Gem::RequestSet.new + installed = [] + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + end + +@@ -128,7 +128,7 @@ def test_install_from_gemdeps_local + + rs = Gem::RequestSet.new + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + io.flush + +@@ -150,7 +150,7 @@ def test_install_from_gemdeps_lockfile + rs = Gem::RequestSet.new + installed = [] + +- open 'gem.deps.rb.lock', 'w' do |io| ++ File.open 'gem.deps.rb.lock', 'w' do |io| + io.puts <<-LOCKFILE + GEM + remote: #{@gem_repo} +@@ -167,7 +167,7 @@ def test_install_from_gemdeps_lockfile + LOCKFILE + end + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "b"' + end + +@@ -190,7 +190,7 @@ def test_install_from_gemdeps_version_mismatch + rs = Gem::RequestSet.new + installed = [] + +- open 'gem.deps.rb', 'w' do |io| ++ File.open 'gem.deps.rb', 'w' do |io| + io.puts <<-GEM_DEPS + gem "a" + ruby "0" +diff --git test/rubygems/test_gem_request_set_lockfile.rb test/rubygems/test_gem_request_set_lockfile.rb +index 908f97303e..7460b7efad 100644 +--- test/rubygems/test_gem_request_set_lockfile.rb ++++ test/rubygems/test_gem_request_set_lockfile.rb +@@ -31,7 +31,7 @@ def lockfile + def write_lockfile lockfile + @lock_file = File.expand_path "#{@gem_deps_file}.lock" + +- open @lock_file, 'w' do |io| ++ File.open @lock_file, 'w' do |io| + io.write lockfile + end + end +@@ -387,7 +387,7 @@ def test_to_s_git + s.add_dependency 'c', '~> 1.0' + end + +- open 'b.gemspec', 'w' do |io| ++ File.open 'b.gemspec', 'w' do |io| + io.write b.to_ruby + end + +@@ -400,7 +400,7 @@ def test_to_s_git + Dir.chdir 'c' do + c = Gem::Specification.new 'c', 1 + +- open 'c.gemspec', 'w' do |io| ++ File.open 'c.gemspec', 'w' do |io| + io.write c.to_ruby + end + +@@ -455,7 +455,7 @@ def test_write_error + + gem_deps_lock_file = "#{@gem_deps_file}.lock" + +- open gem_deps_lock_file, 'w' do |io| ++ File.open gem_deps_lock_file, 'w' do |io| + io.write 'hello' + end + +diff --git test/rubygems/test_gem_request_set_lockfile_parser.rb test/rubygems/test_gem_request_set_lockfile_parser.rb +index 9946c522d9..f3517da43a 100644 +--- test/rubygems/test_gem_request_set_lockfile_parser.rb ++++ test/rubygems/test_gem_request_set_lockfile_parser.rb +@@ -536,7 +536,7 @@ def test_parse_missing + end + + def write_lockfile lockfile +- open @lock_file, 'w' do |io| ++ File.open @lock_file, 'w' do |io| + io.write lockfile + end + end +diff --git test/rubygems/test_gem_request_set_lockfile_tokenizer.rb test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +index ab506a14e6..f4aba6d94a 100644 +--- test/rubygems/test_gem_request_set_lockfile_tokenizer.rb ++++ test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +@@ -295,7 +295,7 @@ def test_unget + end + + def write_lockfile lockfile +- open @lock_file, 'w' do |io| ++ File.open @lock_file, 'w' do |io| + io.write lockfile + end + end +diff --git test/rubygems/test_gem_resolver_git_specification.rb test/rubygems/test_gem_resolver_git_specification.rb +index 9e8e2c5715..211757eb20 100644 +--- test/rubygems/test_gem_resolver_git_specification.rb ++++ test/rubygems/test_gem_resolver_git_specification.rb +@@ -70,7 +70,7 @@ def test_install_extension + Dir.chdir 'git/a' do + FileUtils.mkdir_p 'ext/lib' + +- open 'ext/extconf.rb', 'w' do |io| ++ File.open 'ext/extconf.rb', 'w' do |io| + io.puts 'require "mkmf"' + io.puts 'create_makefile "a"' + end +diff --git test/rubygems/test_gem_server.rb test/rubygems/test_gem_server.rb +index 6fe02e480f..a018e65512 100644 +--- test/rubygems/test_gem_server.rb ++++ test/rubygems/test_gem_server.rb +@@ -100,7 +100,7 @@ def test_latest_specs_gemdirs + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + +- open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ File.open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + +@@ -198,7 +198,7 @@ def test_quick_gemdirs + + FileUtils.mkdir_p specs_dir + +- open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ File.open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + +@@ -339,7 +339,7 @@ def test_root_gemdirs + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + +- open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ File.open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + +@@ -353,6 +353,171 @@ def test_root_gemdirs + assert_match 'z 9', @res.body + end + ++ ++ def test_xss_homepage_fix_289313 ++ data = StringIO.new "GET / HTTP/1.0\r\n\r\n" ++ dir = "#{@gemhome}2" ++ ++ spec = util_spec 'xsshomepagegem', 1 ++ spec.homepage = "javascript:confirm(document.domain)" ++ ++ specs_dir = File.join dir, 'specifications' ++ FileUtils.mkdir_p specs_dir ++ ++ open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ io.write spec.to_ruby ++ end ++ ++ server = Gem::Server.new dir, process_based_port, false ++ ++ @req.parse data ++ ++ server.root @req, @res ++ ++ assert_equal 200, @res.status ++ assert_match 'xsshomepagegem 1', @res.body ++ ++ # This verifies that the homepage for this spec is not displayed and is set to ".", because it's not a ++ # valid HTTP/HTTPS URL and could be unsafe in an HTML context. We would prefer to throw an exception here, ++ # but spec.homepage is currently free form and not currently required to be a URL, this behavior may be ++ # validated in future versions of Gem::Specification. ++ # ++ # There are two variant we're checking here, one where rdoc is not present, and one where rdoc is present in the same regex: ++ # ++ # Variant #1 - rdoc not installed ++ # ++ # xsshomepagegem 1 ++ # ++ # ++ # [rdoc] ++ # ++ # ++ # ++ # [www] ++ # ++ # Variant #2 - rdoc installed ++ # ++ # xsshomepagegem 1 ++ # ++ # ++ # \[rdoc\]<\/a> ++ # ++ # ++ # ++ # [www] ++ regex_match = /xsshomepagegem 1<\/b>[\n\s]+(\[rdoc\]<\/span>|\[rdoc\]<\/a>)[\n\s]+\[www\]<\/a>/ ++ assert_match regex_match, @res.body ++ end ++ ++ def test_invalid_homepage ++ data = StringIO.new "GET / HTTP/1.0\r\n\r\n" ++ dir = "#{@gemhome}2" ++ ++ spec = util_spec 'invalidhomepagegem', 1 ++ spec.homepage = "notavalidhomepageurl" ++ ++ specs_dir = File.join dir, 'specifications' ++ FileUtils.mkdir_p specs_dir ++ ++ open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ io.write spec.to_ruby ++ end ++ ++ server = Gem::Server.new dir, process_based_port, false ++ ++ @req.parse data ++ ++ server.root @req, @res ++ ++ assert_equal 200, @res.status ++ assert_match 'invalidhomepagegem 1', @res.body ++ ++ # This verifies that the homepage for this spec is not displayed and is set to ".", because it's not a ++ # valid HTTP/HTTPS URL and could be unsafe in an HTML context. We would prefer to throw an exception here, ++ # but spec.homepage is currently free form and not currently required to be a URL, this behavior may be ++ # validated in future versions of Gem::Specification. ++ # ++ # There are two variant we're checking here, one where rdoc is not present, and one where rdoc is present in the same regex: ++ # ++ # Variant #1 - rdoc not installed ++ # ++ # invalidhomepagegem 1 ++ # ++ # ++ # [rdoc] ++ # ++ # ++ # ++ # [www] ++ # ++ # Variant #2 - rdoc installed ++ # ++ # invalidhomepagegem 1 ++ # ++ # ++ # \[rdoc\]<\/a> ++ # ++ # ++ # ++ # [www] ++ regex_match = /invalidhomepagegem 1<\/b>[\n\s]+(\[rdoc\]<\/span>|\[rdoc\]<\/a>)[\n\s]+\[www\]<\/a>/ ++ assert_match regex_match, @res.body ++ end ++ ++ def test_valid_homepage_http ++ data = StringIO.new "GET / HTTP/1.0\r\n\r\n" ++ dir = "#{@gemhome}2" ++ ++ spec = util_spec 'validhomepagegemhttp', 1 ++ spec.homepage = "http://rubygems.org" ++ ++ specs_dir = File.join dir, 'specifications' ++ FileUtils.mkdir_p specs_dir ++ ++ open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ io.write spec.to_ruby ++ end ++ ++ server = Gem::Server.new dir, process_based_port, false ++ ++ @req.parse data ++ ++ server.root @req, @res ++ ++ assert_equal 200, @res.status ++ assert_match 'validhomepagegemhttp 1', @res.body ++ ++ regex_match = /validhomepagegemhttp 1<\/b>[\n\s]+(\[rdoc\]<\/span>|\[rdoc\]<\/a>)[\n\s]+\[www\]<\/a>/ ++ assert_match regex_match, @res.body ++ end ++ ++ def test_valid_homepage_https ++ data = StringIO.new "GET / HTTP/1.0\r\n\r\n" ++ dir = "#{@gemhome}2" ++ ++ spec = util_spec 'validhomepagegemhttps', 1 ++ spec.homepage = "https://rubygems.org" ++ ++ specs_dir = File.join dir, 'specifications' ++ FileUtils.mkdir_p specs_dir ++ ++ open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ io.write spec.to_ruby ++ end ++ ++ server = Gem::Server.new dir, process_based_port, false ++ ++ @req.parse data ++ ++ server.root @req, @res ++ ++ assert_equal 200, @res.status ++ assert_match 'validhomepagegemhttps 1', @res.body ++ ++ regex_match = /validhomepagegemhttps 1<\/b>[\n\s]+(\[rdoc\]<\/span>|\[rdoc\]<\/a>)[\n\s]+\[www\]<\/a>/ ++ assert_match regex_match, @res.body ++ end ++ + def test_specs + data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" + @req.parse data +@@ -378,7 +543,7 @@ def test_specs_gemdirs + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + +- open File.join(specs_dir, spec.spec_name), 'w' do |io| ++ File.open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + +diff --git test/rubygems/test_gem_source.rb test/rubygems/test_gem_source.rb +index 4a93e222f8..8805a9b404 100644 +--- test/rubygems/test_gem_source.rb ++++ test/rubygems/test_gem_source.rb +@@ -110,7 +110,7 @@ def test_fetch_spec_cached + + cache_file = File.join cache_dir, a1.spec_name + +- open cache_file, 'wb' do |io| ++ File.open cache_file, 'wb' do |io| + Marshal.dump a1, io + end + +@@ -163,7 +163,7 @@ def test_load_specs_cached + + cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" + +- open cache_file, 'wb' do |io| ++ File.open cache_file, 'wb' do |io| + Marshal.dump latest_specs, io + end + +@@ -187,7 +187,7 @@ def test_load_specs_cached_empty + + cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" + +- open cache_file, 'wb' do |io| ++ File.open cache_file, 'wb' do |io| + # Setup invalid data in the cache: + io.write Marshal.dump(latest_specs)[0, 10] + end +diff --git test/rubygems/test_gem_source_git.rb test/rubygems/test_gem_source_git.rb +index 0e13a11e7e..8f5d3ee745 100644 +--- test/rubygems/test_gem_source_git.rb ++++ test/rubygems/test_gem_source_git.rb +@@ -229,7 +229,7 @@ def test_specs + Dir.chdir 'b' do + b = Gem::Specification.new 'b', 1 + +- open 'b.gemspec', 'w' do |io| ++ File.open 'b.gemspec', 'w' do |io| + io.write b.to_ruby + end + +diff --git test/rubygems/test_gem_specification.rb test/rubygems/test_gem_specification.rb +index bb6acbc7de..badb297eee 100644 +--- test/rubygems/test_gem_specification.rb ++++ test/rubygems/test_gem_specification.rb +@@ -922,7 +922,7 @@ def test_self_load + end + + def test_self_load_relative +- open 'a-2.gemspec', 'w' do |io| ++ File.open 'a-2.gemspec', 'w' do |io| + io.write @a2.to_ruby_for_cache + end + +@@ -948,6 +948,9 @@ def test_self_load_tainted + @a2.files.clear + + assert_equal @a2, spec ++ ++ ensure ++ $SAFE = 0 + end + + def test_self_load_escape_curly +@@ -1111,7 +1114,7 @@ def test_self_remove_spec + end + + def test_self_remove_spec_removed +- open @a1.spec_file, 'w' do |io| ++ File.open @a1.spec_file, 'w' do |io| + io.write @a1.to_ruby + end + +@@ -1363,13 +1366,13 @@ def test_build_args + + assert_empty @ext.build_args + +- open @ext.build_info_file, 'w' do |io| ++ File.open @ext.build_info_file, 'w' do |io| + io.puts + end + + assert_empty @ext.build_args + +- open @ext.build_info_file, 'w' do |io| ++ File.open @ext.build_info_file, 'w' do |io| + io.puts '--with-foo-dir=wherever' + end + +@@ -1385,9 +1388,9 @@ def test_build_extensions + extconf_rb = File.join @ext.gem_dir, @ext.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +@@ -1435,9 +1438,9 @@ def test_build_extensions_default_gem + extconf_rb = File.join spec.gem_dir, spec.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" + end +@@ -1461,6 +1464,7 @@ def test_build_extensions_error + + def test_build_extensions_extensions_dir_unwritable + skip 'chmod not supported' if Gem.win_platform? ++ skip 'skipped in root privilege' if Process.uid.zero? + + ext_spec + +@@ -1469,9 +1473,9 @@ def test_build_extensions_extensions_dir_unwritable + extconf_rb = File.join @ext.gem_dir, @ext.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +@@ -1486,7 +1490,7 @@ def test_build_extensions_extensions_dir_unwritable + @ext.build_extensions + refute_path_exists @ext.extension_dir + ensure +- unless ($DEBUG or win_platform?) then ++ unless ($DEBUG or win_platform? or Process.uid.zero?) then + FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') + FileUtils.chmod 0755, @ext.base_dir + end +@@ -1502,9 +1506,9 @@ def test_build_extensions_no_extensions_dir_unwritable + extconf_rb = File.join @ext.gem_dir, @ext.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +@@ -1551,9 +1555,9 @@ def test_build_extensions_preview + extconf_rb = File.join @ext.gem_dir, @ext.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +@@ -2882,7 +2886,22 @@ def test_validate_homepage + @a1.validate + end + +- assert_equal '"over at my cool site" is not a URI', e.message ++ assert_equal '"over at my cool site" is not a valid HTTP URI', e.message ++ ++ @a1.homepage = 'ftp://rubygems.org' ++ ++ e = assert_raises Gem::InvalidSpecificationException do ++ @a1.validate ++ end ++ ++ assert_equal '"ftp://rubygems.org" is not a valid HTTP URI', e.message ++ ++ @a1.homepage = 'http://rubygems.org' ++ assert_equal true, @a1.validate ++ ++ @a1.homepage = 'https://rubygems.org' ++ assert_equal true, @a1.validate ++ + end + end + +@@ -3418,9 +3437,9 @@ def test_missing_extensions_eh + extconf_rb = File.join @ext.gem_dir, @ext.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +diff --git test/rubygems/test_gem_stub_specification.rb test/rubygems/test_gem_stub_specification.rb +index 43680265c7..f9a3a236c0 100644 +--- test/rubygems/test_gem_stub_specification.rb ++++ test/rubygems/test_gem_stub_specification.rb +@@ -127,9 +127,9 @@ def test_missing_extensions_eh + extconf_rb = File.join s.gem_dir, s.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + +- open extconf_rb, 'w' do |f| ++ File.open extconf_rb, 'w' do |f| + f.write <<-'RUBY' +- open 'Makefile', 'w' do |f| ++ File.open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo clean" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" +@@ -149,7 +149,7 @@ def test_missing_extensions_eh_default_gem + spec = new_default_spec 'default', 1 + spec.extensions << 'extconf.rb' + +- open spec.loaded_from, 'w' do |io| ++ File.open spec.loaded_from, 'w' do |io| + io.write spec.to_ruby_for_cache + end + +@@ -198,7 +198,7 @@ def test_to_spec_missing_extensions + + def stub_with_version + spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' +- open spec, 'w' do |io| ++ File.open spec, 'w' do |io| + io.write <<-STUB + # -*- encoding: utf-8 -*- + # stub: stub_v 2 ruby lib +@@ -221,7 +221,7 @@ def stub_with_version + + def stub_without_version + spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' +- open spec, 'w' do |io| ++ File.open spec, 'w' do |io| + io.write <<-STUB + # -*- encoding: utf-8 -*- + # stub: stub_v ruby lib +@@ -245,7 +245,7 @@ def stub_without_version + + def stub_with_extension + spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' +- open spec, 'w' do |io| ++ File.open spec, 'w' do |io| + io.write <<-STUB + # -*- encoding: utf-8 -*- + # stub: stub_e 2 ruby lib +@@ -271,7 +271,7 @@ def stub_with_extension + + def stub_without_extension + spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' +- open spec, 'w' do |io| ++ File.open spec, 'w' do |io| + io.write <<-STUB + # -*- encoding: utf-8 -*- + # stub: stub 2 ruby lib +diff --git test/rubygems/test_gem_util.rb test/rubygems/test_gem_util.rb +index b85db44d51..3b7887d931 100644 +--- test/rubygems/test_gem_util.rb ++++ test/rubygems/test_gem_util.rb +@@ -5,6 +5,7 @@ + class TestGemUtil < Gem::TestCase + + def test_class_popen ++ skip "MJIT executes process and it's caught by Process.wait(-1)" if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + assert_equal "0\n", Gem::Util.popen(Gem.ruby, '-e', 'p 0') + + assert_raises Errno::ECHILD do +@@ -29,6 +30,30 @@ def test_traverse_parents + loop { break if enum.next.nil? } # exhaust the enumerator + end + ++ def test_traverse_parents_does_not_crash_on_permissions_error ++ skip 'skipped on MS Windows (chmod has no effect)' if win_platform? ++ ++ FileUtils.mkdir_p 'd/e/f' ++ # remove 'execute' permission from "e" directory and make it ++ # impossible to cd into it and its children ++ FileUtils.chmod(0666, 'd/e') ++ ++ paths = Gem::Util.traverse_parents('d/e/f').to_a ++ ++ assert_equal File.join(@tempdir, 'd'), paths[0] ++ assert_equal @tempdir, paths[1] ++ if File.respond_to?(:realpath) ++ assert_equal File.realpath(Dir.tmpdir), paths[2] ++ assert_equal File.realpath("..", Dir.tmpdir), paths[3] ++ elsif RUBY_PLATFORM !~ /darwin/ ++ assert_equal Dir.tmpdir, paths[2] ++ assert_equal '/', paths[3] ++ end ++ ensure ++ # restore default permissions, allow the directory to be removed ++ FileUtils.chmod(0775, 'd/e') unless win_platform? ++ end ++ + def test_linked_list_find + list = [1,2,3,4,5].inject(Gem::List.new(0)) { |m,o| + Gem::List.new o, m +diff --git test/rubygems/test_gem_version.rb test/rubygems/test_gem_version.rb +index 56c818663e..792ad5f084 100644 +--- test/rubygems/test_gem_version.rb ++++ test/rubygems/test_gem_version.rb +@@ -2,6 +2,8 @@ + require 'rubygems/test_case' + require "rubygems/version" + ++require "minitest/benchmark" ++ + class TestGemVersion < Gem::TestCase + + class V < ::Gem::Version +@@ -102,6 +104,15 @@ def test_initialize_invalid + end + end + ++ def bench_anchored_version_pattern ++ assert_performance_linear 0.5 do |count| ++ version_string = count.times.map {|i| "0" * i.succ }.join(".") << "." ++ version_string =~ Gem::Version::ANCHORED_VERSION_PATTERN ++ end ++ rescue RegexpError ++ skip "It fails to allocate the memory for regex pattern of Gem::Version::ANCHORED_VERSION_PATTERN" ++ end ++ + def test_empty_version + ["", " ", " "].each do |empty| + assert_equal "0", Gem::Version.new(empty).version +diff --git test/rubygems/test_require.rb test/rubygems/test_require.rb +index a846f46833..e292ce226d 100644 +--- test/rubygems/test_require.rb ++++ test/rubygems/test_require.rb +@@ -38,18 +38,6 @@ def assert_require(path) + assert require(path), "'#{path}' was already required" + end + +- def append_latch spec +- dir = spec.gem_dir +- Dir.chdir dir do +- spec.files.each do |file| +- File.open file, 'a' do |fp| +- fp.puts "FILE_ENTERED_LATCH.release" +- fp.puts "FILE_EXIT_LATCH.await" +- end +- end +- end +- end +- + # Providing -I on the commandline should always beat gems + def test_dash_i_beats_gems + a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb" +@@ -80,6 +68,17 @@ def test_dash_i_beats_gems + Object.send :remove_const, :HELLO if Object.const_defined? :HELLO + end + ++ def create_sync_thread ++ Thread.new do ++ begin ++ yield ++ ensure ++ FILE_ENTERED_LATCH.release ++ FILE_EXIT_LATCH.await ++ end ++ end ++ end ++ + def test_concurrent_require + skip 'deadlock' if /^1\.8\./ =~ RUBY_VERSION + +@@ -91,11 +90,8 @@ def test_concurrent_require + + install_specs a1, b1 + +- append_latch a1 +- append_latch b1 +- +- t1 = Thread.new { assert_require 'a' } +- t2 = Thread.new { assert_require 'b' } ++ t1 = create_sync_thread{ assert_require 'a' } ++ t2 = create_sync_thread{ assert_require 'b' } + + # wait until both files are waiting on the exit latch + FILE_ENTERED_LATCH.await +@@ -106,10 +102,8 @@ def test_concurrent_require + assert t1.join, "thread 1 should exit" + assert t2.join, "thread 2 should exit" + ensure +- return if $! # skipping +- +- Object.send :remove_const, :FILE_ENTERED_LATCH +- Object.send :remove_const, :FILE_EXIT_LATCH ++ Object.send :remove_const, :FILE_ENTERED_LATCH if Object.const_defined? :FILE_ENTERED_LATCH ++ Object.send :remove_const, :FILE_EXIT_LATCH if Object.const_defined? :FILE_EXIT_LATCH + end + + def test_require_is_not_lazy_with_exact_req diff --git a/rubygems.attr b/rubygems.attr new file mode 100644 index 0000000..5793bf7 --- /dev/null +++ b/rubygems.attr @@ -0,0 +1,6 @@ +%__rubygems_requires %{_rpmconfigdir}/rubygems.req +%__rubygems_provides %{_rpmconfigdir}/rubygems.prov +%__rubygems_conflicts %{_rpmconfigdir}/rubygems.con +# In non-gem packages, the %%{gem_name} macro is not available and the macro +# stays unexpanded which leads to "invalid regex" error (rhbz#1154067). +%__rubygems_path ^%{?gem_name:%{gem_spec}}%{!?gem_name:this_should_never_match_anything}$ diff --git a/rubygems.con b/rubygems.con new file mode 100644 index 0000000..1a99ed0 --- /dev/null +++ b/rubygems.con @@ -0,0 +1,52 @@ +#!/usr/bin/ruby + +require 'rubygems/package' + +module RubyGemsReq + module Helpers + # Keep only '!=' requirements. + def self.conflicts(requirements) + conflicts = requirements.select {|r| r.first == '!='} + end + + # Converts Gem::Requirement into array of requirements strings compatible + # with RPM .spec file. + def self.requirement_versions_to_rpm(requirement) + self.conflicts(requirement.requirements).map do |op, version| + version == Gem::Version.new(0) ? "" : "= #{version}" + end + end + end + + # Report conflicting gem dependencies including their version. + def self.gem_depenencies(specification) + specification.runtime_dependencies.each do |dependency| + conflict_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement| + requirement_string = "rubygem(#{dependency.name}) #{requirement}" + end + if conflict_strings.length > 0 + conflict_string = conflict_strings.join(' with ') + conflict_string.prepend('(').concat(')') if conflict_strings.length > 1 + puts conflict_string + end + end + end + + # Reports all conflicts specified by all provided .gemspec files. + def self.conflicts + while filename = gets + filename.strip! + begin + specification = Gem::Specification.load filename + + gem_depenencies(specification) + rescue => e + # Ignore all errors. + end + end + end +end + +if __FILE__ == $0 + RubyGemsReq::conflicts +end diff --git a/rubygems.prov b/rubygems.prov new file mode 100644 index 0000000..b7c9777 --- /dev/null +++ b/rubygems.prov @@ -0,0 +1,36 @@ +#!/usr/bin/ruby + +require 'rubygems/package' + +module RubyGemsProv + module Helpers + # If there is some prelease version files, such as rc1 (i.e. non-numeric + # field), prepend this field by tilde instead of dot. + def self.normalize_prerelease(version) + if version.prerelease? + prerelease = version.version.sub /^#{version.release}\./, '' + "#{version.release}-0.1.#{prerelease}" + else + "#{version.release}-1" + end + end + end + + # Reports all functionality gem provides. + def self.provides + while filename = gets + filename.strip! + begin + specification = Gem::Specification.load filename + + puts "rubygem(#{specification.name}) = #{Helpers::normalize_prerelease(specification.version)}" + rescue => e + # Ignore all errors. + end + end + end +end + +if __FILE__ == $0 + RubyGemsProv::provides +end diff --git a/rubygems.req b/rubygems.req new file mode 100644 index 0000000..6868bdd --- /dev/null +++ b/rubygems.req @@ -0,0 +1,78 @@ +#!/usr/bin/ruby + +require 'rubygems/package' + +module RubyGemsReq + module Helpers + # Expands '~>' and '!=' gem requirements. + def self.expand_requirement(requirements) + requirements.inject([]) do |output, r| + output.concat case r.first + when '~>' + expand_pessimistic_requirement(r) + when '!=' + [] + else + [r] + end + end.reject {|r| r.empty? } + end + + # Expands the pessimistic version operator '~>' into equivalent '>=' and + # '<' pair. + def self.expand_pessimistic_requirement(requirement) + next_version = Gem::Version.create(requirement.last).bump + return ['>=', requirement.last], ['<', next_version] + end + + # Converts Gem::Requirement into array of requirements strings compatible + # with RPM .spec file. + def self.requirement_versions_to_rpm(requirement) + self.expand_requirement(requirement.requirements).map do |op, version| + version == Gem::Version.new(0) ? "" : "#{op} #{version}" + end + end + end + + # Report RubyGems dependency, versioned if required. + def self.rubygems_dependency(specification) + Helpers::requirement_versions_to_rpm(specification.required_rubygems_version).each do |requirement| + dependency_string = "ruby(rubygems)" + dependency_string += " #{specification.required_rubygems_version}" if requirement&.length > 0 + puts dependency_string + end + end + + # Report all gem dependencies including their version. + def self.gem_depenencies(specification) + specification.runtime_dependencies.each do |dependency| + dependency_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement| + requirement_string = "rubygem(#{dependency.name})" + requirement_string += " #{requirement}" if requirement&.length > 0 + requirement_string + end + dependency_string = dependency_strings.join(' with ') + dependency_string.prepend('(').concat(')') if dependency_strings.length > 1 + puts dependency_string + end + end + + # Reports all requirements specified by all provided .gemspec files. + def self.requires + while filename = gets + filename.strip! + begin + specification = Gem::Specification.load filename + + rubygems_dependency(specification) + gem_depenencies(specification) + rescue => e + # Ignore all errors. + end + end + end +end + +if __FILE__ == $0 + RubyGemsReq::requires +end diff --git a/test_dependent_scls.rb b/test_dependent_scls.rb deleted file mode 100644 index bff74d0..0000000 --- a/test_dependent_scls.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'test/unit' -require 'rbconfig' -require 'rubygems' -require 'rubygems/defaults/operating_system' - -class TestDependentSCLS < Test::Unit::TestCase - - def setup - # TODO: Different bin dir during build ("/builddir/build/BUILD/ruby-2.0.0-p247") - @bin_dir = Gem::ConfigMap[:bindir].split(File::SEPARATOR).last - @scl_root = '/opt/rh/@SCL@/root' - - @env_orig = ['X_SCLS', 'GEM_PATH'].inject({}) do |env_orig, key| - env_orig[key] = ENV[key].dup - env_orig - end - end - - def teardown - # Avoid caching - Gem.class_eval("@x_scls, @default_locations, @default_dirs, @get_default_dirs = nil, nil, nil, nil") - - @env_orig.each { |key, val| ENV[key] = val } - end - - def test_default_paths - ENV['X_SCLS'] = '@SCL@' # enabled scls - - default_locations = { :system => "#{@scl_root}/usr", - :local => "#{@scl_root}/usr/local" } - assert_equal default_locations, Gem.default_locations - - default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/share/gems", - :ext_dir => "#{@scl_root}/usr/lib64/gems" }, - :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/local/share/gems", - :ext_dir => "#{@scl_root}/usr/local/lib64/gems" } } - assert_equal default_dirs, Gem.default_dirs - end - - # Gem.default_locations and Gem.default_dirs - # should contain paths to dependent scls binary extensions - # if the dependent scl adds itself on $GEM_PATH - # - # See rhbz#1034639 - def test_paths_with_dependent_scl - test_scl = 'ruby_x' - test_root = "/some/prefix/#{test_scl}/root" - - ENV['X_SCLS'] = "@SCL@ #{test_scl}" # enabled scls - ENV['GEM_PATH'] = "#{test_root}/usr/share/gems" - - default_locations = { :system => "#{@scl_root}/usr", - :local => "#{@scl_root}/usr/local", - :"#{test_scl}_system" => "#{test_root}/usr", - :"#{test_scl}_local" => "#{test_root}/usr/local" } - assert_equal default_locations, Gem.default_locations - - default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/share/gems", - :ext_dir => "#{@scl_root}/usr/lib64/gems" }, - :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/local/share/gems", - :ext_dir => "#{@scl_root}/usr/local/lib64/gems" }, - :"#{test_scl}_system" => { :bin_dir => "#{test_root}/usr/#{@bin_dir}", - :gem_dir => "#{test_root}/usr/share/gems", - :ext_dir => "#{test_root}/usr/lib64/gems" }, - :"#{test_scl}_local" => { :bin_dir => "#{test_root}/usr/local/#{@bin_dir}", - :gem_dir => "#{test_root}/usr/local/share/gems", - :ext_dir => "#{test_root}/usr/local/lib64/gems" } } - assert_equal default_dirs, Gem.default_dirs - end - - def test_empty_x_scls - ENV['X_SCLS'] = nil # no enabled scls - - default_locations = { :system => "#{@scl_root}/usr", - :local => "#{@scl_root}/usr/local" } - assert_equal default_locations, Gem.default_locations - - default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/share/gems", - :ext_dir => "#{@scl_root}/usr/lib64/gems" }, - :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", - :gem_dir => "#{@scl_root}/usr/local/share/gems", - :ext_dir => "#{@scl_root}/usr/local/lib64/gems" } } - assert_equal default_dirs, Gem.default_dirs - end - -end