Class: Hackmac::OCValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/hackmac/oc_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(mdev:, config:) ⇒ OCValidator

Returns a new instance of OCValidator.



5
6
7
8
9
10
# File 'lib/hackmac/oc_validator.rb', line 5

def initialize(mdev:, config:)
  @config = config
  mount_path   = Pathname.new('/Volumes').join(mdev)
  @config_plist =
    Pathname.new(mount_path).join(@config.oc.efi_path).join('OC/config.plist')
end

Instance Method Details

#performObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hackmac/oc_validator.rb', line 12

def perform
  isolate do |dir|
    oc = OC.new(config: @config)
    name, data = oc.remote.download_asset
    if name
      File.secure_write(name, data)
      decompress(name)
      result = %x(Utilities/ocvalidate/ocvalidate #{@config_plist.to_s.inspect} 2>&1)
      if $?.success?
        STDERR.puts result
        true
      else
        STDERR.puts "Validation has failed!", "", result
        false
      end
      true
    else
      fail "#{oc} could not be downloaded"
    end
  end
end