vagrant-export 0.3.8 → 0.4.0
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/vagrant-export/exporter.rb +37 -109
- data/lib/vagrant-export/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1122a5f92b1f785a5bc0d32aecaa8081d1bedc3
|
4
|
+
data.tar.gz: eafee68a5a8575bba9adb5c2508aa4b347247cf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2bbed4f4bac8dbf1ed8a63f2dbb82129422cf972ff82edce2dcffd69795b7e9843da9d181cd3ae30a9c3fd09476350e9bcf91cec147001bf86b0cb79302e441
|
7
|
+
data.tar.gz: e01f513a7ce4000e45fbf592ddfdffed942904e69981daa376b7234270792a851074472177c617bfddc359700afeec447655f0e2fd23da649a5225af40017b7b
|
@@ -122,62 +122,6 @@ module VagrantPlugins
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
# Add the private key if we have one
|
127
|
-
# Shamelessly stolen from Vagrant::Action::General::Package
|
128
|
-
def setup_private_key
|
129
|
-
|
130
|
-
# Key generated by vagrant
|
131
|
-
path = @vm.data_dir.join('private_key').to_s
|
132
|
-
|
133
|
-
# Use a different generated key if configured
|
134
|
-
if @private_key != nil
|
135
|
-
path = @private_key.to_s
|
136
|
-
end
|
137
|
-
|
138
|
-
# If we don't have a generated private key, we do nothing
|
139
|
-
return unless File.file?(path)
|
140
|
-
|
141
|
-
# Copy it into our box directory
|
142
|
-
new_path = File.join(@tmp_path, 'private_key')
|
143
|
-
@logger.debug("Copy private key from #{path} to #{new_path}")
|
144
|
-
FileUtils.cp(path, new_path)
|
145
|
-
|
146
|
-
# Append it to the Vagrantfile (or create a Vagrantfile)
|
147
|
-
vf_path = File.join(@tmp_path, 'Vagrantfile')
|
148
|
-
mode = 'w+'
|
149
|
-
|
150
|
-
@logger.debug("Check and add private_key_path setting to #{vf_path}")
|
151
|
-
|
152
|
-
if File.file?(vf_path)
|
153
|
-
mode = 'a'
|
154
|
-
has_private_key_path = false
|
155
|
-
|
156
|
-
@logger.debug('Vagrantfile exists, check for private_key_path')
|
157
|
-
|
158
|
-
File.readlines(vf_path).each { |line|
|
159
|
-
if line.to_s =~ /ssh\.private_key_path/i
|
160
|
-
has_private_key_path = true
|
161
|
-
end
|
162
|
-
}
|
163
|
-
|
164
|
-
if has_private_key_path
|
165
|
-
@logger.debug('Existing Vagrantfile already has a private_key_path setting')
|
166
|
-
return
|
167
|
-
end
|
168
|
-
else
|
169
|
-
@logger.debug('No Vagrantfile found, create one')
|
170
|
-
end
|
171
|
-
|
172
|
-
File.open(vf_path, mode) do |f|
|
173
|
-
f.binmode
|
174
|
-
f.puts
|
175
|
-
f.puts %Q[Vagrant.configure("2") do |config|]
|
176
|
-
f.puts %Q[ config.ssh.private_key_path = File.expand_path("../private_key", __FILE__)]
|
177
|
-
f.puts %Q[end]
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
125
|
def export
|
182
126
|
# Halt the machine
|
183
127
|
if @vm.state.short_description == 'running'
|
@@ -203,11 +147,8 @@ module VagrantPlugins
|
|
203
147
|
|
204
148
|
@logger.debug("Files found in #{current_dir}: #{files}")
|
205
149
|
|
206
|
-
files.select! {|f| !File.directory?(f) }
|
207
|
-
files.select!{ |f| f
|
208
|
-
files.select!{ |f| f !~ /core$/ }
|
209
|
-
files.select!{ |f| f !~ /\.gz$/ }
|
210
|
-
files.select!{ |f| f !~ /.lck$/ }
|
150
|
+
files.select! { |f| !File.directory?(f) }
|
151
|
+
files.select! { |f| f ~ /\.(vmdk|nvram|vmtm|vmx|vmxf)$/ }
|
211
152
|
|
212
153
|
@logger.debug("Copying #{files} to #{exported_path}")
|
213
154
|
|
@@ -216,11 +157,8 @@ module VagrantPlugins
|
|
216
157
|
@vm.ui.info('Compacting Vmware virtual disks')
|
217
158
|
|
218
159
|
Dir.glob(File.join(exported_path, '**', '*.vmdk')) { |f|
|
219
|
-
|
220
|
-
@logger.debug("Running 'vmware-vdiskmanager -d #{f}'")
|
160
|
+
@logger.debug("Compacting disk file #{f}")
|
221
161
|
Vagrant::Util::Subprocess.execute('vmware-vdiskmanager', '-d', f)
|
222
|
-
|
223
|
-
@logger.debug("Running 'vmware-vdiskmanager -k #{f}'")
|
224
162
|
Vagrant::Util::Subprocess.execute('vmware-vdiskmanager', '-k', f)
|
225
163
|
}
|
226
164
|
|
@@ -275,60 +213,50 @@ module VagrantPlugins
|
|
275
213
|
f.write('{"provider":"' + provider_name + '"}')
|
276
214
|
end
|
277
215
|
|
278
|
-
|
279
|
-
|
216
|
+
# Copy additional files
|
217
|
+
additional_files = Dir.glob(File.join(@vm.box.directory, '**', '*'))
|
218
|
+
additional_files.select! { |f| !File.directory?(f) }
|
219
|
+
additional_files.select! { |f| f !~ /(tar|gz|core|lck|log|vmdk|ovf|ova)$/ }
|
220
|
+
additional_files.select! { |f| f !~ /(nvram|vmem|vmsd|vmsn|vmss|vmtm|vmx|vmxf)$/ }
|
280
221
|
|
281
|
-
#
|
282
|
-
|
283
|
-
@logger.debug("Copy includes from #{source_include_path} to #{target_include_path}")
|
284
|
-
FileUtils.cp_r(source_include_path, @tmp_path)
|
285
|
-
end
|
222
|
+
@logger.debug("Copy includes #{additional_files} to #{@tmp_path}")
|
223
|
+
FileUtils.cp_r(additional_files, @tmp_path)
|
286
224
|
|
287
|
-
|
288
|
-
|
289
|
-
vagrantfile_has_mac = false
|
290
|
-
vagrantfile_needs_mac = @vm.provider_name.to_s == 'virtualbox'
|
225
|
+
# Make sure the Vagrantfile includes a HMAC when the provider is virtualbox
|
226
|
+
if @vm.provider_name.to_s == 'virtualbox'
|
291
227
|
|
292
|
-
# Check the original vagrant file for a mac settings
|
293
|
-
if vagrantfile_exists && vagrantfile_needs_mac
|
294
228
|
@logger.debug('Provider needs a hmac setting in the Vagrantfile')
|
295
|
-
File.readlines(original_vagrantfile).each { |line|
|
296
|
-
if line.to_s =~ /base_mac\s*=\s*("|')/i
|
297
|
-
vagrantfile_has_mac = true
|
298
|
-
end
|
299
|
-
}
|
300
|
-
end
|
301
229
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
file.write(Vagrant::Util::TemplateRenderer.render('package_Vagrantfile', {
|
315
|
-
base_mac: @vm.provider.driver.read_mac_address
|
316
|
-
}))
|
230
|
+
vagrantfile_name = File.join(@tmp_path, 'Vagrantfile')
|
231
|
+
vagrantfile_has_mac = false
|
232
|
+
mode = 'w+'
|
233
|
+
|
234
|
+
if File.exist?(vagrantfile_name)
|
235
|
+
mode = 'a'
|
236
|
+
File.readlines(vagrantfile_name.to_s).each { |line|
|
237
|
+
if line.to_s =~ /base_mac\s*=\s*("|')/i
|
238
|
+
@logger.debug("Found HMAC setting in file #{vagrantfile_name.to_s}")
|
239
|
+
vagrantfile_has_mac = true
|
240
|
+
end
|
241
|
+
}
|
317
242
|
end
|
318
243
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
244
|
+
unless vagrantfile_has_mac
|
245
|
+
|
246
|
+
@logger.debug("Found HMAC setting in file #{vagrantfile_name.to_s}")
|
247
|
+
|
248
|
+
vagrantfile_name.open(mode) { |f|
|
249
|
+
hmac_address = @vm.provider.driver.read_mac_address
|
250
|
+
f.binmode
|
251
|
+
f.puts
|
252
|
+
f.puts %Q[# Automatically added by export]
|
253
|
+
f.puts %Q[Vagrant.configure("2") do |config|]
|
254
|
+
f.puts %Q[ config.vm.base_mac = "#{hmac_address}"]
|
255
|
+
f.puts %Q[end]
|
256
|
+
}
|
326
257
|
end
|
327
258
|
end
|
328
259
|
|
329
|
-
# Copy the private key if available
|
330
|
-
setup_private_key
|
331
|
-
|
332
260
|
# Make a box file out of it
|
333
261
|
@box_file_name = @tmp_path + '.box'
|
334
262
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Grossberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Export boxes to .box files including the original Vagrantfile and some
|
14
14
|
cleanups inside the VM
|