lib/xcode/install.rb in xcode-install-1.0.0 vs lib/xcode/install.rb in xcode-install-1.0.1

- old
+ new

@@ -60,11 +60,11 @@ def installed?(version) installed_versions.map(&:version).include?(version) end def installed_versions - @installed ||= installed.map { |x| InstalledXcode.new(x) }.sort do |a, b| + installed.map { |x| InstalledXcode.new(x) }.sort do |a, b| Gem::Version.new(a.version) <=> Gem::Version.new(b.version) end end def install_dmg(dmgPath, suffix = '', switch = true, clean = true) @@ -91,11 +91,13 @@ `sudo rm -f #{xcode_path}` return end enable_developer_mode - InstalledXcode.new(xcode_path).approve_license + 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? @@ -269,11 +271,11 @@ attr_reader :path attr_reader :version def initialize(path) @path = Pathname.new(path) - @version = get_version(path) + @version = get_version end def approve_license license_path = "#{@path}/Contents/Resources/English.lproj/License.rtf" license_id = IO.read(license_path).match(/^EA\d{4}/) @@ -281,13 +283,21 @@ `sudo rm -rf #{license_plist_path}` `sudo /usr/libexec/PlistBuddy -c "add :IDELastGMLicenseAgreedTo string #{license_id}" #{license_plist_path}` `sudo /usr/libexec/PlistBuddy -c "add :IDEXcodeVersionForAgreedToGMLicense string #{@version}" #{license_plist_path}` end + def install_components + `sudo installer -pkg #{@path}/Contents/Resources/Packages/MobileDevice.pkg -target /` + osx_build_version = `sw_vers -buildVersion`.chomp + tools_version = `/usr/libexec/PlistBuddy -c "Print :ProductBuildVersion" "#{@path}/Contents/version.plist"`.chomp + cache_dir = `getconf DARWIN_USER_CACHE_DIR`.chomp + `touch #{cache_dir}com.apple.dt.Xcode.InstallCheckCache_#{osx_build_version}_#{tools_version}` + end + :private - def get_version(xcode_path) - output = `DEVELOPER_DIR='' "#{xcode_path}/Contents/Developer/usr/bin/xcodebuild" -version` + def get_version + output = `DEVELOPER_DIR='' "#{@path}/Contents/Developer/usr/bin/xcodebuild" -version` return '0.0' if output.nil? # ¯\_(ツ)_/¯ output.split("\n").first.split(' ')[1] end end