lib/xcode/install.rb in xcode-install-2.2.0 vs lib/xcode/install.rb in xcode-install-2.2.1
- old
+ new
@@ -140,21 +140,21 @@
end
FileUtils.rm_f(dmg_path) if clean
end
- def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil)
+ def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil, show_release_notes = true)
dmg_path = get_dmg(version, progress, url)
fail Informative, "Failed to download Xcode #{version}." if dmg_path.nil?
if install
install_dmg(dmg_path, "-#{version.split(' ')[0]}", switch, clean)
else
puts "Downloaded Xcode #{version} to '#{dmg_path}'"
end
- open_release_notes_url(version) unless url
+ open_release_notes_url(version) if show_release_notes && !url
end
def open_release_notes_url(version)
return if version.nil?
xcode = seedlist.find { |x| x.name == version }
@@ -245,19 +245,12 @@
download(version, progress, url)
end
def fetch_seedlist
- @xcodes = parse_seedlist(spaceship.send(:request, :get,
- '/services-account/QH65B2/downloadws/listDownloads.action',
- start: '0',
- limit: '1000',
- sort: 'dateModified',
- dir: 'DESC',
- searchTextField: '',
- searchCategories: '',
- search: 'false').body)
+ @xcodes = parse_seedlist(spaceship.send(:request, :post,
+ '/services-account/QH65B2/downloadws/listDownloads.action').body)
names = @xcodes.map(&:name)
@xcodes += prereleases.reject { |pre| names.include?(pre.name) }
File.open(LIST_FILE, 'wb') do |f|
@@ -275,10 +268,12 @@
`mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n")
end
def parse_seedlist(seedlist)
+ fail Informative, seedlist['resultString'] unless seedlist['resultCode'].eql? 0
+
seeds = Array(seedlist['downloads']).select do |t|
/^Xcode [0-9]/.match(t['name'])
end
xcodes = seeds.map { |x| Xcode.new(x) }.reject { |x| x.version < MINIMUM_VERSION }.sort do |a, b|
@@ -391,11 +386,14 @@
def download(progress)
result = Curl.new.fetch(source, CACHE_DIR, nil, nil, progress)
result ? dmg_path : nil
end
- def install(progress)
- download(progress)
+ def install(progress, should_install)
+ dmg_path = download(progress)
+ fail Informative, "Failed to download #{@name}." if dmg_path.nil?
+
+ return unless should_install
prepare_package unless pkg_path.exist?
puts "Please authenticate to install #{name}..."
`sudo installer -pkg #{pkg_path} -target /`
fail Informative, "Could not install #{name}, please try again" unless installed?
source_receipts_dir = '/private/var/db/receipts'