Class: Hackmac::OCUpgrader

Inherits:
Object
  • Object
show all
Includes:
FileUtils::Verbose, AssetTools
Defined in:
lib/hackmac/oc_upgrader.rb

Instance Method Summary collapse

Constructor Details

#initialize(mdev:, config:) ⇒ OCUpgrader

Returns a new instance of OCUpgrader.



8
9
10
11
12
# File 'lib/hackmac/oc_upgrader.rb', line 8

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

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hackmac/oc_upgrader.rb', line 14

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)
      for f in @config.oc.files.map { |x| Pathname.new(x) }
        sf = Pathname.new(dir).join(@config.oc.install_path).join(f)
        cp sf, @install_dir.join(f.dirname)
      end
    else
      fail "#{oc} could not be downloaded"
    end
  end
end

#to_sObject



31
32
33
# File 'lib/hackmac/oc_upgrader.rb', line 31

def to_s
  'Installation into %s' % @install_dir
end