iesd 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aac5e6422553fbc24733e6b6df384a04f026b7ea
4
- data.tar.gz: 9f70b146938796a582bdd5c2d9050f840bd8f6e0
3
+ metadata.gz: 0d6447d914c3336dfcbd31bed32b08e466afd817
4
+ data.tar.gz: 1283183f073d822b41df8721be9068f6771645b7
5
5
  SHA512:
6
- metadata.gz: a0e5bcfae01077ee7927ae424844d65f8c383c2405d0b26e46ce30c9946d73a19e5294e4536e9097fd03f8293e8bea1931c19ebe5b791d4b6fefe6c4911a1bdb
7
- data.tar.gz: 04f8923c1e28f416e27e6c16585228230c62f9569eb6f7359065eb59b06bc4661f0e0d5c434d6c72f12581ad7c1581d9db6d06d9955c3c884bccbcad53917144
6
+ metadata.gz: 3891f8b6de4af530d2708ac096dab375d92cf88070d5fd9f89dced055503d4c15f320b6d7c9257da7f81bbe037080f45f9aa66ad1a2847f2efe4dc16899a5ff8
7
+ data.tar.gz: f181900399e4ed2f78d99cfd6929709a0c8085589ed12604f1d4e9c6ee01eefb3fd5d8308a78dc30aaacc924aa38c29d858aaf27163acdf6f277c700de941dfd
data/bin/iesd CHANGED
@@ -27,7 +27,7 @@ options = {
27
27
  :mach_kernel => nil,
28
28
  :extensions => {
29
29
  :install => [],
30
- :remove => [],
30
+ :uninstall=> [],
31
31
  :kextcache => nil,
32
32
  :postinstall => true
33
33
  }
@@ -39,23 +39,23 @@ optparse = OptionParser.new do |opts|
39
39
  opts.separator ""
40
40
  opts.separator "Specific options:"
41
41
 
42
- opts.on("-i", "--input inputfile",
43
- "Input file (dmg or app)") do |input|
42
+ opts.on("-i", "--input file",
43
+ "Specify the input dmg or app.") do |input|
44
44
  options[:input] = File.absolute_path input
45
45
  end
46
46
 
47
- opts.on("-o", "--output outputfile",
48
- "Output file (dmg)") do |output|
47
+ opts.on("-o", "--output file",
48
+ "Specify the output dmg.") do |output|
49
49
  output << ".dmg" if File.extname(output).downcase != ".dmg"
50
50
  options[:output] = File.absolute_path output
51
51
  end
52
52
 
53
53
  opts.on("-t", "--type type", [:BaseSystem, :InstallESD],
54
- "Output type (BaseSystem, InstallESD)") do |type|
54
+ "Specify the output type. Type could be BaseSystem or InstallESD.") do |type|
55
55
  options[:type] = type
56
56
  end
57
57
 
58
- opts.on("-s", "--[no-]interactive-shell", "Edit in #{ENV["SHELL"]}") do |interactive|
58
+ opts.on("-s", "--[no-]interactive-shell", "Open #{ENV["SHELL"]} inside the temporary mount directory.") do |interactive|
59
59
  options[:interactive] = interactive
60
60
  end
61
61
 
@@ -63,44 +63,46 @@ optparse = OptionParser.new do |opts|
63
63
  opts.separator "HDIUtil options:"
64
64
 
65
65
  opts.on("--grow sectors", OptionParser::DecimalInteger,
66
- "Grow dmg size by number of sectors") do |sectors|
66
+ "Specify the size of the image to grow in 512-byte sectors.") do |sectors|
67
67
  options[:hdiutil][:resize][:grow] = sectors
68
68
  end
69
69
 
70
- opts.on("--[no-]shrink", "Shrink output dmg") do |s|
70
+ opts.on("--[no-]shrink", "Do [not] shrink the output image.") do |s|
71
71
  options[:hdiutil][:resize][:shrink] = s
72
72
  end
73
73
 
74
74
  opts.separator ""
75
75
  opts.separator "Boot options:"
76
76
 
77
- opts.on("--[no-]kernel", "Use mach_kernel as fallback to kernelcache") do |k|
77
+ opts.on("--[no-]fallback-kernel", "Do [not] fallback to mach_kernel when kernelcache fails to boot.") do |k|
78
78
  options[:mach_kernel] = k
79
79
  end
80
80
 
81
81
  opts.separator ""
82
- opts.separator "Extension options:"
82
+ opts.separator "Extensions options:"
83
83
 
84
- opts.on("--remove-kexts x.kext,y.kext,z.kext", Array, "Kexts to remove") do |list|
85
- options[:extensions][:remove] = list
84
+ opts.on("--install-extension kext",
85
+ "Add the kext to the list of the extensions to be installed.") do |kext|
86
+ options[:extensions][:install].push File.absolute_path kext
86
87
  end
87
88
 
88
- opts.on("--install-kexts x.kext,y.kext,z.kext", Array, "Kexts to install") do |list|
89
- options[:extensions][:install] = list.map { |kext| File.absolute_path kext }
89
+ opts.on("--uninstall-extension kext",
90
+ "Add the kext to the list of the extensions to be uninstalled.") do |kext|
91
+ options[:extensions][:uninstall].push kext
90
92
  end
91
93
 
92
- opts.on("--[no-]postinstall-kexts", "Patch OSInstall.pkg to postinstall kexts") do |p|
94
+ opts.on("--[no-]postinstall-extensions", "Do [not] patch OSInstall.pkg to postinstall extensions.") do |p|
93
95
  options[:extensions][:postinstall] = p
94
96
  end
95
97
 
96
- opts.on("--[no-]kextcache", "Rebuild kernelcache") do |c|
98
+ opts.on("--[no-]update-kernelcache", "Do [not] rebuild the startup kernelcache.") do |c|
97
99
  options[:extensions][:kextcache] = c
98
100
  end
99
101
 
100
102
  opts.separator ""
101
103
  opts.separator "Common options:"
102
104
 
103
- opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
105
+ opts.on("--[no-]verbose", "Run verbosely") do |v|
104
106
  ENV['VERBOSE'] = '1'
105
107
  end
106
108
 
@@ -129,7 +131,7 @@ end
129
131
  begin
130
132
  raise "input file does not exist" unless File.exist? options[:input]
131
133
  raise "output file already exists" if File.exist? options[:output]
132
- options[:extensions][:remove].select { |kext|
134
+ options[:extensions][:uninstall].select { |kext|
133
135
  if File.extname(kext) == ".kext"
134
136
  true
135
137
  else
@@ -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.1.2"
5
+ s.version = "1.2.0"
6
6
  s.summary = "Customize OS X InstallESD."
7
7
  s.description = "Modify Extensions, Kextcache and Packages on InstallESD."
8
8
  s.authors = "なつき"
@@ -1,7 +1,5 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
- require "tmpdir"
4
-
5
3
  require "iesd/utility"
6
4
  require "iesd/InstallESD"
7
5
  require "iesd/InstallESD/Extensions"
@@ -8,7 +8,7 @@ module IESD
8
8
  when :BaseSystem, nil
9
9
  Dir.mktmpdir { |tmp|
10
10
  HDIUtil.write(@url, (tmpfile = File.join(tmp, File.basename(@url))), options[:hdiutil]) { |volume_root|
11
- options[:extensions][:up_to_date] = (options[:extensions][:remove].empty? and options[:extensions][:install].empty?)
11
+ options[:extensions][:up_to_date] = (options[:extensions][:uninstall].empty? and options[:extensions][:install].empty?)
12
12
  options[:mach_kernel] = File.exist? File.join(volume_root, "mach_kernel") if options[:mach_kernel].nil?
13
13
 
14
14
  yield volume_root if block_given?
@@ -25,7 +25,7 @@ module IESD
25
25
  HDIUtil.shell volume_root
26
26
  end
27
27
  }
28
- system(Utility::MV, tmpfile, options[:output])
28
+ system("/usr/bin/env", "mv", tmpfile, options[:output])
29
29
  }
30
30
  else
31
31
  raise "invalid output type"
@@ -37,7 +37,7 @@ module IESD
37
37
  def pre_update_extension volume_root, options
38
38
  if !File.exist? (mach_kernel = File.join(volume_root, "mach_kernel")) and (options[:mach_kernel] or !options[:extensions][:up_to_date])
39
39
  IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, *PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
40
- system(Utility::CHFLAGS, "hidden", mach_kernel)
40
+ system("/usr/bin/env", "chflags", "hidden", mach_kernel)
41
41
  end
42
42
  end
43
43
 
@@ -46,13 +46,13 @@ module IESD
46
46
  IESD::Packages::OSInstall.new(File.join(volume_root, *PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
47
47
  end
48
48
  if !options[:mach_kernel] and File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
49
- system(Utility::RM, mach_kernel)
49
+ system("/usr/bin/env", "rm", mach_kernel)
50
50
  end
51
51
  end
52
52
 
53
53
  class Extensions < IESD::Extensions
54
54
  def update extensions
55
- remove extensions[:remove]
55
+ uninstall extensions[:uninstall]
56
56
  install extensions[:install]
57
57
  KextCache.update_volume @volume_root if extensions[:kextcache] or (extensions[:kextcache].nil? and !extensions[:up_to_date])
58
58
  end
@@ -1,20 +1,29 @@
1
1
  module IESD
2
2
  class Extensions
3
3
  EXTENSIONS = %w{ System Library Extensions }
4
+ EXTRA_EXTENSIONS = %w{ Library Extensions }
4
5
 
5
6
  attr_reader :volume_root, :url
6
7
 
7
8
  def initialize volume_root
8
9
  @volume_root = volume_root
9
- @url = File.join @volume_root, *EXTENSIONS
10
+ @extensions = File.join @volume_root, *EXTENSIONS
11
+ @extra_extensions = File.join @volume_root, *EXTRA_EXTENSIONS
10
12
  end
11
13
 
12
- def remove kexts
14
+ def uninstall kexts
13
15
  if !kexts.empty?
14
- oh1 "Removing Extensions"
16
+ oh1 "Uninstalling Extensions"
15
17
  kexts.each { |kext|
16
- system(Utility::RM, "-rf", File.join(@url, kext))
17
- puts "Removed: #{File.join(@url, kext)}"
18
+ kext_url = File.join(@extra_extensions, kext)
19
+ if File.exist? kext_url
20
+ system("/usr/bin/env", "rm", "-rf", kext_url)
21
+ puts "Uninstalled: #{kext_url}"
22
+ else
23
+ kext_url = File.join(@extensions, kext)
24
+ system("/usr/bin/env", "rm", "-rf", kext_url)
25
+ puts "Removed: #{kext_url}"
26
+ end
18
27
  }
19
28
  end
20
29
  end
@@ -23,8 +32,15 @@ module IESD
23
32
  if !kexts.empty?
24
33
  oh1 "Installing Extensions"
25
34
  kexts.each { |kext|
26
- system(Utility::DITTO, kext, File.join(@url, File.basename(kext)))
27
- puts "Installed: #{File.join(@url, File.basename(kext))}"
35
+ kext_url = File.join(@extensions, File.basename(kext))
36
+ if File.exist? kext_url
37
+ system("/usr/bin/env", "ditto", kext, kext_url)
38
+ puts "Overwrote: #{kext_url}"
39
+ else
40
+ kext_url = File.join(@extra_extensions, File.basename(kext)) if File.exist? @extra_extensions
41
+ system("/usr/bin/env", "ditto", kext, kext_url)
42
+ puts "Installed: #{kext_url}"
43
+ end
28
44
  }
29
45
  end
30
46
  end
@@ -1,3 +1,5 @@
1
+ require "shellwords"
2
+
1
3
  module IESD
2
4
  class DMG
3
5
  class InstallESD < HDIUtil::DMG
@@ -13,23 +15,23 @@ module IESD
13
15
  }
14
16
  }
15
17
  }.merge(options)
16
- options[:hdiutil][:resize][:grow] += ( `#{Utility::HDIUTIL} resize -limits "#{@url}"`.chomp.split.map { |s| s.to_i } ).first
18
+ options[:hdiutil][:resize][:grow] += ( `/usr/bin/env hdiutil resize -limits #{@url.shellescape}`.chomp.split.map { |s| s.to_i } ).first
17
19
 
18
20
  show { |installesd|
19
21
  IESD::DMG::BaseSystem.new(File.join(installesd, "BaseSystem.dmg")).export(options) { |basesystem|
20
22
  installesd_packages = File.join installesd, PACKAGES
21
23
  basesystem_packages = File.join basesystem, *IESD::DMG::BaseSystem::PACKAGES
22
24
  oh1 "Copying #{installesd_packages}"
23
- system(Utility::RM, basesystem_packages)
24
- system(Utility::DITTO, installesd_packages, basesystem_packages)
25
+ system("/usr/bin/env", "rm", basesystem_packages)
26
+ system("/usr/bin/env", "ditto", installesd_packages, basesystem_packages)
25
27
  puts "Copied: #{basesystem_packages}"
26
28
 
27
29
  installesd_mach_kernel = File.join installesd, "mach_kernel"
28
30
  basesystem_mach_kernel = File.join basesystem, "mach_kernel"
29
31
  if File.exist? installesd_mach_kernel
30
32
  oh1 "Copying #{installesd_mach_kernel}"
31
- system(Utility::DITTO, installesd_mach_kernel, basesystem_mach_kernel)
32
- system(Utility::CHFLAGS, "hidden", basesystem_mach_kernel)
33
+ system("/usr/bin/env", "ditto", installesd_mach_kernel, basesystem_mach_kernel)
34
+ system("/usr/bin/env", "chflags", "hidden", basesystem_mach_kernel)
33
35
  puts "Copied: #{basesystem_mach_kernel}"
34
36
  end
35
37
  }
@@ -37,7 +39,7 @@ module IESD
37
39
  when :InstallESD, nil
38
40
  Dir.mktmpdir { |tmp|
39
41
  HDIUtil.write(@url, (tmpfile = File.join(tmp, File.basename(@url))), options[:hdiutil]) { |installesd|
40
- options[:extensions][:up_to_date] = (options[:extensions][:remove].empty? and options[:extensions][:install].empty?)
42
+ options[:extensions][:up_to_date] = (options[:extensions][:uninstall].empty? and options[:extensions][:install].empty?)
41
43
  options[:mach_kernel] = File.exist? File.join(installesd, "mach_kernel") if options[:mach_kernel].nil?
42
44
 
43
45
  yield installesd if block_given?
@@ -46,24 +48,24 @@ module IESD
46
48
 
47
49
  basesystem_options = options.clone
48
50
  basesystem_options[:input] = basesystem_options[:output] = File.join(installesd, "BaseSystem.dmg")
49
- basesystem_flags = `#{Utility::LS} -lO "#{basesystem_options[:input]}"`.split[4]
51
+ basesystem_flags = `/usr/bin/env ls -lO #{basesystem_options[:input].shellescape}`.split[4]
50
52
  IESD::DMG::InstallESD::BaseSystem.new(File.join(basesystem_options[:input])).export(basesystem_options) { |basesystem|
51
53
  installesd_mach_kernel = File.join installesd, "mach_kernel"
52
54
  basesystem_mach_kernel = File.join basesystem, "mach_kernel"
53
55
  if File.exist? installesd_mach_kernel
54
56
  oh1 "Copying #{installesd_mach_kernel}"
55
- system(Utility::DITTO, installesd_mach_kernel, basesystem_mach_kernel)
56
- system(Utility::CHFLAGS, "hidden", basesystem_mach_kernel)
57
+ system("/usr/bin/env", "ditto", installesd_mach_kernel, basesystem_mach_kernel)
58
+ system("/usr/bin/env", "chflags", "hidden", basesystem_mach_kernel)
57
59
  puts "Copied: #{basesystem_mach_kernel}"
58
60
  end
59
61
  }
60
- system(Utility::CHFLAGS, basesystem_flags, basesystem_options[:output]) unless basesystem_flags == "-"
62
+ system("/usr/bin/env", "chflags", basesystem_flags, basesystem_options[:output]) unless basesystem_flags == "-"
61
63
 
62
64
  if File.exist? (kextcache = File.join(installesd, "kernelcache"))
63
65
  IESD::DMG::InstallESD::BaseSystem.new(File.join(basesystem_options[:output])).show { |basesystem|
64
66
  oh1 "Updating Kextcache"
65
- system(Utility::DITTO, File.join(basesystem, *KextCache::KERNELCACHE), kextcache)
66
- system(Utility::CHFLAGS, "hidden", kextcache)
67
+ system("/usr/bin/env", "ditto", File.join(basesystem, *KextCache::KERNELCACHE), kextcache)
68
+ system("/usr/bin/env", "chflags", "hidden", kextcache)
67
69
  puts "Updated: #{kextcache}"
68
70
  }
69
71
  end
@@ -76,7 +78,7 @@ module IESD
76
78
  HDIUtil.shell installesd
77
79
  end
78
80
  }
79
- system(Utility::MV, tmpfile, options[:output])
81
+ system("/usr/bin/env", "mv", tmpfile, options[:output])
80
82
  }
81
83
  else
82
84
  raise "invalid output type"
@@ -88,7 +90,7 @@ module IESD
88
90
  def pre_update_extension volume_root, options
89
91
  if !File.exist? (mach_kernel = File.join(volume_root, "mach_kernel")) and (options[:mach_kernel] or !options[:extensions][:up_to_date])
90
92
  IESD::Packages::BaseSystemBinaries.new(File.join(volume_root, *PACKAGES, "BaseSystemBinaries.pkg")).extract_mach_kernel mach_kernel
91
- system(Utility::CHFLAGS, "hidden", mach_kernel)
93
+ system("/usr/bin/env", "chflags", "hidden", mach_kernel)
92
94
  end
93
95
  end
94
96
 
@@ -97,7 +99,7 @@ module IESD
97
99
  IESD::Packages::OSInstall.new(File.join(volume_root, *PACKAGES, "OSInstall.pkg")).postinstall_extensions options[:extensions]
98
100
  end
99
101
  if !options[:mach_kernel] and File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
100
- system(Utility::RM, mach_kernel)
102
+ system("/usr/bin/env", "rm", mach_kernel)
101
103
  end
102
104
  end
103
105
 
@@ -110,7 +112,7 @@ module IESD
110
112
 
111
113
  def post_update_extension volume_root, options
112
114
  if File.exist? (mach_kernel = File.join(volume_root, "mach_kernel"))
113
- system(Utility::RM, mach_kernel)
115
+ system("/usr/bin/env", "rm", mach_kernel)
114
116
  end
115
117
  end
116
118
  end
@@ -1,3 +1,5 @@
1
+ require "shellwords"
2
+
1
3
  module IESD
2
4
  class Packages
3
5
  class BaseSystemBinaries < PKGUtil::PKG
@@ -6,18 +8,18 @@ module IESD
6
8
  payload = "#{pkg}/Payload"
7
9
  cpio = "#{payload}.cpio"
8
10
  ohai "Unarchiving #{payload}"
9
- case `#{Utility::FILE} --brief --mime-type #{payload}`.chomp
11
+ case `/usr/bin/env file --brief --mime-type #{payload.shellescape}`.chomp
10
12
  when "application/x-bzip2"
11
- system(Utility::MV, payload, "#{cpio}.bz2")
12
- system(Utility::BUNZIP2, "#{cpio}.bz2")
13
+ system("/usr/bin/env", "mv", payload, "#{cpio}.bz2")
14
+ system("/usr/bin/env", "bunzip2", "#{cpio}.bz2")
13
15
  when "application/x-gzip"
14
- system(Utility::MV, payload, "#{cpio}.gz")
15
- system(Utility::GUNZIP, "#{cpio}.gz")
16
+ system("/usr/bin/env", "mv", payload, "#{cpio}.gz")
17
+ system("/usr/bin/env", "gunzip", "#{cpio}.gz")
16
18
  end
17
19
  puts "Unarchived: #{cpio}"
18
20
  ohai "Extracting /mach_kernel"
19
- system("#{Utility::CPIO} -p -d -I \"#{cpio}\" -- \"#{payload}\" <<</mach_kernel >/dev/null 2>&1")
20
- system(Utility::MV, "#{payload}/mach_kernel", output)
21
+ system("/usr/bin/env cpio -p -d -I #{cpio.shellescape} -- #{payload.shellescape} <<</mach_kernel >/dev/null 2>&1")
22
+ system("/usr/bin/env", "mv", "#{payload}/mach_kernel", output)
21
23
  puts "Extracted: #{output}"
22
24
  }
23
25
  end
@@ -7,13 +7,19 @@ module IESD
7
7
  script = File.join pkg, *%w{ Scripts postinstall_actions kext.tool }
8
8
  File.open(script, "a+") { |f|
9
9
  f.puts("#!/bin/sh")
10
- extensions[:remove].each { |kext|
11
- f.puts("logger -p install.info \"Removing #{kext}\"")
12
- f.puts("/bin/rm -rf \"$3/System/Library/Extensions/#{kext}\"")
10
+ extensions[:uninstall].each { |kext|
11
+ f.puts(%Q{logger -p install.info "Uninstalling #{kext}"})
12
+ f.puts(%Q{/bin/test -e "$3%{extra_extensions_kext}" && /bin/rm -rf "$3%{extra_extensions_kext}" || /bin/rm -rf "$3%{extensions_kext}"} % {
13
+ :extensions_kext => "/System/Library/Extensions/#{kext}",
14
+ :extra_extensions_kext => "/Library/Extensions/#{kext}"
15
+ })
13
16
  }
14
17
  extensions[:install].each { |kext|
15
- f.puts("logger -p install.info \"Installing #{File.basename kext}\"")
16
- f.puts("/usr/bin/ditto \"/System/Library/Extensions/#{File.basename kext}\" \"$3/System/Library/Extensions/#{File.basename kext}\"")
18
+ f.puts(%Q{logger -p install.info "Installing #{File.basename kext}"})
19
+ f.puts(%Q{/bin/test -e "%{extensions_kext}" && /usr/bin/ditto "%{extensions_kext}" "$3%{extensions_kext}" || /usr/bin/ditto "%{extra_extensions_kext}" "$3%{extra_extensions_kext}"} % {
20
+ :extensions_kext => "/System/Library/Extensions/#{File.basename kext}",
21
+ :extra_extensions_kext => "/Library/Extensions/#{File.basename kext}"
22
+ })
17
23
  }
18
24
  }
19
25
  File.chmod(0755, script)
@@ -1,18 +1 @@
1
- require "tmpdir"
2
-
3
- module Utility
4
- BUNZIP2 = "/usr/bin/bunzip2"
5
- CHFLAGS = "/usr/bin/chflags"
6
- CPIO = "/usr/bin/cpio"
7
- DITTO = "/usr/bin/ditto"
8
- FILE = "/usr/bin/file"
9
- GUNZIP = "/usr/bin/gunzip"
10
- HDIUTIL = "/usr/bin/hdiutil"
11
- KEXTCACHE = "/usr/sbin/kextcache"
12
- LS = "/bin/ls"
13
- MV = "/bin/mv"
14
- PKGUTIL = "/usr/sbin/pkgutil"
15
- RM = "/bin/rm"
16
- end
17
-
18
1
  Dir[File.join(File.dirname(__FILE__), "utility", "*.rb")].each { |rb| require rb }
@@ -1,3 +1,7 @@
1
+ require "shellwords"
2
+ require "tmpdir"
3
+ require_relative "tty"
4
+
1
5
  module HDIUtil
2
6
  DEFAULT_MOUNT_OPTIONS = %w{ -nobrowse -quiet -noverify }
3
7
  DEFAULT_MOUNT_OPTIONS.concat(%w{ -owners on }) if Process.uid == 0
@@ -27,11 +31,11 @@ module HDIUtil
27
31
  Dir.mktmpdir { |tmp|
28
32
  shadow = File.join(tmp, "#{File.basename input}.shadow")
29
33
  shadow_options = ["-shadow", shadow]
30
- format_options = ["-format", `#{Utility::HDIUTIL} imageinfo -format "#{input}"`.chomp]
34
+ format_options = ["-format", `/usr/bin/env hdiutil imageinfo -format #{input.shellescape}`.chomp]
31
35
  Dir.mktmpdir(nil, tmp) { |mountpoint|
32
- resize_limits = `#{Utility::HDIUTIL} resize -limits -shadow "#{shadow}" "#{input}"`.chomp.split.map { |s| s.to_i }
36
+ resize_limits = `/usr/bin/env hdiutil resize -limits -shadow #{shadow.shellescape} #{input.shellescape}`.chomp.split.map { |s| s.to_i }
33
37
  sectors = (resize_limits[1] + options[:resize][:grow]).to_s
34
- system(Utility::HDIUTIL, "resize", "-growonly", "-sectors", sectors, *shadow_options, input)
38
+ system("/usr/bin/env", "hdiutil", "resize", "-growonly", "-sectors", sectors, *shadow_options, input)
35
39
  attach input, mountpoint, [*DEFAULT_MOUNT_OPTIONS, *shadow_options]
36
40
  if block_given?
37
41
  yield mountpoint
@@ -39,29 +43,29 @@ module HDIUtil
39
43
  shell mountpoint
40
44
  end
41
45
  detach input, mountpoint, [*DEFAULT_UNMOUNT_OPTIONS]
42
- system(Utility::HDIUTIL, "resize", "-shrinkonly", "-sectors", "min", *shadow_options, input) if options[:resize][:shrink]
46
+ system("/usr/bin/env", "hdiutil", "resize", "-shrinkonly", "-sectors", "min", *shadow_options, input) if options[:resize][:shrink]
43
47
  }
44
48
  oh1 "Merging #{shadow}"
45
- system(Utility::HDIUTIL, "convert", *DEFAULT_CONVERT_OPTIONS, *format_options, *shadow_options, "-o", output, input)
49
+ system("/usr/bin/env", "hdiutil", "convert", *DEFAULT_CONVERT_OPTIONS, *format_options, *shadow_options, "-o", output, input)
46
50
  puts "Merged: #{output}"
47
51
  }
48
52
  end
49
53
 
50
54
  def self.validate input
51
- Kernel.system("#{Utility::HDIUTIL} imageinfo \"#{input}\" >/dev/null 2>&1")
55
+ Kernel.system(%Q{/usr/bin/env hdiutil imageinfo #{input.shellescape} >/dev/null 2>&1})
52
56
  end
53
57
 
54
58
  private
55
59
 
56
60
  def self.attach dmg, mountpoint, arguments = []
57
61
  ohai "Mounting #{dmg}"
58
- system(Utility::HDIUTIL, "attach", *arguments, "-mountpoint", mountpoint, dmg)
62
+ system("/usr/bin/env", "hdiutil", "attach", *arguments, "-mountpoint", mountpoint, dmg)
59
63
  puts "Mounted: #{mountpoint}"
60
64
  end
61
65
 
62
66
  def self.detach dmg, mountpoint, arguments = []
63
67
  ohai "Unmounting #{dmg}"
64
- system(Utility::HDIUTIL, "detach", *arguments, mountpoint)
68
+ system("/usr/bin/env", "hdiutil", "detach", *arguments, mountpoint)
65
69
  puts "Unmounted: #{mountpoint}"
66
70
  end
67
71
 
@@ -91,10 +95,10 @@ module HDIUtil
91
95
 
92
96
  def update &block
93
97
  Dir.mktmpdir { |tmp|
94
- flags = `#{Utility::LS} -lO "#{@url}"`.split[4]
98
+ flags = `/usr/bin/env ls -lO #{@url.shellescape}`.split[4]
95
99
  HDIUtil.write(@url, (tmpfile = File.join(tmp, File.basename(@url))), &block)
96
- system(Utility::MV, tmpfile, @url)
97
- system(Utility::CHFLAGS, flags, @url) unless flags == "-"
100
+ system("/usr/bin/env", "mv", tmpfile, @url)
101
+ system("/usr/bin/env", "chflags", flags, @url) unless flags == "-"
98
102
  }
99
103
  end
100
104
 
@@ -1,7 +1,10 @@
1
+ require_relative "tty"
2
+
1
3
  module KextCache
2
4
  KEXTCACHE_DEFAULT_OPTIONS = %w{ -v 0 -no-authentication }
3
5
 
4
6
  EXTENSIONS = %w{ System Library Extensions }
7
+ EXTRA_EXTENSIONS = %w{ Library Extensions }
5
8
  KERNELCACHE = %w{ System Library Caches com.apple.kext.caches Startup kernelcache }
6
9
  MKEXT = %w{ System Library Caches com.apple.kext.caches Startup Extensions.mkext }
7
10
  MKEXT_PPC = %w{ System Library Extensions.mkext }
@@ -9,16 +12,18 @@ module KextCache
9
12
  def self.update_volume volume_root
10
13
  oh1 "Updating Kextcache"
11
14
  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)
12
17
  case
13
18
  when (File.exist? (url = File.join(volume_root, *KERNELCACHE)))
14
- system(Utility::KEXTCACHE, *KEXTCACHE_DEFAULT_OPTIONS, "-prelinked-kernel", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", File.join(volume_root, *EXTENSIONS))
19
+ system("/usr/bin/env", "kextcache", *KEXTCACHE_DEFAULT_OPTIONS, "-prelinked-kernel", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", *extensions_path)
15
20
  when (File.exist? (url = File.join(volume_root, *MKEXT)))
16
- system(Utility::KEXTCACHE, *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a i386 -a x86_64 }, "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", File.join(volume_root, *EXTENSIONS))
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)
17
22
  if File.exist? (mkext_ppc = File.join(volume_root, *MKEXT_PPC))
18
- system(Utility::DITTO, url, mkext_ppc)
23
+ system("/usr/bin/env", "ditto", url, mkext_ppc)
19
24
  end
20
25
  when (File.exist? (url = File.join(volume_root, *MKEXT_PPC)))
21
- system(Utility::DITTO, *KEXTCACHE_DEFAULT_OPTIONS, *%w{ -a ppc -a i386 }, "-mkext", url, "-kernel", mach_kernel, "-volume-root", volume_root, "--", File.join(volume_root, *EXTENSIONS))
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)
22
27
  else
23
28
  puts "kextcache aborted: unknown kernel cache type"
24
29
  return
@@ -1,3 +1,6 @@
1
+ require "tmpdir"
2
+ require_relative "tty"
3
+
1
4
  module PKGUtil
2
5
  def self.read input
3
6
  Dir.mktmpdir { |tmp|
@@ -28,13 +31,13 @@ module PKGUtil
28
31
 
29
32
  def self.expand pkg, dir
30
33
  ohai "Expanding #{pkg}"
31
- system(Utility::PKGUTIL, "--expand", pkg, dir)
34
+ system("/usr/bin/env", "pkgutil", "--expand", pkg, dir)
32
35
  puts "Expanded: #{dir}"
33
36
  end
34
37
 
35
38
  def self.flatten dir, pkg
36
39
  ohai "Flattening #{dir}"
37
- system(Utility::PKGUTIL, "--flatten", dir, pkg)
40
+ system("/usr/bin/env", "pkgutil", "--flatten", dir, pkg)
38
41
  puts "Flattened: #{pkg}"
39
42
  end
40
43
 
@@ -1,3 +1,5 @@
1
+ require "shellwords"
2
+
1
3
  module Tty extend self
2
4
  def blue; bold 34; end
3
5
  def white; bold 39; end
@@ -32,14 +34,6 @@ module Tty extend self
32
34
  end
33
35
  end
34
36
 
35
- class Array
36
- def shell_s
37
- cp = dup
38
- first = cp.shift
39
- cp.map{ |arg| arg.gsub " ", "\\ " }.unshift(first) * " "
40
- end
41
- end
42
-
43
37
  def ohai title, *sput
44
38
  title = Tty.truncate(title) if $stdout.tty? && ENV['VERBOSE'].nil?
45
39
  puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
@@ -67,7 +61,7 @@ def odie error
67
61
  end
68
62
 
69
63
  def system *args
70
- abort "Failed during: #{args.shell_s}" unless Kernel.system *args
64
+ abort "Failed during: #{args.shelljoin}" unless Kernel.system *args
71
65
  end
72
66
 
73
67
  def sudo *args
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.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "なつき"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modify Extensions, Kextcache and Packages on InstallESD.
14
14
  email: i@ntk.me