Class: IESD::DMG::InstallESD

Inherits:
HDIUtil::DMG show all
Defined in:
lib/iesd/InstallESD/InstallESD.dmg.rb

Defined Under Namespace

Classes: BaseSystem

Constant Summary collapse

PACKAGES =
%w{ Packages }

Instance Attribute Summary

Attributes inherited from HDIUtil::DMG

#url

Instance Method Summary collapse

Methods inherited from HDIUtil::DMG

#edit, #initialize, #show, #update, #valid?

Constructor Details

This class inherits a constructor from HDIUtil::DMG

Instance Method Details

#export(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/iesd/InstallESD/InstallESD.dmg.rb', line 6

def export options
  case options[:type]
  when :BaseSystem
    options = {
      :hdiutil => {
        :resize => {
          :grow => 0,
        }
      }
    }.merge(options)
    options[:hdiutil][:resize][:grow] += ( `#{Utility::HDIUTIL} resize -limits "#{@url}"`.chomp.split.map { |s| s.to_i } ).first

    show { |installesd|
      IESD::DMG::BaseSystem.new(File.join(installesd, "BaseSystem.dmg")).export(options) { |basesystem|
        installesd_packages = File.join installesd, PACKAGES
        basesystem_packages = File.join basesystem, *IESD::DMG::BaseSystem::PACKAGES
        oh1 "Copying #{installesd_packages}"
        system(Utility::RM, basesystem_packages)
        system(Utility::DITTO, installesd_packages, basesystem_packages)
        puts "Copied: #{basesystem_packages}"

        installesd_mach_kernel = File.join installesd, "mach_kernel"
        basesystem_mach_kernel = File.join basesystem, "mach_kernel"
        if File.exist? installesd_mach_kernel
          oh1 "Copying #{installesd_mach_kernel}"
          system(Utility::DITTO, installesd_mach_kernel, basesystem_mach_kernel)
          system(Utility::CHFLAGS, "hidden", basesystem_mach_kernel)
          puts "Copied: #{basesystem_mach_kernel}"
        end
      }
    }
  when :InstallESD, nil
    Dir.mktmpdir { |tmp|
      HDIUtil.write(@url, (tmpfile = File.join(tmp, File.basename(@url))), options[:hdiutil]) { |installesd|
        options[:extensions][:up_to_date] = (options[:extensions][:remove].empty? and options[:extensions][:install].empty?)
        options[:mach_kernel] = File.exist? File.join(installesd, "mach_kernel") if options[:mach_kernel].nil?

        yield installesd if block_given?

        pre_update_extension installesd, options

        basesystem_options = options.clone
        basesystem_options[:input] = basesystem_options[:output] = File.join(installesd, "BaseSystem.dmg")
        basesystem_flags = `#{Utility::LS} -lO "#{basesystem_options[:input]}"`.split[4]
        IESD::DMG::InstallESD::BaseSystem.new(File.join(basesystem_options[:input])).export(basesystem_options) { |basesystem|
          installesd_mach_kernel = File.join installesd, "mach_kernel"
          basesystem_mach_kernel = File.join basesystem, "mach_kernel"
          if File.exist? installesd_mach_kernel
            oh1 "Copying #{installesd_mach_kernel}"
            system(Utility::DITTO, installesd_mach_kernel, basesystem_mach_kernel)
            system(Utility::CHFLAGS, "hidden", basesystem_mach_kernel)
            puts "Copied: #{basesystem_mach_kernel}"
          end
        }
        system(Utility::CHFLAGS, basesystem_flags, basesystem_options[:output]) unless basesystem_flags == "-"

        if File.exist? (kextcache = File.join(installesd, "kernelcache"))
          IESD::DMG::InstallESD::BaseSystem.new(File.join(basesystem_options[:output])).show { |basesystem|
            oh1 "Updating kextcache"
            system(Utility::DITTO, IESD::DMG::BaseSystem::Extensions.new(basesystem).kextcache.url, kextcache)
            system(Utility::CHFLAGS, "hidden", kextcache)
            puts "Updated: #{kextcache}"
          }
        end

        post_update_extension installesd, options

        if options[:interactive]
          oh1 "Starting Interactive Shell"
          puts "Environment: InstallESD"
          HDIUtil.shell installesd
        end
      }
      system(Utility::MV, tmpfile, options[:output])
    }
  else
    raise "invalid output type"
  end
end