74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/xcode/install.rb', line 74
def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
archive_util = '/System/Library/CoreServices/Applications/Archive Utility.app/Contents/MacOS/Archive Utility'
prompt = "Please authenticate for Xcode installation.\nPassword: "
xcode_beta_path = dmg_path.dirname + 'Xcode-beta.app'
xcode_path = "/Applications/Xcode#{suffix}.app"
if dmg_path.extname == '.xip'
`'#{archive_util}' #{dmg_path}`
`sudo -p "#{prompt}" mv "#{xcode_beta_path}" "#{xcode_path}"`
else
mount_dir = mount(dmg_path)
source = Dir.glob(File.join(mount_dir, 'Xcode*.app')).first
if source.nil?
out = <<-HELP
No `Xcode.app` found in DMG. Please remove #{dmg_path} if you suspect a corrupted
download or run `xcversion update` to see if the version you tried to install
has been pulled by Apple. If none of this is true, please open a new GH issue.
HELP
$stderr.puts out.tr("\n", ' ')
return
end
`sudo -p "#{prompt}" ditto "#{source}" "#{xcode_path}"`
`umount "/Volumes/Xcode"`
end
unless verify_integrity(xcode_path)
`sudo rm -f #{xcode_path}`
return
end
enable_developer_mode
xcode = InstalledXcode.new(xcode_path)
xcode.approve_license
xcode.install_components
if switch
`sudo rm -f #{SYMLINK_PATH}` unless current_symlink.nil?
`sudo ln -sf #{xcode_path} #{SYMLINK_PATH}` unless SYMLINK_PATH.exist?
`sudo xcode-select --switch #{xcode_path}`
puts `xcodebuild -version`
end
FileUtils.rm_f(dmg_path) if clean
end
|