iesd 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d6447d914c3336dfcbd31bed32b08e466afd817
4
- data.tar.gz: 1283183f073d822b41df8721be9068f6771645b7
3
+ metadata.gz: 80dda64df93f32d8ec52093215696a1b0d78ccc8
4
+ data.tar.gz: 96c94678e448ed676a32b93c0cd2f7f1aea9b023
5
5
  SHA512:
6
- metadata.gz: 3891f8b6de4af530d2708ac096dab375d92cf88070d5fd9f89dced055503d4c15f320b6d7c9257da7f81bbe037080f45f9aa66ad1a2847f2efe4dc16899a5ff8
7
- data.tar.gz: f181900399e4ed2f78d99cfd6929709a0c8085589ed12604f1d4e9c6ee01eefb3fd5d8308a78dc30aaacc924aa38c29d858aaf27163acdf6f277c700de941dfd
6
+ metadata.gz: 464aa366bbfd2f74f9d1a8c3242ec44d62c95ab71a87f1227a8607604d09f52a0ac9303b85b931f5eed3f73c641d9d59f5a3edff4958df5d0066146d63c6e562
7
+ data.tar.gz: b13944dd30ea5a6aa223185f0933684a6168db8f7735298b3ba50bb1f2628795870407049bae59acdfd522c7f0722bca98ed8e98d32650a698379fd32761d12d
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.required_ruby_version = ">= 1.9.2"
3
3
 
4
4
  s.name = "iesd"
5
- s.version = "1.2.0"
5
+ s.version = "1.2.1"
6
6
  s.summary = "Customize OS X InstallESD."
7
7
  s.description = "Modify Extensions, Kextcache and Packages on InstallESD."
8
8
  s.authors = "なつき"
@@ -11,10 +11,10 @@ Gem::Specification.new do |s|
11
11
  s.license = "BSD-2-Clause"
12
12
 
13
13
  s.executables = ["iesd"]
14
- s.files = %w{
14
+ s.files = %w[
15
15
  README.md
16
16
  LICENSE.md
17
17
  bin/iesd
18
18
  iesd.gemspec
19
- } + Dir["lib/**/*.rb"]
19
+ ] + Dir["lib/**/*.rb"]
20
20
  end
@@ -1,26 +1,41 @@
1
+ # Install Electronic Software Delivery
1
2
  module IESD
3
+
4
+ # Initialize a new installer Object.
5
+ #
6
+ # Returns an installer APP or DMG if the type of the installer is detected, otherwise nil.
2
7
  def self.new url
3
8
  File.extname(url).downcase == ".app" ? IESD::APP.new(url) : IESD::DMG.new(url)
4
9
  end
5
10
 
11
+ # OS X Installer App
6
12
  class APP
13
+
14
+ # Initialize a new installer APP.
15
+ #
16
+ # Returns an installer APP if the type of the installer is detected, otherwise nil.
7
17
  def self.new url
8
18
  IESD::APP::InstallOSX.validate(url) ? IESD::APP::InstallOSX.new(url) : nil
9
19
  end
10
20
  end
11
21
 
22
+ # OS X Installer DMG
12
23
  class DMG
24
+
25
+ # Initialize a new installer DMG.
26
+ #
27
+ # Returns an installer DMG if the type of the installer is detected, otherwise nil.
13
28
  def self.new url
14
29
  i = nil
15
30
  if HDIUtil::validate url
16
31
  HDIUtil::DMG.new(url).show { |mountpoint|
17
32
  oh1 "Detecting #{url}"
18
33
  case
19
- when (File.exist? File.join(mountpoint, *%w{ .IABootFiles }))
34
+ when (File.exist? File.join(mountpoint, *%w[ .IABootFiles ]))
20
35
  i = IESD::DMG::InstallOSX.new url
21
- when (File.exist? File.join(mountpoint, *%w{ BaseSystem.dmg }))
36
+ when (File.exist? File.join(mountpoint, *%w[ BaseSystem.dmg ]))
22
37
  i = IESD::DMG::InstallESD.new url
23
- when (File.exist? File.join(mountpoint, *%w{ System Installation }))
38
+ when (File.exist? File.join(mountpoint, *%w[ System Installation ]))
24
39
  i = IESD::DMG::BaseSystem.new url
25
40
  else
26
41
  raise "unknown type"
@@ -1,8 +1,17 @@
1
1
  module IESD
2
2
  class DMG
3
+
4
+ # {BaseSystem.dmg}[rdoc-ref:IESD::DMG::BaseSystem]
5
+ #
6
+ # The installer DMG before OS X Lion.
3
7
  class BaseSystem < HDIUtil::DMG
4
- PACKAGES = %w{ System Installation Packages }
5
8
 
9
+ # The relative path to the Packages.
10
+ PACKAGES = File.join %w[ System Installation Packages ]
11
+
12
+ # Export to a new DMG.
13
+ #
14
+ # options - The Dictionary of the export options
6
15
  def export options
7
16
  case options[:type]
8
17
  when :BaseSystem, nil
@@ -34,27 +43,39 @@ module IESD
34
43
 
35
44
  private
36
45
 
46
+ # Perform certain tasks before updating extensions.
47
+ #
48
+ # volume_root - The String path to the volume root
49
+ # options - The Dictionary of the export options
37
50
  def pre_update_extension volume_root, options
38
51
  if !File.exist? (mach_kernel = File.join(volume_root, "mach_kernel")) and (options[:mach_kernel] or !options[:extensions][:up_to_date])
39
- IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, *PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
52
+ IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
40
53
  system("/usr/bin/env", "chflags", "hidden", mach_kernel)
41
54
  end
42
55
  end
43
56
 
57
+ # Perform certain tasks after updating extensions.
58
+ #
59
+ # volume_root - The String path to the volume root
60
+ # options - The Dictionary of the export options
44
61
  def post_update_extension volume_root, options
45
62
  if !options[:extensions][:up_to_date] and options[:extensions][:postinstall]
46
- IESD::Packages::OSInstall.new(File.join(volume_root, *PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
63
+ IESD::Packages::OSInstall.new(File.join(volume_root, PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
47
64
  end
48
65
  if !options[:mach_kernel] and File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
49
66
  system("/usr/bin/env", "rm", mach_kernel)
50
67
  end
51
68
  end
52
69
 
53
- class Extensions < IESD::Extensions
54
- def update extensions
55
- uninstall extensions[:uninstall]
56
- install extensions[:install]
57
- KextCache.update_volume @volume_root if extensions[:kextcache] or (extensions[:kextcache].nil? and !extensions[:up_to_date])
70
+ class Extensions < IESD::Extensions # :nodoc:
71
+
72
+ # Update the Extensions.
73
+ #
74
+ # extensions_options - The Dictionary of the extensions options.
75
+ def update extensions_options
76
+ uninstall extensions_options[:uninstall]
77
+ install extensions_options[:install]
78
+ KextCache.update_volume @volume_root if extensions_options[:kextcache] or (extensions_options[:kextcache].nil? and !extensions_options[:up_to_date])
58
79
  end
59
80
  end
60
81
  end
@@ -1,16 +1,33 @@
1
1
  module IESD
2
+
3
+ # /System/Library/Extensions
2
4
  class Extensions
3
- EXTENSIONS = %w{ System Library Extensions }
4
- EXTRA_EXTENSIONS = %w{ Library Extensions }
5
5
 
6
- attr_reader :volume_root, :url
6
+ # The relative path to the Extensions.
7
+ EXTENSIONS = File.join %w[ System Library Extensions ]
8
+
9
+ # The relative path to the Extra Extensions.
10
+ #
11
+ # Available on Mavericks and later.
12
+ EXTRA_EXTENSIONS = File.join %w[ Library Extensions ]
13
+
14
+ # The String path to the volume root.
15
+ attr_reader :volume_root
16
+ # The String path to the Extensions.
17
+ attr_reader :url
7
18
 
19
+ # Initialize an Extensions.
20
+ #
21
+ # volume_root - The String path to the volume root.
8
22
  def initialize volume_root
9
23
  @volume_root = volume_root
10
- @extensions = File.join @volume_root, *EXTENSIONS
11
- @extra_extensions = File.join @volume_root, *EXTRA_EXTENSIONS
24
+ @extensions = File.join @volume_root, EXTENSIONS
25
+ @extra_extensions = File.join @volume_root, EXTRA_EXTENSIONS
12
26
  end
13
27
 
28
+ # Uninstall extensions.
29
+ #
30
+ # kexts - The Array of extensions to be uninstalled.
14
31
  def uninstall kexts
15
32
  if !kexts.empty?
16
33
  oh1 "Uninstalling Extensions"
@@ -28,6 +45,9 @@ module IESD
28
45
  end
29
46
  end
30
47
 
48
+ # Install extensions.
49
+ #
50
+ # kexts - The Array of extensions to be installed.
31
51
  def install kexts
32
52
  if !kexts.empty?
33
53
  oh1 "Installing Extensions"
@@ -2,9 +2,19 @@ require "shellwords"
2
2
 
3
3
  module IESD
4
4
  class DMG
5
+
6
+ # {InstallESD.dmg}[rdoc-ref:IESD::DMG::InstallESD]
7
+ #
8
+ # The installer DMG for OS X Lion and later.
9
+ # It contains a {BaseSystem.dmg}[rdoc-ref:IESD::DMG::BaseSystem], which is used to install the OS X Recovery.
5
10
  class InstallESD < HDIUtil::DMG
6
- PACKAGES = %w{ Packages }
7
11
 
12
+ # The relative path to the Packages.
13
+ PACKAGES = File.join %w[ Packages ]
14
+
15
+ # Export to a new DMG.
16
+ #
17
+ # options - The Dictionary of the export options
8
18
  def export options
9
19
  case options[:type]
10
20
  when :BaseSystem
@@ -20,7 +30,7 @@ module IESD
20
30
  show { |installesd|
21
31
  IESD::DMG::BaseSystem.new(File.join(installesd, "BaseSystem.dmg")).export(options) { |basesystem|
22
32
  installesd_packages = File.join installesd, PACKAGES
23
- basesystem_packages = File.join basesystem, *IESD::DMG::BaseSystem::PACKAGES
33
+ basesystem_packages = File.join basesystem, IESD::DMG::BaseSystem::PACKAGES
24
34
  oh1 "Copying #{installesd_packages}"
25
35
  system("/usr/bin/env", "rm", basesystem_packages)
26
36
  system("/usr/bin/env", "ditto", installesd_packages, basesystem_packages)
@@ -87,29 +97,45 @@ module IESD
87
97
 
88
98
  private
89
99
 
100
+ # Perform certain tasks before updating extensions.
101
+ #
102
+ # volume_root - The String path to the volume root
103
+ # options - The Dictionary of the export options
90
104
  def pre_update_extension volume_root, options
91
105
  if !File.exist? (mach_kernel = File.join(volume_root, "mach_kernel")) and (options[:mach_kernel] or !options[:extensions][:up_to_date])
92
- IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, *PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
106
+ IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
93
107
  system("/usr/bin/env", "chflags", "hidden", mach_kernel)
94
108
  end
95
109
  end
96
110
 
111
+ # Perform certain tasks after updating extensions.
112
+ #
113
+ # volume_root - The String path to the volume root
114
+ # options - The Dictionary of the export options
97
115
  def post_update_extension volume_root, options
98
116
  if !options[:extensions][:up_to_date] and options[:extensions][:postinstall]
99
- IESD::Packages::OSInstall.new(File.join(volume_root, *PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
117
+ IESD::Packages::OSInstall.new(File.join(volume_root, PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
100
118
  end
101
119
  if !options[:mach_kernel] and File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
102
120
  system("/usr/bin/env", "rm", mach_kernel)
103
121
  end
104
122
  end
105
123
 
106
- class BaseSystem < IESD::DMG::BaseSystem
124
+ class BaseSystem < IESD::DMG::BaseSystem # :nodoc:
107
125
  private
108
126
 
127
+ # Perform certain tasks before updating extensions.
128
+ #
129
+ # volume_root - The String path to the volume root
130
+ # options - The Dictionary of the export options
109
131
  def pre_update_extension volume_root, options
110
132
 
111
133
  end
112
134
 
135
+ # Perform certain tasks after updating extensions.
136
+ #
137
+ # volume_root - The String path to the volume root
138
+ # options - The Dictionary of the export options
113
139
  def post_update_extension volume_root, options
114
140
  if File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
115
141
  system("/usr/bin/env", "rm", mach_kernel)
@@ -1,20 +1,34 @@
1
1
  module IESD
2
2
  class APP
3
+
4
+ # {/Applications/Install OS X.app}[rdoc-ref:IESD::APP::InstallOSX]
5
+ #
6
+ # The installer app for OS X Lion and later.
7
+ # It contains an {InstallESD.dmg}[rdoc-ref:IESD::DMG::InstallESD].
3
8
  class InstallOSX
4
- INSTALLESD_DMG = %w{Contents SharedSupport InstallESD.dmg}
5
9
 
10
+ # The relative path to {InstallESD.dmg}[rdoc-ref:IESD::DMG::InstallESD].
11
+ INSTALLESD_DMG = File.join %w[ Contents SharedSupport InstallESD.dmg ]
12
+
13
+ # Return true if the app is Install OS X.app, otherwise false.
14
+ #
15
+ # url - The String path to the app
6
16
  def self.validate url
7
- File.exist? File.join(url, *INSTALLESD_DMG)
17
+ File.exist? File.join(url, INSTALLESD_DMG)
8
18
  end
9
19
 
10
- def initialize url
20
+ def initialize url # :nodoc:
11
21
  @url = File.absolute_path url
12
22
  end
13
23
 
24
+ # Export to a new DMG.
25
+ #
26
+ # options - The Dictionary of the export options
14
27
  def export options
15
- IESD::DMG::InstallESD.new(File.join @url, *INSTALLESD_DMG).export options
28
+ IESD::DMG::InstallESD.new(File.join @url, INSTALLESD_DMG).export options
16
29
  end
17
30
 
31
+ # Return true if the APP is an Install OS X.app, otherwise false.
18
32
  def valid?
19
33
  IESD::APP::InstallOSX.validate @url
20
34
  end
@@ -1,6 +1,16 @@
1
1
  module IESD
2
2
  class DMG
3
+
4
+ # {Install OS X.dmg}[rdoc-ref:IESD::DMG::InstallOSX]
5
+ #
6
+ # The installer dmg for OS X Mavericks and later.
7
+ # It contains an {Install OS X.app}[rdoc-ref:IESD::APP::InstallOSX].
8
+ # It's generated by `createinstallmedia`, a tool come with the installer app.
3
9
  class InstallOSX < HDIUtil::DMG
10
+
11
+ # Export to a new DMG.
12
+ #
13
+ # options - The Dictionary of the export options
4
14
  def export options
5
15
  show { |mountpoint|
6
16
  IESD::APP::InstallOSX.new(Dir[File.join(mountpoint, "*.app")][0]).export options
@@ -1,4 +1,6 @@
1
1
  module IESD
2
+
3
+ # /System/Installation/Packages/
2
4
  class Packages
3
5
  end
4
6
  end
@@ -2,7 +2,13 @@ require "shellwords"
2
2
 
3
3
  module IESD
4
4
  class Packages
5
+
6
+ # BaseSystemBinaries.pkg
5
7
  class BaseSystemBinaries < PKGUtil::PKG
8
+
9
+ # Extract the mach_kernel.
10
+ #
11
+ # output - The String path to the output file.
6
12
  def extract_mach_kernel output
7
13
  show { |pkg|
8
14
  payload = "#{pkg}/Payload"
@@ -1,5 +1,7 @@
1
1
  module IESD
2
2
  class Packages
3
+
4
+ # OSInstall.mpkg
3
5
  class OSInstallM < PKGUtil::PKG
4
6
  end
5
7
  end
@@ -1,6 +1,12 @@
1
1
  module IESD
2
2
  class Packages
3
+
4
+ # OSInstall.pkg
3
5
  class OSInstall < PKGUtil::PKG
6
+
7
+ # Create the postinstall script for extensions.
8
+ #
9
+ # extensions - The Extensions to update.
4
10
  def postinstall_extensions extensions
5
11
  update { |pkg|
6
12
  oh1 "Creating Extensions Postinstall Script"
@@ -1,5 +1,7 @@
1
1
  module IESD
2
2
  class Packages
3
+
4
+ # OSUpgrade.pkg
3
5
  class OSUpgrade < PKGUtil::PKG
4
6
  end
5
7
  end
@@ -2,24 +2,42 @@ require "shellwords"
2
2
  require "tmpdir"
3
3
  require_relative "tty"
4
4
 
5
+ # +/usr/bin/hdiutil+
6
+ #
7
+ # https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/hdiutil.1.html
5
8
  module HDIUtil
6
- DEFAULT_MOUNT_OPTIONS = %w{ -nobrowse -quiet -noverify }
7
- DEFAULT_MOUNT_OPTIONS.concat(%w{ -owners on }) if Process.uid == 0
8
- DEFAULT_UNMOUNT_OPTIONS = %w{ -quiet }
9
- DEFAULT_CONVERT_OPTIONS = %w{ -quiet }
10
9
 
10
+ # The default options for +hdiutil+.
11
+ DEFAULT_OPTIONS = %w[ -quiet ]
12
+
13
+ # The default options for <code>hdiutil attach</code>.
14
+ DEFAULT_MOUNT_OPTIONS = %w[ -nobrowse -noverify ]
15
+ DEFAULT_MOUNT_OPTIONS.concat(%w[ -owners on ]) if Process.uid == 0
16
+
17
+ # Perform read-only actions on the input image.
18
+ #
19
+ # If a block is given the block will be yielded with the path of the mount point directory, otherwise a shell will be open.
20
+ #
21
+ # input - The String path to the input image.
11
22
  def self.read input
12
23
  Dir.mktmpdir { |mountpoint|
13
- attach input, mountpoint, [*DEFAULT_MOUNT_OPTIONS]
24
+ attach input, mountpoint, [*DEFAULT_OPTIONS, *DEFAULT_MOUNT_OPTIONS]
14
25
  if block_given?
15
26
  yield mountpoint
16
27
  else
17
28
  shell mountpoint
18
29
  end
19
- detach input, mountpoint, [*DEFAULT_UNMOUNT_OPTIONS]
30
+ detach input, mountpoint, [*DEFAULT_OPTIONS]
20
31
  }
21
32
  end
22
33
 
34
+ # Perform read-write actions on the input image and export as the output image.
35
+ #
36
+ # If a block is given the block will be yielded with the path of the mount point directory, otherwise a shell will be open.
37
+ #
38
+ # input - The String path to the input image.
39
+ # output - The String path to the output image.
40
+ # options - The Dictionary of hdiutil options.
23
41
  def self.write input, output, options = {}
24
42
  options = {
25
43
  :resize => {
@@ -36,39 +54,55 @@ module HDIUtil
36
54
  resize_limits = `/usr/bin/env hdiutil resize -limits -shadow #{shadow.shellescape} #{input.shellescape}`.chomp.split.map { |s| s.to_i }
37
55
  sectors = (resize_limits[1] + options[:resize][:grow]).to_s
38
56
  system("/usr/bin/env", "hdiutil", "resize", "-growonly", "-sectors", sectors, *shadow_options, input)
39
- attach input, mountpoint, [*DEFAULT_MOUNT_OPTIONS, *shadow_options]
57
+ attach input, mountpoint, [*DEFAULT_OPTIONS, *DEFAULT_MOUNT_OPTIONS, *shadow_options]
40
58
  if block_given?
41
59
  yield mountpoint
42
60
  else
43
61
  shell mountpoint
44
62
  end
45
- detach input, mountpoint, [*DEFAULT_UNMOUNT_OPTIONS]
63
+ detach input, mountpoint, [*DEFAULT_OPTIONS]
46
64
  system("/usr/bin/env", "hdiutil", "resize", "-shrinkonly", "-sectors", "min", *shadow_options, input) if options[:resize][:shrink]
47
65
  }
48
66
  oh1 "Merging #{shadow}"
49
- system("/usr/bin/env", "hdiutil", "convert", *DEFAULT_CONVERT_OPTIONS, *format_options, *shadow_options, "-o", output, input)
67
+ system("/usr/bin/env", "hdiutil", "convert", *DEFAULT_OPTIONS, *format_options, *shadow_options, "-o", output, input)
50
68
  puts "Merged: #{output}"
51
69
  }
52
70
  end
53
71
 
54
- def self.validate input
55
- Kernel.system(%Q{/usr/bin/env hdiutil imageinfo #{input.shellescape} >/dev/null 2>&1})
72
+ # Returns true if the image is valid, false otherwise.
73
+ #
74
+ # url - The String path to the image.
75
+ def self.validate url
76
+ Kernel.system(%Q[/usr/bin/env hdiutil imageinfo #{url.shellescape} >/dev/null 2>&1])
56
77
  end
57
78
 
58
79
  private
59
80
 
81
+ # Mount a DMG.
82
+ #
83
+ # dmg - The String path to the DMG.
84
+ # mountpoint - The String path to the mount directory.
85
+ # arguments - The Array of the hdiutil attach options.
60
86
  def self.attach dmg, mountpoint, arguments = []
61
87
  ohai "Mounting #{dmg}"
62
88
  system("/usr/bin/env", "hdiutil", "attach", *arguments, "-mountpoint", mountpoint, dmg)
63
89
  puts "Mounted: #{mountpoint}"
64
90
  end
65
91
 
92
+ # Unmount a DMG.
93
+ #
94
+ # dmg - The String path to the DMG.
95
+ # mountpoint - The String path to the unmount directory.
96
+ # arguments - The Array of the hdiutil detach options.
66
97
  def self.detach dmg, mountpoint, arguments = []
67
98
  ohai "Unmounting #{dmg}"
68
99
  system("/usr/bin/env", "hdiutil", "detach", *arguments, mountpoint)
69
100
  puts "Unmounted: #{mountpoint}"
70
101
  end
71
102
 
103
+ # Open a shell in the directory.
104
+ #
105
+ # dir - The String path to the directory.
72
106
  def self.shell dir
73
107
  Dir.chdir(dir) {
74
108
  ohai ENV['SHELL']
@@ -77,22 +111,30 @@ module HDIUtil
77
111
  end
78
112
  end
79
113
 
80
- module HDIUtil
81
- class DMG
114
+ module HDIUtil # :nodoc:
115
+ class DMG # :nodoc:
116
+
117
+ # The String path to the DMG.
82
118
  attr_accessor :url
83
119
 
120
+ # Initialize a new DMG.
121
+ #
122
+ # url - The String path to the DMG.
84
123
  def initialize url
85
124
  @url = File.absolute_path url
86
125
  end
87
126
 
127
+ # Perform read-only actions on the DMG.
88
128
  def show &block
89
129
  HDIUtil.read(@url, &block)
90
130
  end
91
131
 
132
+ # Open a read-write shell in the DMG.
92
133
  def edit
93
134
  update
94
135
  end
95
136
 
137
+ # Perform read-write actions on the DMG.
96
138
  def update &block
97
139
  Dir.mktmpdir { |tmp|
98
140
  flags = `/usr/bin/env ls -lO #{@url.shellescape}`.split[4]
@@ -102,6 +144,7 @@ module HDIUtil
102
144
  }
103
145
  end
104
146
 
147
+ # Returns true if the DMG is a valid image, false otherwise.
105
148
  def valid?
106
149
  HDIUtil.validate @url
107
150
  end
@@ -1,29 +1,54 @@
1
1
  require_relative "tty"
2
2
 
3
+ # +/usr/sbin/kextcache+
4
+ #
5
+ # https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/kextcache.8.html
3
6
  module KextCache
4
- KEXTCACHE_DEFAULT_OPTIONS = %w{ -v 0 -no-authentication }
5
7
 
6
- EXTENSIONS = %w{ System Library Extensions }
7
- EXTRA_EXTENSIONS = %w{ Library Extensions }
8
- KERNELCACHE = %w{ System Library Caches com.apple.kext.caches Startup kernelcache }
9
- MKEXT = %w{ System Library Caches com.apple.kext.caches Startup Extensions.mkext }
10
- MKEXT_PPC = %w{ System Library Extensions.mkext }
8
+ # The default options for kextcache.
9
+ DEFAULT_OPTIONS = %w[ -v 0 -no-authentication ]
11
10
 
11
+ # The relative path to Extensions.
12
+ EXTENSIONS = File.join %w[ System Library Extensions ]
13
+
14
+ # The relative path to Extra Extensions.
15
+ #
16
+ # Available on OS X Mavericks and later.
17
+ EXTRA_EXTENSIONS = File.join %w[ Library Extensions ]
18
+
19
+ # The relative path to kernelcache.
20
+ #
21
+ # Available on OS X Lion and later.
22
+ KERNELCACHE = File.join %w[ System Library Caches com.apple.kext.caches Startup kernelcache ]
23
+
24
+ # The relative path to Extensions.mkext.
25
+ #
26
+ # Available on OS X Snow Leopard.
27
+ MKEXT = File.join %w[ System Library Caches com.apple.kext.caches Startup Extensions.mkext ]
28
+
29
+ # The relative path to Extensions.mkext on PowerPC Macs.
30
+ #
31
+ # Available on OS X Leopard and eailer.
32
+ MKEXT_PPC = File.join %w[ System Library Extensions.mkext ]
33
+
34
+ # Update the kernelcache on a volume.
35
+ #
36
+ # volume_root - The String path to the volume root.
12
37
  def self.update_volume volume_root
13
38
  oh1 "Updating Kextcache"
14
39
  if File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
15
- extensions_path = [File.join(volume_root, *EXTENSIONS)]
16
- extensions_path.push(File.join(volume_root, *EXTRA_EXTENSIONS)) if File.exist? File.join(volume_root, *EXTRA_EXTENSIONS)
40
+ extensions_path = [File.join(volume_root, EXTENSIONS)]
41
+ extensions_path.push(File.join(volume_root, EXTRA_EXTENSIONS)) if File.exist? File.join(volume_root, EXTRA_EXTENSIONS)
17
42
  case
18
- when (File.exist? (url = File.join(volume_root, *KERNELCACHE)))
19
- system("/usr/bin/env", "kextcache", *KEXTCACHE_DEFAULT_OPTIONS, "-prelinked-kernel", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
20
- when (File.exist? (url = File.join(volume_root, *MKEXT)))
21
- system("/usr/bin/env", "kextcache", *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a i386 -a x86_64 }, "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
22
- if File.exist? (mkext_ppc = File.join(volume_root, *MKEXT_PPC))
43
+ when (File.exist? (url = File.join(volume_root, KERNELCACHE)))
44
+ system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, "-prelinked-kernel", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
45
+ when (File.exist? (url = File.join(volume_root, MKEXT)))
46
+ system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, *%w[ -a i386 -a x86_64 ], "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
47
+ if File.exist? (mkext_ppc = File.join(volume_root, MKEXT_PPC))
23
48
  system("/usr/bin/env", "ditto", url, mkext_ppc)
24
49
  end
25
- when (File.exist? (url = File.join(volume_root, *MKEXT_PPC)))
26
- system("/usr/bin/env", "ditto", *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a ppc -a i386 }, "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
50
+ when (File.exist? (url = File.join(volume_root, MKEXT_PPC)))
51
+ system("/usr/bin/env", "kextcache", *DEFAULT_OPTIONS, *%w[ -a ppc -a i386 ], "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
27
52
  else
28
53
  puts "kextcache aborted: unknown kernel cache type"
29
54
  return
@@ -1,7 +1,16 @@
1
1
  require "tmpdir"
2
2
  require_relative "tty"
3
3
 
4
+ # +/usr/sbin/pkgutil+
5
+ #
6
+ # https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man1/pkgutil.1.html
4
7
  module PKGUtil
8
+
9
+ # Perform read-only actions on the input package.
10
+ #
11
+ # If a block is given the block will be yielded with the path of the package expanded directory, otherwise a shell will be open.
12
+ #
13
+ # input - The String path to the input package.
5
14
  def self.read input
6
15
  Dir.mktmpdir { |tmp|
7
16
  tmp = File.join tmp, File.basename(input)
@@ -14,6 +23,12 @@ module PKGUtil
14
23
  }
15
24
  end
16
25
 
26
+ # Perform read-write actions on the input package and export as the output package.
27
+ #
28
+ # If a block is given the block will be yielded with the path of the package expanded directory, otherwise a shell will be open.
29
+ #
30
+ # input - The String path to the input package.
31
+ # output - The String path to the output package.
17
32
  def self.write input, output = input
18
33
  Dir.mktmpdir { |tmp|
19
34
  tmp = File.join tmp, File.basename(input)
@@ -29,18 +44,29 @@ module PKGUtil
29
44
 
30
45
  private
31
46
 
47
+ # Expand a PKG.
48
+ #
49
+ # pkg - The String path to the PKG.
50
+ # dir - The String path to the expand directory.
32
51
  def self.expand pkg, dir
33
52
  ohai "Expanding #{pkg}"
34
53
  system("/usr/bin/env", "pkgutil", "--expand", pkg, dir)
35
54
  puts "Expanded: #{dir}"
36
55
  end
37
56
 
57
+ # Flatten a PKG.
58
+ #
59
+ # dir - The String path to the flatten directory.
60
+ # pkg - The String path to the PKG.
38
61
  def self.flatten dir, pkg
39
62
  ohai "Flattening #{dir}"
40
63
  system("/usr/bin/env", "pkgutil", "--flatten", dir, pkg)
41
64
  puts "Flattened: #{pkg}"
42
65
  end
43
66
 
67
+ # Open a shell in the directory.
68
+ #
69
+ # dir - The String path to the directory.
44
70
  def self.shell dir
45
71
  Dir.chdir(dir) {
46
72
  ohai ENV['SHELL']
@@ -49,22 +75,30 @@ module PKGUtil
49
75
  end
50
76
  end
51
77
 
52
- module PKGUtil
53
- class PKG
78
+ module PKGUtil # :nodoc:
79
+ class PKG # :nodoc:
80
+
81
+ # The String path to the PKG.
54
82
  attr_accessor :url
55
83
 
84
+ # Initialize a new PKG.
85
+ #
86
+ # url - The String path to the PKG.
56
87
  def initialize url
57
88
  @url = File.absolute_path url
58
89
  end
59
90
 
91
+ # Perform read-only actions on the PKG.
60
92
  def show &block
61
93
  PKGUtil.read(@url, &block)
62
94
  end
63
95
 
96
+ # Open a read-write shell in the PKG.
64
97
  def edit
65
98
  update
66
99
  end
67
100
 
101
+ # Perform read-write actions on the PKG.
68
102
  def update &block
69
103
  PKGUtil.write(@url, &block)
70
104
  end
@@ -1,5 +1,6 @@
1
1
  require "shellwords"
2
2
 
3
+ # :enddoc:
3
4
  module Tty extend self
4
5
  def blue; bold 34; end
5
6
  def white; bold 39; end
@@ -61,7 +62,7 @@ def odie error
61
62
  end
62
63
 
63
64
  def system *args
64
- abort "Failed during: #{args.shelljoin}" unless Kernel.system *args
65
+ abort "Failed during: #{args.shelljoin}" unless Kernel.system(*args)
65
66
  end
66
67
 
67
68
  def sudo *args
@@ -70,6 +71,6 @@ def sudo *args
70
71
  else
71
72
  "/usr/bin/sudo #{args.first}"
72
73
  end
73
- ohai *args
74
- system *args
74
+ ohai(*args)
75
+ system(*args)
75
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iesd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "なつき"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modify Extensions, Kextcache and Packages on InstallESD.
14
14
  email: i@ntk.me