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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/macinbox/actions/create_image_from_installer.rb +18 -4
- data/lib/macinbox/actions/create_vmdk_from_image.rb +1 -0
- data/lib/macinbox/cli.rb +2 -1
- data/lib/macinbox/logger.rb +2 -3
- data/lib/macinbox/task.rb +8 -10
- data/lib/macinbox/tty.rb +12 -6
- data/lib/macinbox/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: 474f8768420d2c194e78c4c92696cbeba1138c08
|
4
|
+
data.tar.gz: eb7adcd5810db338a8c81ea38287590ac6597dce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36080184de62a0730413d1ef1c464f9050db3edc969838468b77c073d1e6ac273091530fcaecd8cc152dc1a4effdd8fad128ac684bd2fa26fc1c7a9df8852348
|
7
|
+
data.tar.gz: 79a8b56feb78da81bd4a82cae61a81fea3ef18b4b97811e7ec9047277026986a7f44183314a7e0a8845829d080765c1863e5a57da79424682cfec159b6ab72eb
|
data/Gemfile.lock
CHANGED
@@ -102,16 +102,30 @@ module Macinbox
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def install_vmware_tools
|
105
|
-
|
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
|
-
|
108
|
-
|
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
data/lib/macinbox/logger.rb
CHANGED
@@ -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 +
|
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 +
|
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
|
37
|
-
STDERR.print
|
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
|
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
|
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
|
54
|
-
STDERR.print
|
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
|
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
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
data/lib/macinbox/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|