Gentoo Archives: gentoo-commits

From: Hans de Graaff <graaff@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-ruby/net-scp/files/, dev-ruby/net-scp/
Date: Sat, 03 Mar 2018 07:28:42
Message-Id: 1520061047.bd4c29444ea46119e70dcc842b5f4b0630167ccf.graaff@gentoo
1 commit: bd4c29444ea46119e70dcc842b5f4b0630167ccf
2 Author: Oz N Tiram <oz.tiram <AT> gmail <DOT> com>
3 AuthorDate: Mon Jan 22 07:59:55 2018 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 3 07:10:47 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bd4c2944
7
8 dev-ruby/net-scp: add ruby version 2.4
9
10 This ebuild also corrects the tests to pass
11 with net-ssh-4.0 or later.
12
13 The patches are taken from
14
15 https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-net-sftp.git/
16
17 And from git commits following version 1.2.1 in upstream.
18
19 Bug: https://bugs.gentoo.org/643990
20 Package-Manager: Portage-2.3.19, Repoman-2.3.6
21
22 .../net-scp/files/net-scp-1.2.1-fix-common.path | 28 ++++++++
23 .../files/net-scp-1.2.1-fix-download_test.patch | 21 ++++++
24 .../files/net-scp-1.2.1-fix-download_test_2.patch | 25 +++++++
25 .../files/net-scp-1.2.1-fix-download_test_3.patch | 15 ++++
26 .../files/net-scp-1.2.1-fix-upload_tests.patch | 14 ++++
27 ...1-raise-correct-errors-net-ssh-4.0-compat.patch | 30 ++++++++
28 .../files/net-scp-1.2.1-raise-correct-errors.patch | 80 ++++++++++++++++++++++
29 dev-ruby/net-scp/net-scp-1.2.1-r1.ebuild | 47 +++++++++++++
30 8 files changed, 260 insertions(+)
31
32 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-fix-common.path b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-common.path
33 new file mode 100644
34 index 00000000000..ee262d238cb
35 --- /dev/null
36 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-common.path
37 @@ -0,0 +1,28 @@
38 +--- test/common.rb 2018-01-21 16:23:07.384173147 +0100
39 ++++ test/common.rb 2018-01-21 16:20:34.084172782 +0100
40 +@@ -1,11 +1,11 @@
41 + require 'test/unit'
42 + require 'mocha/setup'
43 +
44 +-begin
45 +- gem 'net-ssh', ">= 2.0.0"
46 +- require 'net/ssh'
47 +-rescue LoadError
48 +- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../net-ssh/lib"
49 ++#begin
50 ++# #gem 'net-ssh', ">= 2.0.0"
51 ++# require 'net/ssh'
52 ++#rescue LoadError
53 ++# $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../net-ssh/lib"
54 +
55 + begin
56 + require 'net/ssh'
57 +@@ -14,7 +14,7 @@
58 + rescue LoadError => e
59 + abort "could not load net/ssh v2 (#{e.inspect})"
60 + end
61 +-end
62 ++#end
63 +
64 + $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
65 +
66
67 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test.patch
68 new file mode 100644
69 index 00000000000..a138fcdb557
70 --- /dev/null
71 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test.patch
72 @@ -0,0 +1,21 @@
73 +--- test/test_download.rb 2018-01-22 02:08:00.000013728 +0100
74 ++++ test/test_download.rb.1 2018-01-22 02:11:49.820014276 +0100
75 +@@ -70,12 +70,12 @@
76 + end
77 +
78 + error = nil
79 +- assert_scripted do
80 +- begin
81 +- scp.download!("/path/to/remote.txt")
82 +- rescue
83 +- error = $!
84 +- end
85 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
86 ++ begin
87 ++ scp.download!("/path/to/remote.txt")
88 ++ rescue
89 ++ error = $!
90 ++ end
91 + end
92 + assert_equal Net::SCP::Error, error.class
93 + assert_equal "SCP did not finish successfully (1): File not found: /path/to/remote.txt\n", error.message
94
95 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_2.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_2.patch
96 new file mode 100644
97 index 00000000000..55a8e5f16bc
98 --- /dev/null
99 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_2.patch
100 @@ -0,0 +1,25 @@
101 +--- test/test_download.rb 2018-01-22 02:26:56.440016436 +0100
102 ++++ test/test_download.rb 2018-01-22 02:32:46.076017270 +0100
103 +@@ -116,7 +116,9 @@
104 +
105 + def test_download_io_with_recursive_should_raise_error
106 + expect_scp_session "-f -r /path/to/remote.txt"
107 +- assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
108 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
109 ++ assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
110 ++ end
111 + end
112 +
113 + def test_download_io_with_preserve_should_ignore_preserve
114 +@@ -154,8 +156,9 @@
115 + channel.sends_ok
116 + channel.gets_data "D0755 0 remote\n"
117 + end
118 +-
119 +- assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
120 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
121 ++ assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
122 ++ end
123 + end
124 +
125 + def test_download_should_raise_error_if_gets_not_ok
126
127 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_3.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_3.patch
128 new file mode 100644
129 index 00000000000..12df02c1f00
130 --- /dev/null
131 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-download_test_3.patch
132 @@ -0,0 +1,15 @@
133 +--- test/test_download.rb 2018-01-22 02:35:45.200017696 +0100
134 ++++ test/test_download.rb.1 2018-01-22 02:38:40.000018113 +0100
135 +@@ -217,8 +217,10 @@
136 + channel.gets_data "E\n"
137 + channel.sends_ok
138 + end
139 +-
140 +- scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
141 ++
142 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
143 ++ scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
144 ++ end
145 + assert_equal "a" * 1234, file.io.string
146 + end
147 +
148
149 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-fix-upload_tests.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-upload_tests.patch
150 new file mode 100644
151 index 00000000000..73c34359afc
152 --- /dev/null
153 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-fix-upload_tests.patch
154 @@ -0,0 +1,14 @@
155 +--- test/test_upload.rb 2018-01-22 08:15:30.996002204 +0100
156 ++++ test/test_upload.rb.1 2018-01-22 08:18:09.328002581 +0100
157 +@@ -155,8 +155,9 @@
158 + expect_scp_session("-t /path/to/remote") do |channel|
159 + channel.gets_ok
160 + end
161 +-
162 +- assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") }
163 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
164 ++ assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") }
165 ++ end
166 + end
167 +
168 + def test_upload_empty_directory_should_create_directory_and_finish
169
170 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors-net-ssh-4.0-compat.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors-net-ssh-4.0-compat.patch
171 new file mode 100644
172 index 00000000000..3431f06b7cf
173 --- /dev/null
174 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors-net-ssh-4.0-compat.patch
175 @@ -0,0 +1,30 @@
176 +--- test/test_download.rb 2018-01-22 01:47:38.932010818 +0100
177 ++++ test/test_download.rb.1 2018-01-22 01:49:14.552011046 +0100
178 +@@ -205,9 +205,11 @@
179 + channel.sends_ok
180 + channel.gets_data "\1"
181 + end
182 +-
183 +- e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
184 +- assert_equal("\1", e.message)
185 ++
186 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
187 ++ e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
188 ++ assert_equal("\1", e.message)
189 ++ end
190 + end
191 +
192 + def test_download_directory_should_raise_error_if_local_exists_and_is_not_directory
193 +@@ -223,8 +225,10 @@
194 + channel.sends_ok
195 + end
196 +
197 +- e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote", "/path/to/local", :recursive => true) }
198 +- assert_match(/exists and is not a directory/, e.message)
199 ++ Net::SSH::Test::Extensions::IO.with_test_extension do
200 ++ e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote", "/path/to/local", :recursive => true) }
201 ++ assert_match(/exists and is not a directory/, e.message)
202 ++ end
203 + end
204 +
205 + def test_download_directory_should_create_directory_and_files_locally
206
207 diff --git a/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors.patch b/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors.patch
208 new file mode 100644
209 index 00000000000..a23164ef818
210 --- /dev/null
211 +++ b/dev-ruby/net-scp/files/net-scp-1.2.1-raise-correct-errors.patch
212 @@ -0,0 +1,80 @@
213 +--- README.rdoc
214 ++++ README.rdoc
215 +@@ -42,7 +42,7 @@ In a nutshell:
216 + data = Net::SCP::download!("remote.host.com", "username", "/remote/path")
217 +
218 + # use a persistent connection to transfer files
219 +- Net::SCP.start("remote.host.com", "username", :ssh => { :password => "password" }) do |scp|
220 ++ Net::SCP.start("remote.host.com", "username", :password => "password") do |scp|
221 + # upload a file to a remote server
222 + scp.upload! "/local/path", "/remote/path"
223 +
224 +--- lib/net/scp.rb
225 ++++ lib/net/scp.rb
226 +@@ -395,7 +395,7 @@ module Net
227 + def await_response_state(channel)
228 + return if channel[:buffer].available == 0
229 + c = channel[:buffer].read_byte
230 +- raise "#{c.chr}#{channel[:buffer].read}" if c != 0
231 ++ raise Net::SCP::Error, "#{c.chr}#{channel[:buffer].read}" if c != 0
232 + channel[:next], channel[:state] = nil, channel[:next]
233 + send("#{channel[:state]}_state", channel)
234 + end
235 +--- lib/net/scp/download.rb
236 ++++ lib/net/scp/download.rb
237 +@@ -129,7 +129,7 @@ module Net; class SCP
238 + channel[:local] = File.join(channel[:local], directive[:name])
239 +
240 + if File.exists?(channel[:local]) && !File.directory?(channel[:local])
241 +- raise "#{channel[:local]} already exists and is not a directory"
242 ++ raise Net::SCP::Error, "#{channel[:local]} already exists and is not a directory"
243 + elsif !File.exists?(channel[:local])
244 + Dir.mkdir(channel[:local], directive[:mode] | 0700)
245 + end
246 +@@ -162,4 +162,4 @@ module Net; class SCP
247 + end
248 + end
249 +
250 +-end; end
251 +\ No newline at end of file
252 ++end; end
253 +--- test/test_download.rb
254 ++++ test/test_download.rb
255 +@@ -158,6 +158,37 @@ class TestDownload < Net::SCP::TestCase
256 + assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
257 + end
258 +
259 ++ def test_download_should_raise_error_if_gets_not_ok
260 ++ prepare_file("/path/to/local.txt", "")
261 ++
262 ++ expect_scp_session "-f /path/to/remote.txt" do |channel|
263 ++ channel.sends_ok
264 ++ channel.gets_data "C0666 0 remote.txt\n"
265 ++ channel.sends_ok
266 ++ channel.gets_data "\1"
267 ++ end
268 ++
269 ++ e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
270 ++ assert_equal("\1", e.message)
271 ++ end
272 ++
273 ++ def test_download_directory_should_raise_error_if_local_exists_and_is_not_directory
274 ++ File.stubs(:exists?).with("/path/to/local").returns(true)
275 ++ File.stubs(:exists?).with("/path/to/local/remote").returns(true)
276 ++ File.stubs(:directory?).with("/path/to/local/remote").returns(false)
277 ++
278 ++ expect_scp_session "-f -r /path/to/remote" do |channel|
279 ++ channel.sends_ok
280 ++ channel.gets_data "D0755 0 remote\n"
281 ++ channel.sends_ok
282 ++ channel.gets_data "E\n"
283 ++ channel.sends_ok
284 ++ end
285 ++
286 ++ e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote", "/path/to/local", :recursive => true) }
287 ++ assert_match(/exists and is not a directory/, e.message)
288 ++ end
289 ++
290 + def test_download_directory_should_create_directory_and_files_locally
291 + file = nil
292 + prepare_directory "/path/to/local" do |dir|
293
294 diff --git a/dev-ruby/net-scp/net-scp-1.2.1-r1.ebuild b/dev-ruby/net-scp/net-scp-1.2.1-r1.ebuild
295 new file mode 100644
296 index 00000000000..2d152002dd2
297 --- /dev/null
298 +++ b/dev-ruby/net-scp/net-scp-1.2.1-r1.ebuild
299 @@ -0,0 +1,47 @@
300 +# Copyright 1999-2018 Gentoo Foundation
301 +# Distributed under the terms of the GNU General Public License v2
302 +
303 +EAPI=5
304 +
305 +USE_RUBY="ruby23 ruby24"
306 +
307 +RUBY_FAKEGEM_EXTRADOC="CHANGES.txt README.rdoc"
308 +
309 +RUBY_FAKEGEM_TASK_TEST=""
310 +
311 +inherit ruby-fakegem
312 +
313 +DESCRIPTION="A pure Ruby implementation of the SCP client protocol"
314 +HOMEPAGE="https://github.com/net-ssh/net-scp"
315 +
316 +LICENSE="GPL-2"
317 +SLOT="4"
318 +KEYWORDS="~amd64"
319 +IUSE=""
320 +
321 +RUBY_PATCHES=(
322 + ${P}-raise-correct-errors.patch
323 + ${P}-fix-common.path
324 + ${P}-fix-download_test.patch
325 + ${P}-fix-download_test_2.patch
326 + ${P}-fix-download_test_3.patch
327 + ${P}-fix-upload_tests.patch
328 + ${P}-raise-correct-errors-net-ssh-4.0-compat.patch
329 + )
330 +
331 +ruby_add_bdepend "
332 + doc? ( >=dev-ruby/net-ssh-4.0:4 )
333 + test? (
334 + >=dev-ruby/net-ssh-4.0:4
335 + dev-ruby/mocha
336 + )"
337 +
338 +ruby_add_rdepend ">=dev-ruby/net-ssh-4.0:4"
339 +
340 +all_ruby_prepare() {
341 + sed -i -e 's/>= 2.0.0/~> 2.0/' test/common.rb || die
342 +}
343 +
344 +each_ruby_test() {
345 + ${RUBY} -Ilib:test test/test_all.rb || die
346 +}