macinbox 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e49666706dec8dad1c141d5753afe62f2c3a228
4
- data.tar.gz: 6999cf488fa3110249b0e2e03ce00dc8fd92fa4e
3
+ metadata.gz: 474f8768420d2c194e78c4c92696cbeba1138c08
4
+ data.tar.gz: eb7adcd5810db338a8c81ea38287590ac6597dce
5
5
  SHA512:
6
- metadata.gz: 9897e34975452ab3811e5c7d56b697e33cf8c6d7aa1e6d2d57c924911d948d5d5a897f49dbf92eeb37906ac7046b8c336a68a2379618a44468c52a630ebe3f09
7
- data.tar.gz: cfe86479f9863fa453807345b8f900bee06ebb0a3f6413ee4dd1b4ae05efc4dcc0518355f735d232271643e18aa2e1bf2dcabb4d08da8ff81afc31037c2d87df
6
+ metadata.gz: 36080184de62a0730413d1ef1c464f9050db3edc969838468b77c073d1e6ac273091530fcaecd8cc152dc1a4effdd8fad128ac684bd2fa26fc1c7a9df8852348
7
+ data.tar.gz: 79a8b56feb78da81bd4a82cae61a81fea3ef18b4b97811e7ec9047277026986a7f44183314a7e0a8845829d080765c1863e5a57da79424682cfec159b6ab72eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- macinbox (1.0.0)
4
+ macinbox (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -102,16 +102,30 @@ module Macinbox
102
102
  end
103
103
 
104
104
  def install_vmware_tools
105
- Logger.info "Installing the VMware Tools..." do
105
+ @collector.on_cleanup do
106
+ %x( hdiutil detach -quiet -force #{@tools_mountpoint.shellescape} > /dev/null 2>&1 ) if @tools_mountpoint
107
+ end
106
108
 
107
- @collector.on_cleanup do
108
- %x( hdiutil detach -quiet -force #{@tools_mountpoint.shellescape} > /dev/null 2>&1 ) if @tools_mountpoint
109
+ tools_image = "#{@vmware_fusion_app}/Contents/Library/isoimages/darwin.iso"
110
+
111
+ unless File.exist? tools_image
112
+ Logger.info "Downloading the VMware Tools..." do
113
+ bundle_version = Task.backtick %W[ defaults read #{"/Applications/VMware Fusion.app/Contents/Info.plist"} CFBundleVersion ]
114
+ bundle_short_version = Task.backtick %W[ defaults read #{"/Applications/VMware Fusion.app/Contents/Info.plist"} CFBundleShortVersionString ]
115
+ darwin_iso_url = "http://softwareupdate.vmware.com/cds/vmw-desktop/fusion/#{bundle_short_version}/#{bundle_version}/packages/com.vmware.fusion.tools.darwin.zip.tar"
116
+ Dir.chdir(@temp_dir) do
117
+ Task.run %W[ curl -O #{darwin_iso_url} ]
118
+ Task.run %W[ tar -xf com.vmware.fusion.tools.darwin.zip.tar com.vmware.fusion.tools.darwin.zip ]
119
+ Task.run %W[ unzip com.vmware.fusion.tools.darwin.zip payload/darwin.iso ]
120
+ end
121
+ tools_image = "#{@temp_dir}/payload/darwin.iso"
109
122
  end
123
+ end
110
124
 
125
+ Logger.info "Installing the VMware Tools..." do
111
126
  @tools_mountpoint = "#{@temp_dir}/tools_mountpoint"
112
127
  FileUtils.mkdir @tools_mountpoint
113
128
 
114
- tools_image = "#{@vmware_fusion_app}/Contents/Library/isoimages/darwin.iso"
115
129
  tools_package = "#{@tools_mountpoint}/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg"
116
130
  tools_package_dir = "#{@temp_dir}/tools_package"
117
131
 
@@ -55,6 +55,7 @@ module Macinbox
55
55
  Task.run %W[ #{rawdiskCreator} create #{@device} fullDevice rawdisk lsilogic ]
56
56
  Task.run %W[ #{vdiskmanager} -t 0 -r rawdisk.vmdk macinbox.vmdk ]
57
57
  end
58
+ %x( diskutil eject #{@device.shellescape} > /dev/null 2>&1 )
58
59
  end
59
60
 
60
61
  Logger.info "Moving the VMDK to the destination..." do
data/lib/macinbox/cli.rb CHANGED
@@ -53,7 +53,8 @@ module Macinbox
53
53
  else
54
54
  collector.remove_temp_dirs
55
55
  end
56
- STDERR.print TTY::CURSOR_NORMAL
56
+ STDERR.print TTY::Color::RESET
57
+ STDERR.print TTY::Cursor::NORMAL
57
58
  end
58
59
 
59
60
  ["TERM", "INT", "EXIT"].each do |signal|
@@ -2,7 +2,6 @@ require 'macinbox/tty'
2
2
 
3
3
  module Macinbox
4
4
  class Logger
5
- include TTY
6
5
  PREFIXES = ["• ", " + ", " - "]
7
6
  @@depth = 0
8
7
  def self.prefix
@@ -12,7 +11,7 @@ module Macinbox
12
11
  @@depth = 0
13
12
  end
14
13
  def self.info(msg)
15
- STDERR.puts GREEN + prefix + msg + BLACK
14
+ STDERR.puts TTY::Color::GREEN + prefix + msg + TTY::Color::RESET
16
15
  if block_given?
17
16
  @@depth += 1
18
17
  yield
@@ -20,7 +19,7 @@ module Macinbox
20
19
  end
21
20
  end
22
21
  def self.error(msg)
23
- STDERR.puts RED + prefix + msg + BLACK
22
+ STDERR.puts TTY::Color::RED + prefix + msg + TTY::Color::RESET
24
23
  end
25
24
  end
26
25
  end
data/lib/macinbox/task.rb CHANGED
@@ -6,8 +6,6 @@ module Macinbox
6
6
 
7
7
  class Task
8
8
 
9
- include TTY
10
-
11
9
  def self.run(cmd)
12
10
  system(*cmd) or raise Macinbox::Error.new("#{cmd.slice(0)} failed with non-zero exit code: #{$?.to_i}")
13
11
  end
@@ -33,15 +31,15 @@ module Macinbox
33
31
  end
34
32
 
35
33
  def self.run_with_progress(activity, cmd, opts={})
36
- STDERR.print CURSOR_INVISIBLE
37
- STDERR.print CLEAR_LINE + GREEN + progress_bar(activity, 0.0) + BLACK
34
+ STDERR.print TTY::Cursor::INVISIBLE
35
+ STDERR.print TTY::Line::CLEAR + TTY::Color::GREEN + progress_bar(activity, 0.0) + TTY::Color::RESET
38
36
  IO.popen cmd, opts do |pipe|
39
37
  pipe.each_line do |line|
40
38
  percent = yield line
41
- STDERR.print CLEAR_LINE + GREEN + progress_bar(activity, percent) + BLACK if percent
39
+ STDERR.print TTY::Line::CLEAR + TTY::Color::GREEN + progress_bar(activity, percent) + TTY::Color::RESET if percent
42
40
  end
43
41
  end
44
- STDERR.puts CURSOR_NORMAL
42
+ STDERR.puts TTY::Cursor::NORMAL
45
43
  end
46
44
 
47
45
  def self.write_file_to_io_with_progress(source, destination)
@@ -50,21 +48,21 @@ module Macinbox
50
48
  bytes_written = 0
51
49
  total_size = File.size(source)
52
50
  last_percent_done = -1
53
- STDERR.print CURSOR_INVISIBLE
54
- STDERR.print CLEAR_LINE + GREEN + progress_bar(activity, 0.0) + BLACK
51
+ STDERR.print TTY::Cursor::INVISIBLE
52
+ STDERR.print TTY::Line::CLEAR + TTY::Color::GREEN + progress_bar(activity, 0.0) + TTY::Color::RESET
55
53
  File.open(source) do |file|
56
54
  until eof
57
55
  begin
58
56
  bytes_written += destination.write(file.readpartial(1024*1024))
59
57
  percent_done = ((bytes_written.to_f / total_size.to_f) * 100).round(1)
60
58
  last_percent_done = percent_done
61
- STDERR.print CLEAR_LINE + GREEN + progress_bar(activity, percent_done) + BLACK
59
+ STDERR.print TTY::Line::CLEAR + TTY::Color::GREEN + progress_bar(activity, percent_done) + TTY::Color::RESET
62
60
  rescue EOFError
63
61
  eof = true
64
62
  end
65
63
  end
66
64
  end
67
- STDERR.puts CURSOR_NORMAL
65
+ STDERR.puts TTY::Cursor::NORMAL
68
66
  end
69
67
 
70
68
  def self.backtick(cmd)
data/lib/macinbox/tty.rb CHANGED
@@ -1,10 +1,16 @@
1
1
  module Macinbox
2
2
  module TTY
3
- BLACK = %x(tput setaf 0)
4
- RED = %x(tput setaf 1)
5
- GREEN = %x(tput setaf 2)
6
- CLEAR_LINE = "\r" + %x( tput el )
7
- CURSOR_INVISIBLE = %x( tput civis )
8
- CURSOR_NORMAL = %x( tput cnorm )
3
+ module Color
4
+ RED = STDERR.isatty ? %x(tput setaf 1) : ""
5
+ GREEN = STDERR.isatty ? %x(tput setaf 2) : ""
6
+ RESET = STDERR.isatty ? %x(tput sgr0) : ""
7
+ end
8
+ module Line
9
+ CLEAR = STDERR.isatty ? "\r" + %x( tput el ) : ""
10
+ end
11
+ module Cursor
12
+ INVISIBLE = %x( tput civis )
13
+ NORMAL = %x( tput cnorm )
14
+ end
9
15
  end
10
16
  end
@@ -1,3 +1,3 @@
1
1
  module Macinbox
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macinbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Kramer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-03 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler