Module: KextCache

Defined in:
lib/iesd/utility/kextcache.rb

Overview

Constant Summary collapse

DEFAULT_OPTIONS =

The default options for kextcache.

%w[ -v 0 -no-authentication ]
EXTENSIONS =

The relative path to Extensions.

File.join %w[ System Library Extensions ]
EXTRA_EXTENSIONS =

The relative path to Extra Extensions.

Available on OS X Mavericks and later.

File.join %w[ Library Extensions ]
KERNELCACHE =

The relative path to kernelcache.

Available on OS X Lion and later.

File.join %w[ System Library Caches com.apple.kext.caches Startup kernelcache ]
MKEXT =

The relative path to Extensions.mkext.

Available on OS X Snow Leopard.

File.join %w[ System Library Caches com.apple.kext.caches Startup Extensions.mkext ]
MKEXT_PPC =

The relative path to Extensions.mkext on PowerPC Macs.

Available on OS X Leopard and eailer.

File.join %w[ System Library Extensions.mkext ]

Class Method Summary collapse

Class Method Details

.update_volume(volume_root) ⇒ Object

Update the kernelcache on a volume.

volume_root - The String path to the volume root.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/iesd/utility/kextcache.rb', line 37

def self.update_volume volume_root
  oh1 "Updating Kextcache"
  if File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
    extensions_path = [File.join(volume_root, EXTENSIONS)]
    extensions_path.push(File.join(volume_root, EXTRA_EXTENSIONS)) if File.exist? File.join(volume_root, EXTRA_EXTENSIONS)
    case
    when (File.exist? (url = File.join(volume_root, KERNELCACHE)))
      system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, "-prelinked-kernel", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
    when (File.exist? (url = File.join(volume_root, MKEXT)))
      system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, *%w[ -a i386 -a x86_64 ], "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
      if File.exist? (mkext_ppc = File.join(volume_root, MKEXT_PPC))
        system("/usr/bin/env", "ditto", url, mkext_ppc)
      end
    when (File.exist? (url = File.join(volume_root, MKEXT_PPC)))
      system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, *%w[ -a ppc -a i386 ], "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
    else
      puts "kextcache aborted: unknown kernel cache type"
      return
    end
    puts "Updated: #{url}"
  else
    opoo "kextcache aborted: mach_kernel not found"
  end
end