uricp 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5646c45d26dfa89933ac2cb28089ac771dff6a43719fcaba2304e741060a0b7f
4
- data.tar.gz: 05172e7eab7420dc2b393ad93328d0250c2ae804b4fb3c1707c87e3f11d5180b
3
+ metadata.gz: f38405ebdde7785ddfaae980ae8ea97a32b886a4778ed373c515355c83645550
4
+ data.tar.gz: 620d2a7673fb0f97e55d96b4fd82b812a43fc0d1fb95e4e3cb3d004966554678
5
5
  SHA512:
6
- metadata.gz: 9a8830466e53007d4f2459a610978fb458e7771e8bdd7af61a69b502b42247b68f98b50801c900d7798437f4e56d4aadfe5ceeb9d4e946856c5c969b043bb1ac
7
- data.tar.gz: 57a7b66754c00b8fd48d4c8149fbbe47357ff9e7033013f9b5f33735c179a7350e1bd815e83ef03d68f8e9323c1615a853fafbe1031ad115f15dd7fa07b89c22
6
+ metadata.gz: d2ea74ee72bb58341219df825766095e2b0a55e57a404d070067b67647cf13aaf9296f0cf3c2933722927260091b954bb56766b89cf0868f184b56131068838c
7
+ data.tar.gz: 259b2b1ec6191447ca65698a780cccc31dce106f8473e88be13a5a4776a808aec04ba0a6467da3c09c0e7470f7fa1d74cedcdd9a06a3ee96636636d88434aa25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uricp (0.0.34)
4
+ uricp (0.0.35)
5
5
  childprocess (~> 1.0)
6
6
  filesize (= 0.0.2)
7
7
  methadone (~> 2.0.2)
@@ -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
- [0x184D2204].pack('V'),
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
- [0x184D2204].pack('V'),
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}"
@@ -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,13 @@ module Uricp::Strategy
65
69
  :qcow2un
66
70
  end
67
71
  else
68
- :raw
72
+ magic += io.read(2).to_s
73
+ puts magic.unpack('H12')
74
+ if xz?(magic)
75
+ :xz
76
+ else
77
+ :raw
78
+ end
69
79
  end
70
80
  end
71
81
 
@@ -83,6 +93,10 @@ module Uricp::Strategy
83
93
  options['source-format'] == :lz4
84
94
  end
85
95
 
96
+ def xz_source?
97
+ options['source-format'] == :xz
98
+ end
99
+
86
100
  def raw_target?
87
101
  options['target-format'] == :raw
88
102
  end
@@ -120,7 +134,7 @@ module Uricp::Strategy
120
134
  end
121
135
 
122
136
  def supported_source?
123
- options['source-format'] && !lz4_source?
137
+ options['source-format'] && !lz4_source? && !xz_source?
124
138
  end
125
139
 
126
140
  def rbd_image_spec(uri)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uricp::Strategy
4
- class PipedDecompress
4
+ class PipedDecompressLz4
5
5
  include Uricp::Strategy::Common
6
6
 
7
7
  def appropriate?
@@ -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
@@ -37,7 +37,8 @@ module Uricp
37
37
  Strategy::PipedCacheConvert,
38
38
  Strategy::PipedCache,
39
39
  Strategy::PipedLocalDecompress,
40
- Strategy::PipedDecompress,
40
+ Strategy::PipedDecompressLz4,
41
+ Strategy::PipedDecompressXz,
41
42
  Strategy::LocalConvert,
42
43
  Strategy::LocalLink,
43
44
  Strategy::PipedCompress,
data/lib/uricp/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uricp
4
- VERSION = '0.0.34'
4
+ VERSION = '0.0.35'
5
5
  DEFAULT_SEGMENT_SIZE = '5 GiB'
6
6
  end
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/piped_decompress'
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.34
4
+ version: 0.0.35
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-10-31 00:00:00.000000000 Z
11
+ date: 2022-11-30 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/piped_decompress.rb
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