uricp 0.0.34 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/features/cacheable_from_uri.feature +8 -0
- data/features/step_definitions/uricp_steps.rb +11 -2
- data/lib/uricp/curl_primitives.rb +2 -2
- data/lib/uricp/strategy/common.rb +15 -2
- data/lib/uricp/strategy/{piped_decompress.rb → piped_decompress_lz4.rb} +1 -1
- data/lib/uricp/strategy/piped_decompress_xz.rb +33 -0
- data/lib/uricp/strategy/piped_remote_get.rb +1 -1
- data/lib/uricp/uri_strategy.rb +2 -1
- data/lib/uricp/version.rb +1 -1
- data/lib/uricp.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdf0146a9045790fac899c6fd9dd0a2de8d77d8ed5f6e8d652c994ae12bcd5f7
|
4
|
+
data.tar.gz: 6c5b2e4b0f7b210f74f56b0fca2a6ab1ada244110d82f2dba06fab7bd2aefef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d1e3ed8d8eda28f56714cf79785a28d2b0733c1f16fe6e2c3d30e4a30fcd6f8f046e275776f7243f43179b281c6966211c1f32192c446a85df6e9453e1e2ee
|
7
|
+
data.tar.gz: d389fd727dde31846e9cdd0f18b0eddb2cba12ef476fdd61819a271caf1bf77afb83f96ba83c9f21c3433f9fb1adaf412a77914028aee416c94d3ac37e527072
|
data/Gemfile.lock
CHANGED
@@ -73,6 +73,14 @@ Feature: Download Public VM images
|
|
73
73
|
Then a 102400 byte file named "/tmp/uricp/srv-testy" should exist
|
74
74
|
And a 102400 byte file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
75
75
|
|
76
|
+
Scenario: HTTP URI raw.xz to raw via cache
|
77
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
78
|
+
When I successfully run `uricp --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.raw.xz file:///tmp/uricp/srv-testy`
|
79
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
80
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "raw"
|
81
|
+
And a file named "/tmp/uricp/cache/freedos.raw.xz" should exist
|
82
|
+
And the file named "/tmp/uricp/cache/freedos.raw.xz" should have a file format of "xz"
|
83
|
+
|
76
84
|
Scenario: Unsupported source URI should error
|
77
85
|
Given a correctly initialised cache at "/tmp/uricp"
|
78
86
|
When I run `uricp --target-format=raw --cache=/tmp/uricp wibble://some/url file:///tmp/uricp/srv-testy`
|
@@ -2,9 +2,14 @@ Then(/^the file named "(.*?)" should have a file format of "(.*?)"$/) do |filena
|
|
2
2
|
case format
|
3
3
|
when 'lz4'
|
4
4
|
assert_exact_output(
|
5
|
-
[
|
5
|
+
%w[04224d18].pack('H8'),
|
6
6
|
File.open(filename, 'rb') { |f| f.read(4) } || String.new
|
7
7
|
)
|
8
|
+
when 'xz'
|
9
|
+
assert_exact_output(
|
10
|
+
%w[fd377a585a00].pack('H12'),
|
11
|
+
File.open(filename, 'rb') { |f| f.read(6) } || String.new
|
12
|
+
)
|
8
13
|
when 'qcow2v3', 'qcow3'
|
9
14
|
steps %{
|
10
15
|
When I successfully run `qemu-img info #{filename}`
|
@@ -13,9 +18,13 @@ Then(/^the file named "(.*?)" should have a file format of "(.*?)"$/) do |filena
|
|
13
18
|
}
|
14
19
|
else
|
15
20
|
assert_no_partial_output(
|
16
|
-
[
|
21
|
+
%w[04224d18].pack('H8'),
|
17
22
|
File.open(filename, 'rb') { |f| f.read(4) } || String.new
|
18
23
|
)
|
24
|
+
assert_no_partial_output(
|
25
|
+
%w[fd377a585a00].pack('H12'),
|
26
|
+
File.open(filename, 'rb') { |f| f.read(6) } || String.new
|
27
|
+
)
|
19
28
|
steps(%{
|
20
29
|
When I successfully run `qemu-img info #{filename}`
|
21
30
|
Then the output from "qemu-img info #{filename}" should contain "file format: #{format}"
|
@@ -42,7 +42,7 @@ module Uricp::CurlPrimitives
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def curl_upload_from(source, destination = to)
|
45
|
-
"#{curl_command} #{authentication} -T '#{source}' '#{destination}';"
|
45
|
+
"#{curl_command} #{authentication} -H 'Content-Type: application/octet-stream' -T '#{source}' '#{destination}';"
|
46
46
|
end
|
47
47
|
|
48
48
|
def curl_download_to_pipe
|
@@ -50,6 +50,6 @@ module Uricp::CurlPrimitives
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def curl_manifest(object_manifest, destination = to)
|
53
|
-
"#{curl_command} #{authentication} -X PUT -H 'X-Object-Manifest: #{object_manifest}' '#{destination}' --data-binary ''"
|
53
|
+
"#{curl_command} #{authentication} -X PUT -H 'Content-Type: application/octet-stream' -H 'X-Object-Manifest: #{object_manifest}' '#{destination}' --data-binary ''"
|
54
54
|
end
|
55
55
|
end
|
@@ -50,6 +50,10 @@ module Uricp::Strategy
|
|
50
50
|
magic.unpack('a3C') == ['QFI', 0xfb]
|
51
51
|
end
|
52
52
|
|
53
|
+
def xz?(magic)
|
54
|
+
magic.unpack('H12') == %w[fd377a585a00]
|
55
|
+
end
|
56
|
+
|
53
57
|
def encoding(io)
|
54
58
|
magic = io.read(4).to_s
|
55
59
|
if lz4?(magic)
|
@@ -65,7 +69,12 @@ module Uricp::Strategy
|
|
65
69
|
:qcow2un
|
66
70
|
end
|
67
71
|
else
|
68
|
-
|
72
|
+
magic += io.read(2).to_s
|
73
|
+
if xz?(magic)
|
74
|
+
:xz
|
75
|
+
else
|
76
|
+
:raw
|
77
|
+
end
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
@@ -83,6 +92,10 @@ module Uricp::Strategy
|
|
83
92
|
options['source-format'] == :lz4
|
84
93
|
end
|
85
94
|
|
95
|
+
def xz_source?
|
96
|
+
options['source-format'] == :xz
|
97
|
+
end
|
98
|
+
|
86
99
|
def raw_target?
|
87
100
|
options['target-format'] == :raw
|
88
101
|
end
|
@@ -120,7 +133,7 @@ module Uricp::Strategy
|
|
120
133
|
end
|
121
134
|
|
122
135
|
def supported_source?
|
123
|
-
options['source-format'] && !lz4_source?
|
136
|
+
options['source-format'] && !lz4_source? && !xz_source?
|
124
137
|
end
|
125
138
|
|
126
139
|
def rbd_image_spec(uri)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Uricp::Strategy
|
4
|
+
class PipedDecompressXz
|
5
|
+
include Uricp::Strategy::Common
|
6
|
+
|
7
|
+
def appropriate?
|
8
|
+
case from.scheme
|
9
|
+
when 'pipe'
|
10
|
+
return proposal if xz_source?
|
11
|
+
end
|
12
|
+
debug "#{self.class.name}: not appropriate"
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def command
|
17
|
+
'xz -d |'
|
18
|
+
end
|
19
|
+
|
20
|
+
def proposal
|
21
|
+
@proposed_options = options.dup
|
22
|
+
@proposed_options.delete('source-format')
|
23
|
+
if @proposed_options['target-format']
|
24
|
+
@proposed_options['source-format'] = :raw
|
25
|
+
if @proposed_options['source-format'] == @proposed_options['target-format']
|
26
|
+
@proposed_options.delete('source-format')
|
27
|
+
@proposed_options.delete('target-format')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -59,7 +59,7 @@ module Uricp::Strategy
|
|
59
59
|
|
60
60
|
size_headers = headers
|
61
61
|
size_headers['Range'] = 'bytes=0-0'
|
62
|
-
options['from_uri'].open(
|
62
|
+
options['from_uri'].open(size_headers) do |u|
|
63
63
|
match = %r{bytes\s+(\d+)-(\d+)/(\d+|\*)}i.match(u.meta['content-range'])
|
64
64
|
match && match[3].to_i
|
65
65
|
end
|
data/lib/uricp/uri_strategy.rb
CHANGED
@@ -37,7 +37,8 @@ module Uricp
|
|
37
37
|
Strategy::PipedCacheConvert,
|
38
38
|
Strategy::PipedCache,
|
39
39
|
Strategy::PipedLocalDecompress,
|
40
|
-
Strategy::
|
40
|
+
Strategy::PipedDecompressLz4,
|
41
|
+
Strategy::PipedDecompressXz,
|
41
42
|
Strategy::LocalConvert,
|
42
43
|
Strategy::LocalLink,
|
43
44
|
Strategy::PipedCompress,
|
data/lib/uricp/version.rb
CHANGED
data/lib/uricp.rb
CHANGED
@@ -16,7 +16,8 @@ require 'uricp/strategy/local_link'
|
|
16
16
|
require 'uricp/strategy/piped_cache'
|
17
17
|
require 'uricp/strategy/piped_cache_convert'
|
18
18
|
require 'uricp/strategy/piped_compress'
|
19
|
-
require 'uricp/strategy/
|
19
|
+
require 'uricp/strategy/piped_decompress_lz4'
|
20
|
+
require 'uricp/strategy/piped_decompress_xz'
|
20
21
|
require 'uricp/strategy/piped_local_compress'
|
21
22
|
require 'uricp/strategy/piped_local_decompress'
|
22
23
|
require 'uricp/strategy/piped_local_get'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uricp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.36
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -202,7 +202,8 @@ files:
|
|
202
202
|
- lib/uricp/strategy/piped_cache.rb
|
203
203
|
- lib/uricp/strategy/piped_cache_convert.rb
|
204
204
|
- lib/uricp/strategy/piped_compress.rb
|
205
|
-
- lib/uricp/strategy/
|
205
|
+
- lib/uricp/strategy/piped_decompress_lz4.rb
|
206
|
+
- lib/uricp/strategy/piped_decompress_xz.rb
|
206
207
|
- lib/uricp/strategy/piped_local_compress.rb
|
207
208
|
- lib/uricp/strategy/piped_local_decompress.rb
|
208
209
|
- lib/uricp/strategy/piped_local_get.rb
|