| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library update_homebrew; | 5 library update_homebrew; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (revisions[channel] == revision) { | 100 if (revisions[channel] == revision) { |
| 101 print("Channel $channel is already at revision $revision in homebrew."); | 101 print("Channel $channel is already at revision $revision in homebrew."); |
| 102 exit(0); | 102 exit(0); |
| 103 } | 103 } |
| 104 revisions[channel] = revision; | 104 revisions[channel] = revision; |
| 105 var hashes = await getHashes(revisions); | 105 var hashes = await getHashes(revisions); |
| 106 var devVersion = await getVersion('dev', revisions['dev']); | 106 var devVersion = await getVersion('dev', revisions['dev']); |
| 107 | 107 |
| 108 var stableVersion = await getVersion('stable', revisions['stable']); | 108 var stableVersion = await getVersion('stable', revisions['stable']); |
| 109 | 109 |
| 110 await new File('$repository/dartium.rb').writeAsString( | |
| 111 createDartiumFormula(revisions, hashes, devVersion, stableVersion), | |
| 112 flush: true); | |
| 113 await new File('$repository/dart.rb').writeAsString( | 110 await new File('$repository/dart.rb').writeAsString( |
| 114 createDartFormula(revisions, hashes, devVersion, stableVersion), | 111 createDartFormula(revisions, hashes, devVersion, stableVersion), |
| 115 flush: true); | 112 flush: true); |
| 116 } | 113 } |
| 117 | 114 |
| 118 String createDartiumFormula( | |
| 119 Map revisions, Map hashes, String devVersion, String stableVersion) => ''' | |
| 120 require 'formula' | |
| 121 | |
| 122 class Dartium < Formula | |
| 123 homepage "https://www.dartlang.org" | |
| 124 | |
| 125 version '$stableVersion' | |
| 126 url '$urlBase/stable/release/${revisions['stable']}/$dartiumFile' | |
| 127 sha256 '${hashes['stable'][dartiumFile]}' | |
| 128 | |
| 129 devel do | |
| 130 version '$devVersion' | |
| 131 url '$urlBase/dev/release/${revisions['dev']}/$dartiumFile' | |
| 132 sha256 '${hashes['dev'][dartiumFile]}' | |
| 133 | |
| 134 resource 'content_shell' do | |
| 135 url '$urlBase/dev/release/${revisions['dev']}/$contentShellFile' | |
| 136 sha256 '${hashes['dev'][contentShellFile]}' | |
| 137 end | |
| 138 end | |
| 139 | |
| 140 resource 'content_shell' do | |
| 141 url '$urlBase/stable/release/${revisions['stable']}/$contentShellFile' | |
| 142 sha256 '${hashes['stable'][contentShellFile]}' | |
| 143 end | |
| 144 | |
| 145 def shim_script target | |
| 146 <<-EOS.undent | |
| 147 #!/bin/bash | |
| 148 exec "#{prefix}/#{target}" "\$@" | |
| 149 EOS | |
| 150 end | |
| 151 | |
| 152 def install | |
| 153 dartium_binary = 'Chromium.app/Contents/MacOS/Chromium' | |
| 154 prefix.install Dir['*'] | |
| 155 (bin+"dartium").write shim_script dartium_binary | |
| 156 | |
| 157 content_shell_binary = 'Content Shell.app/Contents/MacOS/Content Shell' | |
| 158 prefix.install resource('content_shell') | |
| 159 (bin+"content_shell").write shim_script content_shell_binary | |
| 160 end | |
| 161 | |
| 162 def caveats; <<-EOS.undent | |
| 163 DEPRECATED | |
| 164 In the future, use the `dart` formula using | |
| 165 `--with-dartium` and/or `--with-content-shell` | |
| 166 | |
| 167 To use with IntelliJ, set the Dartium execute home to: | |
| 168 #{prefix}/Chromium.app | |
| 169 EOS | |
| 170 end | |
| 171 | |
| 172 test do | |
| 173 system "#{bin}/dartium" | |
| 174 end | |
| 175 end | |
| 176 '''; | |
| 177 | |
| 178 String createDartFormula( | 115 String createDartFormula( |
| 179 Map revisions, Map hashes, String devVersion, String stableVersion) => ''' | 116 Map revisions, Map hashes, String devVersion, String stableVersion) => ''' |
| 180 require 'formula' | 117 require 'formula' |
| 181 | 118 |
| 182 class Dart < Formula | 119 class Dart < Formula |
| 183 homepage 'https://www.dartlang.org/' | 120 homepage 'https://www.dartlang.org/' |
| 184 | 121 |
| 185 version '$stableVersion' | 122 version '$stableVersion' |
| 186 if MacOS.prefer_64_bit? | 123 if MacOS.prefer_64_bit? |
| 187 url '$urlBase/stable/release/${revisions['stable']}/$x64File' | 124 url '$urlBase/stable/release/${revisions['stable']}/$x64File' |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 260 |
| 324 await runGit(['push']); | 261 await runGit(['push']); |
| 325 } finally { | 262 } finally { |
| 326 await tempDir.delete(recursive: true); | 263 await tempDir.delete(recursive: true); |
| 327 } | 264 } |
| 328 }, onError: (error, chain) { | 265 }, onError: (error, chain) { |
| 329 print(error); | 266 print(error); |
| 330 print(chain.terse); | 267 print(chain.terse); |
| 331 }); | 268 }); |
| 332 } | 269 } |
| OLD | NEW |