vagrant-export 0.4.1 → 0.4.2

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
  SHA1:
3
- metadata.gz: 081ac42c7d7c7fc536631f148a6169561e8ccd9a
4
- data.tar.gz: 0a80a48a476b5e743a1f37ebd96dc02df126d844
3
+ metadata.gz: 6e695757f1e8987195d06bdc0a690ac4b7d776dc
4
+ data.tar.gz: 42dd5af71a1ad5e04e240d8e7ded7c1ac600a0d6
5
5
  SHA512:
6
- metadata.gz: 8b38d562b1d89947f8139811cf1b799e4c90261a0d1532525e9007db2f5effd3551281598e156fb717115b3e9a33bbffab3d4e2ccf565ddf65a6ab849bd0dc4f
7
- data.tar.gz: 05981e87e43e6fcbacbd76928adc728ad61e30fa9d3c4586f8d5cb4a2eb3fb5f8d502091895a1ecb533d9b3e49d2ec3fc8741c280558c0ea6802f55bb42d25e5
6
+ metadata.gz: c09434885f41d9e40d11a67adb0b0c79d076531fe812520e8137340c64c43b73dc6fd746a8cfb09cc37b8eb37e23af26667d3680c5e790d7df976d7138e90f34
7
+ data.tar.gz: bddab4aacb17e68033fda5f574ec5bbba052d77c4d9b7b5248368d64bdfbb72d77a030e9f2eaffcf6ec7bce1855dc3a245439da039624ee7f42bed7d14102b5a
@@ -161,7 +161,7 @@ module VagrantPlugins
161
161
 
162
162
  else
163
163
 
164
- ovf_file = File.join(exported_path, @vm.box.name.gsub(/[^a-zA-Z0-9]+/, '_')) + '.ovf'
164
+ ovf_file = File.join(exported_path, 'box.ovf')
165
165
  vm_id = @vm.id.to_s
166
166
 
167
167
  opts = {}
@@ -191,6 +191,38 @@ module VagrantPlugins
191
191
  @logger.debug("Exported VM to #{exported_path}")
192
192
  end
193
193
 
194
+ # This will copy the generated private key into the box and use
195
+ # it for SSH by default. We have to do this because we now generate
196
+ # random keypairs on boot, so packaged boxes would stop working
197
+ # without this.
198
+ # Samelessly copied from Vagrant::Action::General::Package
199
+ def setup_private_key
200
+
201
+ # If we don't have a data dir, we also do nothing (base package)
202
+ return if !@vm.data_dir
203
+
204
+ # If we don't have a generated private key, we do nothing
205
+ path = @vm.data_dir.join("private_key")
206
+ return if !path.file?
207
+
208
+ # Copy it into our box directory
209
+ dir = Pathname.new(@tmp_path)
210
+ new_path = dir.join("vagrant_private_key")
211
+ FileUtils.cp(path, new_path)
212
+
213
+ # Append it to the Vagrantfile (or create a Vagrantfile)
214
+ vf_path = dir.join("Vagrantfile")
215
+ mode = "w+"
216
+ mode = "a" if vf_path.file?
217
+ vf_path.open(mode) do |f|
218
+ f.binmode
219
+ f.puts
220
+ f.puts %Q[Vagrant.configure("2") do |config|]
221
+ f.puts %Q[ config.ssh.private_key_path = File.expand_path("../vagrant_private_key", __FILE__)]
222
+ f.puts %Q[end]
223
+ end
224
+ end
225
+
194
226
  def files(bare)
195
227
 
196
228
  provider_name = @vm.provider_name.to_s
@@ -223,6 +255,9 @@ module VagrantPlugins
223
255
  FileUtils.cp_r(additional_files, @tmp_path)
224
256
  end
225
257
 
258
+ # Include a generated private key if it exists
259
+ setup_private_key
260
+
226
261
  # Make sure the Vagrantfile includes a HMAC when the provider is virtualbox
227
262
  if @vm.provider_name.to_s == 'virtualbox'
228
263
 
@@ -250,7 +285,6 @@ module VagrantPlugins
250
285
  hmac_address = @vm.provider.driver.read_mac_address
251
286
  f.binmode
252
287
  f.puts
253
- f.puts %Q[# Automatically added by export]
254
288
  f.puts %Q[Vagrant.configure("2") do |config|]
255
289
  f.puts %Q[ config.vm.base_mac = "#{hmac_address}"]
256
290
  f.puts %Q[end]
@@ -268,29 +302,26 @@ module VagrantPlugins
268
302
  box_files = Dir.glob(File.join(@tmp_path, '**', '*'))
269
303
  @logger.debug("Create box file #{@box_file_name} containing #{box_files}")
270
304
  bash_exec = Vagrant::Util::Which.which('bash').to_s;
305
+
306
+ total_size = 0
307
+ files_list = []
308
+ box_files.each { |f|
309
+ total_size += File.size(f)
310
+ files_list.push(f.to_s.gsub(@tmp_path.to_s, '').gsub(/^[\/\\]+/, ''))
311
+ }
312
+ @logger.debug("Complete size of files is #{total_size} bytes")
313
+ @logger.debug("Files argument for bash script: #{files_list}")
271
314
 
272
315
  if File.executable?(bash_exec) && ['pv', 'tar', 'gzip'].all? {|cmd| Vagrant::Util::Which.which(cmd) != nil }
273
- total_size = 0
274
- files_list = []
275
-
276
316
  @logger.debug('Using custom packaging command to create progress output')
277
317
  @env.ui.info('Starting compression', new_line: false)
278
318
 
279
- box_files.each { |f|
280
- total_size += File.size(f)
281
- files_list.push(f.to_s.gsub(@tmp_path.to_s, '').gsub(/^[\/\\]+/, ''))
282
- }
283
-
284
- @logger.debug("Complete size of files is #{total_size} bytes")
285
-
286
319
  opts = {}
287
320
  opts[:notify] = [:stderr, :stdout]
288
321
 
289
322
  script_file = File.absolute_path(File.expand_path('../../../res/progress_tar.sh', __FILE__))
290
323
  files_list = files_list.join(' ')
291
324
 
292
- @logger.debug("Files argument for bash script: #{files_list}")
293
-
294
325
  Vagrant::Util::Subprocess.execute(bash_exec, script_file, @tmp_path.to_s, total_size.to_s, @box_file_name, files_list, opts) { |io, data|
295
326
  d = data.to_s
296
327
  p = d.match(/\d+/).to_a
@@ -301,13 +332,11 @@ module VagrantPlugins
301
332
  @env.ui.clear_line
302
333
  @env.ui.info(p.pop.to_s + '%', new_line: false)
303
334
  end
304
-
305
335
  }
306
336
 
307
337
  @env.ui.clear_line
308
-
309
338
  else
310
- Vagrant::Util::Subprocess.execute('bsdtar', '-czf', @box_file_name, *box_files)
339
+ Vagrant::Util::Subprocess.execute('bsdtar', '-czf', @box_file_name, '-C', @tmp_path.to_s, *files_list)
311
340
  end
312
341
  end
313
342
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module VagrantPlugins
7
7
  module Export
8
- VERSION = '0.4.1'
8
+ VERSION = '0.4.2'
9
9
  end
10
10
  end
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.1
4
+ version: 0.4.2
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-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-28 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
@@ -29,6 +29,7 @@ files:
29
29
  - lib/vagrant-export/version.rb
30
30
  - res/cleanup.sh
31
31
  - res/progress_tar.sh
32
+ - vagrant-export-0.4.1.gem
32
33
  - vagrant-export.gemspec
33
34
  homepage: https://github.com/trenker/vagrant-export
34
35
  licenses: