Class: IESD::Extensions::KextCache

Inherits:
Object
  • Object
show all
Defined in:
lib/iesd/InstallESD/Extensions.rb

Constant Summary collapse

KEXTCACHE_DEFAULT_OPTIONS =
%w{ -v 0 -no-authentication }
KERNELCACHE =
%w{ System Library Caches com.apple.kext.caches Startup kernelcache }
MKEXT =
%w{ System Library Caches com.apple.kext.caches Startup Extensions.mkext }
MKEXT_PPC =
%w{ System Library Extensions.mkext }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(extensions) ⇒ KextCache

Returns a new instance of KextCache.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/iesd/InstallESD/Extensions.rb', line 41

def initialize extensions
  @extensions = extensions
  @volume_root = extensions.volume_root

  case
  when (File.exist? (@url = File.join(@volume_root, *KERNELCACHE)))
    @type = :kernelcache
  when (File.exist? (@url = File.join(@volume_root, *MKEXT)))
    @type = :mkext
  when (File.exist? (@url = File.join(@volume_root, *MKEXT_PPC)))
    @type = :mkext_ppc
  else
    @url = nil
  end
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



39
40
41
# File 'lib/iesd/InstallESD/Extensions.rb', line 39

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



39
40
41
# File 'lib/iesd/InstallESD/Extensions.rb', line 39

def url
  @url
end

#volume_rootObject (readonly)

Returns the value of attribute volume_root.



39
40
41
# File 'lib/iesd/InstallESD/Extensions.rb', line 39

def volume_root
  @volume_root
end

Instance Method Details

#updateObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/iesd/InstallESD/Extensions.rb', line 57

def update
  if File.exist? (mach_kernel = File.join(@volume_root, "mach_kernel"))
    oh1 "Updating Kextcache"
    case @type
    when :kernelcache
      system(Utility::KEXTCACHE, *KEXTCACHE_DEFAULT_OPTIONS, "-prelinked-kernel", @url, "-kernel", mach_kernel, "-volume-root", @volume_root, "--", @extensions.url)
    when :mkext
      system(Utility::KEXTCACHE, *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a i386 -a x86_64 }, "-mkext", @url, "-kernel", mach_kernel, "-volume-root", @volume_root, "--", @extensions.url)
      if File.exist? (mkext_ppc = File.join(@volume_root, *MKEXT_PPC))
        system(Utility::DITTO, @url, mkext_ppc)
      end
    when :mkext_ppc
      system(Utility::DITTO, *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a ppc -a i386 }, "-mkext", @url, "-kernel", mach_kernel, "-volume-root", @volume_root, "--", extensions.url)
    end
    puts "Updated: #{@url}"
  else
    opoo "kextcache aborted because mach_kernel is not available"
  end
end