fix build error by upgrading to ruby3

(cherry picked from commit 338907f235eb730548c956dce46f3145f0b04aa0)
This commit is contained in:
chen-jan 2022-02-22 09:47:47 +08:00 committed by openeuler-sync-bot
parent f9a5c3c5c7
commit 2cfd0c8ec9
2 changed files with 65 additions and 6 deletions

View File

@ -0,0 +1,52 @@
From 975e87883a4f65966df59a5e757f03b66dd7e571 Mon Sep 17 00:00:00 2001
From: Hans de Graaff <hans@degraaff.org>
Date: Mon, 29 Apr 2019 18:41:35 +0200
Subject: [PATCH] Rewrite unix fork reopen to be compatible with ruby 2.6
On ruby 2.6 the original code would fail specs:
lib/childprocess/unix/fork_exec_process.rb:32:in `reopen': exclusive
access mode is not supported (ArgumentError)
The documentation for reopen shows that it has two ways to call it:
reopen(other_IO) -> ios
reopen(path, mode [,opt]) -> ios
With ruby 2.4 and 2.5 calling reopen with a path and no mode seems to
work fine, but with ruby 2.6 this triggers the spec failure.
This commit splits the calls based on stdout/stderr availability so
that both types of reopen calls can get the required parameters. This
fixes the 2.6 specs while being backward compatible with ruby 2.4 and
2.5.
---
lib/childprocess/unix/fork_exec_process.rb | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/childprocess/unix/fork_exec_process.rb b/lib/childprocess/unix/fork_exec_process.rb
index 5ed2a79..cc7a850 100644
--- a/lib/childprocess/unix/fork_exec_process.rb
+++ b/lib/childprocess/unix/fork_exec_process.rb
@@ -29,8 +29,16 @@ module ChildProcess
exec_r.close
set_env
- STDOUT.reopen(stdout || "/dev/null")
- STDERR.reopen(stderr || "/dev/null")
+ if stdout
+ STDOUT.reopen(stdout)
+ else
+ STDOUT.reopen("/dev/null", "a+")
+ end
+ if stderr
+ STDERR.reopen(stderr)
+ else
+ STDERR.reopen("/dev/null", "a+")
+ end
if duplex?
STDIN.reopen(reader)
--
2.33.0

View File

@ -2,11 +2,12 @@
Summary: A simple and reliable gem for controlling external programs Summary: A simple and reliable gem for controlling external programs
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 0.5.9 Version: 0.5.9
Release: 1 Release: 2
License: MIT License: MIT
URL: http://github.com/enkessler/childprocess URL: http://github.com/enkessler/childprocess
Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem
BuildRequires: rubygems-devel rubygem(rspec) >= 3 Patch1: Rewrite-unix-fork-reopen-to-be-compatible-with-ruby-.patch
BuildRequires: rubygems-devel rubygem(rspec) >= 3 rubygem(did_you_mean)
BuildArch: noarch BuildArch: noarch
%description %description
This gem aims at being a simple and reliable solution for controlling external This gem aims at being a simple and reliable solution for controlling external
@ -20,10 +21,13 @@ BuildArch: noarch
Documentation for %{name} Documentation for %{name}
%prep %prep
%setup -q -c -T %setup -q -n %{gem_name}-%{version}
%gem_install -n %{SOURCE0}
%patch1 -p1
%build %build
gem build ../%{gem_name}-%{version}.gemspec
%gem_install
%install %install
mkdir -p %{buildroot}%{gem_dir} mkdir -p %{buildroot}%{gem_dir}
@ -56,5 +60,8 @@ popd
%doc %doc %{gem_docdir} %doc %doc %{gem_docdir}
%changelog %changelog
* Tue Feb 22 2022 chenchen <chen_aka_jan@163.com> - 0.5.9-2
- fix build error caused by upgrading to ruby3
* Tue Aug 18 2020 wanglin <wanglin175@huawei.com> - 0.5.9-1 * Tue Aug 18 2020 wanglin <wanglin175@huawei.com> - 0.5.9-1
- package init - package init