cangallo 0.0.2.1 → 0.0.3
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 +4 -4
- data/lib/cangallo/libguestfs.rb +49 -2
- data/lib/cangallo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21b6ff98e9fcbbf383de70f0f06f9863e45a84b
|
4
|
+
data.tar.gz: c383ca0b87759da70f78a982f52b899c3b22e0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a58a2b3f477cf582c334b6920a3dc4b22991f901a111fa78818862830f83296e15510b113457fc2502e237fdc30511234fe50478a554ff5f2fe2d6c80c8df87e
|
7
|
+
data.tar.gz: 0c4ad7d347a66d809cf748d76f0392e1db07f92ed49438e0a23b04fb1ab6ae6d3f645b7136e7cd4830bc3cd97abee5f5185f5474bd8af4395ea0d346236c4da9
|
data/lib/cangallo/libguestfs.rb
CHANGED
@@ -25,6 +25,8 @@ require 'rubygems'
|
|
25
25
|
class Cangallo
|
26
26
|
|
27
27
|
class LibGuestfs
|
28
|
+
CUSTOMIZE_CMD = /^([^\s]+)\s+(.*)$/
|
29
|
+
|
28
30
|
def self.virt_customize(image, commands, params = "")
|
29
31
|
version = self.version
|
30
32
|
|
@@ -50,14 +52,28 @@ class Cangallo
|
|
50
52
|
"--commands-from-file #{cmd_file.path}"
|
51
53
|
else
|
52
54
|
cmd_params = commands.map do |line|
|
53
|
-
m = line.match(
|
55
|
+
m = line.match(CUSTOMIZE_CMD)
|
54
56
|
if m
|
55
|
-
|
57
|
+
command = m[1]
|
58
|
+
parms = m[2].strip
|
59
|
+
|
60
|
+
if command == 'copy-in'
|
61
|
+
command = 'upload'
|
62
|
+
parms, new_command = copy_in(parms)
|
63
|
+
|
64
|
+
[
|
65
|
+
"--" + command + " " + Shellwords.escape(parms),
|
66
|
+
"--run-command " + Shellwords.escape(new_command)
|
67
|
+
]
|
68
|
+
else
|
69
|
+
"--" + command + " " + Shellwords.escape(parms)
|
70
|
+
end
|
56
71
|
else
|
57
72
|
nil
|
58
73
|
end
|
59
74
|
end
|
60
75
|
|
76
|
+
cmd_params.flatten!
|
61
77
|
cmd_params.compact!
|
62
78
|
|
63
79
|
customize_command = "virt-customize -a #{image} #{params.join(" ")} " <<
|
@@ -88,5 +104,36 @@ class Cangallo
|
|
88
104
|
nil
|
89
105
|
end
|
90
106
|
end
|
107
|
+
|
108
|
+
def self.copy_in(str)
|
109
|
+
local, remote = str.split(':')
|
110
|
+
|
111
|
+
raise "Source '#{local}' does not exist" if !File.exist?(local)
|
112
|
+
|
113
|
+
upload_local = local
|
114
|
+
upload_remote = remote
|
115
|
+
run_command = nil
|
116
|
+
|
117
|
+
if File.directory?(local)
|
118
|
+
upload_local_tmp = Tempfile.new("canga")
|
119
|
+
upload_local_tmp.close
|
120
|
+
|
121
|
+
upload_local = upload_local_tmp.path
|
122
|
+
upload_remote = "/tmp/#{File.basename(upload_local)}"
|
123
|
+
|
124
|
+
|
125
|
+
local_parent_dir = File.dirname(local)
|
126
|
+
local_name = File.basename(local)
|
127
|
+
rc = system("tar czf #{upload_local} -C #{local_parent_dir} #{local_name}")
|
128
|
+
|
129
|
+
raise "Error creating tar archive for '#{local_name}'" if !rc
|
130
|
+
|
131
|
+
run_command = "tar xf #{upload_remote} -C #{remote}"
|
132
|
+
end
|
133
|
+
|
134
|
+
upload_param = "#{upload_local}:#{upload_remote}"
|
135
|
+
|
136
|
+
return upload_param, run_command
|
137
|
+
end
|
91
138
|
end
|
92
139
|
end
|
data/lib/cangallo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cangallo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Fontan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- lib/cangallo/qcow2.rb
|
55
55
|
- lib/cangallo/repo.rb
|
56
56
|
- lib/cangallo/version.rb
|
57
|
-
homepage:
|
57
|
+
homepage: https://canga.io
|
58
58
|
licenses:
|
59
59
|
- Apache-2.0
|
60
60
|
metadata: {}
|